Message ID | 20231006125557.212681-2-m.majewski2@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fix Samsung pinctrl driver static allocation of GPIO base warning | expand |
On Fri, Oct 6, 2023 at 8:01 AM Mateusz Majewski <m.majewski2@samsung.com> wrote: > > dev_pinctrl_register function immediately enables the pinctrl subsystem, Nitpick: dev -> devm > which is unpreferable in general, since drivers might be unable to > handle calls immediately. Hence devm_pinctrl_register_and_init, which > does not call pinctrl_enable, is preferred. > > In case of our driver using the old function does not seem to be > problematic for now, but will become an issue when we postpone parts of > pinctrl initialization in a future commit, and it is a good idea to move > off a deprecated-ish function anyway. > > Signed-off-by: Mateusz Majewski <m.majewski2@samsung.com> > --- > drivers/pinctrl/samsung/pinctrl-samsung.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c > index e54847040b4a..e496af72a587 100644 > --- a/drivers/pinctrl/samsung/pinctrl-samsung.c > +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c > @@ -904,11 +904,11 @@ static int samsung_pinctrl_register(struct platform_device *pdev, > if (ret) > return ret; > > - drvdata->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, > - drvdata); > - if (IS_ERR(drvdata->pctl_dev)) { > + ret = devm_pinctrl_register_and_init(&pdev->dev, ctrldesc, drvdata, > + &drvdata->pctl_dev); > + if (ret) { > dev_err(&pdev->dev, "could not register pinctrl driver\n"); > - return PTR_ERR(drvdata->pctl_dev); > + return ret; > } > > for (bank = 0; bank < drvdata->nr_banks; ++bank) { > @@ -1176,6 +1176,10 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) > if (ret) > goto err_unregister; > > + ret = pinctrl_enable(drvdata->pctl_dev); > + if (ret) > + goto err_unregister; > + > platform_set_drvdata(pdev, drvdata); > > return 0; > -- > 2.42.0 >
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index e54847040b4a..e496af72a587 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -904,11 +904,11 @@ static int samsung_pinctrl_register(struct platform_device *pdev, if (ret) return ret; - drvdata->pctl_dev = devm_pinctrl_register(&pdev->dev, ctrldesc, - drvdata); - if (IS_ERR(drvdata->pctl_dev)) { + ret = devm_pinctrl_register_and_init(&pdev->dev, ctrldesc, drvdata, + &drvdata->pctl_dev); + if (ret) { dev_err(&pdev->dev, "could not register pinctrl driver\n"); - return PTR_ERR(drvdata->pctl_dev); + return ret; } for (bank = 0; bank < drvdata->nr_banks; ++bank) { @@ -1176,6 +1176,10 @@ static int samsung_pinctrl_probe(struct platform_device *pdev) if (ret) goto err_unregister; + ret = pinctrl_enable(drvdata->pctl_dev); + if (ret) + goto err_unregister; + platform_set_drvdata(pdev, drvdata); return 0;
dev_pinctrl_register function immediately enables the pinctrl subsystem, which is unpreferable in general, since drivers might be unable to handle calls immediately. Hence devm_pinctrl_register_and_init, which does not call pinctrl_enable, is preferred. In case of our driver using the old function does not seem to be problematic for now, but will become an issue when we postpone parts of pinctrl initialization in a future commit, and it is a good idea to move off a deprecated-ish function anyway. Signed-off-by: Mateusz Majewski <m.majewski2@samsung.com> --- drivers/pinctrl/samsung/pinctrl-samsung.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)