Re: [PATCH] scsi: ufs: sysfs: add is_ascii_output entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/10/21 2:53 AM, Arthur Simchaev wrote:
> +static bool is_ascii_output = true;

[ ... ]

>  static const char *ufschd_uic_link_state_to_string(
>  			enum uic_link_state state)
>  {
> @@ -693,7 +695,15 @@ static ssize_t _name##_show(struct device *dev,				\
>  				      SD_ASCII_STD);			\
>  	if (ret < 0)							\
>  		goto out;						\
> -	ret = sysfs_emit(buf, "%s\n", desc_buf);			\
> +	if (is_ascii_output) {						\
> +		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);						\

Please do not introduce a mode variable but instead introduce a new
attribute such that there is one attribute for the unicode output and
one attribute for the ASCII output. Mode variables are troublesome when
e.g. two scripts try to set the mode attribute concurrently.

Thanks,

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux