public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: sd: Use sd_first_printk() where possible
@ 2020-06-08  4:57 Damien Le Moal
  2020-06-08  7:22 ` Johannes Thumshirn
  2020-06-10  2:27 ` Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Damien Le Moal @ 2020-06-08  4:57 UTC (permalink / raw)
  To: linux-scsi, Martin K . Petersen

In sd.c and sd_zbc.c, replace sd_printk() calls conditional to
sdkp->first_scan with calls to sd_first_printk(). This simplifies the
code (no functional changes).

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd.c     | 19 ++++++++++---------
 drivers/scsi/sd_zbc.c | 18 +++++++-----------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index d90fefffe31b..dfa94b5c84c5 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2362,9 +2362,9 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
 	/* Lowest aligned logical block */
 	alignment = ((buffer[14] & 0x3f) << 8 | buffer[15]) * sector_size;
 	blk_queue_alignment_offset(sdp->request_queue, alignment);
-	if (alignment && sdkp->first_scan)
-		sd_printk(KERN_NOTICE, sdkp,
-			  "physical block alignment offset: %u\n", alignment);
+	if (alignment)
+		sd_first_printk(KERN_NOTICE, sdkp,
+			"physical block alignment offset: %u\n", alignment);
 
 	if (buffer[14] & 0x80) { /* LBPME */
 		sdkp->lbpme = 1;
@@ -2978,14 +2978,15 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
 			 * with partitions as regular block devices.
 			 */
 			q->limits.zoned = BLK_ZONED_NONE;
-			if (sdkp->zoned == 2 && sdkp->first_scan)
-				sd_printk(KERN_NOTICE, sdkp,
-					  "Drive-managed SMR disk\n");
+			if (sdkp->zoned == 2)
+				sd_first_printk(KERN_NOTICE, sdkp,
+						"Drive-managed SMR disk\n");
 		}
 	}
-	if (blk_queue_is_zoned(q) && sdkp->first_scan)
-		sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n",
-		      q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");
+	if (blk_queue_is_zoned(q))
+		sd_first_printk(KERN_NOTICE, sdkp,
+			"Host-%s zoned block device\n",
+			q->limits.zoned == BLK_ZONED_HM ? "managed" : "aware");
 
  out:
 	kfree(buffer);
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 6f7eba66687e..cb3c291c03db 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -571,9 +571,8 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
 	 * are not supported.
 	 */
 	if (!sdkp->urswrz) {
-		if (sdkp->first_scan)
-			sd_printk(KERN_NOTICE, sdkp,
-			  "constrained reads devices are not supported\n");
+		sd_first_printk(KERN_NOTICE, sdkp,
+			"constrained reads devices are not supported\n");
 		return -ENODEV;
 	}
 
@@ -609,11 +608,10 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,
 		/* The max_lba field is the capacity of this device */
 		max_lba = get_unaligned_be64(&buf[8]);
 		if (sdkp->capacity != max_lba + 1) {
-			if (sdkp->first_scan)
-				sd_printk(KERN_WARNING, sdkp,
-					"Changing capacity from %llu to max LBA+1 %llu\n",
-					(unsigned long long)sdkp->capacity,
-					(unsigned long long)max_lba + 1);
+			sd_first_printk(KERN_WARNING, sdkp,
+				  "Changing capacity from %llu to max LBA+1 %llu\n",
+				  (unsigned long long)sdkp->capacity,
+				  (unsigned long long)max_lba + 1);
 			sdkp->capacity = max_lba + 1;
 		}
 	}
@@ -622,9 +620,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,
 	rec = buf + 64;
 	zone_blocks = get_unaligned_be64(&rec[8]);
 	if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
-		if (sdkp->first_scan)
-			sd_printk(KERN_NOTICE, sdkp,
-				  "Zone size too large\n");
+		sd_first_printk(KERN_NOTICE, sdkp, "Zone size too large\n");
 		return -EFBIG;
 	}
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-10  2:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-08  4:57 [PATCH] scsi: sd: Use sd_first_printk() where possible Damien Le Moal
2020-06-08  7:22 ` Johannes Thumshirn
2020-06-10  2:27 ` Martin K. Petersen
2020-06-10  2:30   ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox