[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250521143317.637-1-tanghuan@vivo.com>
Date: Wed, 21 May 2025 22:33:17 +0800
From: Huan Tang <tanghuan@...o.com>
To: peter.wang@...iatek.com
Cc: James.Bottomley@...senPartnership.com,
alim.akhtar@...sung.com,
angelogioacchino.delregno@...labora.com,
avri.altman@....com,
bvanassche@....org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-mediatek@...ts.infradead.org,
linux-scsi@...r.kernel.org,
luhongfei@...o.com,
manivannan.sadhasivam@...aro.org,
martin.petersen@...cle.com,
matthias.bgg@...il.com,
opensource.kernel@...o.com,
quic_nguyenb@...cinc.com,
tanghuan@...o.com,
wenxing.cheng@...o.com
Subject: Re: [PATCH v5] ufs: core: Add HID support
>> +static const char * const hid_trigger_mode[] = {"disable",
>> "enable"};
>> +
>> +static ssize_t analysis_trigger_store(struct device *dev,
>> + struct device_attribute *attr, const char *buf,
>> size_t count)
>> +{
>> + struct ufs_hba *hba = dev_get_drvdata(dev);
>> + int mode;
>> + int ret;
>> +
>> + mode = sysfs_match_string(hid_trigger_mode, buf);
>> + if (mode < 0)
>> + return -EINVAL;
>>
>
> Hi Haun,
>
> Consider use below coding style for readability.
>
> if (sysfs_streq(buf, "enable"))
> mode = ...;
> else if (sysfs_streq(buf, "disable"))
> mode = ...;
> else
> return -EINVAL;
Hi peter sir,
Thank you for your comments and guidanceļ¼
I think your modification will indeed improve the readability of the code.
What do you think of the following changes?
ufs-sysfs.c
+static ssize_t analysis_trigger_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ int mode;
+ int ret;
+
+ if (sysfs_streq(buf, "enable"))
+ mode = HID_ANALYSIS_ENABLE;
+ else if (sysfs_streq(buf, "disable"))
+ mode = HID_ANALYSIS_AND_DEFRAG_DISABLE;
+ else
+ return -EINVAL;
+
+ ret = hid_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
+ QUERY_ATTR_IDN_HID_DEFRAG_OPERATION, &mode);
+
+ return ret < 0 ? ret : count;
+}
+
+static DEVICE_ATTR_WO(analysis_trigger);
+
+static ssize_t defrag_trigger_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct ufs_hba *hba = dev_get_drvdata(dev);
+ int mode;
+ int ret;
+
+ if (sysfs_streq(buf, "enable"))
+ mode = HID_ANALYSIS_AND_DEFRAG_ENABLE;
+ else if (sysfs_streq(buf, "disable"))
+ mode = HID_ANALYSIS_AND_DEFRAG_DISABLE;
+ else
+ return -EINVAL;
+
+ ret = hid_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
+ QUERY_ATTR_IDN_HID_DEFRAG_OPERATION, &mode);
+
+ return ret < 0 ? ret : count;
+}
Thanks
Huan
Powered by blists - more mailing lists