Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] rtc: assorted bug fixes across RTC drivers
@ 2026-12-02 20:22 Lee Jones
  2026-12-02 20:22 ` [PATCH v2 02/10] rtc: mt6397: handle non-DT platform device matching in probe Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Lee Jones @ 2026-12-02 20:22 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, George G. Davis, Mark A. Greer, Tianping.Fang,
	Alexander Bigga, Alexandre Belloni, Alexandre Torgue,
	Andrew Jeffery, Andrew Morton, AngeloGioacchino Del Regno,
	Avi Fishman, Benjamin Fair, Dave Gerlach, dmitry pervushin,
	Dmitry Rakhchev, Domen Puncer, Eddie Huang,
	Enric Balletbo i Serra, Eric Liu, Gary Bisson, Imre Kaloz,
	Jacky Huang, Johan Hovold, John Rigby, Joshua Kinard, Keerthy,
	linux-arm-kernel, linux-mediatek, linux-rtc, linux-stm32,
	lm-sensors, Matthias Brugger, Matthias Fuchs, Maxime Coquelin,
	Medad CChien, Mia Lin, Ming-Jen Chen, Nancy Yuen, openbmc,
	Patrick Venture, Pavel Machek, Peter Hartley, Piotr Ziecik,
	Ran Bi, Ryan Brue, Sean Wang, Sebastian Reichel, Sergei Poselenov,
	Shan-Chun Hung, Tali Perry, Tomer Maimon, Tony Lindgren,
	Wim Van Sebroeck, Wolfgang Grandegger, Wolfram Sang, Yingjoe Chen

This v2 series addresses review feedback on the OMAP RTC power-off
patch and rebases cleanly onto rtc-next.

These issues were reported by Sashiko.

v1 => v2:
 - Rebase onto rtc-next
 - rtc: omap: Update Fixes: tag to 5a99ae0092fe ("soc: ti: pm33xx:
   AM437X: Add rtc_only with ddr in self-refresh support"), reword the
   commit message accordingly, and drop the unrelated refactoring in
   omap_rtc_power_off() (Johan)

Cc: "George G. Davis" <gdavis@mvista.com>
Cc: "Mark A. Greer" <mgreer@mvista.com>
Cc: "Tianping.Fang" <tianping.fang@mediatek.com>
Cc: Alexander Bigga <ab@mycable.de>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Andrew Jeffery <andrew@codeconstruct.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Avi Fishman <avifishman70@gmail.com>
Cc: Benjamin Fair <benjaminfair@google.com>
Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: dmitry pervushin <dpervushin@embeddedalley.com>
Cc: Dmitry Rakhchev <rda@emcraft.com>
Cc: Domen Puncer <domen.puncer@telargo.com>
Cc: Eddie Huang <eddie.huang@mediatek.com>
Cc: Enric Balletbo i Serra <eballetbo@kernel.org>
Cc: Eric Liu <liuer@nvidia.com>
Cc: Gary Bisson <gary.bisson@boundarydevices.com>
Cc: Imre Kaloz <kaloz@kernel.org>
Cc: Jacky Huang <ychuang3@nuvoton.com>
Cc: Johan Hovold <johan@kernel.org>
Cc: John Rigby <jcrigby@gmail.com>
Cc: Joshua Kinard <linux@kumba.dev>
Cc: Keerthy <j-keerthy@ti.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-rtc@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: lm-sensors@lm-sensors.org
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Medad CChien <ctcchien@nuvoton.com>
Cc: Mia Lin <mimi05633@gmail.com>
Cc: Ming-Jen Chen <mjchen@nuvoton.com>
Cc: Nancy Yuen <yuenn@google.com>
Cc: openbmc@lists.ozlabs.org
Cc: Patrick Venture <venture@google.com>
Cc: Pavel Machek <pavel@denx.de>
Cc: Peter Hartley <peter.hartley@sigmatel.com>
Cc: Piotr Ziecik <kosmo@semihalf.com>
Cc: Ran Bi <ran.bi@mediatek.com>
Cc: Ryan Brue <ryanbrue.dev@gmail.com>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Sergei Poselenov <sposelenov@emcraft.com>
Cc: Shan-Chun Hung <schung@nuvoton.com>
Cc: Tali Perry <tali.perry1@gmail.com>
Cc: Tomer Maimon <tmaimon77@gmail.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Wolfram Sang <wsa@kernel.org>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>

Lee Jones (10):
  rtc: rx8025: pass parent I2C device in clock_adjust_ppb sysfs
    callbacks
  rtc: mt6397: handle non-DT platform device matching in probe
  rtc: ma35d1: allocate RTC device before requesting interrupt
  rtc: mpc5121: get interrupts via platform_get_irq()
  rtc: m41t80: use devm helpers for square-wave clock registration
  rtc: nct3018y: fix clock provider use-after-free and leak on unbind
  rtc: stmp3xxx: unregister child watchdog platform device on unbind
  rtc: ds1685: check driver data for NULL in ds1685_rtc_poweroff()
  rtc: omap: prevent NULL and dangling pointer dereferences in power-off
    path
  rtc: bq32k: use u8 register buffer in trickle_charge_bypass sysfs

 drivers/rtc/rtc-bq32k.c    |  6 ++++--
 drivers/rtc/rtc-ds1685.c   |  6 ++----
 drivers/rtc/rtc-m41t80.c   |  5 +++--
 drivers/rtc/rtc-ma35d1.c   | 14 ++++++-------
 drivers/rtc/rtc-mpc5121.c  | 41 ++++++++++++++------------------------
 drivers/rtc/rtc-mt6397.c   | 19 ++++++++++++++++++
 drivers/rtc/rtc-nct3018y.c |  3 ++-
 drivers/rtc/rtc-omap.c     |  9 ++++++---
 drivers/rtc/rtc-rx8025.c   |  4 ++--
 drivers/rtc/rtc-stmp3xxx.c | 29 ++++++++++++++++-----------
 10 files changed, 77 insertions(+), 59 deletions(-)

-- 
2.56.1.911.g883d8bcb20-goog



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 02/10] rtc: mt6397: handle non-DT platform device matching in probe
  2026-12-02 20:22 [PATCH v2 00/10] rtc: assorted bug fixes across RTC drivers Lee Jones
@ 2026-12-02 20:22 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2026-12-02 20:22 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, stable, Tianping.Fang, Alexandre Belloni,
	AngeloGioacchino Del Regno, Eddie Huang, linux-arm-kernel,
	linux-mediatek, linux-rtc, Matthias Brugger, Ran Bi, Ryan Brue,
	Sean Wang, Sebastian Reichel, Yingjoe Chen

The parent MediaTek PMIC MFD driver instantiates RTC platform
subdevices even when the optional RTC child Device Tree node is omitted,
and devices can also be bound via sysfs driver_override.  In those
cases, of_device_get_match_data() returns NULL, yet mtk_rtc_probe()
succeeds with rtc->data left NULL and mtk_rtc_write_trigger()
subsequently crashes when dereferencing rtc->data->wrtgr.

Provide a platform_device_id table covering the MediaTek PMIC RTC cells
and fall back to platform_get_device_id() when no OF match data is
present, returning -ENODEV if neither match path provides driver data.

Fixes: 29ee40091e27 ("rtc: mt6397: Add support for the MediaTek MT6358 RTC")
Closes: https://sashiko.dev/#/bug/linux-35993d35-d776-4f86-9bd2-42c6ee078f88
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---

v1 => v2:
 - No changes

Cc: "Tianping.Fang" <tianping.fang@mediatek.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Eddie Huang <eddie.huang@mediatek.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-rtc@vger.kernel.org
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Ran Bi <ran.bi@mediatek.com>
Cc: Ryan Brue <ryanbrue.dev@gmail.com>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>

 drivers/rtc/rtc-mt6397.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index d6e156516aa6..248073b22a3e 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -343,6 +343,14 @@ static int mtk_rtc_probe(struct platform_device *pdev)
 	rtc->addr_base = res->start;
 
 	rtc->data = of_device_get_match_data(&pdev->dev);
+	if (!rtc->data) {
+		const struct platform_device_id *id = platform_get_device_id(pdev);
+
+		if (!id)
+			return -ENODEV;
+
+		rtc->data = (const struct mtk_rtc_data *)id->driver_data;
+	}
 
 	rtc->irq = platform_get_irq(pdev, 0);
 	if (rtc->irq < 0)
@@ -427,6 +435,16 @@ static const struct of_device_id mt6397_rtc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mt6397_rtc_of_match);
 
+static const struct platform_device_id mt6397_rtc_id[] = {
+	{ "mt6323-rtc", (kernel_ulong_t)&mt6397_rtc_data },
+	{ "mt6357-rtc", (kernel_ulong_t)&mt6358_rtc_data },
+	{ "mt6358-rtc", (kernel_ulong_t)&mt6358_rtc_data },
+	{ "mt6359-rtc", (kernel_ulong_t)&mt6358_rtc_data },
+	{ "mt6397-rtc", (kernel_ulong_t)&mt6397_rtc_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(platform, mt6397_rtc_id);
+
 static struct platform_driver mtk_rtc_driver = {
 	.driver = {
 		.name = "mt6397-rtc",
@@ -434,6 +452,7 @@ static struct platform_driver mtk_rtc_driver = {
 		.pm = &mt6397_pm_ops,
 	},
 	.probe	= mtk_rtc_probe,
+	.id_table = mt6397_rtc_id,
 };
 
 module_platform_driver(mtk_rtc_driver);
-- 
2.56.1.911.g883d8bcb20-goog



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 20:22 [PATCH v2 00/10] rtc: assorted bug fixes across RTC drivers Lee Jones
2026-12-02 20:22 ` [PATCH v2 02/10] rtc: mt6397: handle non-DT platform device matching in probe Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox