aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2010-08-10 21:02:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-11 11:59:08 -0400
commit49946f68149a723659eca253376ac555d4b73280 (patch)
tree687ce58ab1a4ca573290b1634752a55ef5521861 /drivers/gpio
parent4a22b8a4ad5561436b16f5278d2f9e406ffb8705 (diff)
pcf857x: support working w/o platform data
Provide sane defaults for pcf857x, so the driver can be used w/o providing platform data (and thus can be simply bound via OF tree). Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Cc: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <david-b@pacbell.net> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/pcf857x.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index 29f19ce3e80..879b473aab5 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -190,7 +190,6 @@ static int pcf857x_probe(struct i2c_client *client,
190 pdata = client->dev.platform_data; 190 pdata = client->dev.platform_data;
191 if (!pdata) { 191 if (!pdata) {
192 dev_dbg(&client->dev, "no platform data\n"); 192 dev_dbg(&client->dev, "no platform data\n");
193 return -EINVAL;
194 } 193 }
195 194
196 /* Allocate, initialize, and register this gpio_chip. */ 195 /* Allocate, initialize, and register this gpio_chip. */
@@ -200,7 +199,7 @@ static int pcf857x_probe(struct i2c_client *client,
200 199
201 mutex_init(&gpio->lock); 200 mutex_init(&gpio->lock);
202 201
203 gpio->chip.base = pdata->gpio_base; 202 gpio->chip.base = pdata ? pdata->gpio_base : -1;
204 gpio->chip.can_sleep = 1; 203 gpio->chip.can_sleep = 1;
205 gpio->chip.dev = &client->dev; 204 gpio->chip.dev = &client->dev;
206 gpio->chip.owner = THIS_MODULE; 205 gpio->chip.owner = THIS_MODULE;
@@ -278,7 +277,7 @@ static int pcf857x_probe(struct i2c_client *client,
278 * to zero, our software copy of the "latch" then matches the chip's 277 * to zero, our software copy of the "latch" then matches the chip's
279 * all-ones reset state. Otherwise it flags pins to be driven low. 278 * all-ones reset state. Otherwise it flags pins to be driven low.
280 */ 279 */
281 gpio->out = ~pdata->n_latch; 280 gpio->out = pdata ? ~pdata->n_latch : ~0;
282 281
283 status = gpiochip_add(&gpio->chip); 282 status = gpiochip_add(&gpio->chip);
284 if (status < 0) 283 if (status < 0)
@@ -299,7 +298,7 @@ static int pcf857x_probe(struct i2c_client *client,
299 /* Let platform code set up the GPIOs and their users. 298 /* Let platform code set up the GPIOs and their users.
300 * Now is the first time anyone could use them. 299 * Now is the first time anyone could use them.
301 */ 300 */
302 if (pdata->setup) { 301 if (pdata && pdata->setup) {
303 status = pdata->setup(client, 302 status = pdata->setup(client,
304 gpio->chip.base, gpio->chip.ngpio, 303 gpio->chip.base, gpio->chip.ngpio,
305 pdata->context); 304 pdata->context);
@@ -322,7 +321,7 @@ static int pcf857x_remove(struct i2c_client *client)
322 struct pcf857x *gpio = i2c_get_clientdata(client); 321 struct pcf857x *gpio = i2c_get_clientdata(client);
323 int status = 0; 322 int status = 0;
324 323
325 if (pdata->teardown) { 324 if (pdata && pdata->teardown) {
326 status = pdata->teardown(client, 325 status = pdata->teardown(client,
327 gpio->chip.base, gpio->chip.ngpio, 326 gpio->chip.base, gpio->chip.ngpio,
328 pdata->context); 327 pdata->context);