Re: [PATCH 07/18] media: staging: atomisp: fix endianess issues

2018-03-28 Thread Mauro Carvalho Chehab
Em Tue, 27 Mar 2018 14:02:55 +0300
Andy Shevchenko  escreveu:

> On Mon, 2018-03-26 at 17:10 -0400, Mauro Carvalho Chehab wrote:
> > There are lots of be-related warnings there, as it doesn't properly
> > mark what data uses bigendian.  
> 
> > @@ -107,7 +107,7 @@ mt9m114_write_reg(struct i2c_client *client, u16
> > data_length, u16 reg, u32 val)
> > int num_msg;
> > struct i2c_msg msg;
> > unsigned char data[6] = {0};
> > -   u16 *wreg;
> > +   __be16 *wreg;
> >   
> 
> > +   u16 *wdata = (void *)[2];
> > +
> > +   *wdata = be16_to_cpu(*(__be16 *)[2]);  
> 
> > +   u32 *wdata = (void *)[2];
> > +
> > +   *wdata = be32_to_cpu(*(__be32 *)[2]);  
> 
> For x86 it is okay, though in general it should use get_unaligned().
> 

Yeah, it makes sense to change those to use 
get_unaligned_be16()/get_unaligned_be32(), but still the endianness
issue remains, as it will still require the usage of __be casts.

The main goal here in this patch series is to get rid of hundreds
of smatch/sparce warnings, as it makes very hard to identify new
warnings, due to all polution inside atomisp.

A change to get_unaligned_foo() is meant to do a different
thing: to make those i2c drivers more arch-independent.

So, feel free to submit a separate patch doing that, on the
top of it.

Thanks,
Mauro


Re: [PATCH 07/18] media: staging: atomisp: fix endianess issues

2018-03-27 Thread Andy Shevchenko
On Mon, 2018-03-26 at 17:10 -0400, Mauro Carvalho Chehab wrote:
> There are lots of be-related warnings there, as it doesn't properly
> mark what data uses bigendian.

> @@ -107,7 +107,7 @@ mt9m114_write_reg(struct i2c_client *client, u16
> data_length, u16 reg, u32 val)
>   int num_msg;
>   struct i2c_msg msg;
>   unsigned char data[6] = {0};
> - u16 *wreg;
> + __be16 *wreg;
> 

> + u16 *wdata = (void *)[2];
> +
> + *wdata = be16_to_cpu(*(__be16 *)[2]);

> + u32 *wdata = (void *)[2];
> +
> + *wdata = be32_to_cpu(*(__be32 *)[2]);

For x86 it is okay, though in general it should use get_unaligned().

-- 
Andy Shevchenko 
Intel Finland Oy


[PATCH 07/18] media: staging: atomisp: fix endianess issues

2018-03-26 Thread Mauro Carvalho Chehab
There are lots of be-related warnings there, as it doesn't properly
mark what data uses bigendian.

Warnings fixed:

drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15:expected 
unsigned short [unsigned] [short] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:134:15:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast 
to restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast 
to restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast 
to restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:140:26: warning: cast 
to restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:144:26: warning: cast 
to restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27:expected 
unsigned short [unsigned] [usertype] addr
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:256:27:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25:expected 
unsigned short [unsigned] [short] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:302:25:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25:expected 
unsigned int [unsigned] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c:306:25:got 
restricted __be32 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to 
restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to 
restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to 
restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:97:24: warning: cast to 
restricted __be16
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:99:24: warning: cast to 
restricted __be32
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15:expected 
unsigned short [unsigned] [short] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:134:15:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24:expected 
unsigned short [unsigned] [short] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:141:24:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27:expected 
unsigned short [unsigned] [usertype] addr
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:177:27:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25: warning: 
incorrect type in assignment (different base types)
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25:expected 
unsigned short [unsigned] [short] [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2680.c:198:25:got 
restricted __be16 [usertype] 
drivers/staging/media/atomisp/i2c/atomisp-ov2722.c:88:24: warning: cast to 
restricted __be16