diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-03-12 08:44:02 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-03-13 23:15:12 +0100 |
commit | 2dc9215d7c94f7f9f34ccf8b1710ad73d82f6216 (patch) | |
tree | b8bae66b916e1f64dd725a68bca2182ee315bf66 /drivers/power | |
parent | e44ea364394499d38a26ed4c9668fb378ae8797f (diff) |
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>
Diffstat (limited to 'drivers/power')
59 files changed, 190 insertions, 150 deletions
diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c index bd3c997f4fee..a99d7f2829a7 100644 --- a/drivers/power/88pm860x_battery.c +++ b/drivers/power/88pm860x_battery.c @@ -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; diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c index 734ec4afa14d..ac352a6c03ea 100644 --- a/drivers/power/88pm860x_charger.c +++ b/drivers/power/88pm860x_charger.c @@ -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; diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 4ebf7b0819f7..d5683f503a4e 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c @@ -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; diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 8c8d170ff0f8..cee9b9e46825 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -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; diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index d30387bc4c21..73bdb4dc4142 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -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; diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index ab54b8dea670..0da4415cbc10 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -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; diff --git a/drivers/power/axp288_fuel_gauge.c b/drivers/power/axp288_fuel_gauge.c index c86e709c1880..2bec8d241e62 100644 --- a/drivers/power/axp288_fuel_gauge.c +++ b/drivers/power/axp288_fuel_gauge.c @@ -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; diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index 2333d7f1182b..9b509025d687 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c @@ -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; diff --git a/drivers/power/bq24190_charger.c b/drivers/power/bq24190_charger.c index d0e8236a6404..54eb58485d55 100644 --- a/drivers/power/bq24190_charger.c +++ b/drivers/power/bq24190_charger.c @@ -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; diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c index d022b823305b..242e79bfe217 100644 --- a/drivers/power/bq24735-charger.c +++ b/drivers/power/bq24735-charger.c @@ -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); diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index ba08b5926bfd..a992e43908a2 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c @@ -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; diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 14b0d85318eb..df27600880b9 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c @@ -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); diff --git a/drivers/power/collie_battery.c b/drivers/power/collie_battery.c index 594e4dbc2d51..e7a808d1758a 100644 --- a/drivers/power/collie_battery.c +++ b/drivers/power/collie_battery.c @@ -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; diff --git a/drivers/power/da9030_battery.c b/drivers/power/da9030_battery.c index 78cd5d66144b..a87406ef18ee 100644 --- a/drivers/power/da9030_battery.c +++ b/drivers/power/da9030_battery.c @@ -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; diff --git a/drivers/power/da9052-battery.c b/drivers/power/da9052-battery.c index d17250f745c2..54ba9ddb6d4f 100644 --- a/drivers/power/da9052-battery.c +++ b/drivers/power/da9052-battery.c @@ -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; diff --git a/drivers/power/da9150-charger.c b/drivers/power/da9150-charger.c index 4df97ea8dcde..db8ba5d8d1e3 100644 --- a/drivers/power/da9150-charger.c +++ b/drivers/power/da9150-charger.c @@ -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; diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c index 85b4e6eca0b1..e82dff0bbb20 100644 --- a/drivers/power/ds2760_battery.c +++ b/drivers/power/ds2760_battery.c @@ -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; diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c index 9f418fa879e5..b1d3570ea730 100644 --- a/drivers/power/ds2780_battery.c +++ b/drivers/power/ds2780_battery.c @@ -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; diff --git a/drivers/power/ds2781_battery.c b/drivers/power/ds2781_battery.c index 0a5acc6fc6f0..50686dc59711 100644 --- a/drivers/power/ds2781_battery.c +++ b/drivers/power/ds2781_battery.c @@ -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; diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c index 39694883d3bf..2dcb96a83cee 100644 --- a/drivers/power/ds2782_battery.c +++ b/drivers/power/ds2782_battery.c @@ -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; diff --git a/drivers/power/generic-adc-battery.c b/drivers/power/generic-adc-battery.c index 0a566ac3eefd..4575955de7c5 100644 --- a/drivers/power/generic-adc-battery.c +++ b/drivers/power/generic-adc-battery.c @@ -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; diff --git a/drivers/power/goldfish_battery.c b/drivers/power/goldfish_battery.c index 29eba88a2963..61d437f8cf76 100644 --- a/drivers/power/goldfish_battery.c +++ b/drivers/power/goldfish_battery.c @@ -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_su |