* [PATCH 1/4] mod_devicetable: helper macro for declaring oftree module device table
2019-06-01 13:52 RFC: declaring DT match tables (2nd take) Enrico Weigelt, metux IT consult
@ 2019-06-01 13:52 ` Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 2/4] drivers: block: xsysace: use MODULE_DECLARE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-01 13:52 UTC (permalink / raw)
To: linux-kernel
Cc: vireshk, b.zolnierkie, axboe, herbert, davem, linux-ide,
linux-block, linux-crypto
Little helper macros 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);
Or declare the whole table via:
MODULE_DECLARE_OF_TABLE(foo,
{ .compatible = "foo" },
{ .compatible = "bar" });
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
include/linux/mod_devicetable.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c..5f4f2dc8 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -245,6 +245,19 @@ 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)
+#define MODULE_DECLARE_OF_TABLE(name,entries...) \
+static const struct of_device_id name[] = { entries, {} };
+#else
+#define MODULE_OF_TABLE(name)
+#define MODULE_DECLARE_OF_TABLE(name,entries...) \
+static const struct of_device_id *name = NULL;
+#endif /* CONFIG_OF */
+
/* VIO */
struct vio_device_id {
char type[32];
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] drivers: block: xsysace: use MODULE_DECLARE_OF_TABLE() and of_match_ptr()
2019-06-01 13:52 RFC: declaring DT match tables (2nd take) Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 1/4] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
@ 2019-06-01 13:52 ` Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 3/4] drivers: crypto: picoxcell_crypto: use MODULE_DECLARE_OF_TABLE() Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 4/4] drivers: ata: " Enrico Weigelt, metux IT consult
3 siblings, 0 replies; 5+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-01 13:52 UTC (permalink / raw)
To: linux-kernel
Cc: vireshk, b.zolnierkie, axboe, herbert, davem, linux-ide,
linux-block, linux-crypto
Using MODULE_DECLARE_OF_TABLE() and of_match_ptr() macros to get
rid of some #ifdef CONFIG_OF and thus make the code a bit slimmer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
drivers/block/xsysace.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 464c9092..d8e5dd7 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1219,26 +1219,18 @@ 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[] = {
+MODULE_DECLARE_OF_TABLE(ace_of_match,
{ .compatible = "xlnx,opb-sysace-1.00.b", },
{ .compatible = "xlnx,opb-sysace-1.00.c", },
{ .compatible = "xlnx,xps-sysace-1.00.a", },
- { .compatible = "xlnx,sysace", },
- {},
-};
-MODULE_DEVICE_TABLE(of, ace_of_match);
-#else /* CONFIG_OF */
-#define ace_of_match NULL
-#endif /* CONFIG_OF */
+ { .compatible = "xlnx,sysace", });
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 related [flat|nested] 5+ messages in thread
* [PATCH 3/4] drivers: crypto: picoxcell_crypto: use MODULE_DECLARE_OF_TABLE()
2019-06-01 13:52 RFC: declaring DT match tables (2nd take) Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 1/4] mod_devicetable: helper macro for declaring oftree module device table Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 2/4] drivers: block: xsysace: use MODULE_DECLARE_OF_TABLE() and of_match_ptr() Enrico Weigelt, metux IT consult
@ 2019-06-01 13:52 ` Enrico Weigelt, metux IT consult
2019-06-01 13:52 ` [PATCH 4/4] drivers: ata: " Enrico Weigelt, metux IT consult
3 siblings, 0 replies; 5+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-01 13:52 UTC (permalink / raw)
To: linux-kernel
Cc: vireshk, b.zolnierkie, axboe, herbert, davem, linux-ide,
linux-block, linux-crypto
Using MODULE_DECLARE_OF_TABLE() macro to get rid of some #ifdef CONFIG_OF
and make the code a bit slimmer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
drivers/crypto/picoxcell_crypto.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c
index b985cb85..3c299f2 100644
--- a/drivers/crypto/picoxcell_crypto.c
+++ b/drivers/crypto/picoxcell_crypto.c
@@ -1612,14 +1612,9 @@ 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[] = {
+MODULE_DECLARE_OF_TABLE(spacc_of_id_table,
{ .compatible = "picochip,spacc-ipsec" },
- { .compatible = "picochip,spacc-l2" },
- {}
-};
-MODULE_DEVICE_TABLE(of, spacc_of_id_table);
-#endif /* CONFIG_OF */
+ { .compatible = "picochip,spacc-l2" });
static int spacc_probe(struct platform_device *pdev)
{
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] drivers: ata: use MODULE_DECLARE_OF_TABLE()
2019-06-01 13:52 RFC: declaring DT match tables (2nd take) Enrico Weigelt, metux IT consult
` (2 preceding siblings ...)
2019-06-01 13:52 ` [PATCH 3/4] drivers: crypto: picoxcell_crypto: use MODULE_DECLARE_OF_TABLE() Enrico Weigelt, metux IT consult
@ 2019-06-01 13:52 ` Enrico Weigelt, metux IT consult
3 siblings, 0 replies; 5+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-06-01 13:52 UTC (permalink / raw)
To: linux-kernel
Cc: vireshk, b.zolnierkie, axboe, herbert, davem, linux-ide,
linux-block, linux-crypto
Using MODULE_DECLARE_OF_TABLE() macro to get rid of some #ifdef CONFIG_OF
and make the code a bit slimmer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
drivers/ata/pata_arasan_cf.c | 9 ++-------
drivers/ata/sata_mv.c | 9 ++-------
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index ebecab8..22de61f 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -943,13 +943,8 @@ static int arasan_cf_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(arasan_cf_pm_ops, arasan_cf_suspend, arasan_cf_resume);
-#ifdef CONFIG_OF
-static const struct of_device_id arasan_cf_id_table[] = {
- { .compatible = "arasan,cf-spear1340" },
- {}
-};
-MODULE_DEVICE_TABLE(of, arasan_cf_id_table);
-#endif
+MODULE_DECLARE_OF_TABLE(arasan_cf_id_table,
+ { .compatible = "arasan,cf-spear1340" });
static struct platform_driver arasan_cf_driver = {
.probe = arasan_cf_probe,
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index da585d2..bac48cd 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4273,14 +4273,9 @@ static int mv_platform_resume(struct platform_device *pdev)
#define mv_platform_resume NULL
#endif
-#ifdef CONFIG_OF
-static const struct of_device_id mv_sata_dt_ids[] = {
+MODULE_DECLARE_OF_TABLE(mv_sata_dt_ids,
{ .compatible = "marvell,armada-370-sata", },
- { .compatible = "marvell,orion-sata", },
- {},
-};
-MODULE_DEVICE_TABLE(of, mv_sata_dt_ids);
-#endif
+ { .compatible = "marvell,orion-sata", });
static struct platform_driver mv_platform_driver = {
.probe = mv_platform_probe,
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread