diff mbox series

[v6,6/8] scsi: ufs: Simplify ufshcd_set_dev_pwr_mode()

Message ID 20220929224421.587465-7-bvanassche@acm.org
State Superseded
Headers show
Series Prepare for constifying SCSI host templates | expand

Commit Message

Bart Van Assche Sept. 29, 2022, 10:44 p.m. UTC
Simplify the code for incrementing the SCSI device reference count in
ufshcd_set_dev_pwr_mode(). This patch removes one scsi_device_put() call
that happens from atomic context.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Adrian Hunter Oct. 3, 2022, 6:28 a.m. UTC | #1
On 30/09/22 01:44, Bart Van Assche wrote:
> Simplify the code for incrementing the SCSI device reference count in
> ufshcd_set_dev_pwr_mode(). This patch removes one scsi_device_put() call
> that happens from atomic context.
> 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Avri Altman <avri.altman@wdc.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Not sure what patch set "v6 6/8" refers to, nevertheless:

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/ufs/core/ufshcd.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 7c15cbc737b4..6e61372fe027 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -8753,15 +8753,10 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
>  
>  	spin_lock_irqsave(hba->host->host_lock, flags);
>  	sdp = hba->ufs_device_wlun;
> -	if (sdp) {
> +	if (sdp && scsi_device_online(sdp))
>  		ret = scsi_device_get(sdp);
> -		if (!ret && !scsi_device_online(sdp)) {
> -			ret = -ENODEV;
> -			scsi_device_put(sdp);
> -		}
> -	} else {
> +	else
>  		ret = -ENODEV;
> -	}
>  	spin_unlock_irqrestore(hba->host->host_lock, flags);
>  
>  	if (ret)
Bart Van Assche Oct. 3, 2022, 4:23 p.m. UTC | #2
On 10/2/22 23:28, Adrian Hunter wrote:
> On 30/09/22 01:44, Bart Van Assche wrote:
>> Simplify the code for incrementing the SCSI device reference count in
>> ufshcd_set_dev_pwr_mode(). This patch removes one scsi_device_put() call
>> that happens from atomic context.
>>
>> Cc: Adrian Hunter <adrian.hunter@intel.com>
>> Cc: Avri Altman <avri.altman@wdc.com>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> 
> Not sure what patch set "v6 6/8" refers to, nevertheless:
> 
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

Hi Adrian,

That means that this is the sixth patch of eight in version 6 of the 
patch series that prepares for constifying the SCSI host template. The 
entire patch series is available here: 
https://lore.kernel.org/linux-scsi/20220929224421.587465-1-bvanassche@acm.org/

Anyway, thanks for the review.

Bart.
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 7c15cbc737b4..6e61372fe027 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8753,15 +8753,10 @@  static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
 	sdp = hba->ufs_device_wlun;
-	if (sdp) {
+	if (sdp && scsi_device_online(sdp))
 		ret = scsi_device_get(sdp);
-		if (!ret && !scsi_device_online(sdp)) {
-			ret = -ENODEV;
-			scsi_device_put(sdp);
-		}
-	} else {
+	else
 		ret = -ENODEV;
-	}
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
 	if (ret)