* RFC: get rid of #ifdef CONFIG_OF's around of match tables
@ 2019-05-31 11:54 Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 1/3] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-05-31 11:54 UTC (permalink / raw)
To: linux-kernel; +Cc: axboe, herbert, davem, linux-block, linux-crypto
Hi folks,
we've got many places where code declaring oftree match tables is
enclodes by #ifdef CONFIG_OF, so it can also be built w/o oftree
support.
To make this easier to read, I'm proposing a new helper macro
MODULE_OF_TABLE(foo) which just calls MODULE_DEVICE_TABLE(of, foo)
when CONFIG_OF enabled, otherwise just noop. Along w/ of_match_ptr(),
we can get rid most of these #ifdef CONFIG_OF cases. I believe, the
compiler can automatically optimize-away the unused tables.
(correct me if I'm wrong)
This queue just introduces the macro and converts two random examples.
I'll post more patches for the rest of the tree, if you folks aggree
to this approach. And also I'd like to do the same w/ ACPI, PCI, etc.
Another idea I'm currently thinking about is moving the whole table
definition into a macro call, so the tables won't even get defined
when CONFIG_OF isn't defined, and we've got even less to type. It
then would look like this:
MODULE_DECLARE_OF_MATCH(foo_of_match,
{ .compatible = "acme,foo" },
{ .compatible = "acme,bar" })
(note that the macro also defines the sentinel on its own).
What do you think about this idea ?
--mtx
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/3] mod_devicetable: helper macro for declaring oftree module device table
2019-05-31 11:54 RFC: get rid of #ifdef CONFIG_OF's around of match tables Enrico Weigelt, metux IT consult
@ 2019-05-31 11:54 ` Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 2/3] drivers: block: xsysace: use MODULE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 3/3] drivers: crypto: picoxcell_crypto: use MODULE_OF_TABLE() Enrico Weigelt, metux IT consult
2 siblings, 0 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-05-31 11:54 UTC (permalink / raw)
To: linux-kernel; +Cc: axboe, herbert, davem, linux-block, linux-crypto
Little helper macro that declares an oftree module device table,
if CONFIG_OF is enabled. Otherwise it's just noop. Helpful for
reducing the number of #ifdef's.
Instead of:
MODULE_DEVICE_TABLE(of, foo)
now use:
MODULE_OF_TABLE(foo)
Signed-off-by: Enrico Weigelt <info@metux.net>
---
include/linux/mod_devicetable.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c..0551b53 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -245,6 +245,15 @@ struct of_device_id {
const void *data;
};
+/*
+ * macro for adding the of module device table only if CONFIG_OF enabled
+ */
+#ifdef CONFIG_OF
+#define MODULE_OF_TABLE(name) MODULE_DEVICE_TABLE(of,name)
+#else
+#define MODULE_OF_TABLE(name)
+#endif /* CONFIG_OF */
+
/* VIO */
struct vio_device_id {
char type[32];
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/3] drivers: block: xsysace: use MODULE_OF_TABLE() and of_match_ptr()
2019-05-31 11:54 RFC: get rid of #ifdef CONFIG_OF's around of match tables Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 1/3] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
@ 2019-05-31 11:54 ` Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 3/3] drivers: crypto: picoxcell_crypto: use MODULE_OF_TABLE() Enrico Weigelt, metux IT consult
2 siblings, 0 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-05-31 11:54 UTC (permalink / raw)
To: linux-kernel; +Cc: axboe, herbert, davem, linux-block, linux-crypto
Using MODULE_OF_TABLE() and of_match_ptr() macros to get rid of
some #ifdef CONFIG_OF and thus make the code a bit slimmer.
These macros already check whether CONFIG_OF is set and if it's
not, just no-op. The compiler then should be able to optimize-
away unreferenced structs.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
drivers/block/xsysace.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 464c9092..6ebd656 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1219,7 +1219,6 @@ static int ace_remove(struct platform_device *dev)
return 0;
}
-#if defined(CONFIG_OF)
/* Match table for of_platform binding */
static const struct of_device_id ace_of_match[] = {
{ .compatible = "xlnx,opb-sysace-1.00.b", },
@@ -1228,17 +1227,14 @@ static int ace_remove(struct platform_device *dev)
{ .compatible = "xlnx,sysace", },
{},
};
-MODULE_DEVICE_TABLE(of, ace_of_match);
-#else /* CONFIG_OF */
-#define ace_of_match NULL
-#endif /* CONFIG_OF */
+MODULE_OF_TABLE(ace_of_match);
static struct platform_driver ace_platform_driver = {
.probe = ace_probe,
.remove = ace_remove,
.driver = {
.name = "xsysace",
- .of_match_table = ace_of_match,
+ .of_match_table = of_match_ptr(ace_of_match),
},
};
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 3/3] drivers: crypto: picoxcell_crypto: use MODULE_OF_TABLE()
2019-05-31 11:54 RFC: get rid of #ifdef CONFIG_OF's around of match tables Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 1/3] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 2/3] drivers: block: xsysace: use MODULE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
@ 2019-05-31 11:54 ` Enrico Weigelt, metux IT consult
2 siblings, 0 replies; 4+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-05-31 11:54 UTC (permalink / raw)
To: linux-kernel; +Cc: axboe, herbert, davem, linux-block, linux-crypto
Using MODULE_OF_TABLE() macro to get rid of some #ifdef
CONFIG_OF and thus make the code a bit slimmer.
These macros already check whether CONFIG_OF is set and if it's
not, just no-op. The compiler then should be able to optimize-
away unreferenced structs.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
drivers/crypto/picoxcell_crypto.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index 05b89e7..e637f6f 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -1625,14 +1625,12 @@ static DEVICE_ATTR(stat_irq_thresh, 0644, spacc_stat_irq_thresh_show,
},
};
-#ifdef CONFIG_OF
static const struct of_device_id spacc_of_id_table[] = {
{ .compatible = "picochip,spacc-ipsec" },
{ .compatible = "picochip,spacc-l2" },
{}
};
-MODULE_DEVICE_TABLE(of, spacc_of_id_table);
-#endif /* CONFIG_OF */
+MODULE_OF_TABLE(spacc_of_id_table);
static int spacc_probe(struct platform_device *pdev)
{
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-31 11:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 11:54 RFC: get rid of #ifdef CONFIG_OF's around of match tables Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 1/3] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 2/3] drivers: block: xsysace: use MODULE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
2019-05-31 11:54 ` [PATCH 3/3] drivers: crypto: picoxcell_crypto: use MODULE_OF_TABLE() Enrico Weigelt, metux IT consult
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®