Skip to content

Commit 2c7e46e

Browse files
krzksre
authored andcommitted
power: supply: sysfs: Constify pointer passed to dev_attr_psp()
Memory pointer by pointer passed to dev_attr_psp() is not modified, so with help of container_of_const() (preferred than container_of()) can be made pointer to const for code safety. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20251126171859.72465-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 688364a commit 2c7e46e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/power/supply/power_supply_sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ static struct power_supply_attr power_supply_attrs[] __ro_after_init = {
235235
static struct attribute *
236236
__power_supply_attrs[POWER_SUPPLY_ATTR_CNT + 1] __ro_after_init;
237237

238-
static const struct power_supply_attr *to_ps_attr(struct device_attribute *attr)
238+
static const struct power_supply_attr *to_ps_attr(const struct device_attribute *attr)
239239
{
240-
return container_of(attr, struct power_supply_attr, dev_attr);
240+
return container_of_const(attr, struct power_supply_attr, dev_attr);
241241
}
242242

243-
static enum power_supply_property dev_attr_psp(struct device_attribute *attr)
243+
static enum power_supply_property dev_attr_psp(const struct device_attribute *attr)
244244
{
245245
return to_ps_attr(attr) - power_supply_attrs;
246246
}

0 commit comments

Comments
 (0)