scsi: mptfusion: Clear the warnings indicating that the variable is not used
Subsystems (2)
cover scsi: mptfusion: Clear the warnings indicating that the variable is not used
Fix below warnings:drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt’:drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]
324 | unsigned long time_count;
| ^~~~~~~~~~
drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo’:
drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable]
1372 | u8 port;
| ^~~~
drivers/message/fusion/mptctl.c: In function ‘mptctl_hp_hostinfo’:
drivers/message/fusion/mptctl.c:2337:8: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable]
2337 | int retval;
| ^~~~~~Zhen Lei (3):
scsi: mptfusion: Remove unused local variable 'time_count'
scsi: mptfusion: Remove unused local variable 'port'
scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()
drivers/message/fusion/mptctl.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/3 scsi: mptfusion: Remove unused local variable 'time_count'
Fixes the following W=1 kernel build warning:
drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt:drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]
--- drivers/message/fusion/mptctl.c | 2 -- 1 file changed, 2 deletions(-)
drivers/message/fusion/mptctl.c +0 -2
@@ -321,7 +321,6 @@ mptctl_do_taskmgmt(MPT_ADAPTER *ioc, u8 tm_type, u8 bus_id, u8 target_id)int ii;int retval;unsigned long timeout; -unsigned long time_count;u16 iocstatus;
@@ -383,7 +382,6 @@ mptctl_do_taskmgmt(MPT_ADAPTER *ioc, u8 tm_type, u8 bus_id, u8 target_id) ioc->name, tm_type, timeout)); INITIALIZE_MGMT_STATUS(ioc->taskmgmt_cmds.status) - time_count = jiffies;if ((ioc->facts.IOCCapabilities &MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q ) && (ioc->facts.MsgVersion >=MPI_VERSION_01_05 ))mpt_put_msg_frame_hi_pri (mptctl_taskmgmt_id, ioc, mf);
Signature · 1 line
2.21.1
PATCH 2/3 scsi: mptfusion: Remove unused local variable 'port'
In reply to Zhen LeiFixes the following W=1 kernel build warning:
drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable]
--- drivers/message/fusion/mptctl.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/message/fusion/mptctl.c +0 -6
@@ -1367,7 +1367,6 @@ mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg)int lun;int maxWordsLeft;int numBytes; -u8 port;struct scsi_device *sdev;if (copy_from_user (&karg, uarg,sizeof (struct mpt_ioctl_targetinfo ))) {
@@ -1379,13 +1378,8 @@ mptctl_gettargetinfo (MPT_ADAPTER *ioc, unsigned long arg)dctlprintk (ioc,printk (MYIOC_s_DEBUG_FMT"mptctl_gettargetinfo called.\n" , ioc->name)); -/* Get the port number and set the maximum number of bytes -* in the returned structure. -* Ignore the port setting. -*/ numBytes = karg.hdr.maxDataSize -sizeof (mpt_ioctl_header); maxWordsLeft = numBytes/sizeof (int ); - port = karg.hdr.port;if (maxWordsLeft <=0 ) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n",
Signature · 1 line
2.21.1
PATCH 3/3 scsi: mptfusion: Fix error return code of mptctl_hp_hostinfo()
In reply to Zhen LeiEnsure that all "goto out" error branches return correct error codes. Currently, always returns 0.
--- drivers/message/fusion/mptctl.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/message/fusion/mptctl.c +12 -8
@@ -2326,7 +2326,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)ToolboxIstwiReadWriteRequest_t *IstwiRWRequest;MPT_FRAME_HDR *mf =NULL ;unsigned long timeleft; -int retval; +int retval =0 ;u32 msgcontext;/* Reset long to int. Should affect IA64 and SPARC only
@@ -2453,6 +2453,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)if ((mf =mpt_get_msg_frame (mptctl_id, ioc)) ==NULL ) {dfailprintk (ioc,printk (MYIOC_s_WARN_FMT"%s, no msg frames!!\n" , ioc->name, __func__)); + retval = -EFAULT ; goto out; }
@@ -2471,12 +2472,13 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) IstwiRWRequest->DeviceAddr =0xB0 ; pbuf =pci_alloc_consistent (ioc->pcidev,4 , &buf_dma); -if (!pbuf) +if (!pbuf) { + retval = -ENOMEM ; goto out; + } ioc->add_sge ((char *)&IstwiRWRequest->SGL, (MPT_SGE_FLAGS_SSIMPLE_READ |4 ), buf_dma); - retval =0 ;SET_MGMT_MSG_CONTEXT (ioc->ioctl_cmds.msg_context, IstwiRWRequest->MsgContext);INITIALIZE_MGMT_STATUS (ioc->ioctl_cmds.status)
@@ -2486,10 +2488,10 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size) timeleft =wait_for_completion_timeout (&ioc->ioctl_cmds.done,HZ *MPT_IOCTL_DEFAULT_TIMEOUT );if (!(ioc->ioctl_cmds.status &MPT_MGMT_STATUS_COMMAND_GOOD )) { - retval = -ETIME ;printk (MYIOC_s_WARN_FMT"%s: failed\n" , ioc->name, __func__);if (ioc->ioctl_cmds.status &MPT_MGMT_STATUS_DID_IOCRESET ) {mpt_free_msg_frame (ioc, mf); + retval = -ETIME ; goto out; }if (!timeleft) {
@@ -2497,9 +2499,11 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)"HOST INFO command timeout, doorbell=0x%08x\n" , ioc->name, mpt_GetIocState(ioc, 0));mptctl_timeout_expired (ioc, mf); - }else - goto retry_wait; - goto out; + retval = -ETIME ; + goto out; + } + + goto retry_wait; }/*
@@ -2530,7 +2534,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)return -EFAULT ; } -return 0 ; +return retval; }
Signature · 1 line
2.21.1
Martin K. Petersen
AppliedZhen,
Quoted 4 lines
Zhen Lei (3):
scsi: mptfusion: Remove unused local variable 'time_count'
scsi: mptfusion: Remove unused local variable 'port'
scsi: mptfusion: Fix error return code ofmptctl_hp_hostinfo()
I applied patches 1+2. I hesitate making functional changes to such an old driver.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 10 lines · Martin K. Petersen
Zhen,
Quoted 4 lines
Zhen Lei (3):
scsi: mptfusion: Remove unused local variable 'time_count'
scsi: mptfusion: Remove unused local variable 'port'
scsi: mptfusion: Fix error return code ofmptctl_hp_hostinfo()I applied patches 1+2. I hesitate making functional changes to such an old driver.
I think patch 3 does not change any functions. The current modification only ensures that error codes are correctly returned in the error branch. In the previous version, 0 is always returned.
Quoted 1 line
Martin K. Petersen
AppliedQuoted 14 lines · Zhen Lei
Fix below warnings:
drivers/message/fusion/mptctl.c: In function ‘mptctl_do_taskmgmt’:drivers/message/fusion/mptctl.c:324:17: warning: variable ‘time_count’ set but not used [-Wunused-but-set-variable]324 | unsigned long time_count; | ^~~~~~~~~~ drivers/message/fusion/mptctl.c: In function ‘mptctl_gettargetinfo’: drivers/message/fusion/mptctl.c:1372:7: warning: variable ‘port’ set but not used [-Wunused-but-set-variable] 1372 | u8 port; | ^~~~ drivers/message/fusion/mptctl.c: In function ‘mptctl_hp_hostinfo’: drivers/message/fusion/mptctl.c:2337:8: warning: variable ‘retval’ set but not used [-Wunused-but-set-variable] 2337 | int retval; | ^~~~~~
Quoted 1 line
[...]
Applied to 5.13/scsi-queue, thanks!
[1/3] scsi: mptfusion: Remove unused local variable 'time_count'
https://git.kernel.org/mkp/scsi/c/039cf3816648 [2/3] scsi: mptfusion: Remove unused local variable 'port' https://git.kernel.org/mkp/scsi/c/30264737bd95
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering