Skip to content

Commit b4a38ac

Browse files
Cyanoxygenopsiff
authored andcommitted
AOSCOS: scsi: dc395x: correctly discard the return value in certain reads
There are certain read operations performed in this code which doesn't really don't 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. Signed-off-by: Xinhui Yang <cyan@cyano.uk> Signed-off-by: Mingcong Bai <jeffbai@aosc.io> (cherry picked from commit ff2493fa584d247df75026d6842f5f60027a42eb) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 03db3cb commit b4a38ac

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/scsi/dc395x.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@
9494
#define DC395x_LOCK_IO(dev,flags) spin_lock_irqsave(((struct Scsi_Host *)dev)->host_lock, flags)
9595
#define DC395x_UNLOCK_IO(dev,flags) spin_unlock_irqrestore(((struct Scsi_Host *)dev)->host_lock, flags)
9696

97+
/*
98+
* read operations that may trigger side effects in the hardware,
99+
* but the value can or should be discarded.
100+
*/
101+
#define DC395x_peek8(acb,address) (void)(inb(acb->io_port_base + (address)))
102+
97103
#define DC395x_read8(acb,address) (u8)(inb(acb->io_port_base + (address)))
98104
#define DC395x_read16(acb,address) (u16)(inw(acb->io_port_base + (address)))
99105
#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)
10001006
DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
10011007
clear_fifo(acb, "eh_bus_reset");
10021008
/* Delete pending IRQ */
1003-
DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
1009+
DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
10041010
set_basic_config(acb);
10051011

10061012
reset_dev_param(acb);
@@ -2029,8 +2035,8 @@ static void data_io_transfer(struct AdapterCtlBlk *acb,
20292035
DC395x_write8(acb, TRM_S1040_SCSI_CONFIG2,
20302036
CFG2_WIDEFIFO);
20312037
if (io_dir & DMACMD_DIR) {
2032-
DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
2033-
DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
2038+
DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
2039+
DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
20342040
} else {
20352041
/* Danger, Robinson: If you find KGs
20362042
* scattered over the wide disk, the driver
@@ -2044,7 +2050,7 @@ static void data_io_transfer(struct AdapterCtlBlk *acb,
20442050
/* Danger, Robinson: If you find a collection of Ks on your disk
20452051
* something broke :-( */
20462052
if (io_dir & DMACMD_DIR)
2047-
DC395x_read8(acb, TRM_S1040_SCSI_FIFO);
2053+
DC395x_peek8(acb, TRM_S1040_SCSI_FIFO);
20482054
else
20492055
DC395x_write8(acb, TRM_S1040_SCSI_FIFO, 'K');
20502056
}
@@ -2892,7 +2898,7 @@ static void set_basic_config(struct AdapterCtlBlk *acb)
28922898
DMA_FIFO_HALF_HALF | DMA_ENHANCE /*| DMA_MEM_MULTI_READ */ ;
28932899
DC395x_write16(acb, TRM_S1040_DMA_CONFIG, wval);
28942900
/* Clear pending interrupt status */
2895-
DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
2901+
DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
28962902
/* Enable SCSI interrupt */
28972903
DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x7F);
28982904
DC395x_write8(acb, TRM_S1040_DMA_INTEN, EN_SCSIINTR | EN_DMAXFERERROR
@@ -3799,7 +3805,7 @@ static void adapter_uninit_chip(struct AdapterCtlBlk *acb)
37993805
reset_scsi_bus(acb);
38003806

38013807
/* clear any pending interrupt state */
3802-
DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS);
3808+
DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS);
38033809
}
38043810

38053811

0 commit comments

Comments
 (0)