Lines Matching refs:psy

61 	struct power_supply *psy = data;
64 if (__power_supply_is_supplied_by(psy, pst)) {
75 struct power_supply *psy = container_of(work, struct power_supply,
78 dev_dbg(psy->dev, "%s\n", __func__);
80 spin_lock_irqsave(&psy->changed_lock, flags);
88 if (likely(psy->changed)) {
89 psy->changed = false;
90 spin_unlock_irqrestore(&psy->changed_lock, flags);
91 class_for_each_device(power_supply_class, NULL, psy,
93 power_supply_update_leds(psy);
95 PSY_EVENT_PROP_CHANGED, psy);
96 kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
97 spin_lock_irqsave(&psy->changed_lock, flags);
105 if (likely(!psy->changed))
106 pm_relax(psy->dev);
107 spin_unlock_irqrestore(&psy->changed_lock, flags);
110 void power_supply_changed(struct power_supply *psy)
114 dev_dbg(psy->dev, "%s\n", __func__);
116 spin_lock_irqsave(&psy->changed_lock, flags);
117 psy->changed = true;
118 pm_stay_awake(psy->dev);
119 spin_unlock_irqrestore(&psy->changed_lock, flags);
120 schedule_work(&psy->changed_work);
130 struct power_supply *psy = data;
136 np = of_parse_phandle(psy->of_node, "power-supplies", i++);
141 dev_info(psy->dev, "%s: Found supply : %s\n",
142 psy->name, epsy->name);
143 psy->supplied_from[i-1] = (char *)epsy->name;
144 psy->num_supplies++;
154 static int power_supply_populate_supplied_from(struct power_supply *psy)
158 error = class_for_each_device(power_supply_class, NULL, psy,
161 dev_dbg(psy->dev, "%s %d\n", __func__, error);
199 static int power_supply_check_supplies(struct power_supply *psy)
205 if (psy->supplied_from && psy->num_supplies > 0)
209 if (!psy->of_node)
215 np = of_parse_phandle(psy->of_node, "power-supplies", cnt++);
223 dev_dbg(psy->dev, "Failed to find supply!\n");
233 psy->supplied_from = devm_kzalloc(psy->dev, sizeof(psy->supplied_from),
235 if (!psy->supplied_from) {
236 dev_err(psy->dev, "Couldn't allocate memory for supply list\n");
240 *psy->supplied_from = devm_kzalloc(psy->dev, sizeof(char *) * (cnt - 1),
242 if (!*psy->supplied_from) {
243 dev_err(psy->dev, "Couldn't allocate memory for supply list\n");
247 return power_supply_populate_supplied_from(psy);
250 static inline int power_supply_check_supplies(struct power_supply *psy)
259 struct power_supply *psy = data;
262 if (__power_supply_is_supplied_by(epsy, psy))
269 int power_supply_am_i_supplied(struct power_supply *psy)
273 error = class_for_each_device(power_supply_class, NULL, psy,
276 dev_dbg(psy->dev, "%s %d\n", __func__, error);
285 struct power_supply *psy = dev_get_drvdata(dev);
289 if (psy->type != POWER_SUPPLY_TYPE_BATTERY)
290 if (!psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &ret))
315 int power_supply_set_battery_charged(struct power_supply *psy)
317 if (psy->type == POWER_SUPPLY_TYPE_BATTERY && psy->set_charged) {
318 psy->set_charged(psy);
329 struct power_supply *psy = dev_get_drvdata(dev);
331 return strcmp(psy->name, name) == 0;
369 int power_supply_powers(struct power_supply *psy, struct device *dev)
371 return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers");
397 struct power_supply *psy;
402 psy = tzd->devdata;
403 ret = psy->get_property(psy, POWER_SUPPLY_PROP_TEMP, &val);
416 static int psy_register_thermal(struct power_supply *psy)
420 if (psy->no_thermal)
423 /* Register battery zone device psy reports temperature */
424 for (i = 0; i < psy->num_properties; i++) {
425 if (psy->properties[i] == POWER_SUPPLY_PROP_TEMP) {
426 psy->tzd = thermal_zone_device_register(psy->name, 0, 0,
427 psy, &psy_tzd_ops, NULL, 0, 0);
428 return PTR_ERR_OR_ZERO(psy->tzd);
434 static void psy_unregister_thermal(struct power_supply *psy)
436 if (IS_ERR_OR_NULL(psy->tzd))
438 thermal_zone_device_unregister(psy->tzd);
445 struct power_supply *psy;
449 psy = tcd->devdata;
450 ret = psy->get_property(psy,
461 struct power_supply *psy;
465 psy = tcd->devdata;
466 ret = psy->get_property(psy,
477 struct power_supply *psy;
481 psy = tcd->devdata;
483 ret = psy->set_property(psy,
495 static int psy_register_cooler(struct power_supply *psy)
499 /* Register for cooling device if psy can control charging */
500 for (i = 0; i < psy->num_properties; i++) {
501 if (psy->properties[i] ==
503 psy->tcd = thermal_cooling_device_register(
504 (char *)psy->name,
505 psy, &psy_tcd_ops);
506 return PTR_ERR_OR_ZERO(psy->tcd);
512 static void psy_unregister_cooler(struct power_supply *psy)
514 if (IS_ERR_OR_NULL(psy->tcd))
516 thermal_cooling_device_unregister(psy->tcd);
519 static int psy_register_thermal(struct power_supply *psy)
524 static void psy_unregister_thermal(struct power_supply *psy)
528 static int psy_register_cooler(struct power_supply *psy)
533 static void psy_unregister_cooler(struct power_supply *psy)
539 struct power_supply *psy, bool ws)
554 dev_set_drvdata(dev, psy);
555 psy->dev = dev;
557 rc = dev_set_name(dev, "%s", psy->name);
561 INIT_WORK(&psy->changed_work, power_supply_changed_work);
563 rc = power_supply_check_supplies(psy);
569 spin_lock_init(&psy->changed_lock);
578 rc = psy_register_thermal(psy);
582 rc = psy_register_cooler(psy);
586 rc = power_supply_create_triggers(psy);
590 power_supply_changed(psy);
595 psy_unregister_cooler(psy);
597 psy_unregister_thermal(psy);
608 int power_supply_register(struct device *parent, struct power_supply *psy)
610 return __power_supply_register(parent, psy, true);
614 int power_supply_register_no_ws(struct device *parent, struct power_supply *psy)
616 return __power_supply_register(parent, psy, false);
620 void power_supply_unregister(struct power_supply *psy)
622 cancel_work_sync(&psy->changed_work);
623 sysfs_remove_link(&psy->dev->kobj, "powers");
624 power_supply_remove_triggers(psy);
625 psy_unregister_cooler(psy);
626 psy_unregister_thermal(psy);
627 device_init_wakeup(psy->dev, false);
628 device_unregister(psy->dev);