From nobody Thu Oct 2 02:15:18 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 From nobody Thu Oct 2 02:15:18 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 AB3EA246BC7; Wed, 24 Sep 2025 05:57:43 +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=1758693465; cv=none; b=dvJ37+K+Aegzdb+dLPGgOP+KeAkvL6BtYVM0B+qoNfcYIHnRNjvTPYLRlwa03ak0TAMp3xAX6otHVpbi9kDXgY+f2u1Hvky0YIT074Ap8UBQ/MkUeoqvp1mgDZFl33FfqRMqNmMcXrFy4CtdyiqU8YQLMxS5rPCFHjZmFQ9q/hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758693465; c=relaxed/simple; bh=RY98zhyMeHdIe7oz1vmNIMN1hoojLCcBjgCdD486iY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qdwsSGuNPo/5+D594nla3qOzc6b0Nl5yJJLvNZQlLewbDyd8jTyQGVtSSncB7bEzvPA7iRIcjuM24VadAKhJsA4w5tsF0pBmEcNcS45J72RpDWU0WEYYgrlEyjF0Uq0DwvL/nJPoOe7A2sgjTj7taONXc54mMH0YkIo5vYa3F68= 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=Y5LyuWRv; 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="Y5LyuWRv" From: Xinhui Yang DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyano.uk; s=dkim; t=1758693461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E1OyOTy+j30pzlwfHanTxfG7kMQ+teePd67XVj8f1Ng=; b=Y5LyuWRvqFkACBDrq6BR6Ah9OCwmfOXHo0N9S6qInXJL2htKcJX5RSReUe2a2NaDTJiZIR 07QQ/wJ7AuaZXtIhytqspgtiZfBJ2p1/8oKPDax7VXX8Czl2yY9Rc5ElLrEwXkTTl/+kOR WDYl+kWACclRTYJbgTHSI+5zCobuTVgH/iIDsMzZUVNIc5KJBgpUF2ICwIdTG4Rkxedvrb En7glIPyY09qvdvGoPUXcfaEYtseAJ9oplecUdCNTXkvMfFMe0ltAfjgEFmzw14j+6FQUr PQj0kt0JnAj/X1oXsiEQq2Q8wgVRkqYaliS//rjZIssbmxd9hAgOPLJvd3eVVg== 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 2/2] scsi: dc395x: improve code formatting for the macros Date: Wed, 24 Sep 2025 13:56:27 +0800 Message-ID: <20250924055628.1929177-3-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-Transfer-Encoding: quoted-printable X-Spamd-Bar: -- Content-Type: text/plain; charset="utf-8" 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/1ae97d061da14b0d85c0938c3000ed57ccd= 39382.camel@HansenPartnership.com/ Signed-off-by: Xinhui Yang --- 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 =20 =20 -#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) =20 /* * 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 + (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= ))) -#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_bas= e + (address)) +#define DC395x_write32(acb, address, value) outl((value), acb->io_port_bas= e + (address)) =20 #define TAG_NONE 255 =20 --=20 2.51.0