Skip to contentSkip to conversation

fixes and improvement for sprd hwspinlock

PATCH In review Chunyan Zhang 2 participants 6 messages Oct 30, 2020 – Nov 3, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Chunyan Zhang

author reviewer
#0 lore raw

v2 cover fixes and improvement for sprd hwspinlock

From: Chunyan Zhang <[email protected]>

Changes since v1:
* Change to add __maybe_unsed rather than not use of_match_ptr().

Chunyan Zhang (2):
hwspinlock: sprd: fixed warning of unused variable
'sprd_hwspinlock_of_match'
hwspinlock: sprd: use module_platform_driver() instead postcore
initcall

 drivers/hwspinlock/sprd_hwspinlock.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH v2 1/2 hwspinlock: sprd: fixed warning of unused variable 'sprd_hwspinlock_of_match'

From: Chunyan Zhang <[email protected]>

The macro function of_match_ptr() is NULL if CONFIG_OF is not set, then Clang compiler would complain the of_device_id variable is unused.

But using of_match_ptr() is space saving, for this case, the unused structure 'sprd_hwspinlock_of_match' would be not built into symbol table if CONFIG_OF is not set, probably depends on the compiler though.

So adding __maybe_unsed seems a good approach to fix this warning.

Fixes d8c8bbbb1aba ("hwspinlock: sprd: Add hardware spinlock driver")
---
 drivers/hwspinlock/sprd_hwspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwspinlock/sprd_hwspinlock.c +1 -1
index 36dc8038bbb4..4c63e2546064 100644
@@ -138,7 +138,7 @@ static int sprd_hwspinlock_probe(struct platform_device *pdev)
 					 SPRD_HWLOCKS_NUM);
 }
 
-static const struct of_device_id sprd_hwspinlock_of_match[] = {
+static const __maybe_unused struct of_device_id sprd_hwspinlock_of_match[] = {
 	{ .compatible = "sprd,hwspinlock-r3p0", },
 	{ /* sentinel */ }
 };
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): CADBw62oQj+K_-nyoZyMJSQ6VaqcNHbX9gbyLEzV9+Od1cVmC5A@mail.gmail.com

#3 lore raw

Re: [PATCH v2 1/2] hwspinlock: sprd: fixed warning of unused variable 'sprd_hwspinlock_of_match'

Quoted 14 lines · Baolin Wang
Quoted 6 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

The macro function of_match_ptr() is NULL if CONFIG_OF is not set, then Clang compiler would complain the of_device_id variable is unused.

But using of_match_ptr() is space saving, for this case, the unused

structure

Quoted 1 line

'sprd_hwspinlock_of_match' would be not built into symbol table if

CONFIG_OF

Quoted 4 lines

is not set, probably depends on the compiler though.

So adding __maybe_unsed seems a good approach to fix this warning.

Quoted 9 lines
Quoted 4 lines
Fixes d8c8bbbb1aba ("hwspinlock: sprd: Add hardware spinlock driver")

---

I'd like to remove this wrapper, and just depend on the CONFIG_OF. But I have no objection for this patch. So

As noted on the first line of the probe function, this driver isn't going to do anything when CONFIG_OF is disabled - and I don't think we should worry too much about space savings during COMPILE_TEST.

So I would prefer that we simply drop the of_match_ptr()

But I believe that's what you're saying as well Baolin?

Regards,
Bjorn

Quoted 27 lines

Review

Quoted 5 lines
 drivers/hwspinlock/sprd_hwspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/hwspinlock/sprd_hwspinlock.c

drivers/hwspinlock/sprd_hwspinlock.c static int sprd_hwspinlock_probe(struct

Quoted 4 lines

index 36dc8038bbb4..4c63e2546064 100644

drivers/hwspinlock/sprd_hwspinlock.c +0 -0
@@ -138,7 +138,7 @@ static int sprd_hwspinlock_probe(struct

platform_device *pdev)

drivers/hwspinlock/sprd_hwspinlock.c static int sprd_hwspinlock_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/hwspinlock/sprd_hwspinlock.c +1 -1
                                         SPRD_HWLOCKS_NUM);
 }
 
-static const struct of_device_id sprd_hwspinlock_of_match[] = {
+static const __maybe_unused struct of_device_id

sprd_hwspinlock_of_match[] = {

Quoted 7 lines
drivers/hwspinlock/sprd_hwspinlock.c +0 -1
        { .compatible = "sprd,hwspinlock-r3p0", },
        { /* sentinel */ }
 };
--

2.20.1

Signature · 1 line
Baolin Wang
author reviewer
#4 lore raw

Re: [PATCH v2 1/2] hwspinlock: sprd: fixed warning of unused variable 'sprd_hwspinlock_of_match'

Quoted 27 lines · Bjorn Andersson
Quoted 14 lines · Baolin Wang
Quoted 6 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

The macro function of_match_ptr() is NULL if CONFIG_OF is not set, then Clang compiler would complain the of_device_id variable is unused.

But using of_match_ptr() is space saving, for this case, the unused

structure

Quoted 1 line

'sprd_hwspinlock_of_match' would be not built into symbol table if

CONFIG_OF

Quoted 4 lines

is not set, probably depends on the compiler though.

So adding __maybe_unsed seems a good approach to fix this warning.

Quoted 9 lines
Quoted 4 lines
Fixes d8c8bbbb1aba ("hwspinlock: sprd: Add hardware spinlock driver")

---

I'd like to remove this wrapper, and just depend on the CONFIG_OF. But I have no objection for this patch. So

Quoted 5 lines

As noted on the first line of the probe function, this driver isn't going to do anything when CONFIG_OF is disabled - and I don't think we should worry too much about space savings during COMPILE_TEST.

So I would prefer that we simply drop the of_match_ptr()

Ok, that's what the v1 does.
Bjorn, could you please pick up the 1st patch in v1 [1]?

Thanks,
Chunyan

[1] https://lkml.org/lkml/2020/10/26/87

Quoted 33 lines

But I believe that's what you're saying as well Baolin?

Regards,
Bjorn

Quoted 27 lines

Review

Quoted 5 lines
 drivers/hwspinlock/sprd_hwspinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/hwspinlock/sprd_hwspinlock.c

drivers/hwspinlock/sprd_hwspinlock.c static int sprd_hwspinlock_probe(struct

Quoted 4 lines

index 36dc8038bbb4..4c63e2546064 100644

drivers/hwspinlock/sprd_hwspinlock.c +0 -0
@@ -138,7 +138,7 @@ static int sprd_hwspinlock_probe(struct

platform_device *pdev)

drivers/hwspinlock/sprd_hwspinlock.c static int sprd_hwspinlock_probe(struct platform_device *pdev)

Quoted 5 lines
drivers/hwspinlock/sprd_hwspinlock.c +1 -1
                                         SPRD_HWLOCKS_NUM);
 }
 
-static const struct of_device_id sprd_hwspinlock_of_match[] = {
+static const __maybe_unused struct of_device_id

sprd_hwspinlock_of_match[] = {

Quoted 7 lines
drivers/hwspinlock/sprd_hwspinlock.c +0 -1
        { .compatible = "sprd,hwspinlock-r3p0", },
        { /* sentinel */ }
 };
--

2.20.1

--
Baolin Wang

author reviewer
#5 lore raw

PATCH v2 2/2 hwspinlock: sprd: use module_platform_driver() instead postcore initcall

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

The hardware spinlock devices are defined in the DT, there's no need for init calls order, remove boilerplate code by using module_platform_driver.

---
 drivers/hwspinlock/sprd_hwspinlock.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/hwspinlock/sprd_hwspinlock.c +1 -12
index 4c63e2546064..19d1924044e5 100644
@@ -151,18 +151,7 @@ static struct platform_driver sprd_hwspinlock_driver = {
 		.of_match_table = of_match_ptr(sprd_hwspinlock_of_match),
 	},
 };
-
-static int __init sprd_hwspinlock_init(void)
-{
-	return platform_driver_register(&sprd_hwspinlock_driver);
-}
-postcore_initcall(sprd_hwspinlock_init);
-
-static void __exit sprd_hwspinlock_exit(void)
-{
-	platform_driver_unregister(&sprd_hwspinlock_driver);
-}
-module_exit(sprd_hwspinlock_exit);
+module_platform_driver(sprd_hwspinlock_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Hardware spinlock driver for Spreadtrum");
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH v2 2/2] hwspinlock: sprd: use module_platform_driver() instead postcore initcall

Quoted 6 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

The hardware spinlock devices are defined in the DT, there's no need for init calls order, remove boilerplate code by using module_platform_driver.

Applied this patch with Baolin's r-b.

Thank you,
Bjorn

Quoted 31 lines
---
 drivers/hwspinlock/sprd_hwspinlock.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/hwspinlock/sprd_hwspinlock.c +1 -12
index 4c63e2546064..19d1924044e5 100644
@@ -151,18 +151,7 @@ static struct platform_driver sprd_hwspinlock_driver = {
 		.of_match_table = of_match_ptr(sprd_hwspinlock_of_match),
 	},
 };
-
-static int __init sprd_hwspinlock_init(void)
-{
-	return platform_driver_register(&sprd_hwspinlock_driver);
-}
-postcore_initcall(sprd_hwspinlock_init);
-
-static void __exit sprd_hwspinlock_exit(void)
-{
-	platform_driver_unregister(&sprd_hwspinlock_driver);
-}
-module_exit(sprd_hwspinlock_exit);
+module_platform_driver(sprd_hwspinlock_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Hardware spinlock driver for Spreadtrum");
Signature · 1 line
2.20.1