diff options
-rw-r--r-- | drivers/power/bq2415x_charger.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/power/bq2415x_charger.c b/drivers/power/bq2415x_charger.c index c745d278815d..6c534dcbc19c 100644 --- a/drivers/power/bq2415x_charger.c +++ b/drivers/power/bq2415x_charger.c | |||
@@ -1594,27 +1594,27 @@ static int bq2415x_probe(struct i2c_client *client, | |||
1594 | ret = of_property_read_u32(np, "ti,current-limit", | 1594 | ret = of_property_read_u32(np, "ti,current-limit", |
1595 | &bq->init_data.current_limit); | 1595 | &bq->init_data.current_limit); |
1596 | if (ret) | 1596 | if (ret) |
1597 | goto error_2; | 1597 | goto error_3; |
1598 | ret = of_property_read_u32(np, "ti,weak-battery-voltage", | 1598 | ret = of_property_read_u32(np, "ti,weak-battery-voltage", |
1599 | &bq->init_data.weak_battery_voltage); | 1599 | &bq->init_data.weak_battery_voltage); |
1600 | if (ret) | 1600 | if (ret) |
1601 | goto error_2; | 1601 | goto error_3; |
1602 | ret = of_property_read_u32(np, "ti,battery-regulation-voltage", | 1602 | ret = of_property_read_u32(np, "ti,battery-regulation-voltage", |
1603 | &bq->init_data.battery_regulation_voltage); | 1603 | &bq->init_data.battery_regulation_voltage); |
1604 | if (ret) | 1604 | if (ret) |
1605 | goto error_2; | 1605 | goto error_3; |
1606 | ret = of_property_read_u32(np, "ti,charge-current", | 1606 | ret = of_property_read_u32(np, "ti,charge-current", |
1607 | &bq->init_data.charge_current); | 1607 | &bq->init_data.charge_current); |
1608 | if (ret) | 1608 | if (ret) |
1609 | goto error_2; | 1609 | goto error_3; |
1610 | ret = of_property_read_u32(np, "ti,termination-current", | 1610 | ret = of_property_read_u32(np, "ti,termination-current", |
1611 | &bq->init_data.termination_current); | 1611 | &bq->init_data.termination_current); |
1612 | if (ret) | 1612 | if (ret) |
1613 | goto error_2; | 1613 | goto error_3; |
1614 | ret = of_property_read_u32(np, "ti,resistor-sense", | 1614 | ret = of_property_read_u32(np, "ti,resistor-sense", |
1615 | &bq->init_data.resistor_sense); | 1615 | &bq->init_data.resistor_sense); |
1616 | if (ret) | 1616 | if (ret) |
1617 | goto error_2; | 1617 | goto error_3; |
1618 | } else { | 1618 | } else { |
1619 | memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); | 1619 | memcpy(&bq->init_data, pdata, sizeof(bq->init_data)); |
1620 | } | 1620 | } |
@@ -1624,19 +1624,19 @@ static int bq2415x_probe(struct i2c_client *client, | |||
1624 | ret = bq2415x_power_supply_init(bq); | 1624 | ret = bq2415x_power_supply_init(bq); |
1625 | if (ret) { | 1625 | if (ret) { |
1626 | dev_err(bq->dev, "failed to register power supply: %d\n", ret); | 1626 | dev_err(bq->dev, "failed to register power supply: %d\n", ret); |
1627 | goto error_2; | 1627 | goto error_3; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | ret = bq2415x_sysfs_init(bq); | 1630 | ret = bq2415x_sysfs_init(bq); |
1631 | if (ret) { | 1631 | if (ret) { |
1632 | dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret); | 1632 | dev_err(bq->dev, "failed to create sysfs entries: %d\n", ret); |
1633 | goto error_3; | 1633 | goto error_4; |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | ret = bq2415x_set_defaults(bq); | 1636 | ret = bq2415x_set_defaults(bq); |
1637 | if (ret) { | 1637 | if (ret) { |
1638 | dev_err(bq->dev, "failed to set default values: %d\n", ret); | 1638 | dev_err(bq->dev, "failed to set default values: %d\n", ret); |
1639 | goto error_4; | 1639 | goto error_5; |
1640 | } | 1640 | } |
1641 | 1641 | ||
1642 | if (bq->notify_psy) { | 1642 | if (bq->notify_psy) { |
@@ -1644,7 +1644,7 @@ static int bq2415x_probe(struct i2c_client *client, | |||
1644 | ret = power_supply_reg_notifier(&bq->nb); | 1644 | ret = power_supply_reg_notifier(&bq->nb); |
1645 | if (ret) { | 1645 | if (ret) { |
1646 | dev_err(bq->dev, "failed to reg notifier: %d\n", ret); | 1646 | dev_err(bq->dev, "failed to reg notifier: %d\n", ret); |
1647 | goto error_5; | 1647 | goto error_6; |
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | /* Query for initial reported_mode and set it */ | 1650 | /* Query for initial reported_mode and set it */ |
@@ -1664,11 +1664,14 @@ static int bq2415x_probe(struct i2c_client *client, | |||
1664 | dev_info(bq->dev, "driver registered\n"); | 1664 | dev_info(bq->dev, "driver registered\n"); |
1665 | return 0; | 1665 | return 0; |
1666 | 1666 | ||
1667 | error_6: | ||
1667 | error_5: | 1668 | error_5: |
1668 | error_4: | ||
1669 | bq2415x_sysfs_exit(bq); | 1669 | bq2415x_sysfs_exit(bq); |
1670 | error_3: | 1670 | error_4: |
1671 | bq2415x_power_supply_exit(bq); | 1671 | bq2415x_power_supply_exit(bq); |
1672 | error_3: | ||
1673 | if (bq->notify_psy) | ||
1674 | power_supply_put(bq->notify_psy); | ||
1672 | error_2: | 1675 | error_2: |
1673 | kfree(name); | 1676 | kfree(name); |
1674 | error_1: | 1677 | error_1: |
@@ -1685,8 +1688,10 @@ static int bq2415x_remove(struct i2c_client *client) | |||
1685 | { | 1688 | { |
1686 | struct bq2415x_device *bq = i2c_get_clientdata(client); | 1689 | struct bq2415x_device *bq = i2c_get_clientdata(client); |
1687 | 1690 | ||
1688 | if (bq->notify_psy) | 1691 | if (bq->notify_psy) { |
1689 | power_supply_unreg_notifier(&bq->nb); | 1692 | power_supply_unreg_notifier(&bq->nb); |
1693 | power_supply_put(bq->notify_psy); | ||
1694 | } | ||
1690 | 1695 | ||
1691 | bq2415x_sysfs_exit(bq); | 1696 | bq2415x_sysfs_exit(bq); |
1692 | bq2415x_power_supply_exit(bq); | 1697 | bq2415x_power_supply_exit(bq); |