From: Ian Molton <spyro@f2s.com>
To: linux-mtd@lists.infradead.org
Cc: tglx@linutronix.de
Subject: [PATCH] provide overrideable read_id()
Date: Tue, 24 Aug 2004 01:28:06 +0100 [thread overview]
Message-ID: <20040824012806.365a3781.spyro@f2s.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
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.
[-- Attachment #2: include.diff --]
[-- Type: application/octet-stream, Size: 638 bytes --]
--- include/linux/mtd/nand.h 2004-07-07 23:00:26.000000000 +0100
+++ /home/ian/projects/e740/linux1/linux/kernel26/include/linux/mtd/nand.h 2004-08-20 17:08:00.409319171 +0100
@@ -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);
[-- Attachment #3: driver.diff --]
[-- Type: application/octet-stream, Size: 2515 bytes --]
--- drivers/mtd/nand/nand_base.c 2004-08-09 23:00:18.000000000 +0100
+++ /home/ian/projects/e740/linux1/linux/kernel26/drivers/mtd/nand/nand_base.c 2004-08-24 00:29:44.000000000 +0100
@@ -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)
reply other threads:[~2004-08-24 0:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040824012806.365a3781.spyro@f2s.com \
--to=spyro@f2s.com \
--cc=linux-mtd@lists.infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox