[PATCH 256/510] staging: iio: dac: Use spi_device_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michael Hennerich <michael.hennerich@xxxxxxxxxx>

Signed-off-by: Michael Hennerich <michael.hennerich@xxxxxxxxxx>
Acked-by: Jonathan Cameron <jic23@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
 drivers/staging/iio/dac/ad5624r_spi.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c
index 17588b4..b7c1661 100644
--- a/drivers/staging/iio/dac/ad5624r_spi.c
+++ b/drivers/staging/iio/dac/ad5624r_spi.c
@@ -209,13 +209,8 @@ static const struct attribute_group ad5624r_attribute_group = {
 
 static int __devinit ad5624r_probe(struct spi_device *spi)
 {
-
 	struct ad5624r_state *st;
 	int ret = 0;
-	char *chip_name = spi->dev.platform_data;
-
-	if (!chip_name)
-		return -ENODEV;
 
 	st = kzalloc(sizeof(*st), GFP_KERNEL);
 	if (st == NULL) {
@@ -224,17 +219,7 @@ static int __devinit ad5624r_probe(struct spi_device *spi)
 	}
 	spi_set_drvdata(spi, st);
 
-	if (strcmp(chip_name, "ad5624r") == 0)
-		st->data_len = 12;
-	else if (strcmp(chip_name, "ad5644r") == 0)
-		st->data_len = 14;
-	else if (strcmp(chip_name, "ad5664r") == 0)
-		st->data_len = 16;
-	else {
-		dev_err(&spi->dev, "not supported chip type\n");
-		ret = -EINVAL;
-		goto error_ret;
-	}
+	st->data_len = spi_get_device_id(spi)->driver_data;
 
 	st->us = spi;
 	st->indio_dev = iio_allocate_device();
@@ -278,6 +263,13 @@ static int __devexit ad5624r_remove(struct spi_device *spi)
 	return 0;
 }
 
+static const struct spi_device_id ad5624r_id[] = {
+	{"ad5624r", 12},
+	{"ad5644r", 14},
+	{"ad5664r", 16},
+	{}
+};
+
 static struct spi_driver ad5624r_driver = {
 	.driver = {
 		.name = "ad5624r",
@@ -285,6 +277,7 @@ static struct spi_driver ad5624r_driver = {
 	},
 	.probe = ad5624r_probe,
 	.remove = __devexit_p(ad5624r_remove),
+	.id_table = ad5624r_id,
 };
 
 static __init int ad5624r_spi_init(void)
-- 
1.7.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux