From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "tanghuan@vivo.com" <tanghuan@vivo.com>
Cc: "martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>,
"bvanassche@acm.org" <bvanassche@acm.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"opensource.kernel@vivo.com" <opensource.kernel@vivo.com>,
"manivannan.sadhasivam@linaro.org"
<manivannan.sadhasivam@linaro.org>,
"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
"quic_nguyenb@quicinc.com" <quic_nguyenb@quicinc.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"avri.altman@wdc.com" <avri.altman@wdc.com>,
"wenxing.cheng@vivo.com" <wenxing.cheng@vivo.com>,
"luhongfei@vivo.com" <luhongfei@vivo.com>
Subject: Re: [PATCH v5] ufs: core: Add HID support
Date: Thu, 22 May 2025 03:26:41 +0000 [thread overview]
Message-ID: <f59c50ee3f5858535eca2887f326a8bb1117371f.camel@mediatek.com> (raw)
In-Reply-To: <20250521143317.637-1-tanghuan@vivo.com>
On Wed, 2025-05-21 at 22:33 +0800, Huan Tang wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> > > +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
>
Hi Huan,
looks good to me.
Thanks
Peter
next prev parent reply other threads:[~2025-05-22 3:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 9:40 [PATCH v5] ufs: core: Add HID support Huan Tang
2025-05-20 13:14 ` Peter Wang (王信友)
2025-05-20 20:13 ` Bart Van Assche
2025-05-21 2:22 ` Peter Wang (王信友)
2025-05-21 14:33 ` Huan Tang
2025-05-22 3:26 ` Peter Wang (王信友) [this message]
2025-05-20 16:01 ` Bean Huo
2025-05-20 20:22 ` Bart Van Assche
2025-05-21 14:32 ` Huan Tang
2025-05-21 14:56 ` Bean Huo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f59c50ee3f5858535eca2887f326a8bb1117371f.camel@mediatek.com \
--to=peter.wang@mediatek.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luhongfei@vivo.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=opensource.kernel@vivo.com \
--cc=quic_nguyenb@quicinc.com \
--cc=tanghuan@vivo.com \
--cc=wenxing.cheng@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox