public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Jean Delvare <khali@linux-fr.org>,
	Till Harbaum <till@harbaum.org>
Subject: [24/25] i2c-tiny-usb: Fix on big-endian systems
Date: Tue, 25 May 2010 11:09:22 -0700	[thread overview]
Message-ID: <20100525181214.431662028@clark.site> (raw)
In-Reply-To: <20100525181259.GA18630@kroah.com>

2.6.27-stable review patch.  If anyone has any objections, please let us know.

------------------
From: Jean Delvare <khali@linux-fr.org>

commit 1c010ff8912cbc08d80e865aab9c32b6b00c527d upstream.

The functionality bit vector is always returned as a little-endian
32-bit number by the device, so it must be byte-swapped to the host
endianness.

On the other hand, the delay value is handled by the USB stack, so no
byte swapping is needed on our side.

This fixes bug #15105:
http://bugzilla.kernel.org/show_bug.cgi?id=15105

Reported-by: Jens Richter <jens@richter-stutensee.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Jens Richter <jens@richter-stutensee.de>
Cc: Till Harbaum <till@harbaum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/i2c/busses/i2c-tiny-usb.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--- a/drivers/i2c/busses/i2c-tiny-usb.c
+++ b/drivers/i2c/busses/i2c-tiny-usb.c
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/module.h>
+#include <linux/types.h>
 
 /* include interfaces to usb layer */
 #include <linux/usb.h>
@@ -31,8 +32,8 @@
 #define CMD_I2C_IO_END		(1<<1)
 
 /* i2c bit delay, default is 10us -> 100kHz */
-static int delay = 10;
-module_param(delay, int, 0);
+static unsigned short delay = 10;
+module_param(delay, ushort, 0);
 MODULE_PARM_DESC(delay, "bit delay in microseconds, "
 		 "e.g. 10 for 100kHz (default is 100kHz)");
 
@@ -109,7 +110,7 @@ static int usb_xfer(struct i2c_adapter *
 
 static u32 usb_func(struct i2c_adapter *adapter)
 {
-	u32 func;
+	__le32 func;
 
 	/* get functionality from adapter */
 	if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) !=
@@ -118,7 +119,7 @@ static u32 usb_func(struct i2c_adapter *
 		return 0;
 	}
 
-	return func;
+	return le32_to_cpu(func);
 }
 
 /* This is the actual algorithm we define */
@@ -216,8 +217,7 @@ static int i2c_tiny_usb_probe(struct usb
 		 "i2c-tiny-usb at bus %03d device %03d",
 		 dev->usb_dev->bus->busnum, dev->usb_dev->devnum);
 
-	if (usb_write(&dev->adapter, CMD_SET_DELAY,
-		      cpu_to_le16(delay), 0, NULL, 0) != 0) {
+	if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) {
 		dev_err(&dev->adapter.dev,
 			"failure setting delay to %dus\n", delay);
 		retval = -EIO;



  parent reply	other threads:[~2010-05-25 18:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-25 18:12 [00/25] 2.6.27.47-stable review, take 2 Greg KH
2010-05-25 18:08 ` [01/25] ALSA: mixart: range checking proc file Greg KH
2010-05-25 18:09 ` [02/25] ext4: invalidate pages if delalloc block allocation fails Greg KH
2010-05-25 18:09 ` [03/25] percpu counter: clean up percpu_counter_sum_and_set() Greg KH
2010-05-25 18:09 ` [04/25] ext4: Make sure all the block allocation paths reserve blocks Greg KH
2010-05-25 18:09 ` [05/25] ext4: Add percpu dirty block accounting Greg KH
2010-05-25 18:09 ` [06/25] ext4: Retry block reservation Greg KH
2010-05-25 18:09 ` [07/25] ext4: Retry block allocation if we have free blocks left Greg KH
2010-05-25 18:09 ` [08/25] ext4: Use tag dirty lookup during mpage_da_submit_io Greg KH
2010-05-25 18:09 ` [09/25] vfs: Remove the range_cont writeback mode Greg KH
2010-05-25 18:09 ` [10/25] tty: release_one_tty() forgets to put pids Greg KH
2010-05-25 18:09 ` [11/25] [SCSI] megaraid_sas: fix for 32bit apps Greg KH
2010-05-25 18:09 ` [12/25] trace: Fix inappropriate substraction on tracing_pages_allocated in trace_free_page() Greg KH
2010-05-25 18:09 ` [13/25] clockevent: Prevent dead lock on clockevents_lock Greg KH
2010-05-25 18:09 ` [14/25] nfsd4: bug in read_buf Greg KH
2010-05-25 18:09 ` [15/25] USB: fix testing the wrong variable in fs_create_by_name() Greg KH
2010-05-25 18:09 ` [16/25] nfs d_revalidate() is too trigger-happy with d_drop() Greg KH
2010-05-25 18:09 ` [17/25] NFS: rsize and wsize settings ignored on v4 mounts Greg KH
2010-05-25 18:09 ` [18/25] i2c: Fix probing of FSC hardware monitoring chips Greg KH
2010-05-25 18:09 ` [19/25] libata: ensure NCQ error result taskfile is fully initialized before returning it via qc->result_tf Greg KH
2010-05-25 18:09 ` [20/25] libata: retry FS IOs even if it has failed with AC_ERR_INVALID Greg KH
2010-05-25 18:09 ` [21/25] svc: Clean up deferred requests on transport destruction Greg KH
2010-05-25 18:09 ` [22/25] hwmon: (w83781d) Request I/O ports individually for probing Greg KH
2010-05-25 18:09 ` [23/25] i2c-i801: Dont use the block buffer for I2C block writes Greg KH
2010-05-25 18:09 ` Greg KH [this message]
2010-05-25 18:09 ` [25/25] nfsd: fix vm overcommit crash Greg KH

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=20100525181214.431662028@clark.site \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=till@harbaum.org \
    --cc=torvalds@linux-foundation.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