linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Datta, Shubhrajyoti" <shubhrajyoti@ti.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Jonathan Cameron <kernel@jic23.retrosnub.co.uk>,
	Christoph Mair <christoph.mair@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] BMP085  : Change the macro to swap
Date: Thu, 24 Jun 2010 18:11:01 +0530	[thread overview]
Message-ID: <0680EC522D0CC943BC586913CF3768C003B3553D0C@dbde02.ent.ti.com> (raw)


Changing the macro to swap the bytes as the reason that the first byte is the MSB and the next is LSB.

Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
---
 drivers/misc/bmp085.c |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/bmp085.c b/drivers/misc/bmp085.c
index 8af6f1b..74c5b12 100644
--- a/drivers/misc/bmp085.c
+++ b/drivers/misc/bmp085.c
@@ -79,18 +79,35 @@ static s32 bmp085_read_calibration_data(struct i2c_client *client)
 
 	if (status != BMP085_CALIBRATION_DATA_LENGTH*sizeof(u16))
 		return -EIO;
-
-	cali->AC1 =  be16_to_cpu(tmp[0]);
-	cali->AC2 =  be16_to_cpu(tmp[1]);
-	cali->AC3 =  be16_to_cpu(tmp[2]);
-	cali->AC4 =  be16_to_cpu(tmp[3]);
-	cali->AC5 =  be16_to_cpu(tmp[4]);
-	cali->AC6 = be16_to_cpu(tmp[5]);
-	cali->B1 = be16_to_cpu(tmp[6]);
-	cali->B2 = be16_to_cpu(tmp[7]);
-	cali->MB = be16_to_cpu(tmp[8]);
-	cali->MC = be16_to_cpu(tmp[9]);
-	cali->MD = be16_to_cpu(tmp[10]);
+/*
+ * From the datasheet
+ *
+ * BMP085 Reg Addr
+ * parameter	|	MSB	|	LSB
+ * AC1		|	0xAA	|	0xAB
+ * AC2		|	0xAC	|	0xAD
+ * AC3		|	0xAE	|	0xAF
+ * AC4		|	0xB0	|	0xB1
+ * AC5		|	0xB2	|	0xB3
+ * AC6		|	0xB4	|	0xB5
+ * B1		|	0xB6	|	0xB7
+ * B2		|	0xB8	|	0xB9
+ * MB		|	0xBA	|	0xBB
+ * MC		|	0xBC	|	0xBD
+ * MC		|	0xBE	|	0xBF
+ *
+ */
+	cali->AC1 =  swab16(tmp[0]);
+	cali->AC2 =  swab16(tmp[1]);
+	cali->AC3 =  swab16(tmp[2]);
+	cali->AC4 =  swab16(tmp[3]);
+	cali->AC5 =  swab16(tmp[4]);
+	cali->AC6 = swab16(tmp[5]);
+	cali->B1 = swab16(tmp[6]);
+	cali->B2 = swab16(tmp[7]);
+	cali->MB = swab16(tmp[8]);
+	cali->MC = swab16(tmp[9]);
+	cali->MD = swab16(tmp[10]);
 	return 0;
 }
 
-- 
1.5.4.7


             reply	other threads:[~2010-06-24 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24 12:41 Datta, Shubhrajyoti [this message]
2010-06-24 12:52 ` [PATCH] BMP085 : Change the macro to swap Jonathan Cameron
2010-06-25 13:00   ` Datta, Shubhrajyoti
2010-06-25 13:34     ` Christoph Mair

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=0680EC522D0CC943BC586913CF3768C003B3553D0C@dbde02.ent.ti.com \
    --to=shubhrajyoti@ti.com \
    --cc=akpm@linux-foundation.org \
    --cc=christoph.mair@gmail.com \
    --cc=kernel@jic23.retrosnub.co.uk \
    --cc=linux-kernel@vger.kernel.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).