Re: [PATCH] hwmon: (cros-ec_hwmon) Fix access to restricted __le16

From: Thomas Weißschuh
Date: Thu Jun 06 2024 - 16:49:13 EST


On 2024-06-06 13:16:59+0000, Guenter Roeck wrote:
> On 6/6/24 12:53, Thomas Weißschuh wrote:
> > Thanks!
> >
> > On 2024-06-06 11:05:07+0000, Guenter Roeck wrote:
> > > 0-day complains:
> > >
> > > drivers-hwmon-cros_ec_hwmon.c:sparse:sparse:cast-to-restricted-__le16
> > >
> > > Fix by using a __le16 typed variable as parameter to le16_to_cpu().
> > >
> > > Fixes: bc3e45258096 ("hwmon: add ChromeOS EC driver")
> > > Cc: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
> > > Cc: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
> > > Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> >
> > Acked-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
> >
> > Guenter, does sparse work locally for you?
> >
>
> It does, but I use the version from git://repo.or.cz/smatch.git.

That does indeed look much better, thanks.


I have another question about the endianness conversion in general.
The only places I see doing a conversion are
cros_ec_sensors_cmd_read_u16() and the original cros_ec hwmon driver.

Also the documentation of the EC protocol does not specify anything in
that regard.
Instead there is the following comment in host_event_set_bit():

/*
* The overall host event implementation assumes it's running on and
* communicating with little-endian architectures.
*/

Can the conversion be dropped?