provide overrideable read_id()
PATCH 1/1 provide overrideable read_id()
Hi.
Heres the patch(es) to allow read_id to be overridden. makes the code a tad clearer too IMO. Default behaviour is preserved.
This supports the new TC6393XB Smartmedia driver.
home/ian/projects/e740/linux1/linux/kernel26/include/linux/mtd/nand.h renamed from linux/mtd/nand.h +1 -0
@@ -281,6 +281,7 @@void (*read_buf)(struct mtd_info *mtd,u_char *buf,int len);int (*verify_buf)(struct mtd_info *mtd,const u_char *buf,int len);void (*select_chip)(struct mtd_info *mtd,int chip); +void (*read_id)(struct mtd_info *mtd,int *maf_id,int *dev_id);int (*block_bad)(struct mtd_info *mtd,loff_t ofs,int getchip);int (*block_markbad)(struct mtd_info *mtd,loff_t ofs);void (*hwcontrol)(struct mtd_info *mtd,int cmd);
home/ian/projects/e740/linux1/linux/kernel26/drivers/mtd/nand/nand_base.c renamed from mtd/nand/nand_base.c +27 -13
@@ -37,7 +37,7 @@* The AG-AND chips have nice features for speed improvement, * which are not supported yet. Read / program 4 pages in one go. * -* $Id: nand_base.c,v 1.115 2004/08/09 13:19:45 dwmw2 Exp $ +* $Id: nand_base.c,v 1.3 2004/08/23 23:29:44 spyro Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -164,6 +164,25 @@return readb (this->IO_ADDR_R); } +/* +* nand_read_id - [DEFAULT] read the manufacturer and chip IDs +* @mtd: MTD device structure +* @maf_id: pointer to int to store maf. id in +* @dev_id: pointer to int to store device id in. +* +*/ +static void nand_read_id (struct mtd_info *mtd,int *maf_id,int *dev_id) +{ +struct nand_chip *this = mtd->priv; + +/* Send the command for reading device ID */ + this->cmdfunc (mtd,NAND_CMD_READID ,0x00 ,-1 ); + +/* Read manufacturer and device IDs */ + *maf_id = this->read_byte (mtd); + *dev_id = this->read_byte (mtd); +} +/** * nand_write_byte - [DEFAULT] write one byte to the chip * @mtd: MTD device structure
@@ -2235,6 +2254,8 @@if (!this->select_chip) this->select_chip = nand_select_chip; +if (!this->read_id) + this->read_id = nand_read_id;if (!this->write_byte) this->write_byte = busw ? nand_write_byte16 : nand_write_byte;if (!this->read_byte)
@@ -2259,12 +2280,8 @@/* Select the device */ this->select_chip (mtd,0 ); -/* Send the command for reading device ID */ - this->cmdfunc (mtd,NAND_CMD_READID ,0x00 ,-1 ); - -/* Read manufacturer and device IDs */ - nand_maf_id = this->read_byte (mtd); - nand_dev_id = this->read_byte (mtd); +/* Read device ID */ + this->read_id (mtd, &nand_maf_id, &nand_dev_id);/* Print and store flash device information */ for (i =0 ; nand_flash_ids[i].name !=NULL ; i++) {
@@ -2365,14 +2382,11 @@ }for (i=1 ; i < maxchips; i++) { +int maf_id, dev_id; this->select_chip (mtd, i); + this->read_id (mtd, &maf_id, &dev_id); -/* Send the command for reading device ID */ - this->cmdfunc (mtd,NAND_CMD_READID ,0x00 ,-1 ); - -/* Read manufacturer and device IDs */ -if (nand_maf_id != this->read_byte (mtd) || - nand_dev_id != this->read_byte (mtd)) +if (nand_maf_id != maf_id || nand_dev_id != nand_dev_id)break ; }if (i >1 )