Re: [PATCH v1 5/7] power: bq24190_charger: Reorder init sequence in probe()

Hans de Goede
2017-03-22T12:24:48Z

Hi,

On 21-03-17 23:09, Liam Breck wrote:
> From: Liam Breck <kernel@networkimprov.net>
>
> We need a struct power_supply object from register() before
> calling setup_dt()
>
> Cc: Mark Greer <mgreer@animalcreek.com>
> Signed-off-by: Liam Breck <kernel@networkimprov.net>

Looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans

> ---
> drivers/power/supply/bq24190_charger.c | 37 +++++++++++++++++-----------------
> 1 file changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index ad09e48..2fbc7f3 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -1386,16 +1386,6 @@ static int bq24190_probe(struct i2c_client *client,
>
> i2c_set_clientdata(client, bdi);
>
> - if (dev->of_node)
> - ret = bq24190_setup_dt(bdi);
> - else
> - ret = bq24190_setup_pdata(bdi, pdata);
> -
> - if (ret) {
> - dev_err(dev, "Can't get irq info\n");
> - return -EINVAL;
> - }
> -
> pm_runtime_enable(dev);
> pm_runtime_use_autosuspend(dev);
> pm_runtime_set_autosuspend_delay(dev, 600);
> @@ -1405,12 +1395,6 @@ static int bq24190_probe(struct i2c_client *client,
> goto out1;
> }
>
> - ret = bq24190_hw_init(bdi);
> - if (ret < 0) {
> - dev_err(dev, "Hardware init failed\n");
> - goto out2;
> - }
> -
> charger_cfg.drv_data = bdi;
> charger_cfg.supplied_to = bq24190_charger_supplied_to;
> charger_cfg.num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to),
> @@ -1431,6 +1415,23 @@ static int bq24190_probe(struct i2c_client *client,
> goto out3;
> }
>
> + if (dev->of_node)
> + ret = bq24190_setup_dt(bdi);
> + else
> + ret = bq24190_setup_pdata(bdi, pdata);
> +
> + if (ret) {
> + dev_err(dev, "Can't get irq info\n");
> + ret = -EINVAL;
> + goto out4;
> + }
> +
> + ret = bq24190_hw_init(bdi);
> + if (ret < 0) {
> + dev_err(dev, "Hardware init failed\n");
> + goto out4;
> + }
> +
> ret = bq24190_sysfs_create_group(bdi);
> if (ret) {
> dev_err(dev, "Can't create sysfs entries\n");
> @@ -1459,6 +1460,8 @@ static int bq24190_probe(struct i2c_client *client,
> bq24190_sysfs_remove_group(bdi);
>
> out4:
> + if (bdi->gpio_int)
> + gpio_free(bdi->gpio_int);
> power_supply_unregister(bdi->battery);
>
> out3:
> @@ -1470,8 +1473,6 @@ static int bq24190_probe(struct i2c_client *client,
> out1:
> pm_runtime_dont_use_autosuspend(dev);
> pm_runtime_disable(dev);
> - if (bdi->gpio_int)
> - gpio_free(bdi->gpio_int);
> return ret;
> }
>
>