projects/linux·commit baf5964e

power: supply: olpc_battery: force the le/be casts

baf5964e · Lubomir Rintel <[email protected]> · 2019-05-11 10:56:14 +02:00

The endianness of data returned from the EC depends on the particular EC
version determined at run time. Cast from little/big endian explicitey
in the routine that flips endianness to the native one to make sparse
happy.

Signed-off-by: Lubomir Rintel <[email protected]>
Reported-by: kbuild test robot <[email protected]>
Fixes: 76311b9a3295 ("power: supply: olpc_battery: Add OLPC XO 1.75 support")
Signed-off-by: Sebastian Reichel <[email protected]>
Commit
baf5964ecfe19a0109fe2e497e72840ce0f488e6
Parents
c8f3c9fe

Changes

1 files changed · +3 −3

FileStatusAddDelContent
drivers/power/supply/olpc_battery.cmodified+3−3View file

drivers/power/supply/olpc_battery.c

View file
diff --git a/drivers/power/supply/olpc_battery.c b/drivers/power/supply/olpc_battery.c
index c628d3a..7720e4c 100644
--- a/drivers/power/supply/olpc_battery.c
+++ b/drivers/power/supply/olpc_battery.c
@@ -327,9 +327,9 @@ static int olpc_bat_get_voltage_max_design(union power_supply_propval *val)
static u16 ecword_to_cpu(struct olpc_battery_data *data, u16 ec_word)
{
if (data->little_endian)
- return le16_to_cpu(ec_word);
+ return le16_to_cpu((__force __le16)ec_word);
else
- return be16_to_cpu(ec_word);
+ return be16_to_cpu((__force __be16)ec_word);
}
/*********************************************************************
@@ -341,7 +341,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
{
struct olpc_battery_data *data = power_supply_get_drvdata(psy);
int ret = 0;
- __be16 ec_word;
+ u16 ec_word;
uint8_t ec_byte;
__be64 ser_buf;