Lines Matching +full:prop +full:-
1 // SPDX-License-Identifier: GPL-2.0
3 * power_supply_hwmon.c - power supply hwmon support.
34 return -EINVAL; in power_supply_hwmon_in_to_property()
48 return -EINVAL; in power_supply_hwmon_curr_to_property()
60 return -EINVAL; in power_supply_hwmon_power_to_property()
94 return -EINVAL; in power_supply_hwmon_temp_to_property()
111 return -EINVAL; in power_supply_hwmon_to_property()
143 for (i = 0; i < attr_list->n_attrs; ++i) { in power_supply_hwmon_has_input()
144 int prop = power_supply_hwmon_to_property(type, in power_supply_hwmon_has_input() local
145 attr_list->attrs[i], channel); in power_supply_hwmon_has_input()
147 if (prop >= 0 && test_bit(prop, psyhw->props)) in power_supply_hwmon_has_input()
178 int prop; in power_supply_hwmon_is_visible() local
187 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_is_visible()
188 if (prop < 0 || !test_bit(prop, psyhw->props)) in power_supply_hwmon_is_visible()
191 if (power_supply_property_is_writeable(psyhw->psy, prop) > 0 && in power_supply_hwmon_is_visible()
225 struct power_supply *psy = psyhw->psy; in power_supply_hwmon_read()
227 int ret, prop; in power_supply_hwmon_read() local
229 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_read()
230 if (prop < 0) in power_supply_hwmon_read()
231 return prop; in power_supply_hwmon_read()
233 ret = power_supply_get_property(psy, prop, &pspval); in power_supply_hwmon_read()
253 * Temp needs to be converted from 1/10 C to milli-C in power_supply_hwmon_read()
258 return -EOVERFLOW; in power_supply_hwmon_read()
261 return -EINVAL; in power_supply_hwmon_read()
274 struct power_supply *psy = psyhw->psy; in power_supply_hwmon_write()
276 int prop; in power_supply_hwmon_write() local
278 prop = power_supply_hwmon_to_property(type, attr, channel); in power_supply_hwmon_write()
279 if (prop < 0) in power_supply_hwmon_write()
280 return prop; in power_supply_hwmon_write()
294 return -EOVERFLOW; in power_supply_hwmon_write()
297 * Temp needs to be converted from 1/10 C to milli-C in power_supply_hwmon_write()
303 return -EINVAL; in power_supply_hwmon_write()
306 return power_supply_set_property(psy, prop, &pspval); in power_supply_hwmon_write()
354 const struct power_supply_desc *desc = psy->desc; in power_supply_add_hwmon_sysfs()
356 struct device *dev = &psy->dev; in power_supply_add_hwmon_sysfs()
363 return -ENOMEM; in power_supply_add_hwmon_sysfs()
367 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
371 psyhw->psy = psy; in power_supply_add_hwmon_sysfs()
372 psyhw->props = devm_bitmap_zalloc(dev, in power_supply_add_hwmon_sysfs()
375 if (!psyhw->props) { in power_supply_add_hwmon_sysfs()
376 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
380 for (i = 0; i < desc->num_properties; i++) { in power_supply_add_hwmon_sysfs()
381 const enum power_supply_property prop = desc->properties[i]; in power_supply_add_hwmon_sysfs() local
383 switch (prop) { in power_supply_add_hwmon_sysfs()
401 set_bit(prop, psyhw->props); in power_supply_add_hwmon_sysfs()
408 name = psy->desc->name; in power_supply_add_hwmon_sysfs()
409 if (strchr(name, '-')) { in power_supply_add_hwmon_sysfs()
414 ret = -ENOMEM; in power_supply_add_hwmon_sysfs()
417 strreplace(new_name, '-', '_'); in power_supply_add_hwmon_sysfs()
437 devres_release_group(&psy->dev, power_supply_add_hwmon_sysfs); in power_supply_remove_hwmon_sysfs()