On Tuesday 05 April 2005 11:01 am, Olav Kongas wrote:
> Hi,
> 
> I am trying to get rid of sparse's bitwise warnings in my 
> isp116x-hcd driver. Regardless of studying the explanations 
> about __bitwise, as for example in 
> http://kerneltrap.org/node/3848 I was still not able to get 
> rid of all the warnings. Could anybody please explain, how 
> to correctly resolve the ones below.
> 
> An example piece of problematic code, compiled on 
> little-endian ARM platform, is the following.
> 
> struct isp116x {
>       void __iomem *addr_reg;
>       ....
> };
> 
> static inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg)
> {
>       writew(cpu_to_le16((__u16) (reg & 0xff)), isp116x->addr_reg);
>       isp116x_delay(isp116x, 300);
> }
> 
> 
> The sparse bitwise warnings about the writew(...) line 
> (#377) are the following.
> 
> drivers/usb/host/isp116x.h:377:6: warning: cast from restricted type
> drivers/usb/host/isp116x.h:377:6: warning: incorrect type in 
>       assignment (different base types)
> drivers/usb/host/isp116x.h:377:6:    expected unsigned short 
>       volatile [unsigned] [short] [force] <noident>
> drivers/usb/host/isp116x.h:377:6:    got restricted unsigned 
>       short [usertype] [force] <noident>
> 
> 
> Here is the same function after preprocessing.
> 
> static inline __attribute__((always_inline)) 
>       void isp116x_write_addr(struct isp116x *isp116x, unsigned reg)
> {
>       ((void)0, *(volatile unsigned short 

That "(void) 0" expression looks bizarre, but probably isn't the root
cause of the problem.

Thing is that "volatile unsigned short *" looks like the wrong type.
Something more like "volatile unsigned short __iomem *" would be
more correct -- annotating it as being i/o space -- and that's
probably (not) wrapped up in writew().

Are you sure that your platform i/o accesors are properly updated?
I don't think all platforms are "sparse-safe" yet.  This specific
error would I think show up with plain old "sparse", so if you're
after an error that only comes with "sparse -Wbitwise" this isn't
the problem.


>       *)((isp116x->addr_reg)) = ((( __le16)(__u16)
>       ((( __le16)(__u16)((__u16) (reg & 0xff)))))));

This also looks odd:  casting a __u16 to an __le16 without
a "__force".  Again, the root cause could be that your platform
isn't fully sparse-safe yet.

- Dave


>        
>       (isp116x)->board->delay(isp116x_to_hcd(isp116x)->self.controller,300);
> }
> 
> 
> Thanks in advance,
> Olav
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> [email protected]
> To unsubscribe, use the last form field at:
> https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to