Thread (28 messages) read the whole thread 28 messages, 6 authors, 2020-09-08

Re: [PATCH v1 2/6] power: supply: Add battery gauge driver for Acer Iconia Tab A500

From: Sebastian Reichel <hidden>
Date: 2020-08-24 21:39:06
Also in: linux-devicetree, linux-leds, linux-tegra, lkml

Hi,

On Mon, Aug 24, 2020 at 09:55:14PM +0300, Dmitry Osipenko wrote:
24.08.2020 17:07, Sebastian Reichel пишет:
quoted
quoted
+static int a500_battery_get_serial_number(struct a500_battery *bat,
+					  union power_supply_propval *val)
+{
+	unsigned int i;
+	s32 ret = 0;
+
+	if (bat->serial[0])
+		goto done;
+
+	a500_ec_lock(bat->ec_chip);
+	for (i = 0; i < BATTERY_SERIAL_LEN / 2; i++) {
+		ret = a500_ec_read_locked(bat->ec_chip,
+					  &ec_data[REG_SERIAL_NUMBER].cmd);
+		if (ret < 0) {
+			bat->serial[0] = '\0';
+			break;
+		}
+
+		bat->serial[i * 2 + 0] = (ret >> 0) & 0xff;
+		bat->serial[i * 2 + 1] = (ret >> 8) & 0xff;
+	}
+	a500_ec_unlock(bat->ec_chip);
+done:
+	val->strval = bat->serial;
+
+	return ret;
+}
If battery is swapped, this will keep the old serial.
Hello, Sebastian! The battery isn't hot-swappable on A500, but it also
should be okay to always re-read the serialno. I'll consider removing
the caching in the v2, thanks.
I assumed it would be hot-swappable because of a500_battery_get_presence().
If it's not hot-swappable, the caching is fine.

-- Sebastian

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help