]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
memstick: annotate endianness of attribute structs
authorHarvey Harrison <harvey.harrison@gmail.com>
Sat, 10 Jan 2009 00:40:56 +0000 (16:40 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 10 Jan 2009 00:54:41 +0000 (16:54 -0800)
The code was shifting the endianness appropriately everywhere, annotate
the structs to avoid the sparse warnings when assigning the endian types
to the struct members, or passing them to be[16|32]_to_cpu:

drivers/memstick/core/mspro_block.c:331:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:333:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:335:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:337:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:341:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:347:4: warning: cast to restricted __be32
drivers/memstick/core/mspro_block.c:356:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:358:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:364:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:367:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:369:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:371:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:377:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:478:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:480:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:482:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:484:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:486:4: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:689:22:    expected unsigned int [unsigned] [assigned] data_address
drivers/memstick/core/mspro_block.c:689:22:    got restricted __be32 [usertype] <noident>
drivers/memstick/core/mspro_block.c:697:3: warning: cast to restricted __be32
drivers/memstick/core/mspro_block.c:960:17: warning: incorrect type in initializer (different base types)
drivers/memstick/core/mspro_block.c:960:17:    expected unsigned short [unsigned] data_count
drivers/memstick/core/mspro_block.c:960:17:    got restricted __be16 [usertype] <noident>
drivers/memstick/core/mspro_block.c:993:6: warning: cast to restricted __be16
drivers/memstick/core/mspro_block.c:995:28: warning: cast to restricted __be16

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/memstick/core/mspro_block.c
include/linux/memstick.h

index 1f1e3982b1aa9499dcc996f08f084c3b20cebc17..de143deb06f0bcbb1dc1da9e738e88cffd431491 100644 (file)
@@ -52,14 +52,14 @@ struct mspro_sys_attr {
 };
 
 struct mspro_attr_entry {
-       unsigned int  address;
-       unsigned int  size;
+       __be32 address;
+       __be32 size;
        unsigned char id;
        unsigned char reserved[3];
 } __attribute__((packed));
 
 struct mspro_attribute {
-       unsigned short          signature;
+       __be16 signature;
        unsigned short          version;
        unsigned char           count;
        unsigned char           reserved[11];
@@ -69,28 +69,28 @@ struct mspro_attribute {
 struct mspro_sys_info {
        unsigned char  class;
        unsigned char  reserved0;
-       unsigned short block_size;
-       unsigned short block_count;
-       unsigned short user_block_count;
-       unsigned short page_size;
+       __be16 block_size;
+       __be16 block_count;
+       __be16 user_block_count;
+       __be16 page_size;
        unsigned char  reserved1[2];
        unsigned char  assembly_date[8];
-       unsigned int   serial_number;
+       __be32 serial_number;
        unsigned char  assembly_maker_code;
        unsigned char  assembly_model_code[3];
-       unsigned short memory_maker_code;
-       unsigned short memory_model_code;
+       __be16 memory_maker_code;
+       __be16 memory_model_code;
        unsigned char  reserved2[4];
        unsigned char  vcc;
        unsigned char  vpp;
-       unsigned short controller_number;
-       unsigned short controller_function;
-       unsigned short start_sector;
-       unsigned short unit_size;
+       __be16 controller_number;
+       __be16 controller_function;
+       __be16 start_sector;
+       __be16 unit_size;
        unsigned char  ms_sub_class;
        unsigned char  reserved3[4];
        unsigned char  interface_type;
-       unsigned short controller_code;
+       __be16 controller_code;
        unsigned char  format_type;
        unsigned char  reserved4;
        unsigned char  device_type;
@@ -124,11 +124,11 @@ struct mspro_specfile {
 } __attribute__((packed));
 
 struct mspro_devinfo {
-       unsigned short cylinders;
-       unsigned short heads;
-       unsigned short bytes_per_track;
-       unsigned short bytes_per_sector;
-       unsigned short sectors_per_track;
+       __be16 cylinders;
+       __be16 heads;
+       __be16 bytes_per_track;
+       __be16 bytes_per_sector;
+       __be16 sectors_per_track;
        unsigned char  reserved[6];
 } __attribute__((packed));
 
@@ -338,8 +338,7 @@ static ssize_t mspro_block_attr_show_sysinfo(struct device *dev,
        rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly date: "
                        "GMT%+d:%d %04u-%02u-%02u %02u:%02u:%02u\n",
                        date_tz, date_tz_f,
-                       be16_to_cpu(*(unsigned short *)
-                                   &x_sys->assembly_date[1]),
+                       be16_to_cpup((__be16 *)&x_sys->assembly_date[1]),
                        x_sys->assembly_date[3], x_sys->assembly_date[4],
                        x_sys->assembly_date[5], x_sys->assembly_date[6],
                        x_sys->assembly_date[7]);
index d0c37e6822349d56b2462b3df9201bfb9bc6dcb5..690c35a9d4ccaa02a6df61338d9306bc0e00cc91 100644 (file)
@@ -100,8 +100,8 @@ struct mspro_param_register {
 #define MEMSTICK_SYS_PAR8   0x40
 #define MEMSTICK_SYS_SERIAL 0x80
 
-       unsigned short data_count;
-       unsigned int   data_address;
+       __be16 data_count;
+       __be32 data_address;
        unsigned char  tpc_param;
 } __attribute__((packed));