trickle-charge: Don't write to already configured supplies

Don't write charge type to devices that are already setup with that
charge type, it serves no purpose and might cause bugs in some drivers.
This commit is contained in:
Bastien Nocera 2022-02-12 22:57:43 +01:00
parent b9730ebc3c
commit 92cf0278b0

View file

@ -54,8 +54,13 @@ set_charge_type (PpdActionTrickleCharge *action,
for (l = devices; l != NULL; l = l->next) {
GUdevDevice *dev = l->data;
const char *value;
if (!g_udev_device_has_sysfs_attr (dev, CHARGE_TYPE_SYSFS_NAME))
value = g_udev_device_get_sysfs_attr_uncached (dev, CHARGE_TYPE_SYSFS_NAME);
if (!value)
continue;
if (g_strcmp0 (charge_type, value) == 0)
continue;
ppd_utils_write_sysfs (dev, CHARGE_TYPE_SYSFS_NAME, charge_type, NULL);