Commit 49946f68 authored by Dmitry Eremin-Solenikov's avatar Dmitry Eremin-Solenikov Committed by Linus Torvalds

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: default avatarDmitry 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4a22b8a4
...@@ -190,7 +190,6 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -190,7 +190,6 @@ static int pcf857x_probe(struct i2c_client *client,
pdata = client->dev.platform_data; pdata = client->dev.platform_data;
if (!pdata) { if (!pdata) {
dev_dbg(&client->dev, "no platform data\n"); dev_dbg(&client->dev, "no platform data\n");
return -EINVAL;
} }
/* Allocate, initialize, and register this gpio_chip. */ /* Allocate, initialize, and register this gpio_chip. */
...@@ -200,7 +199,7 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -200,7 +199,7 @@ static int pcf857x_probe(struct i2c_client *client,
mutex_init(&gpio->lock); mutex_init(&gpio->lock);
gpio->chip.base = pdata->gpio_base; gpio->chip.base = pdata ? pdata->gpio_base : -1;
gpio->chip.can_sleep = 1; gpio->chip.can_sleep = 1;
gpio->chip.dev = &client->dev; gpio->chip.dev = &client->dev;
gpio->chip.owner = THIS_MODULE; gpio->chip.owner = THIS_MODULE;
...@@ -278,7 +277,7 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -278,7 +277,7 @@ static int pcf857x_probe(struct i2c_client *client,
* to zero, our software copy of the "latch" then matches the chip's * to zero, our software copy of the "latch" then matches the chip's
* all-ones reset state. Otherwise it flags pins to be driven low. * all-ones reset state. Otherwise it flags pins to be driven low.
*/ */
gpio->out = ~pdata->n_latch; gpio->out = pdata ? ~pdata->n_latch : ~0;
status = gpiochip_add(&gpio->chip); status = gpiochip_add(&gpio->chip);
if (status < 0) if (status < 0)
...@@ -299,7 +298,7 @@ static int pcf857x_probe(struct i2c_client *client, ...@@ -299,7 +298,7 @@ static int pcf857x_probe(struct i2c_client *client,
/* Let platform code set up the GPIOs and their users. /* Let platform code set up the GPIOs and their users.
* Now is the first time anyone could use them. * Now is the first time anyone could use them.
*/ */
if (pdata->setup) { if (pdata && pdata->setup) {
status = pdata->setup(client, status = pdata->setup(client,
gpio->chip.base, gpio->chip.ngpio, gpio->chip.base, gpio->chip.ngpio,
pdata->context); pdata->context);
...@@ -322,7 +321,7 @@ static int pcf857x_remove(struct i2c_client *client) ...@@ -322,7 +321,7 @@ static int pcf857x_remove(struct i2c_client *client)
struct pcf857x *gpio = i2c_get_clientdata(client); struct pcf857x *gpio = i2c_get_clientdata(client);
int status = 0; int status = 0;
if (pdata->teardown) { if (pdata && pdata->teardown) {
status = pdata->teardown(client, status = pdata->teardown(client,
gpio->chip.base, gpio->chip.ngpio, gpio->chip.base, gpio->chip.ngpio,
pdata->context); pdata->context);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment