[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9ade874b-b69e-615d-b101-2ecc664ba64d@acm.org>
Date: Tue, 16 Mar 2021 20:31:07 -0700
From: Bart Van Assche <bvanassche@....org>
To: Arthur Simchaev <Arthur.Simchaev@....com>,
"James E . J . Bottomley" <jejb@...ux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: alim.akhtar@...sung.com, Bean Huo <beanhuo@...ron.com>
Subject: Re: [PATCH v2] scsi: ufs: sysfs: Print string descriptors as raw data
On 2/15/21 9:40 AM, Arthur Simchaev wrote:
> -#define UFS_STRING_DESCRIPTOR(_name, _pname) \
> +#define UFS_STRING_DESCRIPTOR(_name, _pname, _is_ascii) \
> static ssize_t _name##_show(struct device *dev, \
> struct device_attribute *attr, char *buf) \
> { \
> @@ -690,10 +690,18 @@ static ssize_t _name##_show(struct device *dev, \
> kfree(desc_buf); \
> desc_buf = NULL; \
> ret = ufshcd_read_string_desc(hba, index, &desc_buf, \
> - SD_ASCII_STD); \
> + _is_ascii); \
> if (ret < 0) \
> goto out; \
> - ret = sysfs_emit(buf, "%s\n", desc_buf); \
> + if (_is_ascii) { \
> + ret = sysfs_emit(buf, "%s\n", desc_buf); \
> + } else { \
> + int i; \
> + \
> + for (i = 0; i < desc_buf[0]; i++) \
> + hex_byte_pack(buf + i * 2, desc_buf[i]); \
> + ret = sysfs_emit(buf, "%s\n", buf); \
> + } \
> out: \
> pm_runtime_put_sync(hba->dev); \
> kfree(desc_buf); \
Hex data needs to be parsed before it can be used by any software. Has
it been considered to make the "raw" attributes binary attributes
instead of hex-encoded binary? See also sysfs_create_bin_file().
Thanks,
Bart.
Powered by blists - more mailing lists