diff options
author | David Lechner <dlechner@baylibre.com> | 2024-07-12 11:03:55 -0500 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-08-03 10:13:38 +0100 |
commit | f2e3fbc4443959c966a60519eef04178715dec74 (patch) | |
tree | 7d1f863640412571a407c345bfac0a11fa0818e5 /drivers/iio/dac/mcp4922.c | |
parent | ba2b35841ce9b0cdba125c7f16fb15416258040b (diff) | |
download | lwn-f2e3fbc4443959c966a60519eef04178715dec74.tar.gz lwn-f2e3fbc4443959c966a60519eef04178715dec74.zip |
iio: dac: mcp4922: drop remove() callback
By using devm_iio_device_register(), we can drop the remove() callback
in the mcp4922 driver. We can also remove spi_set_drvdata() since there
are no more callers of spi_get_drvdata(). Also use dev_err_probe()
while we are at it.
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240712-iio-regulator-refactor-round-3-v1-4-835017bae43d@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/dac/mcp4922.c')
-rw-r--r-- | drivers/iio/dac/mcp4922.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/iio/dac/mcp4922.c b/drivers/iio/dac/mcp4922.c index f89af70fa5af..26aa99059813 100644 --- a/drivers/iio/dac/mcp4922.c +++ b/drivers/iio/dac/mcp4922.c @@ -138,7 +138,6 @@ static int mcp4922_probe(struct spi_device *spi) state->vref_mv = ret / 1000; - spi_set_drvdata(spi, indio_dev); id = spi_get_device_id(spi); indio_dev->info = &mcp4922_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -149,22 +148,13 @@ static int mcp4922_probe(struct spi_device *spi) indio_dev->num_channels = MCP4922_NUM_CHANNELS; indio_dev->name = id->name; - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(&spi->dev, "Failed to register iio device: %d\n", - ret); - return ret; - } + ret = devm_iio_device_register(&spi->dev, indio_dev); + if (ret) + return dev_err_probe(&spi->dev, ret, "Failed to register iio device\n"); return 0; } -static void mcp4922_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); -} static const struct spi_device_id mcp4922_id[] = { {"mcp4902", ID_MCP4902}, @@ -180,7 +170,6 @@ static struct spi_driver mcp4922_driver = { .name = "mcp4922", }, .probe = mcp4922_probe, - .remove = mcp4922_remove, .id_table = mcp4922_id, }; module_spi_driver(mcp4922_driver); |