Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1366199

Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write

From Phil Reid <preid@electromag.com.au>
Newsgroups linux.kernel
Subject Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write
Date 2016-03-29 14:10 +0200
Message-ID <ri0D7-61I-9@gated-at.bofh.it> (permalink)
References <rhVtL-2bq-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


G'day Yong,

One comment below.

On 29/03/2016 2:27 PM, Yong Li wrote:
> The current implementation only uses the first byte in *val,
> the second data is always 0. Change it to *(u16 *)val
> to write the two bytes into the register
>
> Signed-off-by: Yong Li <sdliyong@gmail.com>
> ---
>   drivers/gpio/gpio-pca953x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index d0d3065..cf3d410 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -159,7 +159,7 @@ static int pca953x_write_regs(struct pca953x_chip *chip, int reg, u8 *val)
>   		switch (chip->chip_type) {
>   		case PCA953X_TYPE:
>   			ret = i2c_smbus_write_word_data(chip->client,
> -							reg << 1, (u16) *val);
> +							reg << 1, *(u16 *)val);
I don't think this is safe for systems that don't support unaligned memory access.


>   			break;
>   		case PCA957X_TYPE:
>   			ret = i2c_smbus_write_byte_data(chip->client, reg << 1,
>


-- 
Regards
Phil Reid

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] gpio: pca953x: Use correct u16 value for register word write Yong Li <sdliyong@gmail.com> - 2016-03-29 08:40 +0200
  Re: [PATCH] gpio: pca953x: Use correct u16 value for register word  write Phil Reid <preid@electromag.com.au> - 2016-03-29 14:10 +0200
    Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write Yong Li <sdliyong@gmail.com> - 2016-03-29 15:00 +0200
      Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write Alexander Stein <alexander.stein@systec-electronic.com> - 2016-03-29 16:40 +0200
        Re: [PATCH] gpio: pca953x: Use correct u16 value for register word  write Phil Reid <preid@electromag.com.au> - 2016-03-29 18:40 +0200
          Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write Yong Li <sdliyong@gmail.com> - 2016-03-30 04:50 +0200
          Re: [PATCH] gpio: pca953x: Use correct u16 value for register word write Yong Li <sdliyong@gmail.com> - 2016-03-30 07:10 +0200
            Re: [PATCH] gpio: pca953x: Use correct u16 value for register word  write Phil Reid <preid@electromag.com.au> - 2016-03-30 07:20 +0200

csiph-web