Commit 018bcdc5 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] Re: [PATCH] fix sector_div use in scsicam.c

On Mon, Oct 28, 2002 at 01:50:53AM +0100, Andries Brouwer wrote:
> On Sun, Oct 27, 2002 at 06:05:07PM -0600, James Bottomley wrote:
>
> > If the return type will be ignored by most applications, I don't see
> > what the problem is.
>
> There is no problem. My longish reaction was mostly because you used
> "future proofing", that gave the impression that you did not know
> what this is about.
>
> > (like an obviously wrong truncation)
>
> No, the code I wrote was optimal.
> If you have 16 bits and the value is 70000, I prefer returning
> 65535 over 4464.

Why didn't you write is as patch?  James, this in Andries code
in patch from, it get's rid of the ugly sector_div so it should
be in if not just because of that.
parent 6837ef4f
......@@ -78,15 +78,18 @@ int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
/* if something went wrong, then apparently we have to return
a geometry with more than 1024 cylinders */
if (ret || ip[0] > 255 || ip[1] > 63) {
ip[0] = 64;
ip[1] = 32;
sector_div(capacity, ip[0] * ip[1]);
if (capacity > 65534) {
if ((capacity >> 11) > 65534) {
ip[0] = 255;
ip[1] = 63;
sector_div(capacity, ip[0] * ip[1]);
} else {
ip[0] = 64;
ip[1] = 32;
}
ip[2] = capacity;
if (capacity > 65535*63*255)
ip[2] = 65535;
else
ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
}
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment