[PATCH v6 5/8] iio: adc: at91_adc: use local struct device pointer in probe

From: Abdelnasser Hussein

Date: Thu Dec 03 2026 - 12:33:52 EST


Convert the remaining &pdev->dev and &idev->dev uses in at91_adc_probe()
to the local dev pointer, and pass sizeof(*st) to
devm_iio_device_alloc().

Diagnostics that previously used &idev->dev now use the platform device.

Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx>
---
drivers/iio/adc/at91_adc.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index cbaad9473239..2d49fb98fa47 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1010,13 +1010,13 @@ static int at91_adc_probe(struct platform_device *pdev)
struct at91_adc_state *st;
u32 reg, prop;

- idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
+ idev = devm_iio_device_alloc(dev, sizeof(*st));
if (!idev)
return -ENOMEM;

st = iio_priv(idev);

- st->caps = device_get_match_data(&pdev->dev);
+ st->caps = device_get_match_data(dev);
if (!st->caps)
return -ENODATA;

@@ -1054,7 +1054,7 @@ static int at91_adc_probe(struct platform_device *pdev)
device_property_match_string(dev, "atmel,adc-use-res", "lowres") >= 0)
st->res = st->caps->low_res_bits;

- dev_info(&idev->dev, "Resolution used: %u bits\n", st->res);
+ dev_info(dev, "Resolution used: %u bits\n", st->res);

st->registers = &st->caps->registers;
st->num_channels = st->caps->num_channels;
@@ -1068,7 +1068,7 @@ static int at91_adc_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, idev);

- idev->name = dev_name(&pdev->dev);
+ idev->name = dev_name(dev);
idev->modes = INDIO_DIRECT_MODE;
idev->info = &at91_adc_info;

@@ -1087,24 +1087,24 @@ static int at91_adc_probe(struct platform_device *pdev)
at91_adc_writel(st, AT91_ADC_IDR, 0xFFFFFFFF);

if (st->caps->has_tsmr)
- ret = devm_request_irq(&pdev->dev, st->irq,
+ ret = devm_request_irq(dev, st->irq,
at91_adc_9x5_interrupt, 0,
- pdev->dev.driver->name, idev);
+ dev->driver->name, idev);
else
- ret = devm_request_irq(&pdev->dev, st->irq,
+ ret = devm_request_irq(dev, st->irq,
at91_adc_rl_interrupt, 0,
- pdev->dev.driver->name, idev);
+ dev->driver->name, idev);
if (ret)
return ret;

- st->clk = devm_clk_get_enabled(&pdev->dev, "adc_clk");
+ st->clk = devm_clk_get_enabled(dev, "adc_clk");
if (IS_ERR(st->clk))
- return dev_err_probe(&pdev->dev, PTR_ERR(st->clk),
+ return dev_err_probe(dev, PTR_ERR(st->clk),
"Could not prepare or enable the clock.\n");

- st->adc_clk = devm_clk_get_enabled(&pdev->dev, "adc_op_clk");
+ st->adc_clk = devm_clk_get_enabled(dev, "adc_op_clk");
if (IS_ERR(st->adc_clk))
- return dev_err_probe(&pdev->dev, PTR_ERR(st->adc_clk),
+ return dev_err_probe(dev, PTR_ERR(st->adc_clk),
"Could not prepare or enable the ADC clock.\n");

/*
@@ -1116,13 +1116,13 @@ static int at91_adc_probe(struct platform_device *pdev)
adc_clk = clk_get_rate(st->adc_clk);
adc_clk_khz = adc_clk / 1000;

- dev_dbg(&pdev->dev, "Master clock is set as: %d Hz, adc_clk should set as: %d Hz\n",
+ dev_dbg(dev, "Master clock is set as: %d Hz, adc_clk should set as: %d Hz\n",
mstrclk, adc_clk);

prsc = (mstrclk / (2 * adc_clk)) - 1;

if (!st->startup_time)
- return dev_err_probe(&pdev->dev, -EINVAL,
+ return dev_err_probe(dev, -EINVAL,
"No startup time available.\n");
ticks = (*st->caps->calc_startup_ticks)(st->startup_time, adc_clk_khz);

@@ -1149,7 +1149,7 @@ static int at91_adc_probe(struct platform_device *pdev)
/* Setup the ADC channels available on the board */
ret = at91_adc_channel_init(idev);
if (ret < 0)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"Couldn't initialize the channels.\n");

init_waitqueue_head(&st->wq_data_avail);
@@ -1163,12 +1163,12 @@ static int at91_adc_probe(struct platform_device *pdev)
if (!st->touchscreen_type) {
ret = at91_adc_buffer_init(idev);
if (ret < 0)
- return dev_err_probe(&pdev->dev, ret,
+ return dev_err_probe(dev, ret,
"Couldn't initialize the buffer.\n");

ret = at91_adc_trigger_init(idev);
if (ret < 0) {
- dev_err(&pdev->dev, "Couldn't setup the triggers.\n");
+ dev_err(dev, "Couldn't setup the triggers.\n");
at91_adc_buffer_remove(idev);
return ret;
}
@@ -1182,7 +1182,7 @@ static int at91_adc_probe(struct platform_device *pdev)

ret = iio_device_register(idev);
if (ret < 0) {
- dev_err(&pdev->dev, "Couldn't register the device.\n");
+ dev_err(dev, "Couldn't register the device.\n");
goto error_iio_device_register;
}


--
2.56.0