linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Zhan <rongkai.zhan@windriver.com>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix the unlock addr lookup BUG in MTD JEDEC probe
Date: Tue, 25 Jul 2006 11:54:21 +0800	[thread overview]
Message-ID: <44C595ED.7070209@windriver.com> (raw)

Hi All,

This patch fixes a BUG in the function finfo_uaddr() in driver/mtd/chips/jedec_probe.c.
This function will fetch the unlock addr type from the pre-defined flash chip info.

static inline __u8 finfo_uaddr(const struct amd_flash_info *finfo, int device_type)
{
	int uaddr_idx;
	__u8 uaddr = MTD_UADDR_NOT_SUPPORTED;

	switch ( device_type ) {
	case CFI_DEVICETYPE_X8:  uaddr_idx = 0; break;
	case CFI_DEVICETYPE_X16: uaddr_idx = 1; break;
	case CFI_DEVICETYPE_X32: uaddr_idx = 2; break;
	default:
		printk(KERN_NOTICE "MTD: %s(): unknown device_type %d\n",
		       __func__, device_type);
		goto uaddr_done;
	}

	uaddr = finfo->uaddr[uaddr_idx];

	if (uaddr != MTD_UADDR_NOT_SUPPORTED ) {
		/* ASSERT("The unlock addresses for non-8-bit mode
		   are bollocks. We don't really need an array."); */
		uaddr = finfo->uaddr[0];
	}

  uaddr_done:
	return uaddr;
}

However, the later 'if' sentence will force that the first unlock addr type is always returned.
If a chip has two device types (x8 x16) and the chip works in x16 mode, this bug will result in
that the chip can't be probed correctly because the unlock addr doesn't match.

This patch fixes this bug.

Signed-off-by: Rongkai.Zhan <rongkai.zhan@windriver.com>

----
diff --git a/drivers/mtd/chips/jedec_probe.c b/drivers/mtd/chips/jedec_probe.c
index 8f39d0a..a0ab0df 100644
--- a/drivers/mtd/chips/jedec_probe.c
+++ b/drivers/mtd/chips/jedec_probe.c
@@ -1804,7 +1804,7 @@ static inline __u8 finfo_uaddr(const str

  	uaddr = finfo->uaddr[uaddr_idx];

-	if (uaddr != MTD_UADDR_NOT_SUPPORTED ) {
+	if (uaddr == MTD_UADDR_NOT_SUPPORTED ) {
  		/* ASSERT("The unlock addresses for non-8-bit mode
  		   are bollocks. We don't really need an array."); */
  		uaddr = finfo->uaddr[0];

                 reply	other threads:[~2006-07-25  3:54 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=44C595ED.7070209@windriver.com \
    --to=rongkai.zhan@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).