Skip to contentSkip to conversation

rtc: stm32: remove __exit annotation on remove callback

PATCH Applied Arnd Bergmann 5 participants 10 messages Jan 13, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 rtc: stm32: remove __exit annotation on remove callback

The remove function can be called at runtime for a manual 'unbind' operation and must not be left out from a built-in driver, as kbuild complains:

stm32_rtc_remove' referenced in section .data.stm32_rtc_driver' of drivers/rtc/rtc-stm32.o: defined in discarded section `.exit.text' of drivers/rtc/rtc-stm32.o

This removes the extraneous annotation.

Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-stm32.c +1 -1
index c4789b5a5d81..3513e052722f 100644
@@ -657,7 +657,7 @@ static int stm32_rtc_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int __exit stm32_rtc_remove(struct platform_device *pdev)
+static int stm32_rtc_remove(struct platform_device *pdev)
 {
 	struct stm32_rtc *rtc = platform_get_drvdata(pdev);
 	unsigned int cr;
Signature · 1 line
2.9.0
#1 lore raw

PATCH 2/3 rtc: stm32: fix building without CONFIG_OF

The new driver has a stray #ifdef in it that causes a build error:

drivers/rtc/rtc-stm32.c:718:21: error: 'stm32_rtc_of_match' undeclared here (not in a function); did you mean 'stm32_rtc_pm_ops'?

As the #ifdef serves no purpose here, let's just remove it.

Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 --
 1 file changed, 2 deletions(-)
drivers/rtc/rtc-stm32.c +0 -2
index 3513e052722f..8c599f52124c 100644
@@ -490,13 +490,11 @@ static const struct rtc_class_ops stm32_rtc_ops = {
 	.alarm_irq_enable = stm32_rtc_alarm_irq_enable,
 };
 
-#ifdef CONFIG_OF
 static const struct of_device_id stm32_rtc_of_match[] = {
 	{ .compatible = "st,stm32-rtc" },
 	{}
 };
 MODULE_DEVICE_TABLE(of, stm32_rtc_of_match);
-#endif
 
 static int stm32_rtc_init(struct platform_device *pdev,
 			  struct stm32_rtc *rtc)
Signature · 1 line
2.9.0
#2 lore raw

Re: [PATCH 2/3] rtc: stm32: fix building without CONFIG_OF

Quoted 4 lines · Arnd Bergmann

The new driver has a stray #ifdef in it that causes a build error:

drivers/rtc/rtc-stm32.c:718:21: error: 'stm32_rtc_of_match' undeclared here (not in a function); did you mean 'stm32_rtc_pm_ops'?

Quoted 8 lines

As the #ifdef serves no purpose here, let's just remove it.

Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 --
 1 file changed, 2 deletions(-)

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 3/3 rtc: stm32: use 32-bit cast for BIT() macro

In reply to Arnd Bergmann

Using the ~ operator on a BIT() constant results in a large 'unsigned long' constant that won't fit into an 'unsigned int' function argument on 64-bit architectures, resulting in a harmless build warning in x86 allmodconfig:

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_probe':
drivers/rtc/rtc-stm32.c:651:51: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
regmap_update_bits(rtc->dbp, PWR_CR, PWR_CR_DBP, ~PWR_CR_DBP);

This works around the warning by adding an explict cast to 'u32', but that is unfortunately a bit ugly and I feel there should be a better way to do this, possibly with some changes to either the bitops.h header or the regmap API.

Cc Mark Brown <[email protected]>
Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-stm32.c +1 -1
index 8c599f52124c..05d3dc89e55f 100644
@@ -92,7 +92,7 @@
 /* STM32_PWR_CR */
 #define PWR_CR				0x00
 /* STM32_PWR_CR bit field */
-#define PWR_CR_DBP			BIT(8)
+#define PWR_CR_DBP			(u32)BIT(8)
 
 struct stm32_rtc {
 	struct rtc_device *rtc_dev;
Signature · 1 line
2.9.0
#4 lore raw

Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro

drivers/rtc/rtc-stm32.c line 95

Quoted 2 lines · Arnd Bergmann
drivers/rtc/rtc-stm32.c +1 -1
-#define PWR_CR_DBP			BIT(8)
+#define PWR_CR_DBP			(u32)BIT(8)

Shouldn't that have parens around it as it's no longer a simple expression.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
#5 lore raw

Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro

Quoted 6 lines · Russell King - ARM Linux

drivers/rtc/rtc-stm32.c line 95

Quoted 2 lines · Arnd Bergmann
drivers/rtc/rtc-stm32.c +1 -1
-#define PWR_CR_DBP			BIT(8)
+#define PWR_CR_DBP			(u32)BIT(8)

Shouldn't that have parens around it as it's no longer a simple expression.

Yes, at least checkpatch complains about it.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#6 lore raw

Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro

In reply to Arnd Bergmann

Hi Arnd,

Quoted 7 lines · Arnd Bergmann

Using the ~ operator on a BIT() constant results in a large 'unsigned long' constant that won't fit into an 'unsigned int' function argument on 64-bit architectures, resulting in a harmless build warning in x86 allmodconfig:

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_probe':
drivers/rtc/rtc-stm32.c:651:51: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
regmap_update_bits(rtc->dbp, PWR_CR, PWR_CR_DBP, ~PWR_CR_DBP);

I thought I would fix this warning by replacing all ~PWR_CR_DBP by 0, because the mask PWR_CR_DBP prevents other bits to be cleared. In this way, I avoid the ugly cast...

Quoted 19 lines

This works around the warning by adding an explict cast to 'u32', but that is unfortunately a bit ugly and I feel there should be a better way to do this, possibly with some changes to either the bitops.h header or the regmap API.

Cc Mark Brown <[email protected]>
Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-stm32.c +0 -0
index 8c599f52124c..05d3dc89e55f 100644

drivers/rtc/rtc-stm32.c line 98

Quoted 8 lines
drivers/rtc/rtc-stm32.c +1 -1
@@ -92,7 +92,7 @@
 /* STM32_PWR_CR */
 #define PWR_CR				0x00
 /* STM32_PWR_CR bit field */
-#define PWR_CR_DBP			BIT(8)
+#define PWR_CR_DBP			(u32)BIT(8)
 
 struct stm32_rtc {
 	struct rtc_device *rtc_dev;

Regards,
Amelie

#7 lore raw

Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro

Quoted 7 lines · Amelie DELAUNAY
Quoted 6 lines · Arnd Bergmann

Using the ~ operator on a BIT() constant results in a large 'unsigned long'
constant that won't fit into an 'unsigned int' function argument on 64-bit architectures, resulting in a harmless build warning in x86 allmodconfig:

Quoted 8 lines
Quoted 4 lines

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_probe':
drivers/rtc/rtc-stm32.c:651:51: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
regmap_update_bits(rtc->dbp, PWR_CR, PWR_CR_DBP, ~PWR_CR_DBP);

I thought I would fix this warning by replacing all ~PWR_CR_DBP by 0, because the mask PWR_CR_DBP prevents other bits to be cleared. In this way, I avoid the ugly cast...

Good idea, much nicer than mine! Can you send that patch?

Arnd

#8 lore raw

[rtc-linux] Re: [PATCH 3/3] rtc: stm32: use 32-bit cast for BIT() macro

Quoted 18 lines · Arnd Bergmann
Quoted 5 lines · On Fri, Jan 13, 2017 at 4:56 PM, Amelie DELAUNAY <[email protected]…
Quoted 4 lines · Arnd Bergmann

Using the ~ operator on a BIT() constant results in a large 'unsigned long'
constant that won't fit into an 'unsigned int' function argument on

64-bit

Quoted 1 line
Quoted 1 line

architectures, resulting in a harmless build warning in x86

allmodconfig:

Quoted 3 lines
Quoted 3 lines

drivers/rtc/rtc-stm32.c: In function 'stm32_rtc_probe':
drivers/rtc/rtc-stm32.c:651:51: error: large integer implicitly

truncated

Quoted 3 lines
Quoted 2 lines

to unsigned type [-Werror=overflow]
regmap_update_bits(rtc->dbp, PWR_CR, PWR_CR_DBP, ~PWR_CR_DBP);

Quoted 7 lines
Quoted 3 lines

I thought I would fix this warning by replacing all ~PWR_CR_DBP by 0, because the mask PWR_CR_DBP prevents other bits to be cleared. In this way, I avoid the ugly cast...

Good idea, much nicer than mine! Can you send that patch?

Arnd

If it can wait Monday, yes.
Amelie

Signature · 8 lines
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
#9 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

The remove function can be called at runtime for a manual 'unbind' operation and must not be left out from a built-in driver, as kbuild complains:

stm32_rtc_remove' referenced in section .data.stm32_rtc_driver' of drivers/rtc/rtc-stm32.o: defined in discarded section `.exit.text' of drivers/rtc/rtc-stm32.o

Quoted 8 lines

This removes the extraneous annotation.

Fixes 4e64350f42e2 ("rtc: add STM32 RTC driver")
---
 drivers/rtc/rtc-stm32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com