lkml.org 
[lkml]   [2017]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] ACPI: surface3_power: MSHW0011 rev-eng implementation
Hi,

On Thu, Jun 29, 2017 at 02:10:09PM +0200, Benjamin Tissoires wrote:
> [...]
>
> + /* get design capacity */
> + ret = i2c_smbus_read_word_data(client,
> + MSHW0011_BAT0_REG_DESIGN_CAPACITY);
> + if (ret < 0) {
> + dev_err(&client->dev, "Error reading design capacity: %d\n",
> + ret);
> + return ret;
> + }
> + bix->design_capacity = le16_to_cpu(ret);

i2c_smbus_read_word_data() returns native endianess for
little-endian bus (it basically has builtin le16_to_cpu).
Your conversion actually _breaks_ support on big endian
machines by converting it back.

That seems to be a common mistake in the kernel and it
might be a good idea to add some Coccinelle script for
it?

-- Sebastian
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-07-01 02:47    [W:0.291 / U:0.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site