mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mike Frysinger <vapier@gentoo.org>,
	<linux-kernel@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	<drivers@analog.com>, Lars-Peter Clausen <lars@metafoo.de>,
	<stable@kernel.org>
Subject: [PATCH 3/8] firmware: Sigma: Fix endianess issues
Date: Thu, 24 Nov 2011 13:48:22 +0100	[thread overview]
Message-ID: <1322138908-32127-3-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1322138908-32127-1-git-send-email-lars@metafoo.de>

Currently the SigmaDSP firmware loader only works correctly on little-endian
systems. Fix this by using the proper endianess conversion functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: stable@kernel.org
---
 drivers/firmware/sigma.c |    2 +-
 include/linux/sigma.h    |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/sigma.c b/drivers/firmware/sigma.c
index b1ab32a6..749932c 100644
--- a/drivers/firmware/sigma.c
+++ b/drivers/firmware/sigma.c
@@ -127,7 +127,7 @@ int process_sigma_firmware(struct i2c_client *client, const char *name)
 	crc = crc32(0, fw->data + sizeof(*ssfw_head),
 			fw->size - sizeof(*ssfw_head));
 	pr_debug("%s: crc=%x\n", __func__, crc);
-	if (crc != ssfw_head->crc)
+	if (crc != le32_to_cpu(ssfw_head->crc))
 		goto done;
 
 	ssfw.pos = sizeof(*ssfw_head);
diff --git a/include/linux/sigma.h b/include/linux/sigma.h
index 9a138c2..d0de882 100644
--- a/include/linux/sigma.h
+++ b/include/linux/sigma.h
@@ -24,7 +24,7 @@ struct sigma_firmware {
 struct sigma_firmware_header {
 	unsigned char magic[7];
 	u8 version;
-	u32 crc;
+	__le32 crc;
 };
 
 enum {
@@ -40,14 +40,14 @@ enum {
 struct sigma_action {
 	u8 instr;
 	u8 len_hi;
-	u16 len;
-	u16 addr;
+	__le16 len;
+	__be16 addr;
 	unsigned char payload[];
 };
 
 static inline u32 sigma_action_len(struct sigma_action *sa)
 {
-	return (sa->len_hi << 16) | sa->len;
+	return (sa->len_hi << 16) | le16_to_cpu(sa->len);
 }
 
 extern int process_sigma_firmware(struct i2c_client *client, const char *name);
-- 
1.7.7.1



  parent reply	other threads:[~2011-11-24 12:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24 12:48 [PATCH 1/8] firmware: Sigma: Prevent out of bounds memory access Lars-Peter Clausen
2011-11-24 12:48 ` [PATCH 2/8] firmware: Sigma: Skip header during CRC generation Lars-Peter Clausen
2011-11-24 17:21   ` Mike Frysinger
2011-11-25  8:55     ` Lars-Peter Clausen
2011-11-25 20:00       ` Mike Frysinger
2011-11-28  7:56         ` Lars-Peter Clausen
2011-11-29  5:11           ` Mike Frysinger
2011-11-24 12:48 ` Lars-Peter Clausen [this message]
2011-11-24 17:20   ` [PATCH 3/8] firmware: Sigma: Fix endianess issues Mike Frysinger
2011-11-24 12:48 ` [PATCH 4/8] firmware: Sigma: Mark firmware strutcs packed Lars-Peter Clausen
2011-11-24 17:19   ` Mike Frysinger
2011-11-25 10:48     ` Lars-Peter Clausen
2011-11-25 20:07       ` Mike Frysinger
2011-11-24 12:48 ` [PATCH 5/8] ASoC: Move SigmaDSP firmware loader to ASoC Lars-Peter Clausen
2011-11-24 13:15   ` [PATCH v2 " Lars-Peter Clausen
2011-11-24 17:31     ` Mike Frysinger
2011-11-24 12:48 ` [PATCH 6/8] ASoC: SigmaDSP: Provide diagnostic error messages Lars-Peter Clausen
2011-11-24 17:32   ` Mike Frysinger
2011-11-25  8:59     ` Lars-Peter Clausen
2011-11-25 20:02       ` Mike Frysinger
2011-11-24 12:48 ` [PATCH 7/8] ASoC: SigmaDSP: Move private structs and functions to c file Lars-Peter Clausen
2011-11-24 17:31   ` Mike Frysinger
2011-11-24 12:48 ` [PATCH 8/8] ASoC: SigmaDSP: Add regmap support Lars-Peter Clausen
2011-11-24 17:30   ` Mike Frysinger
2011-11-25  9:00     ` Lars-Peter Clausen
2011-11-24 17:26 ` [PATCH 1/8] firmware: Sigma: Prevent out of bounds memory access Mike Frysinger

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=1322138908-32127-3-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=akpm@linux-foundation.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=drivers@analog.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=stable@kernel.org \
    --cc=vapier@gentoo.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

all inboxes | Powered by JetHome®