From: Sascha Hauer <s.hauer@pengutronix.de>
To: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 2/2] gpio: add driver for stmpe io-expander
Date: Tue, 4 Sep 2012 10:13:16 +0200 [thread overview]
Message-ID: <20120904081316.GO26594@pengutronix.de> (raw)
In-Reply-To: <1346670227-1840-3-git-send-email-s.trumtrar@pengutronix.de>
On Mon, Sep 03, 2012 at 01:03:47PM +0200, Steffen Trumtrar wrote:
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
> +static int stmpe_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
> +{
> + struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
> + struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
> + int ret;
> + u8 val;
> +
> + ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
> + val &= ~(1 << (gpio % 8));
> + ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
> +
> + if (ret)
> + dev_err(chip->dev, "couldn't change direction. Write failed!\n");
> +
> + return 0;
Please propagate the error value.
> +}
> +
> +static int stmpe_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
> +{
> + struct stmpe_gpio_chip *stmpegpio = container_of(chip, struct stmpe_gpio_chip, chip);
> + struct stmpe_client_info *ci = (struct stmpe_client_info *)stmpegpio->ci;
> + int ret;
> + u8 val;
> +
> + ci->read_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), &val);
> + val |= 1 << (gpio % 8);
> + ret = ci->write_reg(ci->stmpe, GPIO_SET_DIR + OFFSET(gpio), val);
> +
> + stmpe_gpio_set_value(chip, gpio, value);
> +
> + if (ret)
> + dev_err(chip->dev, "couldn't change direction. Write failed!\n");
> +
> + return 0;
ditto
> +
> +static int stmpe_gpio_probe(struct device_d *dev)
> +{
> + struct stmpe_gpio_chip *stmpegpio;
> + struct stmpe_client_info *ci;
> +
> + stmpegpio = xzalloc(sizeof(*stmpegpio));
> +
> + stmpegpio->base = dev_request_mem_region(dev, 0);
> + stmpegpio->chip.ops = &stmpe_gpio_ops;
> + stmpegpio->ci = dev->platform_data;
> +
> + ci = (struct stmpe_client_info *)stmpegpio->ci;
> +
> + if (ci->stmpe->pdata->gpio_base)
> + stmpegpio->chip.base = ci->stmpe->pdata->gpio_base;
> + else
> + stmpegpio->chip.base = -1;
> +
> + stmpegpio->chip.ngpio = 16;
> + stmpegpio->chip.dev = dev;
> +
> + gpiochip_add(&stmpegpio->chip);
It's worth checking the return value of gpiochip_add. It could indicate
that the selected chip.base is busy.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-09-04 8:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 11:03 [PATCH v2 0/2] Add stmpe mfd Steffen Trumtrar
2012-09-03 11:03 ` [PATCH v2 1/2] mfd: add stmpe-i2c driver Steffen Trumtrar
2012-09-04 8:11 ` Sascha Hauer
2012-09-04 8:18 ` Marc Kleine-Budde
2012-09-03 11:03 ` [PATCH v2 2/2] gpio: add driver for stmpe io-expander Steffen Trumtrar
2012-09-04 8:13 ` Sascha Hauer [this message]
2012-09-04 8:29 ` Marc Kleine-Budde
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=20120904081316.GO26594@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.trumtrar@pengutronix.de \
/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