* [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity
@ 2008-07-30 8:10 Petr Tesarik
2008-07-30 8:18 ` Andrew Morton
0 siblings, 1 reply; 11+ messages in thread
From: Petr Tesarik @ 2008-07-30 8:10 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-ide, Andrew Morton, Jens Axboe, Jan Kara
Resent because of a typo in the LKML address. :(
Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667
still leaves a bug in the error message, because it uses the unconverted
big-endian value for printk.
Fix this by using a local variable in machine byte order. The result is
correct, more readable, and also produces slightly shorter code on i386.
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
ide-cd.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1305,6 +1305,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
int stat;
unsigned char cmd[BLK_MAX_CDB];
unsigned len = sizeof(capbuf);
+ __u32 blocklen;
memset(cmd, 0, BLK_MAX_CDB);
cmd[0] = GPCMD_READ_CDVD_CAPACITY;
@@ -1317,23 +1318,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
/*
* Sanity check the given block size
*/
- switch (capbuf.blocklen) {
- case __constant_cpu_to_be32(512):
- case __constant_cpu_to_be32(1024):
- case __constant_cpu_to_be32(2048):
- case __constant_cpu_to_be32(4096):
+ blocklen = be32_to_cpu(capbuf.blocklen);
+ switch (blocklen) {
+ case 512:
+ case 1024:
+ case 2048:
+ case 4096:
break;
default:
printk(KERN_ERR "%s: weird block size %u\n",
- drive->name, capbuf.blocklen);
+ drive->name, blocklen);
printk(KERN_ERR "%s: default to 2kb block size\n",
drive->name);
- capbuf.blocklen = __constant_cpu_to_be32(2048);
+ blocklen = 2048;
break;
}
*capacity = 1 + be32_to_cpu(capbuf.lba);
- *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
+ *sectors_per_frame = blocklen >> SECTOR_BITS;
return 0;
}
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 8:10 [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity Petr Tesarik @ 2008-07-30 8:18 ` Andrew Morton 2008-07-30 8:52 ` Boris Petkov 0 siblings, 1 reply; 11+ messages in thread From: Andrew Morton @ 2008-07-30 8:18 UTC (permalink / raw) To: Petr Tesarik Cc: linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > Resent because of a typo in the LKML address. :( Thanks. > > Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > still leaves a bug in the error message, because it uses the unconverted > big-endian value for printk. > > Fix this by using a local variable in machine byte order. The result is > correct, more readable, and also produces slightly shorter code on i386. > > Cc: Jens Axboe <jens.axboe@oracle.com> > Cc: Jan Kara <jack@suse.cz> > Signed-off-by: Petr Tesarik <ptesarik@suse.cz> Bart owns this patch now. It got lost for a month and it has already been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, so it'll get complicated. Not a happy little patch. > > ide-cd.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c > --- a/drivers/ide/ide-cd.c > +++ b/drivers/ide/ide-cd.c > @@ -1305,6 +1305,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, > int stat; > unsigned char cmd[BLK_MAX_CDB]; > unsigned len = sizeof(capbuf); > + __u32 blocklen; > > memset(cmd, 0, BLK_MAX_CDB); > cmd[0] = GPCMD_READ_CDVD_CAPACITY; > @@ -1317,23 +1318,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, > /* > * Sanity check the given block size > */ > - switch (capbuf.blocklen) { > - case __constant_cpu_to_be32(512): > - case __constant_cpu_to_be32(1024): > - case __constant_cpu_to_be32(2048): > - case __constant_cpu_to_be32(4096): > + blocklen = be32_to_cpu(capbuf.blocklen); > + switch (blocklen) { > + case 512: > + case 1024: > + case 2048: > + case 4096: > break; > default: > printk(KERN_ERR "%s: weird block size %u\n", > - drive->name, capbuf.blocklen); > + drive->name, blocklen); > printk(KERN_ERR "%s: default to 2kb block size\n", > drive->name); > - capbuf.blocklen = __constant_cpu_to_be32(2048); > + blocklen = 2048; > break; > } > > *capacity = 1 + be32_to_cpu(capbuf.lba); > - *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; > + *sectors_per_frame = blocklen >> SECTOR_BITS; > return 0; > } > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 8:18 ` Andrew Morton @ 2008-07-30 8:52 ` Boris Petkov 2008-07-30 16:33 ` Greg KH 2008-07-30 19:25 ` Bartlomiej Zolnierkiewicz 0 siblings, 2 replies; 11+ messages in thread From: Boris Petkov @ 2008-07-30 8:52 UTC (permalink / raw) To: Andrew Morton, Greg Kroah-Hartman Cc: Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton <akpm@linux-foundation.org> wrote: > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > >> Resent because of a typo in the LKML address. :( > > Thanks. > >> >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 >> still leaves a bug in the error message, because it uses the unconverted >> big-endian value for printk. >> >> Fix this by using a local variable in machine byte order. The result is >> correct, more readable, and also produces slightly shorter code on i386. >> >> Cc: Jens Axboe <jens.axboe@oracle.com> >> Cc: Jan Kara <jack@suse.cz> >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> I definitely like this one better, thanks. Acked-by: Borislav Petkov <petkovbb@gmail.com> > > Bart owns this patch now. It got lost for a month and it has already > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > so it'll get complicated. Not a happy little patch. Greg, can you please apply this one on top of -stable. > >> >> ide-cd.c | 18 ++++++++++-------- >> 1 file changed, 10 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c >> --- a/drivers/ide/ide-cd.c >> +++ b/drivers/ide/ide-cd.c >> @@ -1305,6 +1305,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, >> int stat; >> unsigned char cmd[BLK_MAX_CDB]; >> unsigned len = sizeof(capbuf); >> + __u32 blocklen; >> >> memset(cmd, 0, BLK_MAX_CDB); >> cmd[0] = GPCMD_READ_CDVD_CAPACITY; >> @@ -1317,23 +1318,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, >> /* >> * Sanity check the given block size >> */ >> - switch (capbuf.blocklen) { >> - case __constant_cpu_to_be32(512): >> - case __constant_cpu_to_be32(1024): >> - case __constant_cpu_to_be32(2048): >> - case __constant_cpu_to_be32(4096): >> + blocklen = be32_to_cpu(capbuf.blocklen); >> + switch (blocklen) { >> + case 512: >> + case 1024: >> + case 2048: >> + case 4096: >> break; >> default: >> printk(KERN_ERR "%s: weird block size %u\n", >> - drive->name, capbuf.blocklen); >> + drive->name, blocklen); >> printk(KERN_ERR "%s: default to 2kb block size\n", >> drive->name); >> - capbuf.blocklen = __constant_cpu_to_be32(2048); >> + blocklen = 2048; >> break; >> } >> >> *capacity = 1 + be32_to_cpu(capbuf.lba); >> - *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; >> + *sectors_per_frame = blocklen >> SECTOR_BITS; >> return 0; >> } >> >> > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > -- Regards/Gruß, Boris ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 8:52 ` Boris Petkov @ 2008-07-30 16:33 ` Greg KH 2008-07-30 19:12 ` Borislav Petkov 2008-07-30 19:27 ` Borislav Petkov 2008-07-30 19:25 ` Bartlomiej Zolnierkiewicz 1 sibling, 2 replies; 11+ messages in thread From: Greg KH @ 2008-07-30 16:33 UTC (permalink / raw) To: petkovbb, stable Cc: Andrew Morton, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, Jul 30, 2008 at 10:52:50AM +0200, Boris Petkov wrote: > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton > <akpm@linux-foundation.org> wrote: > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > > > >> Resent because of a typo in the LKML address. :( > > > > Thanks. > > > >> > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > >> still leaves a bug in the error message, because it uses the unconverted > >> big-endian value for printk. > >> > >> Fix this by using a local variable in machine byte order. The result is > >> correct, more readable, and also produces slightly shorter code on i386. > >> > >> Cc: Jens Axboe <jens.axboe@oracle.com> > >> Cc: Jan Kara <jack@suse.cz> > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> > > I definitely like this one better, thanks. > > Acked-by: Borislav Petkov <petkovbb@gmail.com> > > > > > > Bart owns this patch now. It got lost for a month and it has already > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > so it'll get complicated. Not a happy little patch. > > Greg, can you please apply this one on top of -stable. What one? Do you have a git commit id? And please, send stable requests to stable@kernel.org, otherwise they have a tendancy to get lost in my horrible inbox these days... thanks, greg k-h ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 16:33 ` Greg KH @ 2008-07-30 19:12 ` Borislav Petkov 2008-07-30 20:58 ` Greg KH 2008-07-30 19:27 ` Borislav Petkov 1 sibling, 1 reply; 11+ messages in thread From: Borislav Petkov @ 2008-07-30 19:12 UTC (permalink / raw) To: Greg KH Cc: stable, Andrew Morton, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, Jul 30, 2008 at 09:33:28AM -0700, Greg KH wrote: > On Wed, Jul 30, 2008 at 10:52:50AM +0200, Boris Petkov wrote: > > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton > > <akpm@linux-foundation.org> wrote: > > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > > > > > >> Resent because of a typo in the LKML address. :( > > > > > > Thanks. > > > > > >> > > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > > >> still leaves a bug in the error message, because it uses the unconverted > > >> big-endian value for printk. > > >> > > >> Fix this by using a local variable in machine byte order. The result is > > >> correct, more readable, and also produces slightly shorter code on i386. > > >> > > >> Cc: Jens Axboe <jens.axboe@oracle.com> > > >> Cc: Jan Kara <jack@suse.cz> > > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> > > > > I definitely like this one better, thanks. > > > > Acked-by: Borislav Petkov <petkovbb@gmail.com> > > > > > > > > > > Bart owns this patch now. It got lost for a month and it has already > > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > > so it'll get complicated. Not a happy little patch. > > > > Greg, can you please apply this one on top of -stable. > > What one? Do you have a git commit id? Oh, sorry about that. Ok, you should have in both 2.6.25 and .26 the patch with upstream commit id e8e7b9eb11c34ee18bde8b7011af41938d1ad667. I rediffed the new one on top, here's the 2.6.26 version, the 2.6.25 one follows. -- From: Petr Tesarik <ptesarik@suse.cz> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 still leaves a bug in the error message, because it uses the unconverted big-endian value for printk. Fix this by using a local variable in machine byte order. The result is correct, more readable, and also produces slightly shorter code on i386. Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> Acked-by: Borislav Petkov <petkovbb@gmail.com> --- diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 0cc854e..59875bb 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1298,6 +1298,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, int stat; struct request req; + __u32 blocklen; ide_cd_init_rq(drive, &req); @@ -1314,23 +1315,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, /* * Sanity check the given block size */ - switch (capbuf.blocklen) { - case __constant_cpu_to_be32(512): - case __constant_cpu_to_be32(1024): - case __constant_cpu_to_be32(2048): - case __constant_cpu_to_be32(4096): + blocklen = be32_to_cpu(capbuf.blocklen); + switch (blocklen) { + case 512: + case 1024: + case 2048: + case 4096: break; default: printk(KERN_ERR "%s: weird block size %u\n", - drive->name, capbuf.blocklen); + drive->name, blocklen); printk(KERN_ERR "%s: default to 2kb block size\n", drive->name); - capbuf.blocklen = __constant_cpu_to_be32(2048); + blocklen = 2048; break; } *capacity = 1 + be32_to_cpu(capbuf.lba); - *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; + *sectors_per_frame = blocklen >> SECTOR_BITS; return 0; } -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 19:12 ` Borislav Petkov @ 2008-07-30 20:58 ` Greg KH 2008-07-31 3:32 ` Borislav Petkov 0 siblings, 1 reply; 11+ messages in thread From: Greg KH @ 2008-07-30 20:58 UTC (permalink / raw) To: petkovbb, Greg KH, stable, Andrew Morton, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, Jul 30, 2008 at 09:12:57PM +0200, Borislav Petkov wrote: > On Wed, Jul 30, 2008 at 09:33:28AM -0700, Greg KH wrote: > > On Wed, Jul 30, 2008 at 10:52:50AM +0200, Boris Petkov wrote: > > > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton > > > <akpm@linux-foundation.org> wrote: > > > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > > > > > > > >> Resent because of a typo in the LKML address. :( > > > > > > > > Thanks. > > > > > > > >> > > > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > > > >> still leaves a bug in the error message, because it uses the unconverted > > > >> big-endian value for printk. > > > >> > > > >> Fix this by using a local variable in machine byte order. The result is > > > >> correct, more readable, and also produces slightly shorter code on i386. > > > >> > > > >> Cc: Jens Axboe <jens.axboe@oracle.com> > > > >> Cc: Jan Kara <jack@suse.cz> > > > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> > > > > > > I definitely like this one better, thanks. > > > > > > Acked-by: Borislav Petkov <petkovbb@gmail.com> > > > > > > > > > > > > > > Bart owns this patch now. It got lost for a month and it has already > > > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > > > so it'll get complicated. Not a happy little patch. > > > > > > Greg, can you please apply this one on top of -stable. > > > > What one? Do you have a git commit id? > > Oh, sorry about that. Ok, you should have in both 2.6.25 and .26 the patch with > upstream commit id e8e7b9eb11c34ee18bde8b7011af41938d1ad667. I rediffed the new > one on top, here's the 2.6.26 version, the 2.6.25 one follows. I need the patch id when this goes to Linus, in his tree. If you add "cc: stable <stable@kernel.org>" to the signed-off-by area, when it gets into Linus's tree, we will be automatically notified of it. thanks, greg k-h ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 20:58 ` Greg KH @ 2008-07-31 3:32 ` Borislav Petkov 0 siblings, 0 replies; 11+ messages in thread From: Borislav Petkov @ 2008-07-31 3:32 UTC (permalink / raw) To: Greg KH Cc: Greg KH, stable, Andrew Morton, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz On Wed, Jul 30, 2008 at 01:58:36PM -0700, Greg KH wrote: > On Wed, Jul 30, 2008 at 09:12:57PM +0200, Borislav Petkov wrote: > > On Wed, Jul 30, 2008 at 09:33:28AM -0700, Greg KH wrote: > > > On Wed, Jul 30, 2008 at 10:52:50AM +0200, Boris Petkov wrote: > > > > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton > > > > <akpm@linux-foundation.org> wrote: > > > > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > > > > > > > > > >> Resent because of a typo in the LKML address. :( > > > > > > > > > > Thanks. > > > > > > > > > >> > > > > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > > > > >> still leaves a bug in the error message, because it uses the unconverted > > > > >> big-endian value for printk. > > > > >> > > > > >> Fix this by using a local variable in machine byte order. The result is > > > > >> correct, more readable, and also produces slightly shorter code on i386. > > > > >> > > > > >> Cc: Jens Axboe <jens.axboe@oracle.com> > > > > >> Cc: Jan Kara <jack@suse.cz> > > > > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> > > > > > > > > I definitely like this one better, thanks. > > > > > > > > Acked-by: Borislav Petkov <petkovbb@gmail.com> > > > > > > > > > > > > > > > > > > Bart owns this patch now. It got lost for a month and it has already > > > > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > > > > so it'll get complicated. Not a happy little patch. > > > > > > > > Greg, can you please apply this one on top of -stable. > > > > > > What one? Do you have a git commit id? > > > > Oh, sorry about that. Ok, you should have in both 2.6.25 and .26 the patch with > > upstream commit id e8e7b9eb11c34ee18bde8b7011af41938d1ad667. I rediffed the new > > one on top, here's the 2.6.26 version, the 2.6.25 one follows. > > I need the patch id when this goes to Linus, in his tree. If you add > "cc: stable <stable@kernel.org>" to the signed-off-by area, when it gets > into Linus's tree, we will be automatically notified of it. Bart already did that. It's now in his pata-2.6 tree. -- Regards/Gruss, Boris. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 16:33 ` Greg KH 2008-07-30 19:12 ` Borislav Petkov @ 2008-07-30 19:27 ` Borislav Petkov 1 sibling, 0 replies; 11+ messages in thread From: Borislav Petkov @ 2008-07-30 19:27 UTC (permalink / raw) To: Greg KH Cc: stable, Andrew Morton, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara, Bartlomiej Zolnierkiewicz ... and here the rediffed one for 2.6.25.y: --- From: Petr Tesarik <ptesarik@suse.cz> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 still leaves a bug in the error message, because it uses the unconverted big-endian value for printk. Fix this by using a local variable in machine byte order. The result is correct, more readable, and also produces slightly shorter code on i386. Cc: Jens Axboe <jens.axboe@oracle.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> Acked-by: Borislav Petkov <petkovbb@gmail.com> --- diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index e54da02..3b388ca 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -1411,6 +1411,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, int stat; struct request req; + __u32 blocklen; ide_cd_init_rq(drive, &req); @@ -1427,23 +1428,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, /* * Sanity check the given block size */ - switch (capbuf.blocklen) { - case __constant_cpu_to_be32(512): - case __constant_cpu_to_be32(1024): - case __constant_cpu_to_be32(2048): - case __constant_cpu_to_be32(4096): + blocklen = be32_to_cpu(capbuf.blocklen); + switch (blocklen) { + case 512: + case 1024: + case 2048: + case 4096: break; default: printk(KERN_ERR "%s: weird block size %u\n", - drive->name, capbuf.blocklen); + drive->name, blocklen); printk(KERN_ERR "%s: default to 2kb block size\n", drive->name); - capbuf.blocklen = __constant_cpu_to_be32(2048); + blocklen = 2048; break; } *capacity = 1 + be32_to_cpu(capbuf.lba); - *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; + *sectors_per_frame = blocklen >> SECTOR_BITS; return 0; } -- Regards/Gruß, Boris. ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 8:52 ` Boris Petkov 2008-07-30 16:33 ` Greg KH @ 2008-07-30 19:25 ` Bartlomiej Zolnierkiewicz 2008-07-30 20:02 ` Andrew Morton 1 sibling, 1 reply; 11+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-07-30 19:25 UTC (permalink / raw) To: petkovbb Cc: Andrew Morton, Greg Kroah-Hartman, Petr Tesarik, linux-kernel, linux-ide, Jens Axboe, Jan Kara On Wednesday 30 July 2008, Boris Petkov wrote: > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton > <akpm@linux-foundation.org> wrote: > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote: > > > >> Resent because of a typo in the LKML address. :( > > > > Thanks. > > > >> > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667 > >> still leaves a bug in the error message, because it uses the unconverted > >> big-endian value for printk. speaking of aesthetics: __u32 -> u32 ;-) > >> Fix this by using a local variable in machine byte order. The result is > >> correct, more readable, and also produces slightly shorter code on i386. > >> > >> Cc: Jens Axboe <jens.axboe@oracle.com> > >> Cc: Jan Kara <jack@suse.cz> > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz> > > I definitely like this one better, thanks. > > Acked-by: Borislav Petkov <petkovbb@gmail.com> applied > > Bart owns this patch now. It got lost for a month and it has already > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > so it'll get complicated. Not a happy little patch. > > Greg, can you please apply this one on top of -stable. The usual policy is to not apply to -stable patches which are not in Linus' tree so please notify stable@kernelorg team after patch hits mainline. > > > >> > >> ide-cd.c | 18 ++++++++++-------- > >> 1 file changed, 10 insertions(+), 8 deletions(-) > >> > >> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c > >> --- a/drivers/ide/ide-cd.c > >> +++ b/drivers/ide/ide-cd.c > >> @@ -1305,6 +1305,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, > >> int stat; > >> unsigned char cmd[BLK_MAX_CDB]; > >> unsigned len = sizeof(capbuf); > >> + __u32 blocklen; > >> > >> memset(cmd, 0, BLK_MAX_CDB); > >> cmd[0] = GPCMD_READ_CDVD_CAPACITY; > >> @@ -1317,23 +1318,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, > >> /* > >> * Sanity check the given block size > >> */ > >> - switch (capbuf.blocklen) { > >> - case __constant_cpu_to_be32(512): > >> - case __constant_cpu_to_be32(1024): > >> - case __constant_cpu_to_be32(2048): > >> - case __constant_cpu_to_be32(4096): > >> + blocklen = be32_to_cpu(capbuf.blocklen); > >> + switch (blocklen) { > >> + case 512: > >> + case 1024: > >> + case 2048: > >> + case 4096: > >> break; > >> default: > >> printk(KERN_ERR "%s: weird block size %u\n", > >> - drive->name, capbuf.blocklen); > >> + drive->name, blocklen); > >> printk(KERN_ERR "%s: default to 2kb block size\n", > >> drive->name); > >> - capbuf.blocklen = __constant_cpu_to_be32(2048); > >> + blocklen = 2048; > >> break; > >> } > >> > >> *capacity = 1 + be32_to_cpu(capbuf.lba); > >> - *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; > >> + *sectors_per_frame = blocklen >> SECTOR_BITS; > >> return 0; > >> } ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 19:25 ` Bartlomiej Zolnierkiewicz @ 2008-07-30 20:02 ` Andrew Morton 2008-07-30 21:23 ` Bartlomiej Zolnierkiewicz 0 siblings, 1 reply; 11+ messages in thread From: Andrew Morton @ 2008-07-30 20:02 UTC (permalink / raw) To: Bartlomiej Zolnierkiewicz Cc: petkovbb, gregkh, ptesarik, linux-kernel, linux-ide, jens.axboe, jack On Wed, 30 Jul 2008 21:25:53 +0200 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote: > > > Bart owns this patch now. It got lost for a month and it has already > > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > > so it'll get complicated. Not a happy little patch. > > > > Greg, can you please apply this one on top of -stable. > > The usual policy is to not apply to -stable patches which are not in > Linus' tree so please notify stable@kernelorg team after patch hits > mainline. Please put a Cc: <stable@kernel.org> into the changelog. Then the stable people will notice it when Linus commits it. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity 2008-07-30 20:02 ` Andrew Morton @ 2008-07-30 21:23 ` Bartlomiej Zolnierkiewicz 0 siblings, 0 replies; 11+ messages in thread From: Bartlomiej Zolnierkiewicz @ 2008-07-30 21:23 UTC (permalink / raw) To: Andrew Morton Cc: petkovbb, gregkh, ptesarik, linux-kernel, linux-ide, jens.axboe, jack On Wednesday 30 July 2008, Andrew Morton wrote: > On Wed, 30 Jul 2008 21:25:53 +0200 > Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote: > > > > > Bart owns this patch now. It got lost for a month and it has already > > > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x, > > > > so it'll get complicated. Not a happy little patch. > > > > > > Greg, can you please apply this one on top of -stable. > > > > The usual policy is to not apply to -stable patches which are not in > > Linus' tree so please notify stable@kernelorg team after patch hits > > mainline. > > Please put a Cc: <stable@kernel.org> into the changelog. Then the > stable people will notice it when Linus commits it. Done. ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-07-31 3:32 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-07-30 8:10 [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity Petr Tesarik 2008-07-30 8:18 ` Andrew Morton 2008-07-30 8:52 ` Boris Petkov 2008-07-30 16:33 ` Greg KH 2008-07-30 19:12 ` Borislav Petkov 2008-07-30 20:58 ` Greg KH 2008-07-31 3:32 ` Borislav Petkov 2008-07-30 19:27 ` Borislav Petkov 2008-07-30 19:25 ` Bartlomiej Zolnierkiewicz 2008-07-30 20:02 ` Andrew Morton 2008-07-30 21:23 ` Bartlomiej Zolnierkiewicz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox