From nobody Thu Oct 2 03:32:41 2025 Received: from jupiter.guys.cyano.uk (jupiter.guys.cyano.uk [45.63.120.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B9001FDA9E; Wed, 24 Sep 2025 05:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.63.120.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758693460; cv=none; b=u1ewLaoFyzyfYAS+DGN8Yda+g20HgffSBFAPM/juWArYs+Hu8B/9ZR4rG/4Yb1b/u+4msAYFPPqt86qOtp72HwmRmNcrBYoG+lgWBkDvjHCVQTuVonY0sqhhCkx1/dSe8f8c4AN/bwwjEa8XZrx4qNeZulrXoe0eK6jFYc7pYvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758693460; c=relaxed/simple; bh=OIHIefoiZtsjl/1qw+0UWoY+GP8jpQJL3SUC2EDvU/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N+w5EjkrVM9ThAsiZm5hR2/aG5yxGfUumFHCg9/xSOwi/31FjbJtz2ToYQYFRXYXokaqc3LgHNfHuxpEa/XCDfCxe9eYBr5YvWTHnZc99ik5J1kMgpS5VdbMSuWoUUXngPRZzV4Fnii0ONIPZdl9HmUoGeNPTpUispbekOmzJZI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cyano.uk; spf=pass smtp.mailfrom=cyano.uk; dkim=pass (2048-bit key) header.d=cyano.uk header.i=@cyano.uk header.b=YX3zPuAT; arc=none smtp.client-ip=45.63.120.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cyano.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cyano.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cyano.uk header.i=@cyano.uk header.b="YX3zPuAT" From: Xinhui Yang DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyano.uk; s=dkim; t=1758693455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y1HfsTjwGzBxyYzek1x06Bsy2FGe8/POltYftYBU+Ck=; b=YX3zPuAT1/4oHohhcx6r7btavD6TT0jMGDyydlkFwu4sKbxUiGdFXfIRZkdWwDzJ/5qpPO aMrv0xD2kkC4IscTHz3PPMPJl9kR69Nx4j+NVVQoBMo3aRH32NNX0NCgI0UtQt+GHFHitw NS+7UOpEb0ey0+Ommq9pfviAuO2hvYuddcLet7lDfBjzXZke6Enb55atd0FRsEwk8fk1tm KRwjKcZYwhYbG05Tq5gO1JI0GxJL85CLHuMmmgS3HYEziDTOLezBWpaxKk5EOaeWRkQicF V5W0ADR5rmsPdu3og7/ivGtxlwkDs+AKwL2hRcuJjiePzlbVKJh8EFprIeyVow== Authentication-Results: jupiter.guys.cyano.uk; auth=pass smtp.mailfrom=cyan@cyano.uk To: linux-scsi@vger.kernel.org Cc: stable@vger.kernel.org, Mingcong Bai , Kexy Biscuit , Xinhui Yang , Oliver Neukum , Ali Akcaagac , Jamie Lenehan , "James E.J. Bottomley" , "Martin K. Petersen" , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 1/2] scsi: dc395x: correctly discard the return value in certain reads Date: Wed, 24 Sep 2025 13:56:26 +0800 Message-ID: <20250924055628.1929177-2-cyan@cyano.uk> In-Reply-To: <20250924055628.1929177-1-cyan@cyano.uk> References: <20250924055628.1929177-1-cyan@cyano.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: --- 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 =E2=80=98__dc395x_eh_bus_reset=E2=80=99: drivers/scsi/dc395x.c:97:49: error: value computed is not used [-Werror=3Du= nused-value] 97 | #define DC395x_read8(acb,address) (u8)(inb(acb->io_po= rt_base + (address))) | ^~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/dc395x.c:1003:9: note: in expansion of macro =E2=80=98DC395x_r= ead8=E2=80=99 1003 | DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS); | ^~~~~~~~~~~~ drivers/scsi/dc395x.c: In function =E2=80=98data_io_transfer=E2=80=99: drivers/scsi/dc395x.c:97:49: error: value computed is not used [-Werror=3Du= nused-value] 97 | #define DC395x_read8(acb,address) (u8)(inb(acb->io_po= rt_base + (address))) | ^~~~~~~~~~~~~~~~~~~= ~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/dc395x.c:2032:33: note: in expansion of macro =E2=80=98DC395x_= read8=E2=80=99 2032 | DC395x_read8(acb, TRM_S1040_SCSI_FI= FO); 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 --- 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) =20 +/* + * 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 + (addre= ss)))) +/* 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 *cm= d) 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); =20 reset_dev_param(acb); @@ -2029,8 +2035,8 @@ static void data_io_transfer(struct AdapterCtlBlk *ac= b, 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 *ac= b, /* 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 *ac= b) 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); =20 /* clear any pending interrupt state */ - DC395x_read8(acb, TRM_S1040_SCSI_INTSTATUS); + DC395x_peek8(acb, TRM_S1040_SCSI_INTSTATUS); } =20 =20 --=20 2.51.0