Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7e6db20 authored by Damien Le Moal's avatar Damien Le Moal Committed by Martin K. Petersen
Browse files

scsi: sd: Improve sd_print_capacity()



There is no need to call twice string_get_size() when the capacity messages
are not going to be printed. Reverse the message output condition to return
early and avoid executing string_get_size() when it is not necessary.

Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 27752647
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -2565,13 +2565,14 @@ sd_print_capacity(struct scsi_disk *sdkp,
	int sector_size = sdkp->device->sector_size;
	char cap_str_2[10], cap_str_10[10];

	if (!sdkp->first_scan && old_capacity == sdkp->capacity)
		return;

	string_get_size(sdkp->capacity, sector_size,
			STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));
	string_get_size(sdkp->capacity, sector_size,
			STRING_UNITS_10, cap_str_10,
			sizeof(cap_str_10));
			STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));

	if (sdkp->first_scan || old_capacity != sdkp->capacity) {
	sd_printk(KERN_NOTICE, sdkp,
		  "%llu %d-byte logical blocks: (%s/%s)\n",
		  (unsigned long long)sdkp->capacity,
@@ -2584,7 +2585,6 @@ sd_print_capacity(struct scsi_disk *sdkp,

	sd_zbc_print_zones(sdkp);
}
}

/* called with buffer of length 512 */
static inline int