[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f59c50ee3f5858535eca2887f326a8bb1117371f.camel@mediatek.com>
Date: Thu, 22 May 2025 03:26:41 +0000
From: Peter Wang (王信友) <peter.wang@...iatek.com>
To: "tanghuan@...o.com" <tanghuan@...o.com>
CC: "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
"James.Bottomley@...senPartnership.com"
<James.Bottomley@...senPartnership.com>, "bvanassche@....org"
<bvanassche@....org>, AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>, "linux-scsi@...r.kernel.org"
<linux-scsi@...r.kernel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-mediatek@...ts.infradead.org"
<linux-mediatek@...ts.infradead.org>, "opensource.kernel@...o.com"
<opensource.kernel@...o.com>, "manivannan.sadhasivam@...aro.org"
<manivannan.sadhasivam@...aro.org>, "alim.akhtar@...sung.com"
<alim.akhtar@...sung.com>, "quic_nguyenb@...cinc.com"
<quic_nguyenb@...cinc.com>, "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "matthias.bgg@...il.com"
<matthias.bgg@...il.com>, "avri.altman@....com" <avri.altman@....com>,
"wenxing.cheng@...o.com" <wenxing.cheng@...o.com>, "luhongfei@...o.com"
<luhongfei@...o.com>
Subject: Re: [PATCH v5] ufs: core: Add HID support
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
Powered by blists - more mailing lists