From: Bart Van Assche <bvanassche@acm.org>
To: Can Guo <can.guo@oss.qualcomm.com>, martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Peter Wang <peter.wang@mediatek.com>,
Huan Tang <tanghuan@vivo.com>,
"Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
Daniel Lee <chullee@google.com>, Liu Song <liu.song13@zte.com.cn>,
Ram Kumar Dwivedi <ram.dwivedi@oss.qualcomm.com>,
Bean Huo <huobean@gmail.com>,
Adrian Hunter <adrian.hunter@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] scsi: ufs: core: Add a sysfs entry for ufshcd_state
Date: Wed, 25 Feb 2026 10:59:29 -0800 [thread overview]
Message-ID: <7782e4fe-ddc5-4ef4-b632-5c137b31ed73@acm.org> (raw)
In-Reply-To: <20260225022942.345564-3-can.guo@oss.qualcomm.com>
On 2/24/26 6:29 PM, Can Guo wrote:
> +What: /sys/bus/platform/drivers/ufshcd/*/ufshcd_state
> +What: /sys/bus/platform/devices/*.ufs/ufshcd_state
> +Date: February 2026
> +Contact: Can Guo <can.guo@oss.qualcomm.com>
> +Description:
> + This attribute shows the state of ufshcd.
> +
> + The attribute is read only.
Please expand "state of ufshcd", e.g. into "state of the UFS host
controller driver".
> +static const char * const ufshcd_states[] = {
> + [UFSHCD_STATE_RESET] = "reset",
> + [UFSHCD_STATE_OPERATIONAL] = "operational",
> + [UFSHCD_STATE_EH_SCHEDULED_NON_FATAL] = "eh_scheduled_non_fatal",
> + [UFSHCD_STATE_EH_SCHEDULED_FATAL] = "eh_scheduled_fatal",
> + [UFSHCD_STATE_ERROR] = "error",
> +};
Please follow the kernel coding style with regard to spaces around "*".
> +static ssize_t ufshcd_state_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct ufs_hba *hba = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%s\n", ufshcd_states[hba->ufshcd_state]);
> +}
In the above function, please check that hba->ufshcd_state does not
exceed the bounds of the ufshcd_states[] array and also that
ufshcd_states[hba->ufshcd_state] is not NULL.
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index c6c7de7a0603..32a508e1582e 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -7917,6 +7917,8 @@ static void ufshcd_process_probe_result(struct ufs_hba *hba,
> hba->ufshcd_state = UFSHCD_STATE_OPERATIONAL;
> spin_unlock_irqrestore(hba->host->host_lock, flags);
>
> + sysfs_notify(&hba->dev->kobj, NULL, "ufshcd_state");
> +
> trace_ufshcd_init(hba, ret,
> ktime_to_us(ktime_sub(ktime_get(), probe_start)),
> hba->curr_dev_pwr_mode, hba->uic_link_state);
Shouldn't there be one sysfs_notify(&hba->dev->kobj, NULL,
"ufshcd_state") call after every hba->ufshcd_state change?
Thanks,
Bart.
next prev parent reply other threads:[~2026-02-25 18:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260225022942.345564-1-can.guo@oss.qualcomm.com>
2026-02-25 2:29 ` [PATCH v2 1/2] scsi: ufs: core: Add support to notify userspace of UniPro QoS events Can Guo
2026-02-25 18:48 ` Bart Van Assche
2026-03-01 9:09 ` Can Guo
2026-02-25 2:29 ` [PATCH v2 2/2] scsi: ufs: core: Add a sysfs entry for ufshcd_state Can Guo
2026-02-25 18:59 ` Bart Van Assche [this message]
2026-03-01 12:40 ` Can Guo
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=7782e4fe-ddc5-4ef4-b632-5c137b31ed73@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=adrian.hunter@intel.com \
--cc=alim.akhtar@samsung.com \
--cc=avri.altman@wdc.com \
--cc=can.guo@oss.qualcomm.com \
--cc=chullee@google.com \
--cc=huobean@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liu.song13@zte.com.cn \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=quic_nguyenb@quicinc.com \
--cc=ram.dwivedi@oss.qualcomm.com \
--cc=tanghuan@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®