Hi Anton, Please ignore the following patch. > This patch adds a helper function in the power supply core to get the power > supply object from supplied_to list based on power supply attribute. > > Signed-off-by: Ramakrishna Pallala <ramakrishna.pall...@intel.com> > --- > drivers/power/power_supply_core.c | 19 +++++++++++++++++++ > include/linux/power_supply.h | 3 +++ > 2 files changed, 22 insertions(+), 0 deletions(-) > > diff --git a/drivers/power/power_supply_core.c > b/drivers/power/power_supply_core.c > index ff990d2..5845a76 100644 > --- a/drivers/power/power_supply_core.c > +++ b/drivers/power/power_supply_core.c > @@ -158,6 +158,25 @@ struct power_supply > *power_supply_get_by_name(char *name) } > EXPORT_SYMBOL_GPL(power_supply_get_by_name); > > +struct power_supply *power_supply_get_by_suppliedto(struct power_supply > *psy, > + enum power_supply_property psp, int intval) { > + union power_supply_propval ret = {0,}; > + struct power_supply *pst; > + int i; > + > + for (i = 0; i < psy->num_supplicants; i++) { > + pst = power_supply_get_by_name(psy->supplied_to[i]); > + if (!pst || pst->get_property(pst, psp, &ret)) > + continue; > + if (ret.intval == intval) > + return pst; > + } > + > + return NULL; > +} > +EXPORT_SYMBOL_GPL(power_supply_get_by_suppliedto); > + > int power_supply_powers(struct power_supply *psy, struct device *dev) { > return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers"); diff -- > git a/include/linux/power_supply.h b/include/linux/power_supply.h index > 0bafbb1..3cfee0c 100644 > --- a/include/linux/power_supply.h > +++ b/include/linux/power_supply.h > @@ -219,6 +219,9 @@ struct power_supply_info { }; > > extern struct power_supply *power_supply_get_by_name(char *name); > +extern struct power_supply *power_supply_get_by_suppliedto( > + struct power_supply *psy, > + enum power_supply_property psp, int intval); > extern void power_supply_changed(struct power_supply *psy); extern int > power_supply_am_i_supplied(struct power_supply *psy); extern int > power_supply_set_battery_charged(struct power_supply *psy); > -- > 1.7.0.4
-- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/