Re: [PATCH 6/7] scsi: ufs: Enable writing config descriptor

From: Bart Van Assche
Date: Mon Jun 04 2018 - 04:46:13 EST


On Tue, 2018-05-29 at 11:17 -0700, Evan Green wrote:
> This change enables writing to fields of the config descriptor
> via sysfs. It can be used to provision an unprovisioned UFS
> device, or reprovision an unlocked device.
>
> Signed-off-by: Evan Green <evgreen@xxxxxxxxxxxx>
> ---
> drivers/scsi/ufs/ufs-sysfs.c | 64 +++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 61 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c b/drivers/scsi/ufs/ufs-sysfs.c
> index 623c56074572..54e9f3bca9db 100644
> --- a/drivers/scsi/ufs/ufs-sysfs.c
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -252,6 +252,31 @@ static ssize_t ufs_sysfs_read_desc_param(struct ufs_hba *hba,
> return ret;
> }
>
> +static ssize_t ufs_sysfs_write_desc_param(struct ufs_hba *hba,
> + enum desc_idn desc_id,
> + u8 desc_index,
> + u8 param_offset,
> + const char *buf,
> + ssize_t buf_size,
> + u8 width)
> +{
> + int ret;
> + unsigned long long value;
> +
> + if (kstrtoull(buf, 0, &value))
> + return -EINVAL;
> +
> + /* Convert to big endian, and send only the appropriate width. */
> + value = cpu_to_be64(value);
> + ret = ufshcd_rw_desc_param(hba, UPIU_QUERY_OPCODE_WRITE_DESC, desc_id,
> + desc_index, param_offset,
> + (u8 *)&value + 8 - width, width);

Instead of using the above construct, please provide separate versions of
ufs_sysfs_write_desc_param() and ufshcd_rw_desc_param() for each supported
value of "width" (8, 16, 32 and/or 64) and also use the __be8 / __be16 /
__be32 / __be64 annotations for big endian numbers such that it becomes
possible to verify endianness correctness with sparse.

Thanks,

Bart.