Re: [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer
Jonathan Cameron <[email protected]> Sun, 2 Aug 2026 02:58:47 +0100
| Newsgroups | org.kernel.vger.linux-iio,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260802025847.08aed96b@jic23-huawei> |
On Fri, 31 Jul 2026 23:53:46 +0530 [email protected] wrote: > From: Mohammad Shahid <[email protected]> > > Introduce a local 'struct device *dev' variable in iproc_adc_probe() > and use it instead of repeatedly referencing '&pdev->dev'. > > This simplifies the code and makes subsequent error handling changes > less verbose. > > No functional change intended. > > Signed-off-by: Mohammad Shahid <[email protected]> > --- > drivers/iio/adc/bcm_iproc_adc.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) > > diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c > index 1b0dd654402f..29ea35972a23 100644 > --- a/drivers/iio/adc/bcm_iproc_adc.c > +++ b/drivers/iio/adc/bcm_iproc_adc.c > @@ -506,9 +506,10 @@ static int iproc_adc_probe(struct platform_device *pdev) > { > struct iproc_adc_priv *adc_priv; > struct iio_dev *indio_dev = NULL; > + struct device *dev = &pdev->dev; > int ret; > > - indio_dev = devm_iio_device_alloc(&pdev->dev, > + indio_dev = devm_iio_device_alloc(dev, > sizeof(*adc_priv)); indio_dev = devm_iio_device_alloc(dev, sizeof(*adc_priv)); It fit on one line under 80 chars even before the change but it is even shorter now so let us tidy this up whilst we are here. > if (!indio_dev) > return -ENOMEM; > @@ -523,14 +524,14 @@ static int iproc_adc_probe(struct platform_device *pdev) > adc_priv->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, > "adc-syscon"); > if (IS_ERR(adc_priv->regmap)) { > - dev_err(&pdev->dev, "failed to get handle for tsc syscon\n"); > + dev_err(dev, "failed to get handle for tsc syscon\n"); This is creating churn we don't need. Generally I'd suggest only applying the newly available dev where you aren't going to refactor the line later in the series. Then just add a note there to say that alongside using dev_err_probe() you are taking advantage of the now available dev local variable. > ret = PTR_ERR(adc_priv->regmap); > return ret; > } > > - adc_priv->adc_clk = devm_clk_get(&pdev->dev, "tsc_clk"); > + adc_priv->adc_clk = devm_clk_get(dev, "tsc_clk"); > if (IS_ERR(adc_priv->adc_clk)) { > - dev_err(&pdev->dev, > + dev_err(dev, > "failed getting clock tsc_clk\n"); Similar on this one. > ret = PTR_ERR(adc_priv->adc_clk); > return ret; > @@ -543,11 +544,11 @@ static int iproc_adc_probe(struct platform_device *pdev) > ret = regmap_clear_bits(adc_priv->regmap, IPROC_REGCTL2, > IPROC_ADC_AUXIN_SCAN_ENA); > if (ret) { > - dev_err(&pdev->dev, "failed to write IPROC_REGCTL2 %d\n", ret); > + dev_err(dev, "failed to write IPROC_REGCTL2 %d\n", ret); and this one. > return ret; > } > > - ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, > + ret = devm_request_threaded_irq(dev, adc_priv->irqno, > iproc_adc_interrupt_handler, > iproc_adc_interrupt_thread, > IRQF_SHARED, "iproc-adc", indio_dev); > @@ -556,14 +557,14 @@ static int iproc_adc_probe(struct platform_device *pdev) > > ret = clk_prepare_enable(adc_priv->adc_clk); > if (ret) { > - dev_err(&pdev->dev, > + dev_err(dev, > "clk_prepare_enable failed %d\n", ret); And here. > return ret; > } > > ret = iproc_adc_enable(indio_dev); > if (ret) { > - dev_err(&pdev->dev, "failed to enable adc %d\n", ret); > + dev_err(dev, "failed to enable adc %d\n", ret); you probably get the idea by this point! > goto err_adc_enable; > } > > @@ -575,7 +576,7 @@ static int iproc_adc_probe(struct platform_device *pdev) > > ret = iio_device_register(indio_dev); > if (ret) { > - dev_err(&pdev->dev, "iio_device_register failed:err %d\n", ret); > + dev_err(dev, "iio_device_register failed:err %d\n", ret); > goto err_clk; > } >