* [PATCH v4 1/2] scsi: dc395x: correctly discard the return value in certain reads
2025-09-24 5:56 [PATCH v4 0/2] dc395x: fix compiler warnings and improve formatting of the macros Xinhui Yang
@ 2025-09-24 5:56 ` Xinhui Yang
2025-09-24 5:56 ` [PATCH v4 2/2] scsi: dc395x: improve code formatting for the macros Xinhui Yang
1 sibling, 0 replies; 4+ messages in thread
From: Xinhui Yang @ 2025-09-24 5:56 UTC (permalink / raw)
To: linux-scsi
Cc: stable, Mingcong Bai, Kexy Biscuit, Xinhui Yang, Oliver Neukum,
Ali Akcaagac, Jamie Lenehan, James E.J. Bottomley,
Martin K. Petersen, open list
There are certain read operations performed in this code which doesn't
really need its return value. Those read operations either clears the
FIFO buffer, or clears the interruption status. However, unused read
triggers compiler warnings. With CONFIG_WERROR on, these warnings get
converted into errors:
drivers/scsi/dc395x.c: In function ‘__dc395x_eh_bus_reset’:
drivers/scsi/dc395x.c:97:49: error: value computed is not used [-Werror=unused-value]
97 | #define DC395x_read8(acb,address) (u8)(inb(acb->io_port_base + (address)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/dc395x.c:1003:9: note: in expansion of macro ‘DC395x_read8’
1003 | DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
| ^~~~~~~~~~~~
drivers/scsi/dc395x.c: In function ‘data_io_transfer’:
drivers/scsi/dc395x.c:97:49: error: value computed is not used [-Werror=unused-value]
97 | #define DC395x_read8(acb,address) (u8)(inb(acb->io_port_base + (address)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/dc395x.c:2032:33: note: in expansion of macro ‘DC395x_read8’
2032 | DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
Create a new macro DC395x_peek8() to deliberately cast the return value
to void, which tells the compiler we really don't need the return value
of such read operations.
Cc: stable@vger.kernel.org
Signed-off-by: Xinhui Yang <cyan@cyano.uk>
---
drivers/scsi/dc395x.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 386c8359e1cc..aed4f21e8143 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -94,6 +94,12 @@
#define DC395x_LOCK_IO(dev,flags) spin_lock_irqsave(((struct Scsi_Host *)dev)->host_lock, flags)
#define DC395x_UNLOCK_IO(dev,flags) spin_unlock_irqrestore(((struct Scsi_Host *)dev)->host_lock, flags)
+/*
+ * read operations that may trigger side effects in the hardware,
+ * but the value can or should be discarded.
+ */
+#define DC395x_peek8(acb, address) ((void)(inb(acb->io_port_base + (address))))
+/* normal read write operations goes here. */
#define DC395x_read8(acb,address) (u8)(inb(acb->io_port_base + (address)))
#define DC395x_read16(acb,address) (u16)(inw(acb->io_port_base + (address)))
#define DC395x_read32(acb,address) (u32)(inl(acb->io_port_base + (address)))
@@ -1000,7 +1006,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
clear_fifo(acb, "eh_bus_reset");
/* Delete pending IRQ */
- DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
+ DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
set_basic_config(acb);
reset_dev_param(acb);
@@ -2029,8 +2035,8 @@ static void data_io_transfer(struct AdapterCtlBlk *acb,
DC395x_write8(acb, TRM_S1040_SCSI_CONFIG2,
CFG2_WIDEFIFO);
if (io_dir & DMACMD_DIR) {
- DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
- DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
+ DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
+ DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
} else {
/* Danger, Robinson: If you find KGs
* scattered over the wide disk, the driver
@@ -2044,7 +2050,7 @@ static void data_io_transfer(struct AdapterCtlBlk *acb,
/* Danger, Robinson: If you find a collection of Ks on your disk
* something broke :-( */
if (io_dir & DMACMD_DIR)
- DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
+ DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
else
DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 'K');
}
@@ -2892,7 +2898,7 @@ static void set_basic_config(struct AdapterCtlBlk *acb)
DMA_FIFO_HALF_HALF | DMA_ENHANCE /*| DMA_MEM_MULTI_READ */ ;
DC395x_write16(acb, TRM_S1040_DMA_CONFIG, wval);
/* Clear pending interrupt status */
- DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
+ DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
/* Enable SCSI interrupt */
DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x7F);
DC395x_write8(acb, TRM_S1040_DMA_INTEN, EN_SCSIINTR | EN_DMAXFERERROR
@@ -3799,7 +3805,7 @@ static void adapter_uninit_chip(struct AdapterCtlBlk *acb)
reset_scsi_bus(acb);
/* clear any pending interrupt state */
- DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
+ DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v4 2/2] scsi: dc395x: improve code formatting for the macros
2025-09-24 5:56 [PATCH v4 0/2] dc395x: fix compiler warnings and improve formatting of the macros Xinhui Yang
2025-09-24 5:56 ` [PATCH v4 1/2] scsi: dc395x: correctly discard the return value in certain reads Xinhui Yang
@ 2025-09-24 5:56 ` Xinhui Yang
2025-09-24 6:02 ` kernel test robot
1 sibling, 1 reply; 4+ messages in thread
From: Xinhui Yang @ 2025-09-24 5:56 UTC (permalink / raw)
To: linux-scsi
Cc: stable, Mingcong Bai, Kexy Biscuit, Xinhui Yang, Oliver Neukum,
Ali Akcaagac, Jamie Lenehan, James E.J. Bottomley,
Martin K. Petersen, open list
The DC395x_* macros does not have white spaces between their arguments,
and checkpatch.pl throws an error for each change in the macros. Adding
white spaces between the arguments to fix the formatting.
Also, there are no surrounding parentheses in the expressions for the
read macros, since these casts makes the expression a compound, which
checkpatch.pl also complained about.
Removing the type casts of the inb(), inw() and inl() calls. They now
returns the expected type without explicit casting.
This patch does only formatting improvements to make the macro
definitions align with the previous patch.
[1]: https://lore.kernel.org/linux-scsi/1ae97d061da14b0d85c0938c3000ed57ccd39382.camel@HansenPartnership.com/
Signed-off-by: Xinhui Yang <cyan@cyano.uk>
---
drivers/scsi/dc395x.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index aed4f21e8143..1fb954180269 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -91,8 +91,8 @@
#endif
-#define DC395x_LOCK_IO(dev,flags) spin_lock_irqsave(((struct Scsi_Host *)dev)->host_lock, flags)
-#define DC395x_UNLOCK_IO(dev,flags) spin_unlock_irqrestore(((struct Scsi_Host *)dev)->host_lock, flags)
+#define DC395x_LOCK_IO(dev, flags) spin_lock_irqsave(((struct Scsi_Host *)dev)->host_lock, flags)
+#define DC395x_UNLOCK_IO(dev, flags) spin_unlock_irqrestore(((struct Scsi_Host *)dev)->host_lock, flags)
/*
* read operations that may trigger side effects in the hardware,
@@ -100,12 +100,12 @@
*/
#define DC395x_peek8(acb, address) ((void)(inb(acb->io_port_base + (address))))
/* normal read write operations goes here. */
-#define DC395x_read8(acb,address) (u8)(inb(acb->io_port_base + (address)))
-#define DC395x_read16(acb,address) (u16)(inw(acb->io_port_base + (address)))
-#define DC395x_read32(acb,address) (u32)(inl(acb->io_port_base + (address)))
-#define DC395x_write8(acb,address,value) outb((value), acb->io_port_base + (address))
-#define DC395x_write16(acb,address,value) outw((value), acb->io_port_base + (address))
-#define DC395x_write32(acb,address,value) outl((value), acb->io_port_base + (address))
+#define DC395x_read8(acb, address) inb(acb->io_port_base + (address))
+#define DC395x_read16(acb, address) inw(acb->io_port_base + (address))
+#define DC395x_read32(acb, address) inl(acb->io_port_base + (address))
+#define DC395x_write8(acb, address, value) outb((value), acb->io_port_base + (address))
+#define DC395x_write16(acb, address, value) outw((value), acb->io_port_base + (address))
+#define DC395x_write32(acb, address, value) outl((value), acb->io_port_base + (address))
#define TAG_NONE 255
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread