Lines Matching +full:prop +full:-
1 // SPDX-License-Identifier: GPL-2.0
3 * power_supply_hwmon.c - power supply hwmon support.
33 return -EINVAL; in power_supply_hwmon_in_to_property()
47 return -EINVAL; in power_supply_hwmon_curr_to_property()
59 return -EINVAL; in power_supply_hwmon_power_to_property()
93 return -EINVAL; in power_supply_hwmon_temp_to_property()
110 return -EINVAL; in power_supply_hwmon_to_property()
142 for (i = 0; i < attr_list->n_attrs; ++i) { in power_supply_hwmon_has_input()
143 int prop = power_supply_hwmon_to_property(type, in power_supply_hwmon_has_input() local
144 attr_list->attrs[i], channel); in power_supply_hwmon_has_input()
146 if (prop >= 0 && test_bit(prop, psyhw->props)) in power_supply_hwmon_has_input()
177 int prop; in power_supply_hwmon_is_visible() local
186 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_is_visible()
187 if (prop < 0 || !test_bit(prop, psyhw->props)) in power_supply_hwmon_is_visible()
190 if (power_supply_property_is_writeable(psyhw->psy, prop) > 0 && in power_supply_hwmon_is_visible()
224 struct power_supply *psy = psyhw->psy; in power_supply_hwmon_read()
226 int ret, prop; in power_supply_hwmon_read() local
228 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_read()
229 if (prop < 0) in power_supply_hwmon_read()
230 return prop; in power_supply_hwmon_read()
232 ret = power_supply_get_property(psy, prop, &pspval); in power_supply_hwmon_read()
252 * Temp needs to be converted from 1/10 C to milli-C in power_supply_hwmon_read()
257 return -EOVERFLOW; in power_supply_hwmon_read()
260 return -EINVAL; in power_supply_hwmon_read()
273 struct power_supply *psy = psyhw->psy; in power_supply_hwmon_write()
275 int prop; in power_supply_hwmon_write() local
277 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_write()
278 if (prop < 0) in power_supply_hwmon_write()
279 return prop; in power_supply_hwmon_write()
293 return -EOVERFLOW; in power_supply_hwmon_write()
296 * Temp needs to be converted from 1/10 C to milli-C in power_supply_hwmon_write()
302 return -EINVAL; in power_supply_hwmon_write()
305 return power_supply_set_property(psy, prop, &pspval); in power_supply_hwmon_write()
353 const struct power_supply_desc *desc = psy->desc; in power_supply_add_hwmon_sysfs()
355 struct device *dev = &psy->dev; in power_supply_add_hwmon_sysfs()
362 return -ENOMEM; in power_supply_add_hwmon_sysfs()
366 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
370 psyhw->psy = psy; in power_supply_add_hwmon_sysfs()
371 psyhw->props = devm_bitmap_zalloc(dev, in power_supply_add_hwmon_sysfs()
374 if (!psyhw->props) { in power_supply_add_hwmon_sysfs()
375 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
379 for (i = 0; i < desc->num_properties; i++) { in power_supply_add_hwmon_sysfs()
380 const enum power_supply_property prop = desc->properties[i]; in power_supply_add_hwmon_sysfs() local
382 switch (prop) { in power_supply_add_hwmon_sysfs()
400 set_bit(prop, psyhw->props); in power_supply_add_hwmon_sysfs()
407 name = psy->desc->name; in power_supply_add_hwmon_sysfs()
408 if (strchr(name, '-')) { in power_supply_add_hwmon_sysfs()
413 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
416 strreplace(new_name, '-', '_'); in power_supply_add_hwmon_sysfs()
436 devres_release_group(&psy->dev, power_supply_add_hwmon_sysfs); in power_supply_remove_hwmon_sysfs()