Skip to content

Commit

Permalink
[SCSI] sd: fix computation of the full size of the device
Browse files Browse the repository at this point in the history
When computing the full size of the device, we need to cast
sdkp->capacity before shifting, since in some configurations sector_t
can be a 32-bit number.

Also, change ffz(~x) to the more idiomatic ilog2(x).

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
  • Loading branch information
H. Peter Anvin authored and James Bottomley committed Oct 23, 2008
1 parent a865959 commit 520a2c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer)

{
char cap_str_2[10], cap_str_10[10];
u64 sz = sdkp->capacity << ffz(~sector_size);
u64 sz = (u64)sdkp->capacity << ilog2(sector_size);

string_get_size(sz, STRING_UNITS_2, cap_str_2,
sizeof(cap_str_2));
Expand Down

0 comments on commit 520a2c2

Please sign in to comment.