Skip to contentSkip to conversation

power_supply: bq27x00: remove double endian swap

PATCH In review Grazvydas Ignotas 3 participants 3 messages Feb 12, 2010 – Feb 16, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 power_supply: bq27x00: remove double endian swap

The bq27x00 registers are little endian, so just read them as such and don't do double endian swap on LE machines.

This also gets rid of strange looking shift that was done after reading 8bit register because endian swap in bq27x00_read() was messing it up.

---
 drivers/power/bq27x00_battery.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/power/bq27x00_battery.c +3 -8
index 62bb981..537915c 100644
@@ -74,12 +74,7 @@ static enum power_supply_property bq27x00_battery_props[] = {
 static int bq27x00_read(u8 reg, int *rt_value, int b_single,
 			struct bq27x00_device_info *di)
 {
-	int ret;
-
-	ret = di->bus->read(reg, rt_value, b_single, di);
-	*rt_value = be16_to_cpu(*rt_value);
-
-	return ret;
+	return di->bus->read(reg, rt_value, b_single, di);
 }
 
 /*
@@ -161,7 +156,7 @@ static int bq27x00_battery_rsoc(struct bq27x00_device_info *di)
 		return ret;
 	}
 
-	return rsoc >> 8;
+	return rsoc;
 }
 
 #define to_bq27x00_device_info(x) container_of((x), \
@@ -238,7 +233,7 @@ static int bq27200_read(u8 reg, int *rt_value, int b_single,
 		err = i2c_transfer(client->adapter, msg, 1);
 		if (err >= 0) {
 			if (!b_single)
-				*rt_value = get_unaligned_be16(data);
+				*rt_value = get_unaligned_le16(data);
 			else
 				*rt_value = data[0];
 
Signature · 1 line
1.6.3.3
Acked-by on v1 1/4
#1 lore raw
Quoted 8 lines · Grazvydas Ignotas

The bq27x00 registers are little endian, so just read them as such and don't do double endian swap on LE machines.

This also gets rid of strange looking shift that was done after reading 8bit register because endian swap in bq27x00_read() was messing it up.

Signature · 5 lines
GNU/Linux Solutions                  e-mail: [email protected]
Linux Device Driver                          [email protected]
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
#2 lore raw
Quoted 11 lines · Rodolfo Giometti
Quoted 8 lines · Grazvydas Ignotas

The bq27x00 registers are little endian, so just read them as such and don't do double endian swap on LE machines.

This also gets rid of strange looking shift that was done after reading 8bit register because endian swap in bq27x00_read() was messing it up.

Patches 1-4 applied. Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2