From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: Jonathan Corbet <corbet@lwn.net>, Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Peng Fan <peng.fan@nxp.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, arm-scmi@vger.kernel.org,
linux-rtc@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 6/7] rtc: support i.MX95 BBM RTC
Date: Thu, 11 Jul 2024 22:33:37 +0200 [thread overview]
Message-ID: <202407112033378dbbea83@mail.local> (raw)
In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-6-b85a6bf778cb@nxp.com>
Hello,
On 21/06/2024 15:04:41+0800, Peng Fan (OSS) wrote:
> + ret = bbnsm->ops->rtc_time_get(ph, 0, &val);
> + if (ret) {
> + dev_err(dev, "%s: %d\n", __func__, ret);
This is not super useful, you should drop the various dev_err or pr_err
as there is no action the user can take to solve the erro apart from
retrying.
> + return ret;
> + }
> +
> + rtc_time64_to_tm(val, tm);
> +
> + return 0;
> +}
> +
> +static int scmi_imx_bbm_set_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
> + struct scmi_protocol_handle *ph = bbnsm->ph;
> + u64 val;
> + int ret;
> +
> + val = rtc_tm_to_time64(tm);
> +
> + ret = bbnsm->ops->rtc_time_set(ph, 0, val);
> + if (ret)
> + dev_err(dev, "%s: %d\n", __func__, ret);
> +
> + return ret;
> +}
> +
> +static int scmi_imx_bbm_alarm_irq_enable(struct device *dev, unsigned int enable)
> +{
How can userspace disable the alarm?
> + return 0;
> +}
> +
> +static int scmi_imx_bbm_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
> +{
> + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
> + struct scmi_protocol_handle *ph = bbnsm->ph;
> + struct rtc_time *alrm_tm = &alrm->time;
> + u64 val;
> + int ret;
> +
> + val = rtc_tm_to_time64(alrm_tm);
> +
> + ret = bbnsm->ops->rtc_alarm_set(ph, 0, val);
> + if (ret)
> + dev_err(dev, "%s: %d\n", __func__, ret);
> +
> + return ret;
> +}
> +
> +static const struct rtc_class_ops smci_imx_bbm_rtc_ops = {
> + .read_time = scmi_imx_bbm_read_time,
> + .set_time = scmi_imx_bbm_set_time,
> + .set_alarm = scmi_imx_bbm_set_alarm,
> + .alarm_irq_enable = scmi_imx_bbm_alarm_irq_enable,
> +};
> +
> +static int scmi_imx_bbm_rtc_notifier(struct notifier_block *nb, unsigned long event, void *data)
> +{
> + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb);
> + struct scmi_imx_bbm_notif_report *r = data;
> +
> + if (r->is_rtc)
> + rtc_update_irq(bbnsm->rtc_dev, 1, RTC_AF | RTC_IRQF);
> + else
> + pr_err("Unexpected bbm event: %s\n", __func__);
> +
> + return 0;
> +}
> +
> +static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev)
> +{
> + const struct scmi_handle *handle = sdev->handle;
> + struct device *dev = &sdev->dev;
> + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
> + int ret;
> +
> + bbnsm->rtc_dev = devm_rtc_allocate_device(dev);
> + if (IS_ERR(bbnsm->rtc_dev))
> + return PTR_ERR(bbnsm->rtc_dev);
> +
> + bbnsm->rtc_dev->ops = &smci_imx_bbm_rtc_ops;
> + bbnsm->rtc_dev->range_min = 0;
range_min is set to 0 by default, this is not necessary
> + bbnsm->rtc_dev->range_max = U32_MAX;
> +
> + ret = devm_rtc_register_device(bbnsm->rtc_dev);
> + if (ret)
> + return ret;
> +
> + bbnsm->nb.notifier_call = &scmi_imx_bbm_rtc_notifier;
> + return handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM,
> + SCMI_EVENT_IMX_BBM_RTC,
> + NULL, &bbnsm->nb);
Note that failing after devm_rtc_register_device opens the driver to a
race condition as the character device will exist at that time.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2024-07-11 20:35 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 7:04 [PATCH v5 0/7] firmware: support i.MX95 SCMI BBM/MISC Extenstion Peng Fan (OSS)
2024-06-21 7:04 ` [PATCH v5 1/7] Documentation: firmware-guide: add NXP i.MX95 SCMI documentation Peng Fan (OSS)
2024-07-11 13:16 ` Cristian Marussi
2024-07-15 11:47 ` Peng Fan
2024-07-15 12:59 ` Sudeep Holla
2024-07-16 9:56 ` Peng Fan
2024-06-21 7:04 ` [PATCH v5 2/7] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Peng Fan (OSS)
2024-07-11 13:04 ` Cristian Marussi
2024-06-21 7:04 ` [PATCH v5 3/7] firmware: arm_scmi: add initial support for i.MX BBM protocol Peng Fan (OSS)
2024-06-21 7:04 ` [PATCH v5 4/7] firmware: arm_scmi: add initial support for i.MX MISC protocol Peng Fan (OSS)
2024-07-11 13:24 ` Cristian Marussi
2024-06-21 7:04 ` [PATCH v5 5/7] firmware: imx: add i.MX95 MISC driver Peng Fan (OSS)
2024-07-11 13:33 ` Cristian Marussi
2024-06-21 7:04 ` [PATCH v5 6/7] rtc: support i.MX95 BBM RTC Peng Fan (OSS)
2024-07-11 13:39 ` Cristian Marussi
2024-07-11 20:33 ` Alexandre Belloni [this message]
2024-07-14 8:22 ` Peng Fan
2024-07-14 20:01 ` Alexandre Belloni
2024-06-21 7:04 ` [PATCH v5 7/7] input: keyboard: support i.MX95 BBM module Peng Fan (OSS)
2024-07-11 14:01 ` Cristian Marussi
2024-07-11 14:05 ` [PATCH v5 0/7] firmware: support i.MX95 SCMI BBM/MISC Extenstion Cristian Marussi
2024-07-11 19:54 ` Alexandre Belloni
2024-07-14 8:26 ` Peng Fan
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=202407112033378dbbea83@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=arm-scmi@vger.kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=cristian.marussi@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=sudeep.holla@arm.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;
as well as URLs for NNTP newsgroup(s).