* Re: [PATCH] sanitize ->bios_param prototype
[not found] <20021025041735.A28857@lst.de>
@ 2002-10-25 17:18 ` James Bottomley
2002-10-25 17:53 ` Christoph Hellwig
2002-10-25 22:50 ` Andries Brouwer
0 siblings, 2 replies; 3+ messages in thread
From: James Bottomley @ 2002-10-25 17:18 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: James Bottomley, linux-scsi
hch@lst.de said:
> (aka Scsi_Disk or Disk) to each and every lowlevel driver, although
> this structure should be privated to the sd driver.
> All bios_param implementation do only use two fields: .device and
> .capacity. This patch passes down those two directly and gets rid of
> 99% of the sd.h inclusions (*).
> I've tried to not break any driver with this patch, but given the
> number of compiler errors in the current tree I might have missed one
> or two.
I'm getting:
Loading scsi_mod module
/lib/scsi_mod.o: unresolved symbol __udivdi3
The problem seems to be the definition of sector_t for the division. If I
make this fix:
===== drivers/scsi/scsicam.c 1.10 vs edited =====
--- 1.10/drivers/scsi/scsicam.c Thu Oct 24 19:29:22 2002
+++ edited/drivers/scsi/scsicam.c Fri Oct 25 12:10:40 2002
@@ -80,11 +80,11 @@
if (ret || ip[0] > 255 || ip[1] > 63) {
ip[0] = 64;
ip[1] = 32;
- if ((capacity / (ip[0] * ip[1])) > 65534) {
+ if (((unsigned long)capacity / (ip[0] * ip[1])) > 65534) {
ip[0] = 255;
ip[1] = 63;
}
- ip[2] = capacity / (ip[0] * ip[1]);
+ ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
}
return 0;
Then everything works fine. This is obviously not the correct fix, but it's
as good as the previous code, so it should be OK.
James
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sanitize ->bios_param prototype
2002-10-25 17:18 ` [PATCH] sanitize ->bios_param prototype James Bottomley
@ 2002-10-25 17:53 ` Christoph Hellwig
2002-10-25 22:50 ` Andries Brouwer
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2002-10-25 17:53 UTC (permalink / raw)
To: James Bottomley; +Cc: Christoph Hellwig, linux-scsi
On Fri, Oct 25, 2002 at 12:18:51PM -0500, James Bottomley wrote:
> hch@lst.de said:
> > (aka Scsi_Disk or Disk) to each and every lowlevel driver, although
> > this structure should be privated to the sd driver.
>
> > All bios_param implementation do only use two fields: .device and
> > .capacity. This patch passes down those two directly and gets rid of
> > 99% of the sd.h inclusions (*).
>
> > I've tried to not break any driver with this patch, but given the
> > number of compiler errors in the current tree I might have missed one
> > or two.
>
> I'm getting:
>
> Loading scsi_mod module
> /lib/scsi_mod.o: unresolved symbol __udivdi3
>
> The problem seems to be the definition of sector_t for the division. If I
> make this fix:
Ooops - I tested without CONFIG_LBD defined where it's 32bit so I
couldn't trap this bug. I think the right fix would be
to use sector_div (warning, hand-edit patch):
--- 1.10/drivers/scsi/scsicam.c Thu Oct 24 19:29:22 2002
+++ edited/drivers/scsi/scsicam.c Fri Oct 25 12:10:40 2002
@@ -80,11 +80,12 @@
if (ret || ip[0] > 255 || ip[1] > 63) {
ip[0] = 64;
ip[1] = 32;
- if ((capacity / (ip[0] * ip[1])) > 65534) {
+ if (((unsigned long)capacity / (ip[0] * ip[1])) > 65534) {
ip[0] = 255;
ip[1] = 63;
}
- ip[2] = capacity / (ip[0] * ip[1]);
+ sector_div(capacity, (ip[0] * ip[1]));
+ ip[2] = capacity;
}
return 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sanitize ->bios_param prototype
2002-10-25 17:18 ` [PATCH] sanitize ->bios_param prototype James Bottomley
2002-10-25 17:53 ` Christoph Hellwig
@ 2002-10-25 22:50 ` Andries Brouwer
1 sibling, 0 replies; 3+ messages in thread
From: Andries Brouwer @ 2002-10-25 22:50 UTC (permalink / raw)
To: James Bottomley; +Cc: Christoph Hellwig, linux-scsi
On Fri, Oct 25, 2002 at 12:18:51PM -0500, James Bottomley wrote:
> Loading scsi_mod module
> /lib/scsi_mod.o: unresolved symbol __udivdi3
>
> The problem seems to be the definition of sector_t for the division. If I
> make this fix:
>
> ===== drivers/scsi/scsicam.c 1.10 vs edited =====
> --- 1.10/drivers/scsi/scsicam.c Thu Oct 24 19:29:22 2002
> +++ edited/drivers/scsi/scsicam.c Fri Oct 25 12:10:40 2002
> @@ -80,11 +80,11 @@
> if (ret || ip[0] > 255 || ip[1] > 63) {
> ip[0] = 64;
> ip[1] = 32;
> - if ((capacity / (ip[0] * ip[1])) > 65534) {
> + if (((unsigned long)capacity / (ip[0] * ip[1])) > 65534) {
> ip[0] = 255;
> ip[1] = 63;
> }
> - ip[2] = capacity / (ip[0] * ip[1]);
> + ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
> }
>
> return 0;
>
> Then everything works fine. This is obviously not the correct fix, but it's
> as good as the previous code, so it should be OK.
I didn't see hch's patch, but you can always write
if (ret || ip[0] > 255 || ip[1] > 63) {
ip[0] = 64;
ip[1] = 32;
if ((capacity >> 11) > 65534) {
ip[0] = 255;
ip[1] = 63;
}
if (capacity > 65535*63*255)
ip[2] = 65535;
else
ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
}
Andries
(ip[2] is returned in a short, so returning larger values is meaningless;
moreover, the current specification says that ip[2] is ignored)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-10-25 22:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20021025041735.A28857@lst.de>
2002-10-25 17:18 ` [PATCH] sanitize ->bios_param prototype James Bottomley
2002-10-25 17:53 ` Christoph Hellwig
2002-10-25 22:50 ` Andries Brouwer
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).