All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: remove redundant initialization of variable
       [not found] <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p4>
@ 2021-04-30  2:14 ` Keoseong Park
  2021-04-30  8:47   ` Bean Huo
       [not found]   ` <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p6>
  0 siblings, 2 replies; 3+ messages in thread
From: Keoseong Park @ 2021-04-30  2:14 UTC (permalink / raw)
  To: ALIM AKHTAR, avri.altman, jejb, martin.petersen, stanley.chu,
	cang, beanhuo, jaegeuk, adrian.hunter, linux-scsi, linux-kernel
  Cc: Daejun Park, Sung-Jun Park, Jinyoung CHOI

The variable d_lu_wb_buf_alloc may be repeatedly initialized to 0 in a for-loop.
If the variable is set to a value other than 0, it exits the for-loop, so there is no need to reset it to 0.

Since lun and d_lu_wb_buf_alloc are just being used in a else statement inside a local scope, move the declaration of the variables to that scope.

Signed-off-by: Keoseong Park <keosung.park@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 0625da7a42ee..77cc473961a2 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7277,8 +7277,6 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
 static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
 {
 	struct ufs_dev_info *dev_info = &hba->dev_info;
-	u8 lun;
-	u32 d_lu_wb_buf_alloc;
 	u32 ext_ufs_feature;
 
 	if (!ufshcd_is_wb_allowed(hba))
@@ -7318,8 +7316,10 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, u8 *desc_buf)
 				   DEVICE_DESC_PARAM_WB_SHARED_ALLOC_UNITS))
 			goto wb_disabled;
 	} else {
+		u8 lun;
+		u32 d_lu_wb_buf_alloc = 0;
+
 		for (lun = 0; lun < UFS_UPIU_MAX_WB_LUN_ID; lun++) {
-			d_lu_wb_buf_alloc = 0;
 			ufshcd_read_unit_desc_param(hba,
 					lun,
 					UNIT_DESC_PARAM_WB_BUF_ALLOC_UNITS,
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: ufs: remove redundant initialization of variable
  2021-04-30  2:14 ` [PATCH] scsi: ufs: remove redundant initialization of variable Keoseong Park
@ 2021-04-30  8:47   ` Bean Huo
       [not found]   ` <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p6>
  1 sibling, 0 replies; 3+ messages in thread
From: Bean Huo @ 2021-04-30  8:47 UTC (permalink / raw)
  To: keosung.park, ALIM AKHTAR, avri.altman, jejb, martin.petersen,
	stanley.chu, cang, beanhuo, jaegeuk, adrian.hunter, linux-scsi,
	linux-kernel
  Cc: Daejun Park, Sung-Jun Park, Jinyoung CHOI

On Fri, 2021-04-30 at 11:14 +0900, Keoseong Park wrote:
> The variable d_lu_wb_buf_alloc may be repeatedly initialized to 0 in
> a for-loop.
> 
> If the variable is set to a value other than 0, it exits the for-
> loop, so there is no need to reset it to 0.
> 
> 
> 
> Since lun and d_lu_wb_buf_alloc are just being used in a else
> statement inside a local scope, move the declaration of the variables
> to that scope.
> 
> 
> 
> Signed-off-by: Keoseong Park <keosung.park@samsung.com>

UFS Spec 3.1, bDeviceMaxWriteBoosterLUs is 01h, for LU dedicated buffer
mode, WriteBooster Buffer can be configured in only one logical unit.

Bean


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Re: [PATCH] scsi: ufs: remove redundant initialization of variable
       [not found]   ` <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p6>
@ 2021-05-07  3:05     ` Keoseong Park
  0 siblings, 0 replies; 3+ messages in thread
From: Keoseong Park @ 2021-05-07  3:05 UTC (permalink / raw)
  To: Bean Huo, Keoseong Park, ALIM AKHTAR, avri.altman, jejb,
	martin.petersen, stanley.chu, cang, beanhuo, jaegeuk,
	adrian.hunter, linux-scsi, linux-kernel
  Cc: Daejun Park, Sung-Jun Park, Jinyoung CHOI

Hi Bean,

> On Fri, 2021-04-30 at 11:14 +0900, Keoseong Park wrote:
>> The variable d_lu_wb_buf_alloc may be repeatedly initialized to 0 in
>> a for-loop.
>> 
>> If the variable is set to a value other than 0, it exits the for-
>> loop, so there is no need to reset it to 0.
>> 
>> 
>> 
>> Since lun and d_lu_wb_buf_alloc are just being used in a else
>> statement inside a local scope, move the declaration of the variables
>> to that scope.
>> 
>> 
>> 
>> Signed-off-by: Keoseong Park <keosung.park@samsung.com>
> 
>UFS Spec 3.1, bDeviceMaxWriteBoosterLUs is 01h, for LU dedicated buffer
>mode, WriteBooster Buffer can be configured in only one logical unit.
> 
>Bean
> 
> 

I don't think this patch has anything to do with "bDeviceMaxWriteBoosterLUs is 01h".
If the WB LUN is 7, this patch prevents d_lu_wb_buf_alloc from being redundantly initialized 8 times.

Thanks,
Keoseong

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-07  3:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p4>
2021-04-30  2:14 ` [PATCH] scsi: ufs: remove redundant initialization of variable Keoseong Park
2021-04-30  8:47   ` Bean Huo
     [not found]   ` <CGME20210430021419epcms2p402717e968615d301ba18341d28a828ee@epcms2p6>
2021-05-07  3:05     ` Keoseong Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.