power_supply: Move run-time configuration to separate structure

Add new structure 'power_supply_config' for holding run-time
initialization data like of_node, supplies and private driver data.

The power_supply_register() function is changed so all power supply
drivers need updating.

When registering the power supply this new 'power_supply_config' should be
used instead of directly initializing 'struct power_supply'. This allows
changing the ownership of power_supply structure from driver to the
power supply core in next patches.

When a driver does not use of_node or supplies then it should use NULL
as config. If driver uses of_node or supplies then it should allocate
config on stack and initialize it with proper values.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Pavel Machek <pavel@ucw.cz>

[for the nvec part]
Reviewed-by: Marc Dietrich <marvin24@gmx.de>

[for drivers/platform/x86/compal-laptop.c]
Reviewed-by: Darren Hart <dvhart@linux.intel.com>

[for drivers/hid/*]
Reviewed-by: Jiri Kosina <jkosina@suse.cz>

Signed-off-by: Sebastian Reichel <sre@kernel.org>
This commit is contained in:
Krzysztof Kozlowski 2015-03-12 08:44:02 +01:00 committed by Sebastian Reichel
parent e44ea36439
commit 2dc9215d7c
69 changed files with 224 additions and 167 deletions

View File

@ -351,7 +351,7 @@ static int acpi_ac_add(struct acpi_device *device)
ac->charger.properties = ac_props;
ac->charger.num_properties = ARRAY_SIZE(ac_props);
ac->charger.get_property = get_ac_property;
result = power_supply_register(&ac->device->dev, &ac->charger);
result = power_supply_register(&ac->device->dev, &ac->charger, NULL);
if (result)
goto end;

View File

@ -624,7 +624,8 @@ static int sysfs_add_battery(struct acpi_battery *battery)
battery->bat.type = POWER_SUPPLY_TYPE_BATTERY;
battery->bat.get_property = acpi_battery_get_property;
result = power_supply_register_no_ws(&battery->device->dev, &battery->bat);
result = power_supply_register_no_ws(&battery->device->dev,
&battery->bat, NULL);
if (result)
return result;

View File

@ -540,7 +540,7 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
ARRAY_SIZE(sbs_energy_battery_props);
}
battery->bat.get_property = acpi_sbs_battery_get_property;
result = power_supply_register(&sbs->device->dev, &battery->bat);
result = power_supply_register(&sbs->device->dev, &battery->bat, NULL);
if (result)
goto end;
@ -580,7 +580,7 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
sbs->charger.properties = sbs_ac_props;
sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props);
sbs->charger.get_property = sbs_get_ac_property;
power_supply_register(&sbs->device->dev, &sbs->charger);
power_supply_register(&sbs->device->dev, &sbs->charger, NULL);
printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n",
ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line");

View File

@ -439,7 +439,7 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
dev->battery_report_type = report_type;
dev->battery_report_id = field->report->id;
ret = power_supply_register(&dev->dev, battery);
ret = power_supply_register(&dev->dev, battery, NULL);
if (ret != 0) {
hid_warn(dev, "can't register power supply: %d\n", ret);
kfree(battery->name);

View File

@ -1718,7 +1718,7 @@ static int sony_battery_probe(struct sony_sc *sc)
if (!sc->battery.name)
return -ENOMEM;
ret = power_supply_register(&hdev->dev, &sc->battery);
ret = power_supply_register(&hdev->dev, &sc->battery, NULL);
if (ret) {
hid_err(hdev, "Unable to register battery device\n");
goto err_free;

View File

@ -250,7 +250,7 @@ static int wiimod_battery_probe(const struct wiimod_ops *ops,
if (!wdata->battery.name)
return -ENOMEM;
ret = power_supply_register(&wdata->hdev->dev, &wdata->battery);
ret = power_supply_register(&wdata->hdev->dev, &wdata->battery, NULL);
if (ret) {
hid_err(wdata->hdev, "cannot register battery device\n");
goto err_free;

View File

@ -1021,13 +1021,14 @@ static int wacom_initialize_battery(struct wacom *wacom)
wacom->ac.use_for_apm = 0;
error = power_supply_register(&wacom->hdev->dev,
&wacom->battery);
&wacom->battery, NULL);
if (error)
return error;
power_supply_powers(&wacom->battery, &wacom->hdev->dev);
error = power_supply_register(&wacom->hdev->dev, &wacom->ac);
error = power_supply_register(&wacom->hdev->dev, &wacom->ac,
NULL);
if (error) {
power_supply_unregister(&wacom->battery);
return error;

View File

@ -1036,7 +1036,7 @@ static int compal_probe(struct platform_device *pdev)
/* Power supply */
initialize_power_supply_data(data);
err = power_supply_register(&compal_device->dev, &data->psy);
err = power_supply_register(&compal_device->dev, &data->psy, NULL);
if (err < 0)
goto remove;

View File

@ -953,7 +953,7 @@ static int pm860x_battery_probe(struct platform_device *pdev)
else
info->resistor = 300; /* set default internal resistor */
ret = power_supply_register(&pdev->dev, &info->battery);
ret = power_supply_register(&pdev->dev, &info->battery, NULL);
if (ret)
return ret;
info->battery.dev->parent = &pdev->dev;

View File

@ -648,6 +648,7 @@ static struct pm860x_irq_desc {
static int pm860x_charger_probe(struct platform_device *pdev)
{
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config psy_cfg = {};
struct pm860x_charger_info *info;
int ret;
int count;
@ -687,12 +688,12 @@ static int pm860x_charger_probe(struct platform_device *pdev)
info->usb.name = "usb";
info->usb.type = POWER_SUPPLY_TYPE_USB;
info->usb.supplied_to = pm860x_supplied_to;
info->usb.num_supplicants = ARRAY_SIZE(pm860x_supplied_to);
info->usb.properties = pm860x_usb_props;
info->usb.num_properties = ARRAY_SIZE(pm860x_usb_props);
info->usb.get_property = pm860x_usb_get_prop;
ret = power_supply_register(&pdev->dev, &info->usb);
psy_cfg.supplied_to = pm860x_supplied_to;
psy_cfg.num_supplicants = ARRAY_SIZE(pm860x_supplied_to);
ret = power_supply_register(&pdev->dev, &info->usb, &psy_cfg);
if (ret)
goto out;

View File

@ -1058,6 +1058,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct ab8500_btemp *di;
int irq, i, ret = 0;
u8 val;
@ -1095,11 +1096,11 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
di->btemp_psy.properties = ab8500_btemp_props;
di->btemp_psy.num_properties = ARRAY_SIZE(ab8500_btemp_props);
di->btemp_psy.get_property = ab8500_btemp_get_property;
di->btemp_psy.supplied_to = supply_interface;
di->btemp_psy.num_supplicants = ARRAY_SIZE(supply_interface);
di->btemp_psy.external_power_changed =
ab8500_btemp_external_power_changed;
psy_cfg.supplied_to = supply_interface;
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
/* Create a work queue for the btemp */
di->btemp_wq =
@ -1140,7 +1141,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
}
/* Register BTEMP power supply class */
ret = power_supply_register(di->dev, &di->btemp_psy);
ret = power_supply_register(di->dev, &di->btemp_psy, &psy_cfg);
if (ret) {
dev_err(di->dev, "failed to register BTEMP psy\n");
goto free_btemp_wq;

View File

@ -3446,6 +3446,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct ab8500_charger *di;
int irq, i, charger_status, ret = 0, ch_stat;
@ -3483,6 +3484,10 @@ static int ab8500_charger_probe(struct platform_device *pdev)
di->autopower = false;
di->invalid_charger_detect_state = 0;
/* AC and USB supply config */
psy_cfg.supplied_to = supply_interface;
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
/* AC supply */
/* power_supply base class */
di->ac_chg.psy.name = "ab8500_ac";
@ -3490,8 +3495,6 @@ static int ab8500_charger_probe(struct platform_device *pdev)
di->ac_chg.psy.properties = ab8500_charger_ac_props;
di->ac_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_ac_props);
di->ac_chg.psy.get_property = ab8500_charger_ac_get_property;
di->ac_chg.psy.supplied_to = supply_interface;
di->ac_chg.psy.num_supplicants = ARRAY_SIZE(supply_interface),
/* ux500_charger sub-class */
di->ac_chg.ops.enable = &ab8500_charger_ac_en;
di->ac_chg.ops.check_enable = &ab8500_charger_ac_check_enable;
@ -3517,8 +3520,6 @@ static int ab8500_charger_probe(struct platform_device *pdev)
di->usb_chg.psy.properties = ab8500_charger_usb_props;
di->usb_chg.psy.num_properties = ARRAY_SIZE(ab8500_charger_usb_props);
di->usb_chg.psy.get_property = ab8500_charger_usb_get_property;
di->usb_chg.psy.supplied_to = supply_interface;
di->usb_chg.psy.num_supplicants = ARRAY_SIZE(supply_interface),
/* ux500_charger sub-class */
di->usb_chg.ops.enable = &ab8500_charger_usb_en;
di->usb_chg.ops.check_enable = &ab8500_charger_usb_check_enable;
@ -3616,7 +3617,8 @@ static int ab8500_charger_probe(struct platform_device *pdev)
/* Register AC charger class */
if (di->ac_chg.enabled) {
ret = power_supply_register(di->dev, &di->ac_chg.psy);
ret = power_supply_register(di->dev, &di->ac_chg.psy,
&psy_cfg);
if (ret) {
dev_err(di->dev, "failed to register AC charger\n");
goto free_charger_wq;
@ -3625,7 +3627,8 @@ static int ab8500_charger_probe(struct platform_device *pdev)
/* Register USB charger class */
if (di->usb_chg.enabled) {
ret = power_supply_register(di->dev, &di->usb_chg.psy);
ret = power_supply_register(di->dev, &di->usb_chg.psy,
&psy_cfg);
if (ret) {
dev_err(di->dev, "failed to register USB charger\n");
goto free_ac;

View File

@ -3075,6 +3075,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct ab8500_fg *di;
int i, irq;
int ret = 0;
@ -3111,10 +3112,11 @@ static int ab8500_fg_probe(struct platform_device *pdev)
di->fg_psy.properties = ab8500_fg_props;
di->fg_psy.num_properties = ARRAY_SIZE(ab8500_fg_props);
di->fg_psy.get_property = ab8500_fg_get_property;
di->fg_psy.supplied_to = supply_interface;
di->fg_psy.num_supplicants = ARRAY_SIZE(supply_interface),
di->fg_psy.external_power_changed = ab8500_fg_external_power_changed;
psy_cfg.supplied_to = supply_interface;
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
di->bat_cap.max_mah_design = MILLI_TO_MICRO *
di->bm->bat_type[di->bm->batt_id].charge_full_design;
@ -3174,7 +3176,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)
di->flags.batt_id_received = false;
/* Register FG power supply class */
ret = power_supply_register(di->dev, &di->fg_psy);
ret = power_supply_register(di->dev, &di->fg_psy, &psy_cfg);
if (ret) {
dev_err(di->dev, "failed to register FG psy\n");
goto free_inst_curr_wq;

View File

@ -2047,6 +2047,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct abx500_chargalg *di;
int ret = 0;
@ -2080,11 +2081,12 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
di->chargalg_psy.properties = abx500_chargalg_props;
di->chargalg_psy.num_properties = ARRAY_SIZE(abx500_chargalg_props);
di->chargalg_psy.get_property = abx500_chargalg_get_property;
di->chargalg_psy.supplied_to = supply_interface;
di->chargalg_psy.num_supplicants = ARRAY_SIZE(supply_interface),
di->chargalg_psy.external_power_changed =
abx500_chargalg_external_power_changed;
psy_cfg.supplied_to = supply_interface;
psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
/* Initilialize safety timer */
hrtimer_init(&di->safety_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
di->safety_timer.function = abx500_chargalg_safety_timer_expired;
@ -2115,7 +2117,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)
di->chg_info.prev_conn_chg = -1;
/* Register chargalg power supply class */
ret = power_supply_register(di->dev, &di->chargalg_psy);
ret = power_supply_register(di->dev, &di->chargalg_psy, &psy_cfg);
if (ret) {
dev_err(di->dev, "failed to register chargalg psy\n");
goto free_chargalg_wq;

View File

@ -1099,7 +1099,7 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
info->bat.set_property = fuel_gauge_set_property;
info->bat.property_is_writeable = fuel_gauge_property_is_writeable;
info->bat.external_power_changed = fuel_gauge_external_power_changed;
ret = power_supply_register(&pdev->dev, &info->bat);
ret = power_supply_register(&pdev->dev, &info->bat, NULL);
if (ret) {
dev_err(&pdev->dev, "failed to register battery: %d\n", ret);
return ret;

View File

@ -1051,7 +1051,7 @@ static int bq2415x_power_supply_init(struct bq2415x_device *bq)
return -ENOMEM;
}
ret = power_supply_register(bq->dev, &bq->charger);
ret = power_supply_register(bq->dev, &bq->charger, NULL);
if (ret) {
kfree(bq->model);
return ret;

View File

@ -1418,7 +1418,7 @@ static int bq24190_probe(struct i2c_client *client,
bq24190_charger_init(&bdi->charger);
ret = power_supply_register(dev, &bdi->charger);
ret = power_supply_register(dev, &bdi->charger, NULL);
if (ret) {
dev_err(dev, "Can't register charger\n");
goto out2;
@ -1426,7 +1426,7 @@ static int bq24190_probe(struct i2c_client *client,
bq24190_battery_init(&bdi->battery);
ret = power_supply_register(dev, &bdi->battery);
ret = power_supply_register(dev, &bdi->battery, NULL);
if (ret) {
dev_err(dev, "Can't register battery\n");
goto out3;

View File

@ -249,6 +249,7 @@ static int bq24735_charger_probe(struct i2c_client *client,
int ret;
struct bq24735 *charger;
struct power_supply *supply;
struct power_supply_config psy_cfg = {};
char *name;
charger = devm_kzalloc(&client->dev, sizeof(*charger), GFP_KERNEL);
@ -284,9 +285,10 @@ static int bq24735_charger_probe(struct i2c_client *client,
supply->properties = bq24735_charger_properties;
supply->num_properties = ARRAY_SIZE(bq24735_charger_properties);
supply->get_property = bq24735_charger_get_property;
supply->supplied_to = charger->pdata->supplied_to;
supply->num_supplicants = charger->pdata->num_supplicants;
supply->of_node = client->dev.of_node;
psy_cfg.supplied_to = charger->pdata->supplied_to;
psy_cfg.num_supplicants = charger->pdata->num_supplicants;
psy_cfg.of_node = client->dev.of_node;
i2c_set_clientdata(client, charger);
@ -341,7 +343,7 @@ static int bq24735_charger_probe(struct i2c_client *client,
}
}
ret = power_supply_register(&client->dev, supply);
ret = power_supply_register(&client->dev, supply, &psy_cfg);
if (ret < 0) {
dev_err(&client->dev, "Failed to register power supply: %d\n",
ret);

View File

@ -791,7 +791,7 @@ static int bq27x00_powersupply_init(struct bq27x00_device_info *di)
INIT_DELAYED_WORK(&di->work, bq27x00_battery_poll);
mutex_init(&di->lock);
ret = power_supply_register_no_ws(di->dev, &di->bat);
ret = power_supply_register_no_ws(di->dev, &di->bat, NULL);
if (ret) {
dev_err(di->dev, "failed to register battery: %d\n", ret);
return ret;

View File

@ -1740,7 +1740,7 @@ static int charger_manager_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&cm->fullbatt_vchk_work, fullbatt_vchk);
ret = power_supply_register(NULL, &cm->charger_psy);
ret = power_supply_register(NULL, &cm->charger_psy, NULL);
if (ret) {
dev_err(&pdev->dev, "Cannot register charger-manager with name \"%s\"\n",
cm->charger_psy.name);

View File

@ -334,10 +334,10 @@ static int collie_bat_probe(struct ucb1x00_dev *dev)
INIT_WORK(&bat_work, collie_bat_work);
ret = power_supply_register(&dev->ucb->dev, &collie_bat_main.psy);
ret = power_supply_register(&dev->ucb->dev, &collie_bat_main.psy, NULL);
if (ret)
goto err_psy_reg_main;
ret = power_supply_register(&dev->ucb->dev, &collie_bat_bu.psy);
ret = power_supply_register(&dev->ucb->dev, &collie_bat_bu.psy, NULL);
if (ret)
goto err_psy_reg_bu;

View File

@ -541,7 +541,7 @@ static int da9030_battery_probe(struct platform_device *pdev)
goto err_notifier;
da9030_battery_setup_psy(charger);
ret = power_supply_register(&pdev->dev, &charger->psy);
ret = power_supply_register(&pdev->dev, &charger->psy, NULL);
if (ret)
goto err_ps_register;

View File

@ -625,7 +625,7 @@ static s32 da9052_bat_probe(struct platform_device *pdev)
}
}
ret = power_supply_register(&pdev->dev, &bat->psy);
ret = power_supply_register(&pdev->dev, &bat->psy, NULL);
if (ret)
goto err;

View File

@ -550,7 +550,7 @@ static int da9150_charger_probe(struct platform_device *pdev)
usb->properties = da9150_charger_props;
usb->num_properties = ARRAY_SIZE(da9150_charger_props);
usb->get_property = da9150_charger_get_prop;
ret = power_supply_register(dev, usb);
ret = power_supply_register(dev, usb, NULL);
if (ret)
goto usb_fail;
@ -559,7 +559,7 @@ static int da9150_charger_probe(struct platform_device *pdev)
battery->properties = da9150_charger_bat_props;
battery->num_properties = ARRAY_SIZE(da9150_charger_bat_props);
battery->get_property = da9150_charger_battery_get_prop;
ret = power_supply_register(dev, battery);
ret = power_supply_register(dev, battery, NULL);
if (ret)
goto battery_fail;

View File

@ -555,7 +555,7 @@ static int ds2760_battery_probe(struct platform_device *pdev)
if (current_accum)
ds2760_battery_set_current_accum(di, current_accum);
retval = power_supply_register(&pdev->dev, &di->bat);
retval = power_supply_register(&pdev->dev, &di->bat, NULL);
if (retval) {
dev_err(di->dev, "failed to register battery\n");
goto batt_failed;

View File

@ -776,7 +776,7 @@ static int ds2780_battery_probe(struct platform_device *pdev)
dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props);
dev_info->bat.get_property = ds2780_battery_get_property;
ret = power_supply_register(&pdev->dev, &dev_info->bat);
ret = power_supply_register(&pdev->dev, &dev_info->bat, NULL);
if (ret) {
dev_err(dev_info->dev, "failed to register battery\n");
goto fail;

View File

@ -769,7 +769,7 @@ static int ds2781_battery_probe(struct platform_device *pdev)
dev_info->bat.num_properties = ARRAY_SIZE(ds2781_battery_props);
dev_info->bat.get_property = ds2781_battery_get_property;
ret = power_supply_register(&pdev->dev, &dev_info->bat);
ret = power_supply_register(&pdev->dev, &dev_info->bat, NULL);
if (ret) {
dev_err(dev_info->dev, "failed to register battery\n");
goto fail;

View File

@ -424,7 +424,7 @@ static int ds278x_battery_probe(struct i2c_client *client,
INIT_DELAYED_WORK(&info->bat_work, ds278x_bat_work);
ret = power_supply_register(&client->dev, &info->battery);
ret = power_supply_register(&client->dev, &info->battery, NULL);
if (ret) {
dev_err(&client->dev, "failed to register battery\n");
goto fail_register;

View File

@ -312,7 +312,7 @@ static int gab_probe(struct platform_device *pdev)
*/
psy->num_properties = ARRAY_SIZE(gab_props) + index;
ret = power_supply_register(&pdev->dev, psy);
ret = power_supply_register(&pdev->dev, psy, NULL);
if (ret)
goto err_reg_fail;

View File

@ -195,11 +195,11 @@ static int goldfish_battery_probe(struct platform_device *pdev)
if (ret)
return ret;
ret = power_supply_register(&pdev->dev, &data->ac);
ret = power_supply_register(&pdev->dev, &data->ac, NULL);
if (ret)
return ret;
ret = power_supply_register(&pdev->dev, &data->battery);
ret = power_supply_register(&pdev->dev, &data->battery, NULL);
if (ret) {
power_supply_unregister(&data->ac);
return ret;

View File

@ -127,6 +127,7 @@ struct gpio_charger_platform_data *gpio_charger_parse_dt(struct device *dev)
static int gpio_charger_probe(struct platform_device *pdev)
{
const struct gpio_charger_platform_data *pdata = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct gpio_charger *gpio_charger;
struct power_supply *charger;
int ret;
@ -161,9 +162,10 @@ static int gpio_charger_probe(struct platform_device *pdev)
charger->properties = gpio_charger_properties;
charger->num_properties = ARRAY_SIZE(gpio_charger_properties);
charger->get_property = gpio_charger_get_property;
charger->supplied_to = pdata->supplied_to;
charger->num_supplicants = pdata->num_supplicants;
charger->of_node = pdev->dev.of_node;
psy_cfg.supplied_to = pdata->supplied_to;
psy_cfg.num_supplicants = pdata->num_supplicants;
psy_cfg.of_node = pdev->dev.of_node;
ret = gpio_request(pdata->gpio, dev_name(&pdev->dev));
if (ret) {
@ -178,7 +180,7 @@ static int gpio_charger_probe(struct platform_device *pdev)
gpio_charger->pdata = pdata;
ret = power_supply_register(&pdev->dev, charger);
ret = power_supply_register(&pdev->dev, charger, &psy_cfg);
if (ret < 0) {
dev_err(&pdev->dev, "Failed to register power supply: %d\n",
ret);

View File

@ -692,7 +692,7 @@ static int probe(int irq, struct device *dev)
pbi->batt.properties = pmic_battery_props;
pbi->batt.num_properties = ARRAY_SIZE(pmic_battery_props);
pbi->batt.get_property = pmic_battery_get_property;
retval = power_supply_register(dev, &pbi->batt);
retval = power_supply_register(dev, &pbi->batt, NULL);
if (retval) {
dev_err(dev,
"%s(): failed to register pmic battery device with power supply subsystem\n",
@ -712,7 +712,7 @@ static int probe(int irq, struct device *dev)
pbi->usb.properties = pmic_usb_props;
pbi->usb.num_properties = ARRAY_SIZE(pmic_usb_props);
pbi->usb.get_property = pmic_usb_get_property;
retval = power_supply_register(dev, &pbi->usb);
retval = power_supply_register(dev, &pbi->usb, NULL);
if (retval) {
dev_err(dev,
"%s(): failed to register pmic usb device with power supply subsystem\n",

View File

@ -241,11 +241,11 @@ static int micro_batt_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mb);
queue_delayed_work(mb->wq, &mb->update, 1);
ret = power_supply_register(&pdev->dev, &micro_batt_power);
ret = power_supply_register(&pdev->dev, &micro_batt_power, NULL);
if (ret < 0)
goto batt_err;
ret = power_supply_register(&pdev->dev, &micro_ac_power);
ret = power_supply_register(&pdev->dev, &micro_ac_power, NULL);
if (ret < 0)
goto ac_err;

View File

@ -460,7 +460,7 @@ static int isp1704_charger_probe(struct platform_device *pdev)
isp->psy.num_properties = ARRAY_SIZE(power_props);
isp->psy.get_property = isp1704_charger_get_property;
ret = power_supply_register(isp->dev, &isp->psy);
ret = power_supply_register(isp->dev, &isp->psy, NULL);
if (ret)
goto fail1;

View File

@ -330,7 +330,7 @@ static int jz_battery_probe(struct platform_device *pdev)
else
jz4740_adc_set_config(pdev->dev.parent, JZ_ADC_CONFIG_BAT_MB, 0);
ret = power_supply_register(&pdev->dev, &jz_battery->battery);
ret = power_supply_register(&pdev->dev, &jz_battery->battery, NULL);
if (ret) {
dev_err(&pdev->dev, "power supply battery register failed.\n");
goto err_free_charge_irq;

View File

@ -420,6 +420,7 @@ static void lp8727_charger_changed(struct power_supply *psy)
static int lp8727_register_psy(struct lp8727_chg *pchg)
{
struct power_supply_config psy_cfg = {}; /* Only for ac and usb */
struct lp8727_psy *psy;
psy = devm_kzalloc(pchg->dev, sizeof(*psy), GFP_KERNEL);
@ -428,15 +429,16 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
pchg->psy = psy;
psy_cfg.supplied_to = battery_supplied_to;
psy_cfg.num_supplicants = ARRAY_SIZE(battery_supplied_to);
psy->ac.name = "ac";
psy->ac.type = POWER_SUPPLY_TYPE_MAINS;
psy->ac.properties = lp8727_charger_prop;
psy->ac.num_properties = ARRAY_SIZE(lp8727_charger_prop);
psy->ac.get_property = lp8727_charger_get_property;
psy->ac.supplied_to = battery_supplied_to;
psy->ac.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(pchg->dev, &psy->ac))
if (power_supply_register(pchg->dev, &psy->ac, &psy_cfg))
goto err_psy_ac;
psy->usb.name = "usb";
@ -444,10 +446,8 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy->usb.properties = lp8727_charger_prop;
psy->usb.num_properties = ARRAY_SIZE(lp8727_charger_prop);
psy->usb.get_property = lp8727_charger_get_property;
psy->usb.supplied_to = battery_supplied_to;
psy->usb.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(pchg->dev, &psy->usb))
if (power_supply_register(pchg->dev, &psy->usb, &psy_cfg))
goto err_psy_usb;
psy->batt.name = "main_batt";
@ -457,7 +457,7 @@ static int lp8727_register_psy(struct lp8727_chg *pchg)
psy->batt.get_property = lp8727_battery_get_property;
psy->batt.external_power_changed = lp8727_charger_changed;
if (power_supply_register(pchg->dev, &psy->batt))
if (power_supply_register(pchg->dev, &psy->batt, NULL))
goto err_psy_batt;
return 0;

View File

@ -400,15 +400,18 @@ static int lp8788_update_charger_params(struct platform_device *pdev,
static int lp8788_psy_register(struct platform_device *pdev,
struct lp8788_charger *pchg)
{
struct power_supply_config charger_cfg = {};
pchg->charger.name = LP8788_CHARGER_NAME;
pchg->charger.type = POWER_SUPPLY_TYPE_MAINS;
pchg->charger.properties = lp8788_charger_prop;
pchg->charger.num_properties = ARRAY_SIZE(lp8788_charger_prop);
pchg->charger.get_property = lp8788_charger_get_property;
pchg->charger.supplied_to = battery_supplied_to;
pchg->charger.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(&pdev->dev, &pchg->charger))
charger_cfg.supplied_to = battery_supplied_to;
charger_cfg.num_supplicants = ARRAY_SIZE(battery_supplied_to);
if (power_supply_register(&pdev->dev, &pchg->charger, &charger_cfg))
return -EPERM;
pchg->battery.name = LP8788_BATTERY_NAME;
@ -417,7 +420,7 @@ static int lp8788_psy_register(struct platform_device *pdev,
pchg->battery.num_properties = ARRAY_SIZE(lp8788_battery_prop);
pchg->battery.get_property = lp8788_battery_get_property;
if (power_supply_register(&pdev->dev, &pchg->battery)) {
if (power_supply_register(&pdev->dev, &pchg->battery, NULL)) {
power_supply_unregister(&pchg->charger);
return -EPERM;
}

View File

@ -473,7 +473,7 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
goto fail_comm;
}
ret = power_supply_register(&client->dev, &info->supply);
ret = power_supply_register(&client->dev, &info->supply, NULL);
if (ret) {
dev_err(&client->dev, "failed to register ltc2941\n");
goto fail_register;

View File

@ -594,7 +594,7 @@ static int max14577_charger_probe(struct platform_device *pdev)
return ret;
}
ret = power_supply_register(&pdev->dev, &chg->charger);
ret = power_supply_register(&pdev->dev, &chg->charger, NULL);
if (ret) {
dev_err(&pdev->dev, "failed: power supply register\n");
goto err;

View File

@ -224,7 +224,7 @@ static int max17040_probe(struct i2c_client *client,
chip->battery.properties = max17040_battery_props;
chip->battery.num_properties = ARRAY_SIZE(max17040_battery_props);
ret = power_supply_register(&client->dev, &chip->battery);
ret = power_supply_register(&client->dev, &chip->battery, NULL);
if (ret) {
dev_err(&client->dev, "failed: power supply register\n");
return ret;

View File

@ -731,7 +731,7 @@ static int max17042_probe(struct i2c_client *client,
regmap_write(chip->regmap, MAX17042_LearnCFG, 0x0007);
}
ret = power_supply_register(&client->dev, &chip->battery);
ret = power_supply_register(&client->dev, &chip->battery, NULL);
if (ret) {
dev_err(&client->dev, "failed: power supply register\n");
return ret;

View File

@ -714,7 +714,7 @@ static int max77693_charger_probe(struct platform_device *pdev)
goto err;
}
ret = power_supply_register(&pdev->dev, &chg->charger);
ret = power_supply_register(&pdev->dev, &chg->charger, NULL);
if (ret) {
dev_err(&pdev->dev, "failed: power supply register\n");
goto err;

View File

@ -288,7 +288,7 @@ static int max8903_probe(struct platform_device *pdev)
data->psy.properties = max8903_charger_props;
data->psy.num_properties = ARRAY_SIZE(max8903_charger_props);
ret = power_supply_register(dev, &data->psy);
ret = power_supply_register(dev, &data->psy, NULL);
if (ret) {
dev_err(dev, "failed: power supply register.\n");
goto err;

View File

@ -482,6 +482,7 @@ max8925_power_dt_init(struct platform_device *pdev)
static int max8925_power_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config psy_cfg = {}; /* Only for ac and usb */
struct max8925_power_pdata *pdata = NULL;
struct max8925_power_info *info;
int ret;
@ -502,14 +503,15 @@ static int max8925_power_probe(struct platform_device *pdev)
info->adc = chip->adc;
platform_set_drvdata(pdev, info);
psy_cfg.supplied_to = pdata->supplied_to;
psy_cfg.num_supplicants = pdata->num_supplicants;
info->ac.name = "max8925-ac";
info->ac.type = POWER_SUPPLY_TYPE_MAINS;
info->ac.properties = max8925_ac_props;
info->ac.num_properties = ARRAY_SIZE(max8925_ac_props);
info->ac.get_property = max8925_ac_get_prop;
info->ac.supplied_to = pdata->supplied_to;
info->ac.num_supplicants = pdata->num_supplicants;
ret = power_supply_register(&pdev->dev, &info->ac);
ret = power_supply_register(&pdev->dev, &info->ac, &psy_cfg);
if (ret)
goto out;
info->ac.dev->parent = &pdev->dev;
@ -519,10 +521,8 @@ static int max8925_power_probe(struct platform_device *pdev)
info->usb.properties = max8925_usb_props;
info->usb.num_properties = ARRAY_SIZE(max8925_usb_props);
info->usb.get_property = max8925_usb_get_prop;
info->usb.supplied_to = pdata->supplied_to;
info->usb.num_supplicants = pdata->num_supplicants;
ret = power_supply_register(&pdev->dev, &info->usb);
ret = power_supply_register(&pdev->dev, &info->usb, &psy_cfg);
if (ret)
goto out_usb;
info->usb.dev->parent = &pdev->dev;
@ -532,7 +532,7 @@ static int max8925_power_probe(struct platform_device *pdev)
info->battery.properties = max8925_battery_props;
info->battery.num_properties = ARRAY_SIZE(max8925_battery_props);
info->battery.get_property = max8925_bat_get_prop;
ret = power_supply_register(&pdev->dev, &info->battery);
ret = power_supply_register(&pdev->dev, &info->battery, NULL);
if (ret)
goto out_battery;
info->battery.dev->parent = &pdev->dev;

View File

@ -156,7 +156,7 @@ static int max8997_battery_probe(struct platform_device *pdev)
charger->dev = &pdev->dev;
charger->iodev = iodev;
ret = power_supply_register(&pdev->dev, &charger->battery);
ret = power_supply_register(&pdev->dev, &charger->battery, NULL);
if (ret) {
dev_err(&pdev->dev, "failed: power supply register\n");
return ret;

View File

@ -167,7 +167,7 @@ static int max8998_battery_probe(struct platform_device *pdev)
max8998->battery.properties = max8998_battery_props;
max8998->battery.num_properties = ARRAY_SIZE(max8998_battery_props);
ret = power_supply_register(max8998->dev, &max8998->battery);
ret = power_supply_register(max8998->dev, &max8998->battery, NULL);
if (ret) {
dev_err(max8998->dev, "failed: power supply register\n");
goto err;

View File

@ -619,7 +619,7 @@ static int olpc_battery_probe(struct platform_device *pdev)
/* Ignore the status. It doesn't actually matter */
ret = power_supply_register(&pdev->dev, &olpc_ac);
ret = power_supply_register(&pdev->dev, &olpc_ac, NULL);
if (ret)
return ret;
@ -631,7 +631,7 @@ static int olpc_battery_probe(struct platform_device *pdev)
olpc_bat.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
}
ret = power_supply_register(&pdev->dev, &olpc_bat);
ret = power_supply_register(&pdev->dev, &olpc_bat, NULL);
if (ret)
goto battery_failed;

View File

@ -368,6 +368,7 @@ static const u8 mbc_irq_handlers[] = {
static int pcf50633_mbc_probe(struct platform_device *pdev)
{
struct power_supply_config psy_cfg = {};
struct pcf50633_mbc *mbc;
int ret;
int i;
@ -385,45 +386,42 @@ static int pcf50633_mbc_probe(struct platform_device *pdev)
pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
pcf50633_mbc_irq_handler, mbc);
psy_cfg.supplied_to = mbc->pcf->pdata->batteries;
psy_cfg.num_supplicants = mbc->pcf->pdata->num_batteries;
/* Create power supplies */
mbc->adapter.name = "adapter";
mbc->adapter.type = POWER_SUPPLY_TYPE_MAINS;
mbc->adapter.properties = power_props;
mbc->adapter.num_properties = ARRAY_SIZE(power_props);
mbc->adapter.get_property = &adapter_get_property;
mbc->adapter.supplied_to = mbc->pcf->pdata->batteries;
mbc->adapter.num_supplicants = mbc->pcf->pdata->num_batteries;
mbc->usb.name = "usb";
mbc->usb.type = POWER_SUPPLY_TYPE_USB;
mbc->usb.properties = power_props;
mbc->usb.num_properties = ARRAY_SIZE(power_props);
mbc->usb.get_property = usb_get_property;
mbc->usb.supplied_to = mbc->pcf->pdata->batteries;
mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries;
mbc->ac.name = "ac";
mbc->ac.type = POWER_SUPPLY_TYPE_MAINS;
mbc->ac.properties = power_props;
mbc->ac.num_properties = ARRAY_SIZE(power_props);
mbc->ac.get_property = ac_get_property;
mbc->ac.supplied_to = mbc->pcf->pdata->batteries;
mbc->ac.num_supplicants = mbc->pcf->pdata->num_batteries;
ret = power_supply_register(&pdev->dev, &mbc->adapter);
ret = power_supply_register(&pdev->dev, &mbc->adapter, &psy_cfg);
if (ret) {
dev_err(mbc->pcf->dev, "failed to register adapter\n");
return ret;
}
ret = power_supply_register(&pdev->dev, &mbc->usb);
ret = power_supply_register(&pdev->dev, &mbc->usb, &psy_cfg);
if (ret) {
dev_err(mbc->pcf->dev, "failed to register usb\n");
power_supply_unregister(&mbc->adapter);
return ret;
}
ret = power_supply_register(&pdev->dev, &mbc->ac);
ret = power_supply_register(&pdev->dev, &mbc->ac, &psy_cfg);
if (ret) {
dev_err(mbc->pcf->dev, "failed to register ac\n");
power_supply_unregister(&mbc->adapter);

View File

@ -83,8 +83,6 @@ static char *pda_power_supplied_to[] = {
static struct power_supply pda_psy_ac = {
.name = "ac",
.type = POWER_SUPPLY_TYPE_MAINS,
.supplied_to = pda_power_supplied_to,
.num_supplicants = ARRAY_SIZE(pda_power_supplied_to),
.properties = pda_power_props,
.num_properties = ARRAY_SIZE(pda_power_props),
.get_property = pda_power_get_property,
@ -93,8 +91,6 @@ static struct power_supply pda_psy_ac = {
static struct power_supply pda_psy_usb = {
.name = "usb",
.type = POWER_SUPPLY_TYPE_USB,
.supplied_to = pda_power_supplied_to,
.num_supplicants = ARRAY_SIZE(pda_power_supplied_to),
.properties = pda_power_props,
.num_properties = ARRAY_SIZE(pda_power_props),
.get_property = pda_power_get_property,
@ -262,6 +258,7 @@ static int otg_handle_notification(struct notifier_block *nb,
static int pda_power_probe(struct platform_device *pdev)
{
struct power_supply_config psy_cfg = {};
int ret = 0;
dev = &pdev->dev;
@ -309,10 +306,11 @@ static int pda_power_probe(struct platform_device *pdev)
usb_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "usb");
if (pdata->supplied_to) {
pda_psy_ac.supplied_to = pdata->supplied_to;
pda_psy_ac.num_supplicants = pdata->num_supplicants;
pda_psy_usb.supplied_to = pdata->supplied_to;
pda_psy_usb.num_supplicants = pdata->num_supplicants;
psy_cfg.supplied_to = pdata->supplied_to;
psy_cfg.num_supplicants = pdata->num_supplicants;
} else {
psy_cfg.supplied_to = pda_power_supplied_to;
psy_cfg.num_supplicants = ARRAY_SIZE(pda_power_supplied_to);
}
#if IS_ENABLED(CONFIG_USB_PHY)
@ -326,7 +324,7 @@ static int pda_power_probe(struct platform_device *pdev)
#endif
if (pdata->is_ac_online) {
ret = power_supply_register(&pdev->dev, &pda_psy_ac);
ret = power_supply_register(&pdev->dev, &pda_psy_ac, &psy_cfg);
if (ret) {
dev_err(dev, "failed to register %s power supply\n",
pda_psy_ac.name);
@ -347,7 +345,7 @@ static int pda_power_probe(struct platform_device *pdev)
}
if (pdata->is_usb_online) {
ret = power_supply_register(&pdev->dev, &pda_psy_usb);
ret = power_supply_register(&pdev->dev, &pda_psy_usb, &psy_cfg);
if (ret) {
dev_err(dev, "failed to register %s power supply\n",
pda_psy_usb.name);

View File

@ -989,6 +989,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
const struct i2c_device_id *id)
{
struct pm2xxx_platform_data *pl_data = i2c_client->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct pm2xxx_charger *pm2;
int ret = 0;
u8 val;
@ -1047,8 +1048,9 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
pm2->ac_chg.psy.properties = pm2xxx_charger_ac_props;
pm2->ac_chg.psy.num_properties = ARRAY_SIZE(pm2xxx_charger_ac_props);
pm2->ac_chg.psy.get_property = pm2xxx_charger_ac_get_property;
pm2->ac_chg.psy.supplied_to = pm2->pdata->supplied_to;
pm2->ac_chg.psy.num_supplicants = pm2->pdata->num_supplicants;
psy_cfg.supplied_to = pm2->pdata->supplied_to;
psy_cfg.num_supplicants = pm2->pdata->num_supplicants;
/* pm2xxx_charger sub-class */
pm2->ac_chg.ops.enable = &pm2xxx_charger_ac_en;
pm2->ac_chg.ops.kick_wd = &pm2xxx_charger_watchdog_kick;
@ -1093,7 +1095,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
}
/* Register AC charger class */
ret = power_supply_register(pm2->dev, &pm2->ac_chg.psy);
ret = power_supply_register(pm2->dev, &pm2->ac_chg.psy, &psy_cfg);
if (ret) {
dev_err(pm2->dev, "failed to register AC charger\n");
goto free_regulator;

View File

@ -152,7 +152,7 @@ static int __init pmu_bat_init(void)
goto pdev_register_failed;
}
ret = power_supply_register(&bat_pdev->dev, &pmu_ac);
ret = power_supply_register(&bat_pdev->dev, &pmu_ac, NULL);
if (ret)
goto ac_register_failed;
@ -169,7 +169,7 @@ static int __init pmu_bat_init(void)
pbat->bat.get_property = pmu_bat_get_property;
pbat->pbi = &pmu_batteries[i];
ret = power_supply_register(&bat_pdev->dev, &pbat->bat);
ret = power_supply_register(&bat_pdev->dev, &pbat->bat, NULL);
if (ret) {
kfree(pbat);
goto battery_register_failed;

View File

@ -536,7 +536,9 @@ static void psy_unregister_cooler(struct power_supply *psy)
#endif
static int __power_supply_register(struct device *parent,
struct power_supply *psy, bool ws)
struct power_supply *psy,
const struct power_supply_config *cfg,
bool ws)
{
struct device *dev;
int rc;
@ -553,6 +555,12 @@ static int __power_supply_register(struct device *parent,
dev->release = power_supply_dev_release;
dev_set_drvdata(dev, psy);
psy->dev = dev;
if (cfg) {
psy->drv_data = cfg->drv_data;
psy->of_node = cfg->of_node;
psy->supplied_to = cfg->supplied_to;
psy->num_supplicants = cfg->num_supplicants;
}
rc = dev_set_name(dev, "%s", psy->name);
if (rc)
@ -605,15 +613,17 @@ dev_set_name_failed:
return rc;
}
int power_supply_register(struct device *parent, struct power_supply *psy)
int power_supply_register(struct device *parent, struct power_supply *psy,
const struct power_supply_config *cfg)
{
return __power_supply_register(parent, psy, true);
return __power_supply_register(parent, psy, cfg, true);
}
EXPORT_SYMBOL_GPL(power_supply_register);
int power_supply_register_no_ws(struct device *parent, struct power_supply *psy)
int power_supply_register_no_ws(struct device *parent, struct power_supply *psy,
const struct power_supply_config *cfg)
{
return __power_supply_register(parent, psy, false);
return __power_supply_register(parent, psy, cfg, false);
}
EXPORT_SYMBOL_GPL(power_supply_register_no_ws);
@ -624,7 +634,8 @@ static void devm_power_supply_release(struct device *dev, void *res)
power_supply_unregister(*psy);
}
int devm_power_supply_register(struct device *parent, struct power_supply *psy)
int devm_power_supply_register(struct device *parent, struct power_supply *psy,
const struct power_supply_config *cfg)
{
struct power_supply **ptr = devres_alloc(devm_power_supply_release,
sizeof(*ptr), GFP_KERNEL);
@ -632,7 +643,7 @@ int devm_power_supply_register(struct device *parent, struct power_supply *psy)
if (!ptr)
return -ENOMEM;
ret = __power_supply_register(parent, psy, true);
ret = __power_supply_register(parent, psy, cfg, true);
if (ret < 0)
devres_free(ptr);
else {
@ -643,7 +654,8 @@ int devm_power_supply_register(struct device *parent, struct power_supply *psy)
}
EXPORT_SYMBOL_GPL(devm_power_supply_register);
int devm_power_supply_register_no_ws(struct device *parent, struct power_supply *psy)
int devm_power_supply_register_no_ws(struct device *parent, struct power_supply *psy,
const struct power_supply_config *cfg)
{
struct power_supply **ptr = devres_alloc(devm_power_supply_release,
sizeof(*ptr), GFP_KERNEL);
@ -651,7 +663,7 @@ int devm_power_supply_register_no_ws(struct device *parent, struct power_supply
if (!ptr)
return -ENOMEM;
ret = __power_supply_register(parent, psy, false);
ret = __power_supply_register(parent, psy, cfg, false);
if (ret < 0)
devres_free(ptr);
else {

View File

@ -138,7 +138,7 @@ static int rt5033_battery_probe(struct i2c_client *client,
battery->psy.properties = rt5033_battery_props;
battery->psy.num_properties = ARRAY_SIZE(rt5033_battery_props);
ret = power_supply_register(&client->dev, &battery->psy);
ret = power_supply_register(&client->dev, &battery->psy, NULL);
if (ret) {
dev_err(&client->dev, "Failed to register power supply\n");
return ret;

View File

@ -238,7 +238,7 @@ static int rx51_battery_probe(struct platform_device *pdev)
goto error_channel_bsi;
}
ret = power_supply_register(di->dev, &di->bat);
ret = power_supply_register(di->dev, &di->bat, NULL);
if (ret)
goto error_channel_vbat;

View File

@ -310,14 +310,14 @@ static int s3c_adc_bat_probe(struct platform_device *pdev)
main_bat.cable_plugged = 0;
main_bat.status = POWER_SUPPLY_STATUS_DISCHARGING;
ret = power_supply_register(&pdev->dev, &main_bat.psy);
ret = power_supply_register(&pdev->dev, &main_bat.psy, NULL);
if (ret)
goto err_reg_main;
if (pdata->backup_volt_mult) {
backup_bat.client = client;
backup_bat.pdata = pdev->dev.platform_data;
backup_bat.volt_value = -1;
ret = power_supply_register(&pdev->dev, &backup_bat.psy);
ret = power_supply_register(&pdev->dev, &backup_bat.psy, NULL);
if (ret)
goto err_reg_backup;
}

View File

@ -801,6 +801,7 @@ static int sbs_probe(struct i2c_client *client,
{
struct sbs_info *chip;
struct sbs_platform_data *pdata = client->dev.platform_data;
struct power_supply_config psy_cfg = {};
int rc;
int irq;
char *name;
@ -825,7 +826,7 @@ static int sbs_probe(struct i2c_client *client,
chip->power_supply.properties = sbs_properties;
chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties);
chip->power_supply.get_property = sbs_get_property;
chip->power_supply.of_node = client->dev.of_node;
psy_cfg.of_node = client->dev.of_node;
/* ignore first notification of external change, it is generated
* from the power_supply_register call back
*/
@ -892,7 +893,8 @@ skip_gpio:
goto exit_psupply;
}
rc = power_supply_register(&client->dev, &chip->power_supply);
rc = power_supply_register(&client->dev, &chip->power_supply,
&psy_cfg);
if (rc) {
dev_err(&client->dev,
"%s: Failed to register power supply\n", __func__);

View File

@ -1194,6 +1194,7 @@ static int smb347_probe(struct i2c_client *client,
{
static char *battery[] = { "smb347-battery" };
const struct smb347_charger_platform_data *pdata;
struct power_supply_config psy_cfg = {}; /* Only for mains and usb */
struct device *dev = &client->dev;
struct smb347_charger *smb;
int ret;
@ -1223,15 +1224,15 @@ static int smb347_probe(struct i2c_client *client,
if (ret < 0)
return ret;
psy_cfg.supplied_to = battery;
psy_cfg.num_supplicants = ARRAY_SIZE(battery);
if (smb->pdata->use_mains) {
smb->mains.name = "smb347-mains";
smb->mains.type = POWER_SUPPLY_TYPE_MAINS;
smb->mains.get_property = smb347_mains_get_property;
smb->mains.properties = smb347_mains_properties;
smb->mains.num_properties = ARRAY_SIZE(smb347_mains_properties);
smb->mains.supplied_to = battery;
smb->mains.num_supplicants = ARRAY_SIZE(battery);
ret = power_supply_register(dev, &smb->mains);
ret = power_supply_register(dev, &smb->mains, &psy_cfg);
if (ret < 0)
return ret;
}
@ -1242,9 +1243,7 @@ static int smb347_probe(struct i2c_client *client,
smb->usb.get_property = smb347_usb_get_property;
smb->usb.properties = smb347_usb_properties;
smb->usb.num_properties = ARRAY_SIZE(smb347_usb_properties);
smb->usb.supplied_to = battery;
smb->usb.num_supplicants = ARRAY_SIZE(battery);
ret = power_supply_register(dev, &smb->usb);
ret = power_supply_register(dev, &smb->usb, &psy_cfg);
if (ret < 0) {
if (smb->pdata->use_mains)
power_supply_unregister(&smb->mains);
@ -1259,7 +1258,7 @@ static int smb347_probe(struct i2c_client *client,
smb->battery.num_properties = ARRAY_SIZE(smb347_battery_properties);
ret = power_supply_register(dev, &smb->battery);
ret = power_supply_register(dev, &smb->battery, NULL);
if (ret < 0) {
if (smb->pdata->use_usb)
power_supply_unregister(&smb->usb);

View File

@ -157,8 +157,6 @@ static struct power_supply test_power_supplies[] = {
[TEST_AC] = {
.name = "test_ac",
.type = POWER_SUPPLY_TYPE_MAINS,
.supplied_to = test_power_ac_supplied_to,
.num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
.properties = test_power_ac_props,
.num_properties = ARRAY_SIZE(test_power_ac_props),
.get_property = test_power_get_ac_property,
@ -173,14 +171,25 @@ static struct power_supply test_power_supplies[] = {
[TEST_USB] = {
.name = "test_usb",
.type = POWER_SUPPLY_TYPE_USB,
.supplied_to = test_power_ac_supplied_to,
.num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
.properties = test_power_ac_props,
.num_properties = ARRAY_SIZE(test_power_ac_props),
.get_property = test_power_get_usb_property,
},
};
static const struct power_supply_config test_power_configs[] = {
{
/* test_ac */
.supplied_to = test_power_ac_supplied_to,
.num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
}, {
/* test_battery */
}, {
/* test_usb */
.supplied_to = test_power_ac_supplied_to,
.num_supplicants = ARRAY_SIZE(test_power_ac_supplied_to),
},
};
static int __init test_power_init(void)
{
@ -188,9 +197,11 @@ static int __init test_power_init(void)
int ret;
BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_supplies));
BUILD_BUG_ON(TEST_POWER_NUM != ARRAY_SIZE(test_power_configs));
for (i = 0; i < ARRAY_SIZE(test_power_supplies); i++) {
ret = power_supply_register(NULL, &test_power_supplies[i]);
ret = power_supply_register(NULL, &test_power_supplies[i],
&test_power_configs[i]);
if (ret) {
pr_err("%s: failed to register %s\n", __func__,
test_power_supplies[i].name);

View File

@ -358,13 +358,13 @@ static int tosa_bat_probe(struct platform_device *dev)
INIT_WORK(&bat_work, tosa_bat_work);
ret = power_supply_register(&dev->dev, &tosa_bat_main.psy);
ret = power_supply_register(&dev->dev, &tosa_bat_main.psy, NULL);
if (ret)
goto err_psy_reg_main;
ret = power_supply_register(&dev->dev, &tosa_bat_jacket.psy);
ret = power_supply_register(&dev->dev, &tosa_bat_jacket.psy, NULL);
if (ret)
goto err_psy_reg_jacket;
ret = power_supply_register(&dev->dev, &tosa_bat_bu.psy);
ret = power_supply_register(&dev->dev, &tosa_bat_bu.psy, NULL);
if (ret)
goto err_psy_reg_bu;

View File

@ -233,6 +233,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
{
struct tps65090_charger *cdata;
struct tps65090_platform_data *pdata;
struct power_supply_config psy_cfg = {};
uint8_t status1 = 0;
int ret;
int irq;
@ -264,11 +265,12 @@ static int tps65090_charger_probe(struct platform_device *pdev)
cdata->ac.get_property = tps65090_ac_get_property;
cdata->ac.properties = tps65090_ac_props;
cdata->ac.num_properties = ARRAY_SIZE(tps65090_ac_props);
cdata->ac.supplied_to = pdata->supplied_to;
cdata->ac.num_supplicants = pdata->num_supplicants;
cdata->ac.of_node = pdev->dev.of_node;
ret = power_supply_register(&pdev->dev, &cdata->ac);
psy_cfg.supplied_to = pdata->supplied_to;
psy_cfg.num_supplicants = pdata->num_supplicants;
psy_cfg.of_node = pdev->dev.of_node;
ret = power_supply_register(&pdev->dev, &cdata->ac, &psy_cfg);
if (ret) {
dev_err(&pdev->dev, "failed: power supply register\n");
return ret;

View File

@ -590,7 +590,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
bci->ac.num_properties = ARRAY_SIZE(twl4030_charger_props);
bci->ac.get_property = twl4030_bci_get_property;
ret = power_supply_register(&pdev->dev, &bci->ac);
ret = power_supply_register(&pdev->dev, &bci->ac, NULL);
if (ret) {
dev_err(&pdev->dev, "failed to register ac: %d\n", ret);
goto fail_register_ac;
@ -604,7 +604,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
bci->usb_reg = regulator_get(bci->dev, "bci3v1");
ret = power_supply_register(&pdev->dev, &bci->usb);
ret = power_supply_register(&pdev->dev, &bci->usb, NULL);
if (ret) {
dev_err(&pdev->dev, "failed to register usb: %d\n", ret);
goto fail_register_usb;

View File

@ -217,7 +217,7 @@ static int twl4030_madc_battery_probe(struct platform_device *pdev)
twl4030_madc_bat->pdata = pdata;
platform_set_drvdata(pdev, twl4030_madc_bat);
ret = power_supply_register(&pdev->dev, &twl4030_madc_bat->psy);
ret = power_supply_register(&pdev->dev, &twl4030_madc_bat->psy, NULL);
if (ret < 0)
kfree(twl4030_madc_bat);

View File

@ -197,7 +197,7 @@ static int wm831x_backup_probe(struct platform_device *pdev)
backup->properties = wm831x_backup_props;
backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
backup->get_property = wm831x_backup_get_prop;
ret = power_supply_register(&pdev->dev, backup);
ret = power_supply_register(&pdev->dev, backup, NULL);
return ret;
}

View File

@ -536,7 +536,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
wall->properties = wm831x_wall_props;
wall->num_properties = ARRAY_SIZE(wm831x_wall_props);
wall->get_property = wm831x_wall_get_prop;
ret = power_supply_register(&pdev->dev, wall);
ret = power_supply_register(&pdev->dev, wall, NULL);
if (ret)
goto err_kmalloc;
@ -545,7 +545,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
usb->properties = wm831x_usb_props;
usb->num_properties = ARRAY_SIZE(wm831x_usb_props);
usb->get_property = wm831x_usb_get_prop;
ret = power_supply_register(&pdev->dev, usb);
ret = power_supply_register(&pdev->dev, usb, NULL);
if (ret)
goto err_wall;
@ -560,7 +560,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
battery->num_properties = ARRAY_SIZE(wm831x_bat_props);
battery->get_property = wm831x_bat_get_prop;
battery->use_for_apm = 1;
ret = power_supply_register(&pdev->dev, battery);
ret = power_supply_register(&pdev->dev, battery, NULL);
if (ret)
goto err_usb;
}

View File

@ -457,7 +457,7 @@ static int wm8350_power_probe(struct platform_device *pdev)
ac->properties = wm8350_ac_props;
ac->num_properties = ARRAY_SIZE(wm8350_ac_props);
ac->get_property = wm8350_ac_get_prop;
ret = power_supply_register(&pdev->dev, ac);
ret = power_supply_register(&pdev->dev, ac, NULL);
if (ret)
return ret;
@ -466,7 +466,7 @@ static int wm8350_power_probe(struct platform_device *pdev)
battery->num_properties = ARRAY_SIZE(wm8350_bat_props);
battery->get_property = wm8350_bat_get_property;
battery->use_for_apm = 1;
ret = power_supply_register(&pdev->dev, battery);
ret = power_supply_register(&pdev->dev, battery, NULL);
if (ret)
goto battery_failed;
@ -475,7 +475,7 @@ static int wm8350_power_probe(struct platform_device *pdev)
usb->properties = wm8350_usb_props;
usb->num_properties = ARRAY_SIZE(wm8350_usb_props);
usb->get_property = wm8350_usb_get_prop;
ret = power_supply_register(&pdev->dev, usb);
ret = power_supply_register(&pdev->dev, usb, NULL);
if (ret)
goto usb_failed;

View File

@ -244,7 +244,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
bat_ps.properties = prop;
bat_ps.num_properties = props;
ret = power_supply_register(&dev->dev, &bat_ps);
ret = power_supply_register(&dev->dev, &bat_ps, NULL);
if (!ret)
schedule_work(&bat_work);
else

View File

@ -230,7 +230,7 @@ static int z2_batt_probe(struct i2c_client *client,
INIT_WORK(&charger->bat_work, z2_batt_work);
ret = power_supply_register(&client->dev, &charger->batt_ps);
ret = power_supply_register(&client->dev, &charger->batt_ps, NULL);
if (ret)
goto err4;

View File

@ -334,8 +334,6 @@ static struct power_supply nvec_bat_psy = {
static struct power_supply nvec_psy = {
.name = "ac",
.type = POWER_SUPPLY_TYPE_MAINS,
.supplied_to = nvec_power_supplied_to,
.num_supplicants = ARRAY_SIZE(nvec_power_supplied_to),
.properties = nvec_power_props,
.num_properties = ARRAY_SIZE(nvec_power_props),
.get_property = nvec_power_get_property,
@ -376,6 +374,7 @@ static int nvec_power_probe(struct platform_device *pdev)
struct power_supply *psy;
struct nvec_power *power;
struct nvec_chip *nvec = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config psy_cfg = {};
power = devm_kzalloc(&pdev->dev, sizeof(struct nvec_power), GFP_NOWAIT);
if (power == NULL)
@ -387,6 +386,8 @@ static int nvec_power_probe(struct platform_device *pdev)
switch (pdev->id) {
case AC:
psy = &nvec_psy;
psy_cfg.supplied_to = nvec_power_supplied_to;
psy_cfg.num_supplicants = ARRAY_SIZE(nvec_power_supplied_to);
power->notifier.notifier_call = nvec_power_notifier;
@ -407,7 +408,7 @@ static int nvec_power_probe(struct platform_device *pdev)
if (pdev->id == BAT)
get_bat_mfg_data(power);
return power_supply_register(&pdev->dev, psy);
return power_supply_register(&pdev->dev, psy, &psy_cfg);
}
static int nvec_power_remove(struct platform_device *pdev)

View File

@ -176,6 +176,16 @@ union power_supply_propval {
struct device;
struct device_node;
/* Power supply instance specific configuration */
struct power_supply_config {
struct device_node *of_node;
/* Driver private data */
void *drv_data;
char **supplied_to;
size_t num_supplicants;
};
struct power_supply {
const char *name;
enum power_supply_type type;
@ -278,13 +288,17 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
#endif
extern int power_supply_register(struct device *parent,
struct power_supply *psy);
struct power_supply *psy,
const struct power_supply_config *cfg);
extern int power_supply_register_no_ws(struct device *parent,
struct power_supply *psy);
struct power_supply *psy,
const struct power_supply_config *cfg);
extern int devm_power_supply_register(struct device *parent,
struct power_supply *psy);
struct power_supply *psy,
const struct power_supply_config *cfg);
extern int devm_power_supply_register_no_ws(struct device *parent,
struct power_supply *psy);
struct power_supply *psy,
const struct power_supply_config *cfg);
extern void power_supply_unregister(struct power_supply *psy);
extern int power_supply_powers(struct power_supply *psy, struct device *dev);