aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c4
-rw-r--r--drivers/gpio/pca953x.c28
-rw-r--r--drivers/gpio/pcf857x.c36
3 files changed, 32 insertions, 36 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 24c62b848bf9..7f138c6195ff 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -382,7 +382,7 @@ fail:
382 spin_unlock_irqrestore(&gpio_lock, flags); 382 spin_unlock_irqrestore(&gpio_lock, flags);
383 if (status) 383 if (status)
384 pr_debug("%s: gpio-%d status %d\n", 384 pr_debug("%s: gpio-%d status %d\n",
385 __FUNCTION__, gpio, status); 385 __func__, gpio, status);
386 return status; 386 return status;
387} 387}
388EXPORT_SYMBOL_GPL(gpio_direction_input); 388EXPORT_SYMBOL_GPL(gpio_direction_input);
@@ -420,7 +420,7 @@ fail:
420 spin_unlock_irqrestore(&gpio_lock, flags); 420 spin_unlock_irqrestore(&gpio_lock, flags);
421 if (status) 421 if (status)
422 pr_debug("%s: gpio-%d status %d\n", 422 pr_debug("%s: gpio-%d status %d\n",
423 __FUNCTION__, gpio, status); 423 __func__, gpio, status);
424 return status; 424 return status;
425} 425}
426EXPORT_SYMBOL_GPL(gpio_direction_output); 426EXPORT_SYMBOL_GPL(gpio_direction_output);
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index e0e0af536108..93f916720b13 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -23,21 +23,19 @@
23#define PCA953X_INVERT 2 23#define PCA953X_INVERT 2
24#define PCA953X_DIRECTION 3 24#define PCA953X_DIRECTION 3
25 25
26/* This is temporary - in 2.6.26 i2c_driver_data should replace it. */ 26static const struct i2c_device_id pca953x_id[] = {
27struct pca953x_desc {
28 char name[I2C_NAME_SIZE];
29 unsigned long driver_data;
30};
31
32static const struct pca953x_desc pca953x_descs[] = {
33 { "pca9534", 8, }, 27 { "pca9534", 8, },
34 { "pca9535", 16, }, 28 { "pca9535", 16, },
35 { "pca9536", 4, }, 29 { "pca9536", 4, },
36 { "pca9537", 4, }, 30 { "pca9537", 4, },
37 { "pca9538", 8, }, 31 { "pca9538", 8, },
38 { "pca9539", 16, }, 32 { "pca9539", 16, },
33 { "pca9555", 16, },
34 { "pca9557", 8, },
39 /* REVISIT several pca955x parts should work here too */ 35 /* REVISIT several pca955x parts should work here too */
36 { }
40}; 37};
38MODULE_DEVICE_TABLE(i2c, pca953x_id);
41 39
42struct pca953x_chip { 40struct pca953x_chip {
43 unsigned gpio_start; 41 unsigned gpio_start;
@@ -192,26 +190,17 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
192 gc->owner = THIS_MODULE; 190 gc->owner = THIS_MODULE;
193} 191}
194 192
195static int __devinit pca953x_probe(struct i2c_client *client) 193static int __devinit pca953x_probe(struct i2c_client *client,
194 const struct i2c_device_id *id)
196{ 195{
197 struct pca953x_platform_data *pdata; 196 struct pca953x_platform_data *pdata;
198 struct pca953x_chip *chip; 197 struct pca953x_chip *chip;
199 int ret, i; 198 int ret;
200 const struct pca953x_desc *id = NULL;
201 199
202 pdata = client->dev.platform_data; 200 pdata = client->dev.platform_data;
203 if (pdata == NULL) 201 if (pdata == NULL)
204 return -ENODEV; 202 return -ENODEV;
205 203
206 /* this loop vanishes when we get i2c_device_id */
207 for (i = 0; i < ARRAY_SIZE(pca953x_descs); i++)
208 if (!strcmp(pca953x_descs[i].name, client->name)) {
209 id = pca953x_descs + i;
210 break;
211 }
212 if (!id)
213 return -ENODEV;
214
215 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL); 204 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
216 if (chip == NULL) 205 if (chip == NULL)
217 return -ENOMEM; 206 return -ENOMEM;
@@ -291,6 +280,7 @@ static struct i2c_driver pca953x_driver = {
291 }, 280 },
292 .probe = pca953x_probe, 281 .probe = pca953x_probe,
293 .remove = pca953x_remove, 282 .remove = pca953x_remove,
283 .id_table = pca953x_id,
294}; 284};
295 285
296static int __init pca953x_init(void) 286static int __init pca953x_init(void)
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index 1106aa15ac79..aa6cc8b2a2bc 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -26,6 +26,21 @@
26#include <asm/gpio.h> 26#include <asm/gpio.h>
27 27
28 28
29static const struct i2c_device_id pcf857x_id[] = {
30 { "pcf8574", 8 },
31 { "pca8574", 8 },
32 { "pca9670", 8 },
33 { "pca9672", 8 },
34 { "pca9674", 8 },
35 { "pcf8575", 16 },
36 { "pca8575", 16 },
37 { "pca9671", 16 },
38 { "pca9673", 16 },
39 { "pca9675", 16 },
40 { }
41};
42MODULE_DEVICE_TABLE(i2c, pcf857x_id);
43
29/* 44/*
30 * The pcf857x, pca857x, and pca967x chips only expose one read and one 45 * The pcf857x, pca857x, and pca967x chips only expose one read and one
31 * write register. Writing a "one" bit (to match the reset state) lets 46 * write register. Writing a "one" bit (to match the reset state) lets
@@ -142,7 +157,8 @@ static void pcf857x_set16(struct gpio_chip *chip, unsigned offset, int value)
142 157
143/*-------------------------------------------------------------------------*/ 158/*-------------------------------------------------------------------------*/
144 159
145static int pcf857x_probe(struct i2c_client *client) 160static int pcf857x_probe(struct i2c_client *client,
161 const struct i2c_device_id *id)
146{ 162{
147 struct pcf857x_platform_data *pdata; 163 struct pcf857x_platform_data *pdata;
148 struct pcf857x *gpio; 164 struct pcf857x *gpio;
@@ -172,13 +188,8 @@ static int pcf857x_probe(struct i2c_client *client)
172 * 188 *
173 * NOTE: we don't distinguish here between *4 and *4a parts. 189 * NOTE: we don't distinguish here between *4 and *4a parts.
174 */ 190 */
175 if (strcmp(client->name, "pcf8574") == 0 191 gpio->chip.ngpio = id->driver_data;
176 || strcmp(client->name, "pca8574") == 0 192 if (gpio->chip.ngpio == 8) {
177 || strcmp(client->name, "pca9670") == 0
178 || strcmp(client->name, "pca9672") == 0
179 || strcmp(client->name, "pca9674") == 0
180 ) {
181 gpio->chip.ngpio = 8;
182 gpio->chip.direction_input = pcf857x_input8; 193 gpio->chip.direction_input = pcf857x_input8;
183 gpio->chip.get = pcf857x_get8; 194 gpio->chip.get = pcf857x_get8;
184 gpio->chip.direction_output = pcf857x_output8; 195 gpio->chip.direction_output = pcf857x_output8;
@@ -198,13 +209,7 @@ static int pcf857x_probe(struct i2c_client *client)
198 * 209 *
199 * NOTE: we don't distinguish here between '75 and '75c parts. 210 * NOTE: we don't distinguish here between '75 and '75c parts.
200 */ 211 */
201 } else if (strcmp(client->name, "pcf8575") == 0 212 } else if (gpio->chip.ngpio == 16) {
202 || strcmp(client->name, "pca8575") == 0
203 || strcmp(client->name, "pca9671") == 0
204 || strcmp(client->name, "pca9673") == 0
205 || strcmp(client->name, "pca9675") == 0
206 ) {
207 gpio->chip.ngpio = 16;
208 gpio->chip.direction_input = pcf857x_input16; 213 gpio->chip.direction_input = pcf857x_input16;
209 gpio->chip.get = pcf857x_get16; 214 gpio->chip.get = pcf857x_get16;
210 gpio->chip.direction_output = pcf857x_output16; 215 gpio->chip.direction_output = pcf857x_output16;
@@ -313,6 +318,7 @@ static struct i2c_driver pcf857x_driver = {
313 }, 318 },
314 .probe = pcf857x_probe, 319 .probe = pcf857x_probe,
315 .remove = pcf857x_remove, 320 .remove = pcf857x_remove,
321 .id_table = pcf857x_id,
316}; 322};
317 323
318static int __init pcf857x_init(void) 324static int __init pcf857x_init(void)