Commit 1a8dbe6f authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Sebastian Reichel

power_supply: bq2415x_charger: Decrement the power supply's device reference counter

Use power_supply_put() to decrement the power supply's device reference
counter (increased by power_supply_get_by_name() or
power_supply_get_by_phandle()).
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Reviewed-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent 52016ac0
...@@ -1594,27 +1594,27 @@ static int bq2415x_probe(struct i2c_client *client, ...@@ -1594,27 +1594,27 @@ static int bq2415x_probe(struct i2c_client *client,
ret = of_property_read_u32(np, "ti,current-limit", ret = of_property_read_u32(np, "ti,current-limit",
&bq->init_data.current_limit); &bq->init_data.current_limit);
if (ret) if (ret)
goto error_2; goto error_3;
ret = of_property_read_u32(np, "ti,weak-battery-voltage", ret = of_property_read_u32(np, "ti,weak-battery-voltage",
&bq->init_data.weak_battery_voltage); &bq->init_data.weak_battery_voltage);
if (ret) if (ret)
goto error_2; goto error_3;
ret = of_property_read_u32(np, "ti,battery-regulation-voltage", ret = of_property_read_u32(np, "ti,battery-regulation-voltage",
&bq->init_data.battery_regulation_voltage); &bq->init_data.battery_regulation_voltage);
if (ret) if (ret)
goto error_2; goto error_3;
ret = of_property_read_u32(np, "ti,charge-current", ret = of_property_read_u32(np, "ti,charge-current",
&bq->init_data.charge_current); &bq->init_data.charge_current);
if (ret) if (ret)
goto error_2; goto error_3;
ret = of_property_read_u32(np, "ti,termination-current", ret = of_property_read_u32(np, "ti,termination-current",
&bq->init_data.termination_current); &bq->init_data.termination_current);
if (ret) if (ret)
goto error_2; goto error_3;
ret = of_property_read_u32(np, "ti,resistor-sense", ret = of_property_read_u32(np, "ti,resistor-sense",
&bq->init_data.resistor_sense); &bq->init_data.resistor_sense);
if (ret) if (ret)
goto error_2; goto error_3;
} else { } else {
memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); memcpy(&bq->init_data, pdata, sizeof(bq->init_data));
} }
...@@ -1624,19 +1624,19 @@ static int bq2415x_probe(struct i2c_client *client, ...@@ -1624,19 +1624,19 @@ static int bq2415x_probe(struct i2c_client *client,
ret = bq2415x_power_supply_init(bq); ret = bq2415x_power_supply_init(bq);
if (ret) { if (ret) {
dev_err(bq->dev, "failed to register power supply: %d\n", ret); dev_err(bq->dev, "failed to register power supply: %d\n", ret);
goto error_2; goto error_3;
} }
ret = bq2415x_sysfs_init(bq); ret = bq2415x_sysfs_init(bq);
if (ret) { if (ret) {
dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret); dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret);
goto error_3; goto error_4;
} }
ret = bq2415x_set_defaults(bq); ret = bq2415x_set_defaults(bq);
if (ret) { if (ret) {
dev_err(bq->dev, "failed to set default values: %d\n", ret); dev_err(bq->dev, "failed to set default values: %d\n", ret);
goto error_4; goto error_5;
} }
if (bq->notify_psy) { if (bq->notify_psy) {
...@@ -1644,7 +1644,7 @@ static int bq2415x_probe(struct i2c_client *client, ...@@ -1644,7 +1644,7 @@ static int bq2415x_probe(struct i2c_client *client,
ret = power_supply_reg_notifier(&bq->nb); ret = power_supply_reg_notifier(&bq->nb);
if (ret) { if (ret) {
dev_err(bq->dev, "failed to reg notifier: %d\n", ret); dev_err(bq->dev, "failed to reg notifier: %d\n", ret);
goto error_5; goto error_6;
} }
/* Query for initial reported_mode and set it */ /* Query for initial reported_mode and set it */
...@@ -1664,11 +1664,14 @@ static int bq2415x_probe(struct i2c_client *client, ...@@ -1664,11 +1664,14 @@ static int bq2415x_probe(struct i2c_client *client,
dev_info(bq->dev, "driver registered\n"); dev_info(bq->dev, "driver registered\n");
return 0; return 0;
error_6:
error_5: error_5:
error_4:
bq2415x_sysfs_exit(bq); bq2415x_sysfs_exit(bq);
error_3: error_4:
bq2415x_power_supply_exit(bq); bq2415x_power_supply_exit(bq);
error_3:
if (bq->notify_psy)
power_supply_put(bq->notify_psy);
error_2: error_2:
kfree(name); kfree(name);
error_1: error_1:
...@@ -1685,8 +1688,10 @@ static int bq2415x_remove(struct i2c_client *client) ...@@ -1685,8 +1688,10 @@ static int bq2415x_remove(struct i2c_client *client)
{ {
struct bq2415x_device *bq = i2c_get_clientdata(client); struct bq2415x_device *bq = i2c_get_clientdata(client);
if (bq->notify_psy) if (bq->notify_psy) {
power_supply_unreg_notifier(&bq->nb); power_supply_unreg_notifier(&bq->nb);
power_supply_put(bq->notify_psy);
}
bq2415x_sysfs_exit(bq); bq2415x_sysfs_exit(bq);
bq2415x_power_supply_exit(bq); bq2415x_power_supply_exit(bq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment