Re: [PATCH v17 2/2] ufs: sysfs: Resume the proper scsi device

From: Adrian Hunter
Date: Sat Apr 10 2021 - 04:57:05 EST


On 8/04/21 5:49 pm, Asutosh Das wrote:
> Resumes the actual scsi device the unit descriptor of which
> is being accessed instead of the hba alone.
>
> Reviewed-by: Can Guo <cang@xxxxxxxxxxxxxx>
> Signed-off-by: Asutosh Das <asutoshd@xxxxxxxxxxxxxx>
> ---
> drivers/scsi/ufs/ufs-sysfs.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> index d7c3cff..fa57bac 100644
> --- a/drivers/scsi/ufs/ufs-sysfs.c
> +++ b/drivers/scsi/ufs/ufs-sysfs.c

<SNIP>

> @@ -899,11 +899,15 @@ static ssize_t _pname##_show(struct device *dev, \
> struct scsi_device *sdev = to_scsi_device(dev); \
> struct ufs_hba *hba = shost_priv(sdev->host); \
> u8 lun = ufshcd_scsi_to_upiu_lun(sdev->lun); \
> + int ret; \
> if (!ufs_is_valid_unit_desc_lun(&hba->dev_info, lun, \
> _duname##_DESC_PARAM##_puname)) \
> return -EINVAL; \
> - return ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \
> + scsi_autopm_get_device(sdev); \
> + ret = ufs_sysfs_read_desc_param(hba, QUERY_DESC_IDN_##_duname, \
> lun, _duname##_DESC_PARAM##_puname, buf, _size); \
> + scsi_autopm_put_device(sdev); \
> + return ret; \

I am not sure why this change is needed. It it is needed, please add
a comment explaining.