* [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls
@ 2017-07-03 17:45 Andy Shevchenko
2017-07-03 18:21 ` Sebastian Reichel
2017-07-31 13:30 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-07-03 17:45 UTC (permalink / raw)
To: Linus Walleij, linux-gpio, Sebastian Reichel, Gregory CLEMENT,
Yong Li, Phil Reid
Cc: Andy Shevchenko
i2c_smbus commands handle the correct byte order for smbus transactions
internally. This will currently result in incorrect operation on big
endian systems.
Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-pca953x.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 4c9e21300a26..1b9dbf691ae7 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -187,10 +187,9 @@ static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val)
static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
{
- __le16 word = cpu_to_le16(get_unaligned((u16 *)val));
+ u16 word = get_unaligned((u16 *)val);
- return i2c_smbus_write_word_data(chip->client,
- reg << 1, (__force u16)word);
+ return i2c_smbus_write_word_data(chip->client, reg << 1, word);
}
static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
@@ -241,8 +240,7 @@ static int pca953x_read_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
int ret;
ret = i2c_smbus_read_word_data(chip->client, reg << 1);
- val[0] = (u16)ret & 0xFF;
- val[1] = (u16)ret >> 8;
+ put_unaligned(ret, (u16 *)val);
return ret;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls
2017-07-03 17:45 [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls Andy Shevchenko
@ 2017-07-03 18:21 ` Sebastian Reichel
2017-07-31 13:30 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2017-07-03 18:21 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, linux-gpio, Gregory CLEMENT, Yong Li, Phil Reid
[-- Attachment #1: Type: text/plain, Size: 1652 bytes --]
Hi,
On Mon, Jul 03, 2017 at 08:45:30PM +0300, Andy Shevchenko wrote:
> i2c_smbus commands handle the correct byte order for smbus transactions
> internally. This will currently result in incorrect operation on big
> endian systems.
>
> Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
-- Sebastian
> drivers/gpio/gpio-pca953x.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 4c9e21300a26..1b9dbf691ae7 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -187,10 +187,9 @@ static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val)
>
> static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
> {
> - __le16 word = cpu_to_le16(get_unaligned((u16 *)val));
> + u16 word = get_unaligned((u16 *)val);
>
> - return i2c_smbus_write_word_data(chip->client,
> - reg << 1, (__force u16)word);
> + return i2c_smbus_write_word_data(chip->client, reg << 1, word);
> }
>
> static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
> @@ -241,8 +240,7 @@ static int pca953x_read_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
> int ret;
>
> ret = i2c_smbus_read_word_data(chip->client, reg << 1);
> - val[0] = (u16)ret & 0xFF;
> - val[1] = (u16)ret >> 8;
> + put_unaligned(ret, (u16 *)val);
>
> return ret;
> }
> --
> 2.11.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls
2017-07-03 17:45 [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls Andy Shevchenko
2017-07-03 18:21 ` Sebastian Reichel
@ 2017-07-31 13:30 ` Linus Walleij
2017-07-31 14:00 ` Andy Shevchenko
1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2017-07-31 13:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-gpio, Sebastian Reichel, Gregory CLEMENT, Yong Li, Phil Reid
On Mon, Jul 3, 2017 at 7:45 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> i2c_smbus commands handle the correct byte order for smbus transactions
> internally. This will currently result in incorrect operation on big
> endian systems.
>
> Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Patch applied.
As I don't see reported regressions it is applied for -next for
now.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls
2017-07-31 13:30 ` Linus Walleij
@ 2017-07-31 14:00 ` Andy Shevchenko
2017-07-31 14:06 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2017-07-31 14:00 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, Sebastian Reichel, Gregory CLEMENT, Yong Li, Phil Reid
On Mon, 2017-07-31 at 15:30 +0200, Linus Walleij wrote:
> On Mon, Jul 3, 2017 at 7:45 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>
> > i2c_smbus commands handle the correct byte order for smbus
> > transactions
> > internally. This will currently result in incorrect operation on big
> > endian systems.
> >
> > Suggested-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Patch applied.
Thanks!
>
> As I don't see reported regressions it is applied for -next for
> now.
Luckily we have none, though the latest changes to drivers/nfc/fdp/i2c.c
(*) rely on it.
(*) already in v4.13-rc1 IIRC.
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls
2017-07-31 14:00 ` Andy Shevchenko
@ 2017-07-31 14:06 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-07-31 14:06 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, Sebastian Reichel, Gregory CLEMENT, Yong Li, Phil Reid
On Mon, 2017-07-31 at 17:00 +0300, Andy Shevchenko wrote:
> On Mon, 2017-07-31 at 15:30 +0200, Linus Walleij wrote:
> > On Mon, Jul 3, 2017 at 7:45 PM, Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> >
>
> >
> > As I don't see reported regressions it is applied for -next for
> > now.
>
> Luckily we have none, though the latest changes to
> drivers/nfc/fdp/i2c.c
> (*) rely on it.
>
> (*) already in v4.13-rc1 IIRC.
My gosh! It's for different patch!
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-31 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-03 17:45 [PATCH v1] gpio: pca953x: remove incorrect le16_to_cpu calls Andy Shevchenko
2017-07-03 18:21 ` Sebastian Reichel
2017-07-31 13:30 ` Linus Walleij
2017-07-31 14:00 ` Andy Shevchenko
2017-07-31 14:06 ` Andy Shevchenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.