mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: linux-kernel@vger.kernel.org,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
Subject: Re: [PATCH] pcf857x: support working w/o platform data
Date: Fri, 25 Jun 2010 03:17:11 -0700 (PDT)	[thread overview]
Message-ID: <352874.17151.qm@web180303.mail.gq1.yahoo.com> (raw)
In-Reply-To: <1276778870-1065-1-git-send-email-dbaryshkov@gmail.com>



--- On Thu, 6/17/10, Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:

> 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).


Maybe we can get an ack from some OF folk
who are using it in that way?



> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  drivers/gpio/pcf857x.c |    9 ++++-----
>  1 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/pcf857x.c
> b/drivers/gpio/pcf857x.c
> index 29f19ce..879b473 100644
> --- a/drivers/gpio/pcf857x.c
> +++ b/drivers/gpio/pcf857x.c
> @@ -190,7 +190,6 @@ static int pcf857x_probe(struct
> i2c_client *client,
>      pdata = client->dev.platform_data;
>      if (!pdata) {
>         
> dev_dbg(&client->dev, "no platform data\n");
> -        return -EINVAL;
>      }
>  
>      /* Allocate, initialize, and register
> this gpio_chip. */
> @@ -200,7 +199,7 @@ static int pcf857x_probe(struct
> i2c_client *client,
>  
>      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.dev =
> &client->dev;
>      gpio->chip.owner = THIS_MODULE;
> @@ -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
>       * 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);
>      if (status < 0)
> @@ -299,7 +298,7 @@ static int pcf857x_probe(struct
> i2c_client *client,
>      /* Let platform code set up the GPIOs
> and their users.
>       * Now is the first time
> anyone could use them.
>       */
> -    if (pdata->setup) {
> +    if (pdata && pdata->setup)
> {
>          status =
> pdata->setup(client,
>             
>     gpio->chip.base, gpio->chip.ngpio,
>             
>     pdata->context);
> @@ -322,7 +321,7 @@ static int pcf857x_remove(struct
> i2c_client *client)
>      struct pcf857x   
>         *gpio =
> i2c_get_clientdata(client);
>      int   
>            
> status = 0;
>  
> -    if (pdata->teardown) {
> +    if (pdata &&
> pdata->teardown) {
>          status =
> pdata->teardown(client,
>             
>     gpio->chip.base, gpio->chip.ngpio,
>             
>     pdata->context);
> -- 
> 1.7.1
> 
> 


  reply	other threads:[~2010-06-25 10:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-17 12:47 Dmitry Eremin-Solenikov
2010-06-25 10:17 ` David Brownell [this message]
2010-06-27  6:38   ` Dmitry Eremin-Solenikov
2010-06-27  7:05   ` Grant Likely

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=352874.17151.qm@web180303.mail.gq1.yahoo.com \
    --to=david-b@pacbell.net \
    --cc=dbaryshkov@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

all inboxes | Powered by JetHome®