lkml.org 
[lkml]   [2020]   [Feb]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5 V2] staging: iio: adc: ad7192: removed spi_device_id
Date
This patch removes spi_device_id table and moves the
init data (id of the chip) in the .data field
of of_device_id table.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
---
drivers/staging/iio/adc/ad7192.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index 8f2fa154876a..e75d808a2f41 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/sched.h>
#include <linux/delay.h>
+#include <linux/of_device.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -876,8 +877,11 @@ static int ad7192_channels_config(struct iio_dev *indio_dev)
return 0;
}

+static const struct of_device_id ad7192_of_match[];
+
static int ad7192_probe(struct spi_device *spi)
{
+ const struct of_device_id *match;
struct ad7192_state *st;
struct iio_dev *indio_dev;
int ret, voltage_uv = 0;
@@ -927,8 +931,12 @@ static int ad7192_probe(struct spi_device *spi)
goto error_disable_avdd;
}

+ match = of_match_device(ad7192_of_match, &spi->dev);
+ if (!match)
+ return -EINVAL;
+
spi_set_drvdata(spi, indio_dev);
- st->devid = spi_get_device_id(spi)->driver_data;
+ st->devid = (unsigned long)match->data;
indio_dev->dev.parent = &spi->dev;
indio_dev->name = spi_get_device_id(spi)->name;
indio_dev->modes = INDIO_DIRECT_MODE;
@@ -1010,21 +1018,11 @@ static int ad7192_remove(struct spi_device *spi)
return 0;
}

-static const struct spi_device_id ad7192_id[] = {
- {"ad7190", ID_AD7190},
- {"ad7192", ID_AD7192},
- {"ad7193", ID_AD7193},
- {"ad7195", ID_AD7195},
- {}
-};
-
-MODULE_DEVICE_TABLE(spi, ad7192_id);
-
static const struct of_device_id ad7192_of_match[] = {
- { .compatible = "adi,ad7190" },
- { .compatible = "adi,ad7192" },
- { .compatible = "adi,ad7193" },
- { .compatible = "adi,ad7195" },
+ { .compatible = "adi,ad7190", .data = (void *)ID_AD7190},
+ { .compatible = "adi,ad7192", .data = (void *)ID_AD7192 },
+ { .compatible = "adi,ad7193", .data = (void *)ID_AD7193 },
+ { .compatible = "adi,ad7195", .data = (void *)ID_AD7195 },
{}
};

@@ -1037,7 +1035,6 @@ static struct spi_driver ad7192_driver = {
},
.probe = ad7192_probe,
.remove = ad7192_remove,
- .id_table = ad7192_id,
};
module_spi_driver(ad7192_driver);

--
2.20.1
\
 
 \ /
  Last update: 2020-02-05 18:16    [W:0.076 / U:10.880 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site