From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: linux-kernel@vger.kernel.org
Cc: David Brownell <dbrownell@users.sourceforge.net>,
linuxppc-dev@ozlabs.org, i2c@lm-sensors.org,
Jean Delvare <khali@linux-fr.org>,
David Miller <davem@davemloft.net>
Subject: [PATCH 6/7] gpio/pca953x: convert to dev_gpiochip_add and make it work with the OF
Date: Thu, 16 Oct 2008 21:13:06 +0400 [thread overview]
Message-ID: <20081016171306.GF5515@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20081016171222.GA24812@oksana.dev.rtsoft.ru>
With OpenFirmware we can't handle platform data for the devices, so let's
not strictly depend on it. That way we can't set polarity invertion for
this controller, but we'll handle this with active-low/high GPIO flags in
the OF tree.
Also switch the driver to dev_gpiochip calls, so that OF subsystem would
know about the newly registered chips.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
drivers/gpio/pca953x.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index cc84686..6e51fda 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -188,7 +188,6 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
gc->base = chip->gpio_start;
gc->ngpio = gpios;
gc->label = chip->client->name;
- gc->dev = &chip->client->dev;
gc->owner = THIS_MODULE;
}
@@ -200,8 +199,6 @@ static int __devinit pca953x_probe(struct i2c_client *client,
int ret;
pdata = client->dev.platform_data;
- if (pdata == NULL)
- return -ENODEV;
chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
if (chip == NULL)
@@ -209,7 +206,10 @@ static int __devinit pca953x_probe(struct i2c_client *client,
chip->client = client;
- chip->gpio_start = pdata->gpio_base;
+ if (pdata)
+ chip->gpio_start = pdata->gpio_base;
+ else
+ chip->gpio_start = -1;
/* initialize cached registers from their original values.
* we can't share this chip with another i2c master.
@@ -225,16 +225,18 @@ static int __devinit pca953x_probe(struct i2c_client *client,
goto out_failed;
/* set platform specific polarity inversion */
- ret = pca953x_write_reg(chip, PCA953X_INVERT, pdata->invert);
- if (ret)
- goto out_failed;
+ if (pdata) {
+ ret = pca953x_write_reg(chip, PCA953X_INVERT, pdata->invert);
+ if (ret)
+ goto out_failed;
+ }
- ret = gpiochip_add(&chip->gpio_chip);
+ ret = dev_gpiochip_add(&client->dev, &chip->gpio_chip);
if (ret)
goto out_failed;
- if (pdata->setup) {
+ if (pdata && pdata->setup) {
ret = pdata->setup(client, chip->gpio_chip.base,
chip->gpio_chip.ngpio, pdata->context);
if (ret < 0)
@@ -255,7 +257,7 @@ static int pca953x_remove(struct i2c_client *client)
struct pca953x_chip *chip = i2c_get_clientdata(client);
int ret = 0;
- if (pdata->teardown) {
+ if (pdata && pdata->teardown) {
ret = pdata->teardown(client, chip->gpio_chip.base,
chip->gpio_chip.ngpio, pdata->context);
if (ret < 0) {
@@ -265,7 +267,7 @@ static int pca953x_remove(struct i2c_client *client)
}
}
- ret = gpiochip_remove(&chip->gpio_chip);
+ ret = dev_gpiochip_remove(&client->dev, &chip->gpio_chip);
if (ret) {
dev_err(&client->dev, "%s failed, %d\n",
"gpiochip_remove()", ret);
--
1.5.6.3
next prev parent reply other threads:[~2008-10-16 17:13 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-16 17:12 [PATCH 0/7 RFC] Handle I2C GPIO controllers with the OF (was: pca9539 I2C gpio expander) Anton Vorontsov
2008-10-16 17:12 ` [PATCH 1/7] powerpc and sparc: introduce dev_archdata node accessors Anton Vorontsov
2008-10-16 22:36 ` David Miller
2008-10-16 23:02 ` Grant Likely
2008-10-16 17:12 ` [PATCH 2/7] i2c: add info->archdata field Anton Vorontsov
2008-10-17 9:21 ` Jean Delvare
2008-10-22 0:27 ` Benjamin Herrenschmidt
2008-10-22 6:50 ` Jean Delvare
2008-10-22 7:37 ` Benjamin Herrenschmidt
2008-10-22 10:08 ` Anton Vorontsov
2008-10-22 11:07 ` Jean Delvare
2008-10-22 12:50 ` Anton Vorontsov
2008-10-16 17:12 ` [PATCH 3/7] of: fill the archdata for I2C devices Anton Vorontsov
2008-10-22 4:14 ` Grant Likely
2008-10-16 17:12 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-17 20:24 ` David Brownell
2008-10-17 21:29 ` Anton Vorontsov
2008-10-20 7:29 ` David Brownell
2008-10-20 15:48 ` Anton Vorontsov
2008-10-22 0:29 ` Benjamin Herrenschmidt
2008-10-22 1:03 ` Anton Vorontsov
2008-10-22 1:42 ` Anton Vorontsov
2008-10-22 2:28 ` Benjamin Herrenschmidt
2008-10-22 4:20 ` Grant Likely
2008-10-22 4:22 ` David Brownell
2008-10-22 10:36 ` Anton Vorontsov
2008-10-22 10:46 ` Anton Vorontsov
2008-10-22 18:32 ` Anton Vorontsov
2008-10-22 21:04 ` David Brownell
2008-10-22 21:22 ` Anton Vorontsov
2008-10-22 21:52 ` David Brownell
2008-10-22 22:29 ` Anton Vorontsov
2008-10-23 5:19 ` David Brownell
2008-10-23 4:45 ` Benjamin Herrenschmidt
2008-10-23 6:06 ` David Brownell
2008-10-23 6:15 ` David Brownell
2008-10-28 17:45 ` [PATCH 0/6 RFC] OF-glue devices for I2C/SPI (was: " Anton Vorontsov
2008-10-28 17:53 ` [PATCH 0/6 RFC] OF-glue devices for I2C/SPI (was: Re: [PATCH 4/7] gpiolib: implement dev_gpiochip_{add, remove} calls Grant Likely
2008-10-22 2:27 ` [PATCH 4/7] gpiolib: implement dev_gpiochip_{add,remove} calls Benjamin Herrenschmidt
2008-10-16 17:13 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-17 20:25 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add, remove} calls David Brownell
2008-10-17 21:13 ` [PATCH 5/7] of/gpio: implement of_dev_gpiochip_{add,remove} calls Anton Vorontsov
2008-10-16 17:13 ` Anton Vorontsov [this message]
2008-10-16 17:13 ` [PATCH 7/7] i2c/mcu_mpc8349emitx: convert to the new I2C/OF/GPIO infrastructure Anton Vorontsov
2008-10-17 16:07 ` [PATCH 0/7 RFC] Handle I2C GPIO controllers with the OF (was: pca9539 I2C gpio expander) Steven A. Falco
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081016171306.GF5515@oksana.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=davem@davemloft.net \
--cc=dbrownell@users.sourceforge.net \
--cc=i2c@lm-sensors.org \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).