I have the following warnings being thrown by sparse when I run spare on my Linux driver with the following options:
make C=2 CF=-D__CHECK_ENDIAN__
My function is:
static inline u8 rsi_get_register_addr(u8 *addr, u16 offset)
{
return (le16_to_cpu(*(u16 *)&addr[offset]) & 0x7000) >> 12;
}
The warning that is reported by sparse is:
warning: cast to restricted __le16
Can someone help me with understanding what has gone wrong here?
Another issue that I am currently facing is in the following line:
__le16 values[20] = {0xf0, 0xfb, 0xf2, 0xf1};
Sparse gives the following warning:
warning: incorrect type in initializer (different base types) expected restricted __le16
got int
Another issue is:
seq = cpu_to_le16(tmp_hdr->seq >> 4);
The error that I get for this is: restricted __le16 degrades to integer.
Not sure how to resolve this.
How do I rectify all of these issues?
__le16 val[20] = {0x00f0, 0x00fb etc..}2. return (u8)((le16_to_cpu(*(u16 *)&addr[offset]) & 0x7000) >> 12) - vvy__le16 val[20] = {cpu_to_le16(0xf0), cpu_to_le16(0xfb) etc..}- vvy