mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: core: Use readable 'return 0' in ufshcd_hba_capabilities()
       [not found] <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p7>
@ 2023-05-02 11:31 ` Keoseong Park
  2023-05-02 20:28   ` Bart Van Assche
       [not found]   ` <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p5>
  0 siblings, 2 replies; 3+ messages in thread
From: Keoseong Park @ 2023-05-02 11:31 UTC (permalink / raw)
  To: ALIM AKHTAR, avri.altman, bvanassche, jejb, martin.petersen,
	stanley.chu, mani, quic_asutoshd, beanhuo, linux-scsi,
	linux-kernel

The 'err' variable is the result of ufshcd_hba_init_crypto_capabilities()
regardless of MCQ capabilities. Return 'err' immediately when the function
error occurs. And if it is not an error, explicitly return 0.

Anyway, if ufshcd_hba_init_crypto_capabilities() returns error, MCQ
capabilities is not used because it fails to initialize UFS driver.

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

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 9434328ba323..44328eb4158d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2343,18 +2343,20 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
 
 	/* Read crypto capabilities */
 	err = ufshcd_hba_init_crypto_capabilities(hba);
-	if (err)
+	if (err) {
 		dev_err(hba->dev, "crypto setup failed\n");
+		return err;
+	}
 
 	hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
 	if (!hba->mcq_sup)
-		return err;
+		return 0;
 
 	hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP);
 	hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT,
 				     hba->mcq_capabilities);
 
-	return err;
+	return 0;
 }
 
 /**
-- 
2.17.1


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

* Re: [PATCH] scsi: ufs: core: Use readable 'return 0' in ufshcd_hba_capabilities()
  2023-05-02 11:31 ` [PATCH] scsi: ufs: core: Use readable 'return 0' in ufshcd_hba_capabilities() Keoseong Park
@ 2023-05-02 20:28   ` Bart Van Assche
       [not found]   ` <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p5>
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2023-05-02 20:28 UTC (permalink / raw)
  To: keosung.park, ALIM AKHTAR, avri.altman, jejb, martin.petersen,
	stanley.chu, mani, quic_asutoshd, beanhuo, linux-scsi,
	linux-kernel

On 5/2/23 04:31, Keoseong Park wrote:
> The 'err' variable is the result of ufshcd_hba_init_crypto_capabilities()
> regardless of MCQ capabilities. Return 'err' immediately when the function
> error occurs. And if it is not an error, explicitly return 0.
> 
> Anyway, if ufshcd_hba_init_crypto_capabilities() returns error, MCQ
> capabilities is not used because it fails to initialize UFS driver.
> 
> Signed-off-by: Keoseong Park <keosung.park@samsung.com>
> ---
>   drivers/ufs/core/ufshcd.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 9434328ba323..44328eb4158d 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2343,18 +2343,20 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
>   
>   	/* Read crypto capabilities */
>   	err = ufshcd_hba_init_crypto_capabilities(hba);
> -	if (err)
> +	if (err) {
>   		dev_err(hba->dev, "crypto setup failed\n");
> +		return err;
> +	}
>   
>   	hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
>   	if (!hba->mcq_sup)
> -		return err;
> +		return 0;
>   
>   	hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP);
>   	hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT,
>   				     hba->mcq_capabilities);
>   
> -	return err;
> +	return 0;
>   }

The most important change in this patch is that ufshcd_hba_capabilities()
returns earlier if ufshcd_hba_init_crypto_capabilities() fails. Please
change the patch title such that it reflects this change instead of the
other less important change.

Thanks,

Bart.


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

* RE:(2) [PATCH] scsi: ufs: core: Use readable 'return 0' in ufshcd_hba_capabilities()
       [not found]   ` <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p5>
@ 2023-05-03  6:50     ` Keoseong Park
  0 siblings, 0 replies; 3+ messages in thread
From: Keoseong Park @ 2023-05-03  6:50 UTC (permalink / raw)
  To: Bart Van Assche, Keoseong Park, ALIM AKHTAR, avri.altman, jejb,
	martin.petersen, stanley.chu, mani, quic_asutoshd, beanhuo,
	linux-scsi, linux-kernel

>On 5/2/23 04:31, Keoseong Park wrote:
>> The 'err' variable is the result of ufshcd_hba_init_crypto_capabilities()
>> regardless of MCQ capabilities. Return 'err' immediately when the function
>> error occurs. And if it is not an error, explicitly return 0.
>> 
>> Anyway, if ufshcd_hba_init_crypto_capabilities() returns error, MCQ
>> capabilities is not used because it fails to initialize UFS driver.
>> 
>> Signed-off-by: Keoseong Park <keosung.park@samsung.com>
>> ---
>>   drivers/ufs/core/ufshcd.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>> 
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index 9434328ba323..44328eb4158d 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -2343,18 +2343,20 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
>>   
>>   	/* Read crypto capabilities */
>>   	err = ufshcd_hba_init_crypto_capabilities(hba);
>> -	if (err)
>> +	if (err) {
>>   		dev_err(hba->dev, "crypto setup failed\n");
>> +		return err;
>> +	}
>>   
>>   	hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
>>   	if (!hba->mcq_sup)
>> -		return err;
>> +		return 0;
>>   
>>   	hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP);
>>   	hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT,
>>   				     hba->mcq_capabilities);
>>   
>> -	return err;
>> +	return 0;
>>   }
>
>The most important change in this patch is that ufshcd_hba_capabilities()
>returns earlier if ufshcd_hba_init_crypto_capabilities() fails. Please
>change the patch title such that it reflects this change instead of the
>other less important change.

OK, I will change it.

Best Regards,
Keoseong

>
>Thanks,
>
>Bart.

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

end of thread, other threads:[~2023-05-03  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p7>
2023-05-02 11:31 ` [PATCH] scsi: ufs: core: Use readable 'return 0' in ufshcd_hba_capabilities() Keoseong Park
2023-05-02 20:28   ` Bart Van Assche
     [not found]   ` <CGME20230502113116epcms2p7b83da0d683e29f667c38f5430b985388@epcms2p5>
2023-05-03  6:50     ` Keoseong Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®