aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-07-24 06:44:19 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-08-22 07:24:19 -0400
commit5570c2f709bdc455a2e8907919c1214ca8a21859 (patch)
tree63734cc0ca85c82813ffcca1581d8370342dbe39 /drivers/mfd
parent2e47fff113b7468be2d905e381408c05df72f1ae (diff)
mfd: Use device ID matching for WM831x SPI driver
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/wm831x-spi.c138
1 files changed, 19 insertions, 119 deletions
diff --git a/drivers/mfd/wm831x-spi.c b/drivers/mfd/wm831x-spi.c
index dbe11472afce..5ea60cd860fc 100644
--- a/drivers/mfd/wm831x-spi.c
+++ b/drivers/mfd/wm831x-spi.c
@@ -23,29 +23,12 @@
23 23
24static int __devinit wm831x_spi_probe(struct spi_device *spi) 24static int __devinit wm831x_spi_probe(struct spi_device *spi)
25{ 25{
26 const struct spi_device_id *id = spi_get_device_id(spi);
26 struct wm831x *wm831x; 27 struct wm831x *wm831x;
27 enum wm831x_parent type; 28 enum wm831x_parent type;
28 int ret; 29 int ret;
29 30
30 /* Currently SPI support for ID tables is unmerged, we're faking it */ 31 type = (enum wm831x_parent)id->driver_data;
31 if (strcmp(spi->modalias, "wm8310") == 0)
32 type = WM8310;
33 else if (strcmp(spi->modalias, "wm8311") == 0)
34 type = WM8311;
35 else if (strcmp(spi->modalias, "wm8312") == 0)
36 type = WM8312;
37 else if (strcmp(spi->modalias, "wm8320") == 0)
38 type = WM8320;
39 else if (strcmp(spi->modalias, "wm8321") == 0)
40 type = WM8321;
41 else if (strcmp(spi->modalias, "wm8325") == 0)
42 type = WM8325;
43 else if (strcmp(spi->modalias, "wm8326") == 0)
44 type = WM8326;
45 else {
46 dev_err(&spi->dev, "Unknown device type\n");
47 return -EINVAL;
48 }
49 32
50 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); 33 wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL);
51 if (wm831x == NULL) 34 if (wm831x == NULL)
@@ -57,7 +40,7 @@ static int __devinit wm831x_spi_probe(struct spi_device *spi)
57 dev_set_drvdata(&spi->dev, wm831x); 40 dev_set_drvdata(&spi->dev, wm831x);
58 wm831x->dev = &spi->dev; 41 wm831x->dev = &spi->dev;
59 42
60 wm831x->regmap = regmap_init_spi(wm831x->dev, &wm831x_regmap_config); 43 wm831x->regmap = regmap_init_spi(spi, &wm831x_regmap_config);
61 if (IS_ERR(wm831x->regmap)) { 44 if (IS_ERR(wm831x->regmap)) {
62 ret = PTR_ERR(wm831x->regmap); 45 ret = PTR_ERR(wm831x->regmap);
63 dev_err(wm831x->dev, "Failed to allocate register map: %d\n", 46 dev_err(wm831x->dev, "Failed to allocate register map: %d\n",
@@ -90,79 +73,26 @@ static const struct dev_pm_ops wm831x_spi_pm = {
90 .suspend = wm831x_spi_suspend, 73 .suspend = wm831x_spi_suspend,
91}; 74};
92 75
93static struct spi_driver wm8310_spi_driver = { 76static const struct spi_device_id wm831x_spi_ids[] = {
94 .driver = { 77 { "wm8310", WM8310 },
95 .name = "wm8310", 78 { "wm8311", WM8311 },
96 .bus = &spi_bus_type, 79 { "wm8312", WM8312 },
97 .owner = THIS_MODULE, 80 { "wm8320", WM8320 },
98 .pm = &wm831x_spi_pm, 81 { "wm8321", WM8321 },
99 }, 82 { "wm8325", WM8325 },
100 .probe = wm831x_spi_probe, 83 { "wm8326", WM8326 },
101 .remove = __devexit_p(wm831x_spi_remove), 84 { },
102};
103
104static struct spi_driver wm8311_spi_driver = {
105 .driver = {
106 .name = "wm8311",
107 .bus = &spi_bus_type,
108 .owner = THIS_MODULE,
109 .pm = &wm831x_spi_pm,
110 },
111 .probe = wm831x_spi_probe,
112 .remove = __devexit_p(wm831x_spi_remove),
113}; 85};
86MODULE_DEVICE_TABLE(spi, wm831x_spi_id);
114 87
115static struct spi_driver wm8312_spi_driver = { 88static struct spi_driver wm831x_spi_driver = {
116 .driver = { 89 .driver = {
117 .name = "wm8312", 90 .name = "wm831x",
118 .bus = &spi_bus_type,
119 .owner = THIS_MODULE,
120 .pm = &wm831x_spi_pm,
121 },
122 .probe = wm831x_spi_probe,
123 .remove = __devexit_p(wm831x_spi_remove),
124};
125
126static struct spi_driver wm8320_spi_driver = {
127 .driver = {
128 .name = "wm8320",
129 .bus = &spi_bus_type,
130 .owner = THIS_MODULE,
131 .pm = &wm831x_spi_pm,
132 },
133 .probe = wm831x_spi_probe,
134 .remove = __devexit_p(wm831x_spi_remove),
135};
136
137static struct spi_driver wm8321_spi_driver = {
138 .driver = {
139 .name = "wm8321",
140 .bus = &spi_bus_type,
141 .owner = THIS_MODULE,
142 .pm = &wm831x_spi_pm,
143 },
144 .probe = wm831x_spi_probe,
145 .remove = __devexit_p(wm831x_spi_remove),
146};
147
148static struct spi_driver wm8325_spi_driver = {
149 .driver = {
150 .name = "wm8325",
151 .bus = &spi_bus_type,
152 .owner = THIS_MODULE,
153 .pm = &wm831x_spi_pm,
154 },
155 .probe = wm831x_spi_probe,
156 .remove = __devexit_p(wm831x_spi_remove),
157};
158
159static struct spi_driver wm8326_spi_driver = {
160 .driver = {
161 .name = "wm8326",
162 .bus = &spi_bus_type, 91 .bus = &spi_bus_type,
163 .owner = THIS_MODULE, 92 .owner = THIS_MODULE,
164 .pm = &wm831x_spi_pm, 93 .pm = &wm831x_spi_pm,
165 }, 94 },
95 .id_table = wm831x_spi_ids,
166 .probe = wm831x_spi_probe, 96 .probe = wm831x_spi_probe,
167 .remove = __devexit_p(wm831x_spi_remove), 97 .remove = __devexit_p(wm831x_spi_remove),
168}; 98};
@@ -171,33 +101,9 @@ static int __init wm831x_spi_init(void)
171{ 101{
172 int ret; 102 int ret;
173 103
174 ret = spi_register_driver(&wm8310_spi_driver); 104 ret = spi_register_driver(&wm831x_spi_driver);
175 if (ret != 0)
176 pr_err("Failed to register WM8310 SPI driver: %d\n", ret);
177
178 ret = spi_register_driver(&wm8311_spi_driver);
179 if (ret != 0)
180 pr_err("Failed to register WM8311 SPI driver: %d\n", ret);
181
182 ret = spi_register_driver(&wm8312_spi_driver);
183 if (ret != 0)
184 pr_err("Failed to register WM8312 SPI driver: %d\n", ret);
185
186 ret = spi_register_driver(&wm8320_spi_driver);
187 if (ret != 0)
188 pr_err("Failed to register WM8320 SPI driver: %d\n", ret);
189
190 ret = spi_register_driver(&wm8321_spi_driver);
191 if (ret != 0)
192 pr_err("Failed to register WM8321 SPI driver: %d\n", ret);
193
194 ret = spi_register_driver(&wm8325_spi_driver);
195 if (ret != 0)
196 pr_err("Failed to register WM8325 SPI driver: %d\n", ret);
197
198 ret = spi_register_driver(&wm8326_spi_driver);
199 if (ret != 0) 105 if (ret != 0)
200 pr_err("Failed to register WM8326 SPI driver: %d\n", ret); 106 pr_err("Failed to register WM831x SPI driver: %d\n", ret);
201 107
202 return 0; 108 return 0;
203} 109}
@@ -205,13 +111,7 @@ subsys_initcall(wm831x_spi_init);
205 111
206static void __exit wm831x_spi_exit(void) 112static void __exit wm831x_spi_exit(void)
207{ 113{
208 spi_unregister_driver(&wm8326_spi_driver); 114 spi_unregister_driver(&wm831x_spi_driver);
209 spi_unregister_driver(&wm8325_spi_driver);
210 spi_unregister_driver(&wm8321_spi_driver);
211 spi_unregister_driver(&wm8320_spi_driver);
212 spi_unregister_driver(&wm8312_spi_driver);
213 spi_unregister_driver(&wm8311_spi_driver);
214 spi_unregister_driver(&wm8310_spi_driver);
215} 115}
216module_exit(wm831x_spi_exit); 116module_exit(wm831x_spi_exit);
217 117