mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Raphaël Poggi" <poggi.raph@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] i2c: at91: add support of device tree
Date: Thu, 18 Sep 2014 08:27:00 +0200	[thread overview]
Message-ID: <20140918062700.GZ4992@pengutronix.de> (raw)
In-Reply-To: <1410966019-31054-1-git-send-email-poggi.raph@gmail.com>

On Wed, Sep 17, 2014 at 05:00:18PM +0200, Raphaël Poggi wrote:
> Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
> ---
>  drivers/i2c/busses/i2c-at91.c | 91 ++++++++++++++++++++++++++++++++++---------
>  1 file changed, 73 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
> index 399f6a9..6494401 100644
> --- a/drivers/i2c/busses/i2c-at91.c
> +++ b/drivers/i2c/busses/i2c-at91.c
> @@ -186,8 +186,8 @@ static int at91_twi_wait_completion(struct at91_twi_dev *dev)
>  
>  	dev->transfer_status |= status;
>  
> -	while(!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
> -		if(is_timeout(start, AT91_I2C_TIMEOUT)) {
> +	while (!(at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_TXCOMP)) {
> +		if (is_timeout(start, AT91_I2C_TIMEOUT)) {

Normally this change should be in a separate patch.

>  	}, {
> +		.name = "at91sam9x5-i2c",
> +		.driver_data = (unsigned long) &at91sam9x5_config,
> +	}, {

ditto for adding support for a new SoC.

Ok for this time since this driver currently has no users.

> +static struct at91_twi_pdata *at91_twi_get_driver_data(struct device_d *dev)
> +{
> +	struct at91_twi_pdata *i2c_data = NULL;
> +	int rc;
> +
> +	if (dev->device_node) {
> +		const struct of_device_id *match;
> +		match = of_match_node(at91_twi_dt_ids, dev->device_node);
> +		if (!match)
> +			i2c_data = NULL;
> +		else
> +			i2c_data = (struct at91_twi_pdata *)match->data;
> +	} else {
> +		rc = dev_get_drvdata(dev, (unsigned long *)&i2c_data);
> +		if (rc)
> +			i2c_data = NULL;
> +	}

Just call dev_get_drvdata(). It will do the right thing, even for the
device tree case.

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

  parent reply	other threads:[~2014-09-18  6:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17 15:00 Raphaël Poggi
2014-09-17 15:00 ` [PATCH] I2C: at91: fix the method for interrupt Raphaël Poggi
2014-09-18  6:27 ` Sascha Hauer [this message]
2014-09-24 12:57 [PATCH] i2c: at91: fix coding style issue Raphaël Poggi
2014-09-24 12:57 ` [PATCH] i2c: at91: add support of device tree Raphaël Poggi

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=20140918062700.GZ4992@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=poggi.raph@gmail.com \
    /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