rtc: m41t80: Remove deprecated and undocumented compatible strings
PATCH 1/6 rtc: m41t80: Remove deprecated and undocumented compatible strings
The OF match table contains legacy compatibles "st,rv4162" and "rv4162" which were added 9 years ago for compatibility reasons but are not documented in the binding.
Remove them as they are no longer needed after the device tree has been updated to use the correct "microcrystal,rv4162".
--- drivers/rtc/rtc-m41t80.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/rtc/rtc-m41t80.c +0 -9
@@ -131,15 +131,6 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = { .compatible = "microcrystal,rv4162", .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) }, -/* DT compatibility only, do not use compatibles below: */ - { - .compatible = "st,rv4162", - .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) - }, - { - .compatible = "rv4162", - .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) - }, { } };MODULE_DEVICE_TABLE (of, m41t80_of_match);
Signature · 1 line
2.52.0
PATCH 2/6 rtc: m41t80: Rename FEATURE_WD to FEATURE_WDR for clarity
The FEATURE_WD flag indicates extra watchdog resolution support. Rename it to FEATURE_WDR to better reflect its purpose (WatchDog Resolution). No functional change.
--- drivers/rtc/rtc-m41t80.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/rtc/rtc-m41t80.c +6 -6
@@ -67,12 +67,12 @@#define M41T80_FEATURE_HT BIT(0)/* Halt feature */ #define M41T80_FEATURE_BL BIT(1)/* Battery low indicator */ #define M41T80_FEATURE_SQ BIT(2)/* Squarewave feature */ -#define M41T80_FEATURE_WD BIT(3)/* Extra watchdog resolution */ +#define M41T80_FEATURE_WDR BIT(3)/* Extra watchdog resolution */ #define M41T80_FEATURE_SQ_ALT BIT(4)/* RSx bits are in reg 4 */ static const struct i2c_device_id m41t80_id[] = { {"m41t62" ,M41T80_FEATURE_SQ |M41T80_FEATURE_SQ_ALT }, - {"m41t65" ,M41T80_FEATURE_WD }, + {"m41t65" ,M41T80_FEATURE_WDR }, {"m41t80" ,M41T80_FEATURE_SQ }, {"m41t81" ,M41T80_FEATURE_HT |M41T80_FEATURE_SQ }, {"m41t81s" ,M41T80_FEATURE_HT |M41T80_FEATURE_BL |M41T80_FEATURE_SQ },
@@ -81,7 +81,7 @@ static const struct i2c_device_id m41t80_id[] = { { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, - { "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT }, + { "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT }, { } };MODULE_DEVICE_TABLE (i2c, m41t80_id);
@@ -93,7 +93,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = { }, { .compatible = "st,m41t65", - .data = (void *)(M41T80_FEATURE_WD) + .data = (void *)(M41T80_FEATURE_WDR) }, { .compatible = "st,m41t80",
@@ -129,7 +129,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = { }, { .compatible = "microcrystal,rv4162", - .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) + .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT) }, { } };
@@ -661,7 +661,7 @@ static void wdt_ping(void)* M41T65 has three bits for watchdog resolution. Don't set bit 7, as * that would be an invalid resolution. */ -if (clientdata->features &M41T80_FEATURE_WD ) +if (clientdata->features &M41T80_FEATURE_WDR ) i2c_data[1 ] &= ~M41T80_WATCHDOG_RB2 ;i2c_transfer (save_client->adapter, msgs1,1 );
Signature · 1 line
2.52.0
PATCH 3/6 rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution
In reply to Alexander ShiyanFor chips without the extra watchdog resolution (i.e., those with only 2 resolution bits), bit 7 (RB2) must be cleared to avoid invalid settings. The current logic clears RB2 only when extra resolution is present. Reverse the condition.
--- drivers/rtc/rtc-m41t80.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m41t80.c +3 -3
@@ -658,10 +658,10 @@ static void wdt_ping(void) i2c_data[1 ] = wdt_margin <<2 |0x82 ;/* -* M41T65 has three bits for watchdog resolution. Don't set bit 7, as -* that would be an invalid resolution. +* Chips with extra watchdog resolution have three bits. +* Don't set bit 7, as that would be an invalid resolution. */ -if (clientdata->features &M41T80_FEATURE_WDR ) +if (!(clientdata->features &M41T80_FEATURE_WDR )) i2c_data[1 ] &= ~M41T80_WATCHDOG_RB2 ;i2c_transfer (save_client->adapter, msgs1,1 );
Signature · 1 line
2.52.0
Re: [PATCH 3/6] rtc: m41t80: Fix watchdog resolution bit handling for chips without extra resolution
Hello.
Unfortunately, I have reviewed this patch and come to the conclusion that it is incorrect.
Please skip its review (3/6).
Quoted 32 lines
For chips without the extra watchdog resolution (i.e., those with only 2 resolution bits), bit 7 (RB2) must be cleared to avoid invalid settings. The current logic clears RB2 only when extra resolution is present. Reverse the condition.
Fixes d3a126fcf9df ("rtc: rtc-m41t80.c: add support for the ST M41T65 RTC")Signed-off-by Alexander Shiyan <[email protected]>--- drivers/rtc/rtc-m41t80.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/rtc/rtc-m41t80.c +3
-4@@ -658,10 +658,10 @@ static void wdt_ping(void) i2c_data[1 ] = wdt_margin <<2 |0x82 ;/* -* M41T65 has three bits for watchdog resolution. Don't set bit 7, as -* that would be an invalid resolution. +* Chips with extra watchdog resolution have three bits. +* Don't set bit 7, as that would be an invalid resolution. */ -if (clientdata->features &M41T80_FEATURE_WDR ) +if (!(clientdata->features &M41T80_FEATURE_WDR )) i2c_data[1 ] &= ~M41T80_WATCHDOG_RB2 ;i2c_transfer (save_client->adapter, msgs1,1 ); --2.52.0
PATCH 4/6 rtc: m41t80: Add FEATURE_HT to all chips supporting extra watchdog resolution
In reply to Alexander ShiyanThe watchdog driver is only registered if the chip has the Halt feature (FEATURE_HT). Chips like m41t65 and rv4162 support watchdog but lack FEATURE_HT, preventing watchdog registration.
Add FEATURE_HT to those entries so that the watchdog becomes available.
--- drivers/rtc/rtc-m41t80.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-m41t80.c +4 -4
@@ -72,7 +72,7 @@static const struct i2c_device_id m41t80_id[] = { {"m41t62" ,M41T80_FEATURE_SQ |M41T80_FEATURE_SQ_ALT }, - {"m41t65" ,M41T80_FEATURE_WDR }, + {"m41t65" ,M41T80_FEATURE_HT |M41T80_FEATURE_WDR }, {"m41t80" ,M41T80_FEATURE_SQ }, {"m41t81" ,M41T80_FEATURE_HT |M41T80_FEATURE_SQ }, {"m41t81s" ,M41T80_FEATURE_HT |M41T80_FEATURE_BL |M41T80_FEATURE_SQ },
@@ -81,7 +81,7 @@ static const struct i2c_device_id m41t80_id[] = { { "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, { "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, { "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ }, - { "rv4162", M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT }, + { "rv4162", M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT }, { } };MODULE_DEVICE_TABLE (i2c, m41t80_id);
@@ -93,7 +93,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = { }, { .compatible = "st,m41t65", - .data = (void *)(M41T80_FEATURE_WDR) + .data = (void *)(M41T80_FEATURE_HT |M41T80_FEATURE_WDR ) }, { .compatible = "st,m41t80",
@@ -129,7 +129,7 @@ static const __maybe_unused struct of_device_id m41t80_of_match[] = { }, { .compatible = "microcrystal,rv4162", - .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT) + .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ | M41T80_FEATURE_WDR | M41T80_FEATURE_SQ_ALT) }, { } };
Signature · 1 line
2.52.0
PATCH 5/6 rtc: m41t80: Add missing FEATURE_HT and FEATURE_WDR for m41t62
In reply to Alexander ShiyanThe m41t62 chip supports both Halt feature and extra watchdog resolution.
--- drivers/rtc/rtc-m41t80.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-m41t80.c +2 -2
@@ -71,7 +71,7 @@#define M41T80_FEATURE_SQ_ALT BIT(4)/* RSx bits are in reg 4 */ static const struct i2c_device_id m41t80_id[] = { - {"m41t62" ,M41T80_FEATURE_SQ |M41T80_FEATURE_SQ_ALT }, + {"m41t62" ,M41T80_FEATURE_HT |M41T80_FEATURE_SQ |M41T80_FEATURE_WDR |M41T80_FEATURE_SQ_ALT }, {"m41t65" ,M41T80_FEATURE_HT |M41T80_FEATURE_WDR }, {"m41t80" ,M41T80_FEATURE_SQ }, {"m41t81" ,M41T80_FEATURE_HT |M41T80_FEATURE_SQ },
@@ -89,7 +89,7 @@ MODULE_DEVICE_TABLE(i2c, m41t80_id);static const __maybe_unused struct of_device_id m41t80_of_match[] = { { .compatible ="st,m41t62" , - .data = (void *)(M41T80_FEATURE_SQ |M41T80_FEATURE_SQ_ALT ) + .data = (void *)(M41T80_FEATURE_HT |M41T80_FEATURE_SQ |M41T80_FEATURE_WDR |M41T80_FEATURE_SQ_ALT ) }, { .compatible ="st,m41t65" ,
Signature · 1 line
2.52.0
PATCH 6/6 rtc: m41t80: Fix typo: WTD -> WDT
In reply to Alexander ShiyanCorrect a typo in the watchdog identity string that contain "WTD" instead of "WDT".
--- drivers/rtc/rtc-m41t80.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-m41t80.c +1 -1
@@ -748,7 +748,7 @@ static int wdt_ioctl(struct file *file, unsigned int cmd, .options = WDIOF_POWERUNDER | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, .firmware_version = 1, - .identity = "M41T80 WTD" + .identity = "M41T80 WDT" };switch (cmd) {
Signature · 1 line
2.52.0