Re: [PATCH v2] ACPI: surface3_power: MSHW0011 rev-eng implementation

Sebastian Reichel
2017-07-01T00:47:38Z

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]