staging: fbtft: Fix sparse warnings about endianness
Subsystems (2)
PATCH 1/1 staging: fbtft: Fix sparse warnings about endianness
Fixed sparse warnings about endianness. E.g.:
warning: incorrect type in assignment (different base types)
drivers/staging/fbtft/fbtft-io.c +1 -1
@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) src++; } tmp |= ((*src &0x0100 ) ?1 :0 ); - *(u64 *)dst =cpu_to_be64 (tmp); + *(__be64 *)dst =cpu_to_be64 (tmp); dst +=8 ; *dst++ = (u8)(*src++ &0x00FF ); added++;
Signature · 1 line
1.7.9.5
Greg KH
maintainerQuoted 3 lines · maomao xu
Fixed sparse warnings about endianness. E.g.:
warning: incorrect type in assignment (different base types)
Why are these lines indented?
drivers/staging/fbtft/fbtft-io.c int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) · line 74
Quoted 12 lines
Signed-off-by maomao xu <[email protected]>drivers/staging/fbtft/fbtft-io.c +1
-1@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) src++; } tmp |= ((*src &0x0100 ) ?1 :0 ); - *(u64 *)dst =cpu_to_be64 (tmp); + *(__be64 *)dst =cpu_to_be64 (tmp);
Really? That seems very odd. I need a maintainer's ack for this before I can take it...
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 3 lines · maomao xu
Fixed sparse warnings about endianness. E.g.:
warning: incorrect type in assignment (different base types)
Why are these lines indented?
Quoted 2 lines
Signed-off-by maomao xu <[email protected]>
Quoted 13 lines
drivers/staging/fbtft/fbtft-io.c int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) · line 74
Quoted 10 lines
drivers/staging/fbtft/fbtft-io.c +1
-1@@ -71,7 +71,7 @@ int fbtft_write_spi_emulate_9(struct fbtft_par *par, void *buf, size_t len) src++; } tmp |= ((*src &0x0100 ) ?1 :0 ); - *(u64 *)dst =cpu_to_be64 (tmp); + *(__be64 *)dst =cpu_to_be64 (tmp);Really? That seems very odd. I need a maintainer's ack for this before I can take it...
If anything, I would turn the inner loop into
tmp = 0;
for (j = 0; j < 7; j++) {
tmp <<= 9;
tmp |= *src++ & 0x1ff;
}
tmp <<= 1;there - the whole thing looks like an obfuscated "take an array of 9-bit values, each stored in host-endian 16bit, repack them into octets". Which architecture is that supposed to run on? Anything that doesn't like unaligned stores won't be happy with that code...
Another interesting part is that we have size = len / 2 and verify that len is a multiple of 8. I.e. that size is only guaranteed to be a multiple of 4. Each pass through the outer loop consumes 8 16bit values and decrements size by 8, so if len is e.g. 24 we'll end up accepting that, get size equal to 12, pass through the outer loop twice and chew through 32 bytes of buf...