* [PATCH] ide: endian annotations in ide-floppy.c
@ 2008-06-18 22:57 Harvey Harrison
2008-06-18 23:34 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-06-18 22:57 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz; +Cc: Al Viro, linux-ide
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
drivers/ide/ide-floppy.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f05fbc2..cba39fa 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -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);
--
1.5.6.rc3.295.gdca2e
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ide: endian annotations in ide-floppy.c
2008-06-18 22:57 [PATCH] ide: endian annotations in ide-floppy.c Harvey Harrison
@ 2008-06-18 23:34 ` Al Viro
2008-06-19 0:01 ` Harvey Harrison
0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2008-06-18 23:34 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Bartlomiej Zolnierkiewicz, linux-ide
On Wed, Jun 18, 2008 at 03:57:35PM -0700, Harvey Harrison wrote:
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> ---
> drivers/ide/ide-floppy.c | 16 ++++++++--------
> 1 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
> index f05fbc2..cba39fa 100644
> --- a/drivers/ide/ide-floppy.c
> +++ b/drivers/ide/ide-floppy.c
> @@ -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]);
Pointless, IMO - just s/u16/__be16/ in the above.
> - 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.
>
> 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]);
Ditto.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ide: endian annotations in ide-floppy.c
2008-06-18 23:34 ` Al Viro
@ 2008-06-19 0:01 ` Harvey Harrison
2008-06-19 19:49 ` Bartlomiej Zolnierkiewicz
0 siblings, 1 reply; 4+ messages in thread
From: Harvey Harrison @ 2008-06-19 0:01 UTC (permalink / raw)
To: Al Viro; +Cc: Bartlomiej Zolnierkiewicz, linux-ide
On Thu, 2008-06-19 at 00:34 +0100, Al Viro wrote:
> On Wed, Jun 18, 2008 at 03:57:35PM -0700, Harvey Harrison wrote:
> > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> > ---
> > drivers/ide/ide-floppy.c | 16 ++++++++--------
> > 1 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
> > index f05fbc2..cba39fa 100644
> > --- a/drivers/ide/ide-floppy.c
> > +++ b/drivers/ide/ide-floppy.c
> > @@ -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]);
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ide: endian annotations in ide-floppy.c
2008-06-19 0:01 ` Harvey Harrison
@ 2008-06-19 19:49 ` Bartlomiej Zolnierkiewicz
0 siblings, 0 replies; 4+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-06-19 19:49 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Al Viro, linux-ide, Borislav Petkov
On Thursday 19 June 2008, Harvey Harrison wrote:
> On Thu, 2008-06-19 at 00:34 +0100, Al Viro wrote:
> > On Wed, Jun 18, 2008 at 03:57:35PM -0700, Harvey Harrison wrote:
> > > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> > > ---
> > > drivers/ide/ide-floppy.c | 16 ++++++++--------
> > > 1 files changed, 8 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
> > > index f05fbc2..cba39fa 100644
> > > --- a/drivers/ide/ide-floppy.c
> > > +++ b/drivers/ide/ide-floppy.c
> > > @@ -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]);
> >
> > 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.
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-06-19 20:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-18 22:57 [PATCH] ide: endian annotations in ide-floppy.c Harvey Harrison
2008-06-18 23:34 ` Al Viro
2008-06-19 0:01 ` Harvey Harrison
2008-06-19 19:49 ` Bartlomiej Zolnierkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).