Skip to contentSkip to conversation

rtc: gamecube: Propagate address translation error

PATCH New Thorsten Blum 2 participants 10 messages Nov 9 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 rtc: gamecube: Propagate address translation error

If of_address_to_resource() fails, propagate its error code instead of returning -1 from gamecube_rtc_read_offset_from_sram().

Fixes 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
---
 drivers/rtc/rtc-gamecube.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-gamecube.c +1 -1
index 3fd562d3526a..0299f27106c0 100644
@@ -238,7 +238,7 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
 	of_node_put(np);
 	if (ret) {
 		pr_err("no io memory range found\n");
-		return -1;
+		return ret;
 	}
 
 	hw_srnprot = ioremap(res.start, resource_size(&res));
#1 lore raw

PATCH 2/5 rtc: gamecube: Add missing newline to SRAM bias debug message

Add a newline to the SRAM bias debug message to terminate it properly.

---
 drivers/rtc/rtc-gamecube.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-gamecube.c +1 -1
index 0299f27106c0..25290f162cbc 100644
@@ -339,7 +339,7 @@ static int gamecube_rtc_probe(struct platform_device *pdev)
 	ret = gamecube_rtc_read_offset_from_sram(d);
 	if (ret)
 		return ret;
-	dev_dbg(dev, "SRAM bias: 0x%x", d->rtc_bias);
+	dev_dbg(dev, "SRAM bias: 0x%x\n", d->rtc_bias);
 
 	dev_set_drvdata(dev, d);
 
#2 lore raw

Re: [PATCH 2/5] rtc: gamecube: Add missing newline to SRAM bias debug message

Sashiko has reviewed this patch and found no issues.
Quoted 3 lines

Add a newline to the SRAM bias debug message to terminate it properly.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#3 lore raw

PATCH 3/5 rtc: gamecube: Explain why fast_io is enabled

In reply to Thorsten Blum

Replace the TODO with an explanation of why fast_io is enabled.

---
 drivers/rtc/rtc-gamecube.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-gamecube.c +1 -1
index 25290f162cbc..4b45274effdf 100644
@@ -152,7 +152,7 @@ static int exi_write(void *context, u32 reg, u32 data)
 }
 
 static const struct regmap_bus exi_bus = {
-	/* TODO: is that true?  Not that it matters here, but still. */
+	/* Transfers use MMIO and busy-wait for completion without sleeping. */
 	.fast_io = true,
 	.reg_read = exi_read,
 	.reg_write = exi_write,
#4 lore raw

Re: [PATCH 3/5] rtc: gamecube: Explain why fast_io is enabled

Sashiko has reviewed this patch and found no issues.
Quoted 3 lines

Replace the TODO with an explanation of why fast_io is enabled.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#5 lore raw

PATCH 4/5 rtc: gamecube: Use unsigned int for control0

In reply to Thorsten Blum

regmap_read() expects an unsigned int pointer for its output value. Declare control0 as unsigned int to match the expected type.

---
 drivers/rtc/rtc-gamecube.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-gamecube.c +1 -1
index 4b45274effdf..ec672bee0134 100644
@@ -190,7 +190,7 @@ static int gamecube_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned lon
 {
 	struct priv *d = dev_get_drvdata(dev);
 	int value;
-	int control0;
+	unsigned int control0;
 	int ret;
 
 	switch (cmd) {
#6 lore raw

Re: [PATCH 4/5] rtc: gamecube: Use unsigned int for control0

Sashiko has reviewed this patch and found no issues.
Quoted 4 lines

regmap_read() expects an unsigned int pointer for its output value. Declare control0 as unsigned int to match the expected type.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#7 lore raw

PATCH 5/5 rtc: gamecube: Use register definitions

In reply to Thorsten Blum

Use the register definitions to replace the hard-coded addresses to improve readability. Add RTC_SRAM_LAST for the SRAM range end.

---
 drivers/rtc/rtc-gamecube.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/rtc/rtc-gamecube.c +11 -10
index ec672bee0134..dc4299f71f8f 100644
@@ -73,6 +73,7 @@
 #define RTC_COUNTER	0x200000
 #define RTC_SRAM	0x200001
 #define RTC_SRAM_BIAS	0x200004
+#define RTC_SRAM_LAST	0x200010
 #define RTC_SNAPSHOT	0x204000
 #define RTC_ONTMR	0x210000
 #define RTC_OFFTMR	0x210001
@@ -283,11 +284,11 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
 }
 
 static const struct regmap_range rtc_rd_ranges[] = {
-	regmap_reg_range(0x200000, 0x200010),
-	regmap_reg_range(0x204000, 0x204000),
-	regmap_reg_range(0x210000, 0x210001),
-	regmap_reg_range(0x210004, 0x210007),
-	regmap_reg_range(0x21000c, 0x21000d),
+	regmap_reg_range(RTC_COUNTER, RTC_SRAM_LAST),
+	regmap_reg_range(RTC_SNAPSHOT, RTC_SNAPSHOT),
+	regmap_reg_range(RTC_ONTMR, RTC_OFFTMR),
+	regmap_reg_range(RTC_TEST0, RTC_TEST3),
+	regmap_reg_range(RTC_CONTROL0, RTC_CONTROL1),
 };
 
 static const struct regmap_access_table rtc_rd_regs = {
@@ -296,10 +297,10 @@ static const struct regmap_access_table rtc_rd_regs = {
 };
 
 static const struct regmap_range rtc_wr_ranges[] = {
-	regmap_reg_range(0x200000, 0x200010),
-	regmap_reg_range(0x204000, 0x204000),
-	regmap_reg_range(0x210000, 0x210001),
-	regmap_reg_range(0x21000d, 0x21000d),
+	regmap_reg_range(RTC_COUNTER, RTC_SRAM_LAST),
+	regmap_reg_range(RTC_SNAPSHOT, RTC_SNAPSHOT),
+	regmap_reg_range(RTC_ONTMR, RTC_OFFTMR),
+	regmap_reg_range(RTC_CONTROL1, RTC_CONTROL1),
 };
 
 static const struct regmap_access_table rtc_wr_regs = {
@@ -312,7 +313,7 @@ static const struct regmap_config gamecube_rtc_regmap_config = {
 	.val_bits = 32,
 	.rd_table = &rtc_rd_regs,
 	.wr_table = &rtc_wr_regs,
-	.max_register = 0x21000d,
+	.max_register = RTC_CONTROL1,
 	.name = "gamecube-rtc",
 };
 
#8 lore raw

Re: [PATCH 5/5] rtc: gamecube: Use register definitions

Sashiko has reviewed this patch and found no issues.
Quoted 4 lines

Use the register definitions to replace the hard-coded addresses to improve readability. Add RTC_SRAM_LAST for the SRAM range end.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
#9 lore raw
In reply to Thorsten Blum
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

If of_address_to_resource() fails, propagate its error code instead of returning -1 from gamecube_rtc_read_offset_from_sram().

Fixes 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1