Skip to content

Commit 97d3098

Browse files
Taha Ed-Dafilijic23
authored andcommitted
iio: dac: ad5504: introduce local dev pointer
Replace &spi->dev with a local dev pointer to shorten lines, fix alignment, and improve overall readability in the probe function. Signed-off-by: Taha Ed-Dafili <0rayn.dev@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent cc116c1 commit 97d3098

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

drivers/iio/dac/ad5504.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,25 +270,26 @@ static const struct iio_chan_spec ad5504_channels[] = {
270270

271271
static int ad5504_probe(struct spi_device *spi)
272272
{
273-
const struct ad5504_platform_data *pdata = dev_get_platdata(&spi->dev);
273+
struct device *dev = &spi->dev;
274+
const struct ad5504_platform_data *pdata = dev_get_platdata(dev);
274275
struct iio_dev *indio_dev;
275276
struct ad5504_state *st;
276277
int ret;
277278

278-
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
279+
indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
279280
if (!indio_dev)
280281
return -ENOMEM;
281282

282283
st = iio_priv(indio_dev);
283284

284-
ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vcc");
285+
ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
285286
if (ret < 0 && ret != -ENODEV)
286287
return ret;
287288
if (ret == -ENODEV) {
288289
if (pdata->vref_mv)
289290
st->vref_mv = pdata->vref_mv;
290291
else
291-
dev_warn(&spi->dev, "reference voltage unspecified\n");
292+
dev_warn(dev, "reference voltage unspecified\n");
292293
} else {
293294
st->vref_mv = ret / 1000;
294295
}
@@ -304,17 +305,17 @@ static int ad5504_probe(struct spi_device *spi)
304305
indio_dev->modes = INDIO_DIRECT_MODE;
305306

306307
if (spi->irq) {
307-
ret = devm_request_threaded_irq(&spi->dev, spi->irq,
308-
NULL,
309-
&ad5504_event_handler,
310-
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
311-
spi_get_device_id(st->spi)->name,
312-
indio_dev);
308+
ret = devm_request_threaded_irq(dev, spi->irq,
309+
NULL,
310+
&ad5504_event_handler,
311+
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
312+
spi_get_device_id(st->spi)->name,
313+
indio_dev);
313314
if (ret)
314315
return ret;
315316
}
316317

317-
return devm_iio_device_register(&spi->dev, indio_dev);
318+
return devm_iio_device_register(dev, indio_dev);
318319
}
319320

320321
static const struct spi_device_id ad5504_id[] = {

0 commit comments

Comments
 (0)