From: Bean Huo <huobean@gmail.com>
To: Huan Tang <tanghuan@vivo.com>, bvanassche@acm.org
Cc: James.Bottomley@HansenPartnership.com, alim.akhtar@samsung.com,
angelogioacchino.delregno@collabora.com, avri.altman@wdc.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-scsi@vger.kernel.org,
luhongfei@vivo.com, manivannan.sadhasivam@linaro.org,
martin.petersen@oracle.com, matthias.bgg@gmail.com,
opensource.kernel@vivo.com, peter.wang@mediatek.com,
quic_nguyenb@quicinc.com, wenxing.cheng@vivo.com
Subject: Re: [PATCH v5] ufs: core: Add HID support
Date: Wed, 21 May 2025 16:56:50 +0200 [thread overview]
Message-ID: <7e034db7e46a33287f59159401affd58a81abad6.camel@gmail.com> (raw)
In-Reply-To: <20250521143224.587-1-tanghuan@vivo.com>
On Wed, 2025-05-21 at 22:32 +0800, Huan Tang wrote:
> > > > +static const char *ufs_hid_state_to_string(enum ufs_hid_state state)
> > > > +{
> > > > + switch (state) {
> > > > + case HID_IDLE:
> > > > + return "idle";
> > > > + case ANALYSIS_IN_PROGRESS:
> > > > + return "analysis_in_progress";
> > > > + case DEFRAG_REQUIRED:
> > > > + return "defrag_required";
> > > > + case DEFRAG_IN_PROGRESS:
> > > > + return "defrag_in_progress";
> > > > + case DEFRAG_COMPLETED:
> > > > + return "defrag_completed";
> > > > + case DEFRAG_NOT_REQUIRED:
> > > > + return "defrag_not_required";
> > > > + default:
> > > > + return "unknown";
> > > > + }
> > > > +}
> > >
> > > The enum ufs_hid_state values are contiguous and start from 0, maybe change switch-state to :
> > >
> > > #define NUM_UFS_HID_STATES 6
> > > static const char *ufs_hid_states[NUM_UFS_HID_STATES] = {
> > > "idle",
> > > "analysis_in_progress",
> > > "defrag_required",
> > > "defrag_in_progress",
> > > "defrag_completed",
> > > "defrag_not_required"
> > > };
>
> > If this change is made, please use the designated initializer syntax
> > ([label] = "text"). This will make it easier to verify that the
> > enumeration labels and the strings match.
>
> Hi bart and bean sir,
>
> Thank you for your comments and guidance!
>
> What do you think of the following changes?
>
> ufs.h
> +/* bHIDState attribute values */
> +enum ufs_hid_state {
> + HID_IDLE = 0,
> + ANALYSIS_IN_PROGRESS = 1,
> + DEFRAG_REQUIRED = 2,
> + DEFRAG_IN_PROGRESS = 3,
> + DEFRAG_COMPLETED = 4,
> + DEFRAG_NOT_REQUIRED = 5,
> + NUM_UFS_HID_STATES = 6,
> +};
>
> ufs-sysfs.c
> +static const char * const ufs_hid_states[] = {
> + [HID_IDLE] = "idle",
> + [ANALYSIS_IN_PROGRESS] = "analysis_in_progress",
> + [DEFRAG_REQUIRED] = "defrag_required",
> + [DEFRAG_IN_PROGRESS] = "defrag_in_progress",
> + [DEFRAG_COMPLETED] = "defrag_completed",
> + [DEFRAG_NOT_REQUIRED] = "defrag_not_required",
> +};
> +
> +static const char *ufs_hid_state_to_string(enum ufs_hid_state state)
> +{
> + if (state < NUM_UFS_HID_STATES)
> + return ufs_hid_states[state];
> +
> + return "unknown";
> +}
>
> ...
>
> +static ssize_t state_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct ufs_hba *hba = dev_get_drvdata(dev);
> + u32 value;
> + int ret;
> +
> + ret = hid_query_attr(hba, UPIU_QUERY_OPCODE_READ_ATTR,
> + QUERY_ATTR_IDN_HID_STATE, &value);
> + if (ret)
> + return ret;
> +
> + return sysfs_emit(buf, "%s\n", ufs_hid_state_to_string(value));
> +}
>
> Thanks
> Huan
>
>
>
looks good to me, with this change, please add my reviewed-by tag in the next version.
Kind regards,
Bean
prev parent reply other threads:[~2025-05-21 14:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 9:40 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 (王信友)
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 [this message]
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=7e034db7e46a33287f59159401affd58a81abad6.camel@gmail.com \
--to=huobean@gmail.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=peter.wang@mediatek.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
all inboxes | Powered by JetHome®