Skip to content

Commit bcc9ecf

Browse files
jwrdegoedejannau
authored andcommitted
power: supply: Drop use_cnt check from power_supply_property_is_writeable()
power_supply_property_is_writeable() gets called from the is_visible() callback for the sysfs attributes of power_supply class devices and for the sysfs attributes of power_supply core instantiated hwmon class devices. These sysfs attributes get registered by the device_add() respectively power_supply_add_hwmon_sysfs() calls in power_supply_register(). use_cnt gets initialized to 0 and is incremented only after these calls. So when power_supply_property_is_writeable() gets called it always return -ENODEV because of use_cnt == 0. This causes all the attributes to have permissions of 444 even those which should be writable. This used to be a problem only for hwmon sysfs attributes but since commit be6299c ("power: supply: sysfs: use power_supply_property_is_writeable()") this now also impacts power_supply class sysfs attributes. Fixes: be6299c ("power: supply: sysfs: use power_supply_property_is_writeable()") Fixes: e67d4df ("power: supply: Add HWMON compatibility layer") Cc: stable@vger.kernel.org Cc: Thomas Weißschuh <linux@weissschuh.net> Cc: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 08d7e2a commit bcc9ecf

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

drivers/power/supply/power_supply_core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,11 +1232,7 @@ EXPORT_SYMBOL_GPL(power_supply_set_property);
12321232
int power_supply_property_is_writeable(struct power_supply *psy,
12331233
enum power_supply_property psp)
12341234
{
1235-
if (atomic_read(&psy->use_cnt) <= 0 ||
1236-
!psy->desc->property_is_writeable)
1237-
return -ENODEV;
1238-
1239-
return psy->desc->property_is_writeable(psy, psp);
1235+
return psy->desc->property_is_writeable && psy->desc->property_is_writeable(psy, psp);
12401236
}
12411237
EXPORT_SYMBOL_GPL(power_supply_property_is_writeable);
12421238

0 commit comments

Comments
 (0)