ide: endian annotations in ide-floppy.c
PATCH 1/1 ide: endian annotations in ide-floppy.c
--- drivers/ide/ide-floppy.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/ide/ide-floppy.c +8 -8
@@ -921,10 +921,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)set_disk_ro (floppy->disk, floppy->wp); page = &pc.buf[8 ]; - transfer_rate =be16_to_cpu (*(u16 *)&pc.buf[8 +2 ]); - sector_size =be16_to_cpu (*(u16 *)&pc.buf[8 +6 ]); - cyls =be16_to_cpu (*(u16 *)&pc.buf[8 +8 ]); - rpm =be16_to_cpu (*(u16 *)&pc.buf[8 +28 ]); + transfer_rate =be16_to_cpup ((__be16 *)&pc.buf[8 +2 ]); + sector_size =be16_to_cpup ((__be16 *)&pc.buf[8 +6 ]); + cyls =be16_to_cpup ((__be16 *)&pc.buf[8 +8 ]); + rpm =be16_to_cpup ((__be16 *)&pc.buf[8 +28 ]); heads = pc.buf[8 +4 ]; sectors = pc.buf[8 +5 ];
@@ -999,8 +999,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)for (i =0 ; i < desc_cnt; i++) {unsigned int desc_start =4 + i*8 ; - blocks =be32_to_cpu (*(u32 *)&pc.buf[desc_start]); - length =be16_to_cpu (*(u16 *)&pc.buf[desc_start +6 ]); + blocks =be32_to_cpup ((__be32 *)&pc.buf[desc_start]); + length =be16_to_cpup ((__be16 *)&pc.buf[desc_start +6 ]);debug_log ("Descriptor %d: %dkB, %d blocks, %d sector size\n" , i, blocks * length /1024 , blocks, length);
@@ -1121,8 +1121,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)if (u_index >= u_array_size)break ;/* User-supplied buffer too small */ - blocks =be32_to_cpu (*(u32 *)&pc.buf[desc_start]); - length =be16_to_cpu (*(u16 *)&pc.buf[desc_start +6 ]); + blocks =be32_to_cpup ((__be32 *)&pc.buf[desc_start]); + length =be16_to_cpup ((__be16 *)&pc.buf[desc_start +6 ]);if (put_user (blocks, argp))return (-EFAULT );
Signature · 1 line
1.5.6.rc3.295.gdca2e
Quoted 11 lines · Harvey Harrison
Signed-off-by Harvey Harrison <[email protected]>--- drivers/ide/ide-floppy.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)drivers/ide/ide-floppy.c +0
-0@@ -921,10 +921,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)set_disk_ro (floppy->disk, floppy->wp);
drivers/ide/ide-floppy.c static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) · line 927
Quoted 10 lines
drivers/ide/ide-floppy.c +4
-4page = &pc.buf[8 ]; - transfer_rate =be16_to_cpu (*(u16 *)&pc.buf[8 +2 ]); - sector_size =be16_to_cpu (*(u16 *)&pc.buf[8 +6 ]); - cyls =be16_to_cpu (*(u16 *)&pc.buf[8 +8 ]); - rpm =be16_to_cpu (*(u16 *)&pc.buf[8 +28 ]); + transfer_rate =be16_to_cpup ((__be16 *)&pc.buf[8 +2 ]); + sector_size =be16_to_cpup ((__be16 *)&pc.buf[8 +6 ]); + cyls =be16_to_cpup ((__be16 *)&pc.buf[8 +8 ]); + rpm =be16_to_cpup ((__be16 *)&pc.buf[8 +28 ]);
Pointless, IMO - just s/u16/__be16/ in the above.
drivers/ide/ide-floppy.c static int ide_floppy_get_capacity(ide_drive_t *drive) · line 1003
Quoted 4 lines
drivers/ide/ide-floppy.c +2
-2- blocks =be32_to_cpu (*(u32 *)&pc.buf[desc_start]); - length =be16_to_cpu (*(u16 *)&pc.buf[desc_start +6 ]); + blocks =be32_to_cpup ((__be32 *)&pc.buf[desc_start]); + length =be16_to_cpup ((__be16 *)&pc.buf[desc_start +6 ]);
Similar.
drivers/ide/ide-floppy.c static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) · line 1125
Quoted 11 lines
drivers/ide/ide-floppy.c +0
-0debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n",drivers/ide/ide-floppy.c +2
-2i, blocks * length / 1024, blocks, length);@@ -1121,8 +1121,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)if (u_index >= u_array_size)break ;/* User-supplied buffer too small */ - blocks =be32_to_cpu (*(u32 *)&pc.buf[desc_start]); - length =be16_to_cpu (*(u16 *)&pc.buf[desc_start +6 ]); + blocks =be32_to_cpup ((__be32 *)&pc.buf[desc_start]); + length =be16_to_cpup ((__be16 *)&pc.buf[desc_start +6 ]);
Ditto.
Quoted 14 lines · Al Viro
Quoted 13 lines · Harvey Harrison
Signed-off-by Harvey Harrison <[email protected]>--- drivers/ide/ide-floppy.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)drivers/ide/ide-floppy.c +0
-0@@ -921,10 +921,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)set_disk_ro (floppy->disk, floppy->wp); page = &pc.buf[8 ];
Quoted 10 lines
drivers/ide/ide-floppy.c static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) · line 927
Quoted 8 lines
drivers/ide/ide-floppy.c +4
-4- transfer_rate =be16_to_cpu (*(u16 *)&pc.buf[8 +2 ]); - sector_size =be16_to_cpu (*(u16 *)&pc.buf[8 +6 ]); - cyls =be16_to_cpu (*(u16 *)&pc.buf[8 +8 ]); - rpm =be16_to_cpu (*(u16 *)&pc.buf[8 +28 ]); + transfer_rate =be16_to_cpup ((__be16 *)&pc.buf[8 +2 ]); + sector_size =be16_to_cpup ((__be16 *)&pc.buf[8 +6 ]); + cyls =be16_to_cpup ((__be16 *)&pc.buf[8 +8 ]); + rpm =be16_to_cpup ((__be16 *)&pc.buf[8 +28 ]);Pointless, IMO - just s/u16/__be16/ in the above.
The (admittedly) small reason I did it this way is that some arches do have a more efficient pointer version. Not that they use this code, but in principle that's why I used the pointer version.
Cheers,
Harvey
Quoted 26 lines · Harvey Harrison
Quoted 14 lines · Al Viro
Quoted 13 lines · Harvey Harrison
Signed-off-by Harvey Harrison <[email protected]>--- drivers/ide/ide-floppy.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)drivers/ide/ide-floppy.c +0
-0@@ -921,10 +921,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)set_disk_ro (floppy->disk, floppy->wp); page = &pc.buf[8 ];Quoted 10 lines
drivers/ide/ide-floppy.c static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) · line 927
Quoted 8 lines
drivers/ide/ide-floppy.c +4
-4- transfer_rate =be16_to_cpu (*(u16 *)&pc.buf[8 +2 ]); - sector_size =be16_to_cpu (*(u16 *)&pc.buf[8 +6 ]); - cyls =be16_to_cpu (*(u16 *)&pc.buf[8 +8 ]); - rpm =be16_to_cpu (*(u16 *)&pc.buf[8 +28 ]); + transfer_rate =be16_to_cpup ((__be16 *)&pc.buf[8 +2 ]); + sector_size =be16_to_cpup ((__be16 *)&pc.buf[8 +6 ]); + cyls =be16_to_cpup ((__be16 *)&pc.buf[8 +8 ]); + rpm =be16_to_cpup ((__be16 *)&pc.buf[8 +28 ]);Pointless, IMO - just s/u16/__be16/ in the above.
Quoted 3 lines
The (admittedly) small reason I did it this way is that some arches do have a more efficient pointer version. Not that they use this code, but in principle that's why I used the pointer version.
this indeed seems to result in (tiny) improvement on x86-32:
text data bss dec hex filename
7377 196 0 7573 1d95 drivers/ide/ide-floppy.o.before 7370 196 0 7566 1d8e drivers/ide/ide-floppy.o.after
thus I applied it as it is