Commit e8c77ec4 authored by Damien Le Moal's avatar Damien Le Moal Committed by Martin K. Petersen

scsi: sd_zbc: Use well defined macros

Instead of open coding, use the min() macro to calculate a report zones
reply buffer length in sd_zbc_check_zone_size() and the round_up() macro
for calculating the number of zones in sd_zbc_setup().

No functional change is introduced by this patch.
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5eed92d1
...@@ -475,7 +475,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf) ...@@ -475,7 +475,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
return 0; return 0;
} }
#define SD_ZBC_BUF_SIZE 131072 #define SD_ZBC_BUF_SIZE 131072U
/** /**
* sd_zbc_check_zone_size - Check the device zone sizes * sd_zbc_check_zone_size - Check the device zone sizes
...@@ -526,10 +526,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) ...@@ -526,10 +526,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
/* Parse REPORT ZONES header */ /* Parse REPORT ZONES header */
list_length = get_unaligned_be32(&buf[0]) + 64; list_length = get_unaligned_be32(&buf[0]) + 64;
rec = buf + 64; rec = buf + 64;
if (list_length < SD_ZBC_BUF_SIZE) buf_len = min(list_length, SD_ZBC_BUF_SIZE);
buf_len = list_length;
else
buf_len = SD_ZBC_BUF_SIZE;
/* Parse zone descriptors */ /* Parse zone descriptors */
while (rec < buf + buf_len) { while (rec < buf + buf_len) {
...@@ -599,9 +596,8 @@ static int sd_zbc_setup(struct scsi_disk *sdkp) ...@@ -599,9 +596,8 @@ static int sd_zbc_setup(struct scsi_disk *sdkp)
/* chunk_sectors indicates the zone size */ /* chunk_sectors indicates the zone size */
blk_queue_chunk_sectors(sdkp->disk->queue, blk_queue_chunk_sectors(sdkp->disk->queue,
logical_to_sectors(sdkp->device, sdkp->zone_blocks)); logical_to_sectors(sdkp->device, sdkp->zone_blocks));
sdkp->nr_zones = sdkp->capacity >> sdkp->zone_shift; sdkp->nr_zones =
if (sdkp->capacity & (sdkp->zone_blocks - 1)) round_up(sdkp->capacity, sdkp->zone_blocks) >> sdkp->zone_shift;
sdkp->nr_zones++;
if (!sdkp->zones_wlock) { if (!sdkp->zones_wlock) {
sdkp->zones_wlock = kcalloc(BITS_TO_LONGS(sdkp->nr_zones), sdkp->zones_wlock = kcalloc(BITS_TO_LONGS(sdkp->nr_zones),
......
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