linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Bjorn Andersson <andersson@kernel.org>
Cc: Andy Gross <agross@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH 12/24] rtc: pm8xxx: use u32 for timestamps
Date: Thu, 26 Jan 2023 15:20:45 +0100	[thread overview]
Message-ID: <20230126142057.25715-13-johan+linaro@kernel.org> (raw)
In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org>

The PMIC RTC registers are 32-bit so explicitly use u32 rather than
unsigned long for timestamps to reflect the hardware.

This will also help avoid unintentional range extensions when adding
support for managing an external offset.

Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
 drivers/rtc/rtc-pm8xxx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 8a94a19e0d14..b1ce246c501a 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -74,7 +74,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
 	u8 value[NUM_8_BIT_RTC_REGS];
 	bool alarm_enabled;
-	unsigned long secs;
+	u32 secs;
 	int rc;
 
 	if (!rtc_dd->allow_set_time)
@@ -83,7 +83,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	secs = rtc_tm_to_time64(tm);
 	put_unaligned_le32(secs, value);
 
-	dev_dbg(dev, "set time: %ptRd %ptRt (%lu)\n", tm, tm, secs);
+	dev_dbg(dev, "set time: %ptRd %ptRt (%u)\n", tm, tm, secs);
 
 	rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl,
 				      regs->alarm_en, 0, &alarm_enabled);
@@ -131,10 +131,10 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	int rc;
 	u8 value[NUM_8_BIT_RTC_REGS];
-	unsigned long secs;
 	unsigned int reg;
 	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
 	const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
+	u32 secs;
 
 	rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value));
 	if (rc)
@@ -158,7 +158,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	secs = get_unaligned_le32(value);
 	rtc_time64_to_tm(secs, tm);
 
-	dev_dbg(dev, "read time: %ptRd %ptRt (%lu)\n", tm, tm, secs);
+	dev_dbg(dev, "read time: %ptRd %ptRt (%u)\n", tm, tm, secs);
 
 	return 0;
 }
@@ -168,7 +168,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	u8 value[NUM_8_BIT_RTC_REGS];
 	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
 	const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
-	unsigned long secs;
+	u32 secs;
 	int rc;
 
 	secs = rtc_tm_to_time64(&alarm->time);
@@ -201,9 +201,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	int rc;
 	unsigned int ctrl_reg;
 	u8 value[NUM_8_BIT_RTC_REGS];
-	unsigned long secs;
 	struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
 	const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
+	u32 secs;
 
 	rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value,
 			      sizeof(value));
-- 
2.39.1


  parent reply	other threads:[~2023-01-26 14:23 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 14:20 [PATCH 00/24] rtc: pm8xxx: add support for setting time using nvmem Johan Hovold
2023-01-26 14:20 ` [PATCH 01/24] rtc: pm8xxx: fix set-alarm race Johan Hovold
2023-01-26 14:20 ` [PATCH 02/24] rtc: pm8xxx: drop spmi error messages Johan Hovold
2023-01-26 14:20 ` [PATCH 03/24] rtc: pm8xxx: use regmap_update_bits() Johan Hovold
2023-01-26 14:20 ` [PATCH 04/24] rtc: pm8xxx: drop bogus locking Johan Hovold
2023-01-26 14:20 ` [PATCH 05/24] rtc: pm8xxx: return IRQ_NONE on errors Johan Hovold
2023-01-26 14:20 ` [PATCH 06/24] rtc: pm8xxx: drop unused register defines Johan Hovold
2023-01-26 14:20 ` [PATCH 07/24] rtc: pm8xxx: use unaligned le32 helpers Johan Hovold
2023-01-26 14:20 ` [PATCH 08/24] rtc: pm8xxx: clean up time and alarm debugging Johan Hovold
2023-01-26 14:20 ` [PATCH 09/24] rtc: pm8xxx: rename struct device pointer Johan Hovold
2023-01-26 14:20 ` [PATCH 10/24] rtc: pm8xxx: rename alarm irq variable Johan Hovold
2023-01-26 14:20 ` [PATCH 11/24] rtc: pm8xxx: clean up comments Johan Hovold
2023-01-26 14:20 ` Johan Hovold [this message]
2023-01-26 14:20 ` [PATCH 13/24] rtc: pm8xxx: refactor read_time() Johan Hovold
2023-01-26 14:20 ` [PATCH 14/24] rtc: pm8xxx: clean up local declarations Johan Hovold
2023-01-26 14:20 ` [PATCH 15/24] dt-bindings: rtc: qcom-pm8xxx: add nvmem-cell offset Johan Hovold
2023-01-26 15:56   ` Krzysztof Kozlowski
2023-01-26 14:20 ` [PATCH 16/24] rtc: pm8xxx: add support for nvmem offset Johan Hovold
2023-01-27 14:13   ` Srinivas Kandagatla
2023-01-27 15:32     ` Johan Hovold
2023-01-27 15:09   ` Alexandre Belloni
2023-01-27 15:51     ` Johan Hovold
2023-01-27 16:05       ` Alexandre Belloni
2023-02-02 15:12         ` Johan Hovold
2023-02-02 15:21           ` Alexandre Belloni
2023-01-26 14:20 ` [PATCH 17/24] rtc: pm8xxx: add copyright notice Johan Hovold
2023-01-26 16:06   ` Alexandre Belloni
2023-01-27 13:04     ` Johan Hovold
2023-01-27 14:14       ` Krzysztof Kozlowski
2023-02-02 10:22         ` Johan Hovold
2023-01-26 14:20 ` [RFC 18/24] dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset Johan Hovold
2023-01-30 18:49   ` Rob Herring
2023-02-01 16:09     ` Johan Hovold
2023-02-09 16:59       ` Ard Biesheuvel
2023-01-26 14:20 ` [PATCH 19/24] rtc: pm8xxx: add support for uefi offset Johan Hovold
2023-01-26 14:27   ` Johan Hovold
2023-01-27 15:19   ` Alexandre Belloni
2023-01-27 15:26     ` Johan Hovold
2023-01-27 15:59       ` Alexandre Belloni
2023-01-26 14:20 ` [PATCH 20/24] arm64: defconfig: enable Qualcomm SDAM nvmem driver Johan Hovold
2023-01-26 14:20 ` [PATCH 21/24] arm64: dts: qcom: sc8280xp-pmics: add pmk8280 rtc Johan Hovold
2023-01-26 14:20 ` [PATCH 22/24] arm64: dts: qcom: sc8280xp-pmics: add pmk8280 sdam nvram Johan Hovold
2023-01-26 14:20 ` [PATCH 23/24] arm64: dts: qcom: sc8280xp-crd: enable rtc Johan Hovold
2023-01-26 14:20 ` [PATCH 24/24] arm64: dts: qcom: sc8280xp-x13s: " Johan Hovold

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=20230126142057.25715-13-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=a.zummo@towertech.it \
    --cc=agross@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=robh+dt@kernel.org \
    /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).