public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Andreas Schallenberg <Andreas.Schallenberg@3alitytechnica.com>,
	linus.walleij@stericsson.com
Cc: linux-kernel@vger.kernel.org,
	Andreas Schallenberg <Andreas.Schallenberg@3alitytechnica.com>
Subject: Re: [PATCH-RESEND] GPIO/TCA6424: merge I2C transactions, remove cast
Date: Fri, 25 May 2012 18:52:21 -0600	[thread overview]
Message-ID: <20120526005221.5FE113E20AE@localhost> (raw)
In-Reply-To: <0LrHzA-1S4duI0urs-013Ke8@mrelayeu.kundenserver.de>

On Mon, 21 May 2012 09:52:43 +0200, Andreas Schallenberg <Andreas.Schallenberg@3alitytechnica.com> wrote:
> This is a follow-up to "[PATCH v2] Add support for TCA6424":
> - Use 3 byte transfers instead of two separate transfers (2+1 byte)
> - An unnecessary cast removed
> 
> Signed-off-by: Andreas Schallenberg <Andreas.Schallenberg@3alitytechnica.com>

Applied, thanks.

g.

> 
> ---
>  drivers/gpio/gpio-pca953x.c |   27 ++++++++++++++++-----------
>  1 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 1c313c7..5eee524 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -98,12 +98,11 @@ static int pca953x_write_reg(struct pca953x_chip *chip, int reg, u32 val)
>  	if (chip->gpio_chip.ngpio <= 8)
>  		ret = i2c_smbus_write_byte_data(chip->client, reg, val);
>  	else if (chip->gpio_chip.ngpio == 24) {
> -		ret = i2c_smbus_write_word_data(chip->client,
> +		cpu_to_le32s(&val);
> +		ret = i2c_smbus_write_i2c_block_data(chip->client,
>  						(reg << 2) | REG_ADDR_AI,
> -						val & 0xffff);
> -		ret = i2c_smbus_write_byte_data(chip->client,
> -						(reg << 2) + 2,
> -						(val & 0xff0000) >> 16);
> +						3,
> +						(u8 *) &val);
>  	}
>  	else {
>  		switch (chip->chip_type) {
> @@ -135,22 +134,27 @@ static int pca953x_read_reg(struct pca953x_chip *chip, int reg, u32 *val)
>  {
>  	int ret;
>  
> -	if (chip->gpio_chip.ngpio <= 8)
> +	if (chip->gpio_chip.ngpio <= 8) {
>  		ret = i2c_smbus_read_byte_data(chip->client, reg);
> +		*val = ret;
> +	}
>  	else if (chip->gpio_chip.ngpio == 24) {
> -		ret =  i2c_smbus_read_word_data(chip->client, reg << 2);
> -		ret |= (i2c_smbus_read_byte_data(chip->client,
> -						 (reg << 2) + 2)<<16);
> +		*val = 0;
> +		ret = i2c_smbus_read_i2c_block_data(chip->client,
> +						(reg << 2) | REG_ADDR_AI,
> +						3,
> +						(u8 *) val);
> +		le32_to_cpus(val);
> -	}
> -	else
> +	} else {
>  		ret = i2c_smbus_read_word_data(chip->client, reg << 1);
> +		*val = ret;
> +	}
>  
>  	if (ret < 0) {
>  		dev_err(&chip->client->dev, "failed reading register\n");
>  		return ret;
>  	}
>  
> -	*val = (u32)ret;
>  	return 0;
>  }
>  
> -- 
> 1.7.3.4
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

      reply	other threads:[~2012-05-26 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  7:52 [PATCH-RESEND] GPIO/TCA6424: merge I2C transactions, remove cast Andreas Schallenberg
2012-05-26  0:52 ` Grant Likely [this message]

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=20120526005221.5FE113E20AE@localhost \
    --to=grant.likely@secretlab.ca \
    --cc=Andreas.Schallenberg@3alitytechnica.com \
    --cc=linus.walleij@stericsson.com \
    --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