提交 520a2c27 编写于 作者: H H. Peter Anvin 提交者: James Bottomley

[SCSI] sd: fix computation of the full size of the device

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: NH. Peter Anvin <hpa@zytor.com>
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 a8659597
......@@ -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));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册