aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/ad525x_dpot-spi.c
diff options
context:
space:
mode:
authorMichael Hennerich <michael.hennerich@analog.com>2011-11-18 05:05:11 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-18 14:27:02 -0500
commit7f3379de9cd91e52c40a48b8c01ebdb2d2eec5cf (patch)
treef24d960081a21bf72628db7346a9f05f3eea45b6 /drivers/misc/ad525x_dpot-spi.c
parentcfcfc9eca2bcbd26a8e206baeb005b055dbf8e37 (diff)
misc: ad525x_dpot: Add support for SPI module device table matching
Passing device name via platform data, is a leftover from times where SPI module device table matching was not existent. * Add id_table and remove old mechanism. (To my knowledge no intree boards affected) * Miscellaneous other cleanup. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/misc/ad525x_dpot-spi.c')
-rw-r--r--drivers/misc/ad525x_dpot-spi.c97
1 files changed, 38 insertions, 59 deletions
diff --git a/drivers/misc/ad525x_dpot-spi.c b/drivers/misc/ad525x_dpot-spi.c
index 7f9a55afe05d..822749e41fea 100644
--- a/drivers/misc/ad525x_dpot-spi.c
+++ b/drivers/misc/ad525x_dpot-spi.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the Analog Devices digital potentiometers (SPI bus) 2 * Driver for the Analog Devices digital potentiometers (SPI bus)
3 * 3 *
4 * Copyright (C) 2010 Michael Hennerich, Analog Devices Inc. 4 * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
5 * 5 *
6 * Licensed under the GPL-2 or later. 6 * Licensed under the GPL-2 or later.
7 */ 7 */
@@ -11,40 +11,6 @@
11 11
12#include "ad525x_dpot.h" 12#include "ad525x_dpot.h"
13 13
14static const struct ad_dpot_id ad_dpot_spi_devlist[] = {
15 {.name = "ad5160", .devid = AD5160_ID},
16 {.name = "ad5161", .devid = AD5161_ID},
17 {.name = "ad5162", .devid = AD5162_ID},
18 {.name = "ad5165", .devid = AD5165_ID},
19 {.name = "ad5200", .devid = AD5200_ID},
20 {.name = "ad5201", .devid = AD5201_ID},
21 {.name = "ad5203", .devid = AD5203_ID},
22 {.name = "ad5204", .devid = AD5204_ID},
23 {.name = "ad5206", .devid = AD5206_ID},
24 {.name = "ad5207", .devid = AD5207_ID},
25 {.name = "ad5231", .devid = AD5231_ID},
26 {.name = "ad5232", .devid = AD5232_ID},
27 {.name = "ad5233", .devid = AD5233_ID},
28 {.name = "ad5235", .devid = AD5235_ID},
29 {.name = "ad5260", .devid = AD5260_ID},
30 {.name = "ad5262", .devid = AD5262_ID},
31 {.name = "ad5263", .devid = AD5263_ID},
32 {.name = "ad5290", .devid = AD5290_ID},
33 {.name = "ad5291", .devid = AD5291_ID},
34 {.name = "ad5292", .devid = AD5292_ID},
35 {.name = "ad5293", .devid = AD5293_ID},
36 {.name = "ad7376", .devid = AD7376_ID},
37 {.name = "ad8400", .devid = AD8400_ID},
38 {.name = "ad8402", .devid = AD8402_ID},
39 {.name = "ad8403", .devid = AD8403_ID},
40 {.name = "adn2850", .devid = ADN2850_ID},
41 {.name = "ad5270", .devid = AD5270_ID},
42 {.name = "ad5271", .devid = AD5271_ID},
43 {}
44};
45
46/* ------------------------------------------------------------------------- */
47
48/* SPI bus functions */ 14/* SPI bus functions */
49static int write8(void *client, u8 val) 15static int write8(void *client, u8 val)
50{ 16{
@@ -109,36 +75,16 @@ static const struct ad_dpot_bus_ops bops = {
109 .write_r8d8 = write16, 75 .write_r8d8 = write16,
110 .write_r8d16 = write24, 76 .write_r8d16 = write24,
111}; 77};
112
113static const struct ad_dpot_id *dpot_match_id(const struct ad_dpot_id *id,
114 char *name)
115{
116 while (id->name && id->name[0]) {
117 if (strcmp(name, id->name) == 0)
118 return id;
119 id++;
120 }
121 return NULL;
122}
123
124static int __devinit ad_dpot_spi_probe(struct spi_device *spi) 78static int __devinit ad_dpot_spi_probe(struct spi_device *spi)
125{ 79{
126 char *name = spi->dev.platform_data;
127 const struct ad_dpot_id *dpot_id;
128
129 struct ad_dpot_bus_data bdata = { 80 struct ad_dpot_bus_data bdata = {
130 .client = spi, 81 .client = spi,
131 .bops = &bops, 82 .bops = &bops,
132 }; 83 };
133 84
134 dpot_id = dpot_match_id(ad_dpot_spi_devlist, name); 85 return ad_dpot_probe(&spi->dev, &bdata,
135 86 spi_get_device_id(spi)->driver_data,
136 if (dpot_id == NULL) { 87 spi_get_device_id(spi)->name);
137 dev_err(&spi->dev, "%s not in supported device list", name);
138 return -ENODEV;
139 }
140
141 return ad_dpot_probe(&spi->dev, &bdata, dpot_id);
142} 88}
143 89
144static int __devexit ad_dpot_spi_remove(struct spi_device *spi) 90static int __devexit ad_dpot_spi_remove(struct spi_device *spi)
@@ -146,14 +92,47 @@ static int __devexit ad_dpot_spi_remove(struct spi_device *spi)
146 return ad_dpot_remove(&spi->dev); 92 return ad_dpot_remove(&spi->dev);
147} 93}
148 94
95static const struct spi_device_id ad_dpot_spi_id[] = {
96 {"ad5160", AD5160_ID},
97 {"ad5161", AD5161_ID},
98 {"ad5162", AD5162_ID},
99 {"ad5165", AD5165_ID},
100 {"ad5200", AD5200_ID},
101 {"ad5201", AD5201_ID},
102 {"ad5203", AD5203_ID},
103 {"ad5204", AD5204_ID},
104 {"ad5206", AD5206_ID},
105 {"ad5207", AD5207_ID},
106 {"ad5231", AD5231_ID},
107 {"ad5232", AD5232_ID},
108 {"ad5233", AD5233_ID},
109 {"ad5235", AD5235_ID},
110 {"ad5260", AD5260_ID},
111 {"ad5262", AD5262_ID},
112 {"ad5263", AD5263_ID},
113 {"ad5290", AD5290_ID},
114 {"ad5291", AD5291_ID},
115 {"ad5292", AD5292_ID},
116 {"ad5293", AD5293_ID},
117 {"ad7376", AD7376_ID},
118 {"ad8400", AD8400_ID},
119 {"ad8402", AD8402_ID},
120 {"ad8403", AD8403_ID},
121 {"adn2850", ADN2850_ID},
122 {"ad5270", AD5270_ID},
123 {"ad5271", AD5271_ID},
124 {}
125};
126MODULE_DEVICE_TABLE(spi, ad_dpot_spi_id);
127
149static struct spi_driver ad_dpot_spi_driver = { 128static struct spi_driver ad_dpot_spi_driver = {
150 .driver = { 129 .driver = {
151 .name = "ad_dpot", 130 .name = "ad_dpot",
152 .bus = &spi_bus_type,
153 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
154 }, 132 },
155 .probe = ad_dpot_spi_probe, 133 .probe = ad_dpot_spi_probe,
156 .remove = __devexit_p(ad_dpot_spi_remove), 134 .remove = __devexit_p(ad_dpot_spi_remove),
135 .id_table = ad_dpot_spi_id,
157}; 136};
158 137
159static int __init ad_dpot_spi_init(void) 138static int __init ad_dpot_spi_init(void)