* [PATCH 07/37] block: use get/put_endian helpers
@ 2008-05-29 20:18 Harvey Harrison
2008-05-30 7:22 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Harvey Harrison @ 2008-05-29 20:18 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jens Axboe, linux-arch
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
drivers/block/cciss.c | 11 +++++------
drivers/block/paride/pd.c | 8 ++++----
drivers/block/ub.c | 4 ++--
drivers/cdrom/cdrom.c | 2 +-
4 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index e336b05..a7926b6 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1513,8 +1513,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
0, 0, TYPE_CMD);
if (return_code == IO_OK) {
- listlength =
- be32_to_cpu(*(__be32 *) ld_buff->LUNListLength);
+ listlength = get_be32((__be32 *)ld_buff->LUNListLength);
} else { /* reading number of logical volumes failed */
printk(KERN_WARNING "cciss: report logical volume"
" command failed\n");
@@ -2036,8 +2035,8 @@ cciss_read_capacity(int ctlr, int logvol, int withirq, sector_t *total_size,
ctlr, buf, sizeof(ReadCapdata_struct),
1, logvol, 0, NULL, TYPE_CMD);
if (return_code == IO_OK) {
- *total_size = be32_to_cpu(*(__be32 *) buf->total_size);
- *block_size = be32_to_cpu(*(__be32 *) buf->block_size);
+ *total_size = get_be32((__be32 *)buf->total_size);
+ *block_size = get_be32((__be32 *)buf->block_size);
} else { /* read capacity command failed */
printk(KERN_WARNING "cciss: read capacity failed\n");
*total_size = 0;
@@ -2072,8 +2071,8 @@ cciss_read_capacity_16(int ctlr, int logvol, int withirq, sector_t *total_size,
1, logvol, 0, NULL, TYPE_CMD);
}
if (return_code == IO_OK) {
- *total_size = be64_to_cpu(*(__be64 *) buf->total_size);
- *block_size = be32_to_cpu(*(__be32 *) buf->block_size);
+ *total_size = get_be64((__be64 *)buf->total_size);
+ *block_size = get_be32((__be32 *)buf->block_size);
} else { /* read capacity command failed */
printk(KERN_WARNING "cciss: read capacity failed\n");
*total_size = 0;
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 570f3b7..9d8d848 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -663,11 +663,11 @@ static enum action pd_identify(struct pd_unit *disk)
return Fail;
pi_read_block(disk->pi, pd_scratch, 512);
disk->can_lba = pd_scratch[99] & 2;
- disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12));
- disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6));
- disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2));
+ disk->sectors = get_le16((__le16 *)(pd_scratch + 12));
+ disk->heads = get_le16((__le16 *)(pd_scratch + 6));
+ disk->cylinders = get_le16((__le16 *)(pd_scratch + 2));
if (disk->can_lba)
- disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120));
+ disk->capacity = get_le32((__le32 *)(pd_scratch + 120));
else
disk->capacity = disk->sectors * disk->heads * disk->cylinders;
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 3a281ef..41476ce 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1914,8 +1914,8 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
}
/* sd.c special-cases sector size of 0 to mean 512. Needed? Safe? */
- nsec = be32_to_cpu(*(__be32 *)p) + 1;
- bsize = be32_to_cpu(*(__be32 *)(p + 4));
+ nsec = get_be32((__be32 *)p) + 1;
+ bsize = get_be32((__be32 *)(p + 4));
switch (bsize) {
case 512: shift = 0; break;
case 1024: shift = 1; break;
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 69f26eb..4830d32 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -3032,7 +3032,7 @@ static int mmc_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
how much data is available for transfer. buffer[1] is
unfortunately ambigious and the only reliable way seem
to be to simply skip over the block descriptor... */
- offset = 8 + be16_to_cpu(*(__be16 *)(buffer+6));
+ offset = 8 + get_be16((__be16 *)(buffer + 6));
if (offset + 16 > sizeof(buffer))
return -E2BIG;
--
1.5.6.rc0.277.g804cf
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 07/37] block: use get/put_endian helpers
2008-05-29 20:18 [PATCH 07/37] block: use get/put_endian helpers Harvey Harrison
@ 2008-05-30 7:22 ` Jens Axboe
2008-05-30 16:06 ` Harvey Harrison
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2008-05-30 7:22 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Andrew Morton, linux-arch
On Thu, May 29 2008, Harvey Harrison wrote:
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> ---
> drivers/block/cciss.c | 11 +++++------
> drivers/block/paride/pd.c | 8 ++++----
> drivers/block/ub.c | 4 ++--
> drivers/cdrom/cdrom.c | 2 +-
> 4 files changed, 12 insertions(+), 13 deletions(-)
What is the point of this? I'm honestly asking, what is the grand idea
behind changing eg be32_to_cpu() to get_be32()?
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 07/37] block: use get/put_endian helpers
2008-05-30 7:22 ` Jens Axboe
@ 2008-05-30 16:06 ` Harvey Harrison
0 siblings, 0 replies; 3+ messages in thread
From: Harvey Harrison @ 2008-05-30 16:06 UTC (permalink / raw)
To: Jens Axboe; +Cc: Andrew Morton, linux-arch
On Fri, 2008-05-30 at 09:22 +0200, Jens Axboe wrote:
> On Thu, May 29 2008, Harvey Harrison wrote:
> > Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> > ---
> > drivers/block/cciss.c | 11 +++++------
> > drivers/block/paride/pd.c | 8 ++++----
> > drivers/block/ub.c | 4 ++--
> > drivers/cdrom/cdrom.c | 2 +-
> > 4 files changed, 12 insertions(+), 13 deletions(-)
>
> What is the point of this? I'm honestly asking, what is the grand idea
> behind changing eg be32_to_cpu() to get_be32()?
>
It started by introducing a put_be32(val, dest) to cover the idiom:
*(__be32 *)dest = cpu_to_be32(val);
I made put_be32 look like the existing put_unaligned_be32, essentially
adding an aligned helper.
Purely to make a symmetric api, I added the get_be32(ptr) which is
identical to be32_to_cpup (note the p suffix).
As part of this patchset I replaced places like:
be32_to_cpu(*(__be32 *)ptr) -> get_be32((__be32 *)ptr)
My initial version took a void *, but Al Viro requested I keep strict
typechecking, so I made it take a __be32 *.
This is profitable as some arches have an optimized return byte-swapped
from pointer implementation. I could have just as easily replaced it
with be32_to_cpup.
Cheers,
Harvey
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-05-30 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-29 20:18 [PATCH 07/37] block: use get/put_endian helpers Harvey Harrison
2008-05-30 7:22 ` Jens Axboe
2008-05-30 16:06 ` Harvey Harrison
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox