public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Christian Hohnstaedt <chohnstaedt@innominate.com>
To: linux-mtd@lists.infradead.org
Subject: [PATCH] MTD: fix endian issue of additional protection fields
Date: Mon, 12 Jun 2006 17:34:58 +0200	[thread overview]
Message-ID: <20060612153458.GJ24758@tweety> (raw)

add byte-swapping for extended OTP areas (NumProtectionFields > 1)

Signed-off-by: Christian Hohnstaedt <chohnstaedt@innominate.com>

---

 drivers/mtd/chips/cfi_cmdset_0001.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

0bdeefafb76db54cdb12a10e8fcc5c197221c276
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 0d43581..3227d1e 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -279,11 +279,24 @@ read_pri_intelext(struct map_info *map, 
 	if (extp->MajorVersion == '1' && extp->MinorVersion >= '3') {
 		unsigned int extra_size = 0;
 		int nb_parts, i;
+		struct cfi_intelext_otpinfo *otp;
 
 		/* Protection Register info */
 		extra_size += (extp->NumProtectionFields - 1) *
 			      sizeof(struct cfi_intelext_otpinfo);
 
+		if (extp_size < sizeof(*extp) + extra_size)
+			goto need_more;
+
+		/* Byteswapping for additional ProtectionFields */
+		otp = (struct cfi_intelext_otpinfo*)(extp->extra);
+		for (i=1; i<extp->NumProtectionFields; i++) {
+			otp->ProtRegAddr = le32_to_cpu(otp->ProtRegAddr);
+			otp->FactGroups = le16_to_cpu(otp->FactGroups);
+			otp->UserGroups = le16_to_cpu(otp->UserGroups);
+			otp++;
+		}
+
 		/* Burst Read info */
 		extra_size += 2;
 		if (extp_size < sizeof(*extp) + extra_size)
-- 
Christian Hohnstaedt
Software Engineer

Innominate Security Technologies AG  /device attached security/
tel: +49.30.6392-3285
fax: +49.30.6392-3307
Albert-Einstein-Str. 14
D-12489 Berlin, Germany
http://www.innominate.com

             reply	other threads:[~2006-06-12 16:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-12 15:34 Christian Hohnstaedt [this message]
2006-06-12 17:01 ` [PATCH] MTD: fix endian issue of additional protection fields Nicolas Pitre
2006-06-12 22:07   ` Does anyone have patches for Sibley on the 2.4 kernel? Justin Treon
2006-06-12 22:49     ` David Woodhouse
2006-06-13  0:55     ` Nicolas Pitre

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=20060612153458.GJ24758@tweety \
    --to=chohnstaedt@innominate.com \
    --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