Commit 740ec8b5 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] fix sector_div use in scsicam.c

sector_div has the same slightly strange calling convention do_div has:
it's return value is the modulo of the two operators, the division
result is in the first parameter.  Also optimize one of the expensive
64bit division away (okay, okay - it's not exactly an fast-path :))
parent f41f2a01
......@@ -80,11 +80,13 @@ int scsicam_bios_param(struct block_device *bdev, sector_t capacity, int *ip)
if (ret || ip[0] > 255 || ip[1] > 63) {
ip[0] = 64;
ip[1] = 32;
if (sector_div(capacity, ip[0] * ip[1]) > 65534) {
sector_div(capacity, ip[0] * ip[1]);
if (capacity > 65534) {
ip[0] = 255;
ip[1] = 63;
sector_div(capacity, ip[0] * ip[1]);
}
ip[2] = sector_div(capacity, ip[0] * ip[1]);
ip[2] = capacity;
}
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