From: David Brownell <david-b@pacbell.net>
To: "Jean Delvare" <khali@linux-fr.org>
Cc: "eric miao" <eric.y.miao@gmail.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linux Kernel list" <linux-kernel@vger.kernel.org>
Subject: Re: [patch 2.6.24-rc6-mm 8/9] gpiolib: pca9539 i2c gpio expander support
Date: Thu, 3 Jan 2008 17:41:16 -0800 [thread overview]
Message-ID: <200801031741.17663.david-b@pacbell.net> (raw)
In-Reply-To: <FJSgZoJ0.1199281558.1924640.khali@gcu-squad.org>
Le 02 Janvier 2008, Jean Delvare a écrit:
>
> Hi David, hi Eric,
>
> Le 29/12/2007, "David Brownell" <david-b@pacbell.net> a écrit:
> >From: eric miao <eric.miao@marvell.com>
> >
> >This adds a new-style I2C driver with basic support for the sixteen
> >bit PCA9539 GPIO expanders.
> >
> > ...
>
> Random comments:
>
> >+static int pca9539_gpio_get_value(struct gpio_chip *gc, unsigned off)
> >+{
> >+ ...
> >+
> >+ ret = pca9539_read_reg(chip, PCA9539_INPUT, ®_val);
> >+ if (ret < 0) {
> >+ /* NOTE: diagnostic already omitted; that's the
> >+ * best we can do here.
> >+ */
> >+ return 0;
> >+ }
>
> I guess that you really mean "emitted" here, not "omitted"?
Yeah, typo.
> More importantly, I don't agree that it's the best we can do here.
> Maybe it was already discussed before and there's a good reason to not
> report errors from "get" functions at the gpio-core level,
Yes there is. It's by explicit request. Expecting drivers to cope
with per-bit errors is at best unrealistic. This was decided well
over a year ago ... nobody wants to see bit-banging code that spends
more time trying to figure out how to recover from "can't happen"
errors than getting real work done. (None of the SOC-specific GPIO
interfaces being replaced by this generic one returned errors either.)
That said, with things like I2C there actually *could* be errors;
which are impossible with valid parameters to SOC-level GPIOs.
That might argue for gpio_{get,set}_value_cansleep() calls being
able to return fault codes that would be nonsense on the more
widely used gpio_{get,set}_value() alls.
But such a change would be for a different set of patches. This
set does not change *any* driver programming interface. At all.
> >+static int __devinit pca9539_probe(struct i2c_client *client)
> >+{
> >+ (...)
> >+ if (pdata->setup) {
> >+ ret = pdata->setup(client, chip->gpio_chip.base,
> >+ chip->gpio_chip.ngpio, pdata->context);
> >+ if (ret < 0)
> >+ dev_dbg(&client->dev, "setup failed, %d\n", ret);
>
> Should be at least dev_warn() and maybe even dev_err().
It's not treated as an error (i.e. abort the probe); warning
is right.
Hmm, I thought both this issue and the previous one had been
fixed already ... oh, it was the pcf857x driver that fixed that.
Never mind. ;)
> >+ }
> >+ (...)
> >+}
> >+
> >+static int pca9539_remove(struct i2c_client *client)
> >+{
> >+ (...)
> >+ if (pdata->teardown) {
> >+ ret = pdata->teardown(client, chip->gpio_chip.base,
> >+ chip->gpio_chip.ngpio, pdata->context);
> >+ if (ret < 0)
> >+ dev_dbg(&client->dev, "teardown failed, %d\n", ret);
>
> Same thing here.
That was supposed to be dev_err() then "return ret" !
> >+ }
> >+
> >+ ret = gpiochip_remove(&chip->gpio_chip);
> >+ if (ret) {
> >+ dev_err(&client->dev, "failed remove gpio_chip\n");
>
> This error message could certainly be reworded to sound better. Also, for
> consistency you should include the value of "ret" in the message.
Right. So, pretty much like the appended. (Which I'll merge into
refreshed version of this patch.)
--- a/drivers/gpio/pca9539.c
+++ b/drivers/gpio/pca9539.c
@@ -118,7 +118,7 @@ static int pca9539_gpio_get_value(struct
ret = pca9539_read_reg(chip, PCA9539_INPUT, ®_val);
if (ret < 0) {
- /* NOTE: diagnostic already omitted; that's the
+ /* NOTE: diagnostic already emitted; that's the
* best we can do here.
*/
return 0;
@@ -205,7 +205,7 @@ static int __devinit pca9539_probe(struc
ret = pdata->setup(client, chip->gpio_chip.base,
chip->gpio_chip.ngpio, pdata->context);
if (ret < 0)
- dev_dbg(&client->dev, "setup failed, %d\n", ret);
+ dev_warn(&client->dev, "setup failed, %d\n", ret);
}
i2c_set_clientdata(client, chip);
@@ -225,13 +225,17 @@ static int pca9539_remove(struct i2c_cli
if (pdata->teardown) {
ret = pdata->teardown(client, chip->gpio_chip.base,
chip->gpio_chip.ngpio, pdata->context);
- if (ret < 0)
- dev_dbg(&client->dev, "teardown failed, %d\n", ret);
+ if (ret < 0) {
+ dev_err(&client->dev, "%s failed, %d\n",
+ "teardown", ret);
+ return ret;
+ }
}
ret = gpiochip_remove(&chip->gpio_chip);
if (ret) {
- dev_err(&client->dev, "failed remove gpio_chip\n");
+ dev_err(&client->dev, "%s failed, %d\n",
+ "gpiochip_remove()", ret);
return ret;
}
next prev parent reply other threads:[~2008-01-04 1:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200712281927.32575.david-b@pacbell.net>
2007-12-29 3:53 ` [patch 2.6.24-rc6-mm 1/9] gpiolib: add drivers/gpio directory David Brownell
2007-12-29 6:58 ` Sam Ravnborg
2007-12-29 18:19 ` David Brownell
2007-12-29 19:03 ` Sam Ravnborg
2008-01-05 20:07 ` David Brownell
2007-12-29 3:54 ` [patch 2.6.24-rc6-mm 2/9] gpiolib: add gpio provider infrastructure David Brownell
2007-12-29 7:10 ` Sam Ravnborg
2007-12-29 18:35 ` David Brownell
2008-01-05 20:08 ` David Brownell
2007-12-29 3:55 ` [patch 2.6.24-rc6-mm 3/9] gpiolib: update Documentation/gpio.txt David Brownell
2008-01-05 20:09 ` David Brownell
2007-12-29 3:56 ` [patch 2.6.24-rc6-mm 4/9] gpiolib: avr32 at32ap platform support David Brownell
2008-01-05 20:10 ` David Brownell
2008-01-05 20:49 ` Haavard Skinnemoen
2008-01-05 22:09 ` David Brownell
2007-12-29 3:57 ` [patch 2.6.24-rc6-mm 5/9] gpiolib: pxa " David Brownell
2008-01-05 20:11 ` David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 6/9] gpiolib: pcf857x i2c gpio expander support David Brownell
2008-01-05 20:13 ` David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 7/9] gpiolib: mcp23s08 spi " David Brownell
2007-12-29 3:58 ` [patch 2.6.24-rc6-mm 8/9] gpiolib: pca9539 i2c " David Brownell
2008-01-02 13:46 ` Jean Delvare
2008-01-04 1:41 ` David Brownell [this message]
2008-01-05 19:40 ` David Brownell
2008-01-06 12:59 ` Jean Delvare
2007-12-29 3:59 ` [patch 2.6.24-rc6-mm 9/9] gpiolib: deprecate obsolete pca9539 driver David Brownell
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=200801031741.17663.david-b@pacbell.net \
--to=david-b@pacbell.net \
--cc=akpm@linux-foundation.org \
--cc=eric.y.miao@gmail.com \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.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