Re: [PATCH] regulator: rk808: make better use of the gpiod API

Uwe Kleine-König
2015-07-21T14:35:32Z

Hello,

On Tue, Jul 21, 2015 at 10:09:32PM +0900, Krzysztof Kozlowski wrote:
> 2015-07-21 15:59 GMT+09:00 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > @@ -540,14 +540,19 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev,
> > goto dt_parse_end;
> >
> > for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) {
> > - pdata->dvs_gpio[i] = gpiod_get_index(client_dev, "dvs", i);
> > + pdata->dvs_gpio[i] =
> > + devm_gpiod_get_index_optional(client_dev, "dvs", i,
> > + GPIOD_OUT_LOW);
> > if (IS_ERR(pdata->dvs_gpio[i])) {
> > + dev_err(dev, "failed to get dvs%d gpio\n", i);
>
> Missing of_node_put() from of_get_child_by_name() called before.
Good catch, thanks.

> > @@ -561,14 +566,6 @@ dt_parse_end:
> >
> > static int rk808_regulator_remove(struct platform_device *pdev)
> > {
> > - struct rk808_regulator_data *pdata = platform_get_drvdata(pdev);
> > - int i;
> > -
> > - for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) {
> > - if (!IS_ERR(pdata->dvs_gpio[i]))
> > - gpiod_put(pdata->dvs_gpio[i]);
> > - }
> > -
> > return 0;
> > }
>
> The function looks empty so it can be removed entirely.
I assumed that not having a remove function makes the device not
detachable. Not sure about that.
Looking at the code I found that not having a remove function can yield
surprises, though. If your driver has a probe but no remove function the
platform bus glue calls

dev_pm_domain_attach(_dev, true);

at probe time, but not

dev_pm_domain_detach(_dev, true);

at remove. I admit I don't know about that dev_pm_domain stuff, but it
looks wrong to only have one but not the other. Greg?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |