Skip to contentSkip to conversation

add of_match_ptr() macro helper for of_match_table entry

PATCH In review Ben Dooks 2 participants 4 messages Aug 3, 2011 – Sep 30, 2011 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

Do people think this is useful, and if so should I continue converting other subsystems?

A message that is not in the archive (sent off-list or not yet received): 1312362703-10189-1-git-send-email-ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org

author
#2 lore raw

PATCH 1/2 OF: Add of_match_ptr() macro

Add a macro of_match_ptr() that allows the .of_match_table entry in the driver structures to be assigned without having an #ifdef xxx NULL for the case that OF is not enabled

---
 include/linux/of.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/of.h +2 -0
index bd716f8..951e87b 100644
@@ -234,6 +234,7 @@ extern void of_attach_node(struct device_node *);
 extern void of_detach_node(struct device_node *);
 #endif
 
+#define of_match_ptr(_ptr)	(_ptr)
 #else /* CONFIG_OF */
 
 static inline bool of_have_populated_dt(void)
@@ -253,6 +254,7 @@ static inline int of_property_read_string(struct device_node *np,
 	return -ENOSYS;
 }
 
+#define of_match_ptr(_ptr)	NULL
 #endif /* CONFIG_OF */
 
 static inline int of_property_read_u32(const struct device_node *np,
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 2/2 tty: use of_match_ptr() for of_match_table entry

In reply to a message not in the archive

Use the new of_match_ptr() macro for the of_match_table pointer entry to avoid having to #dfine match NULL

---
 drivers/tty/serial/altera_jtaguart.c |    4 +---
 drivers/tty/serial/altera_uart.c     |    4 +---
 drivers/tty/serial/uartlite.c        |    4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)
drivers/tty/serial/altera_jtaguart.c +1 -3
index 60e049b..2075200 100644
@@ -472,8 +472,6 @@ static struct of_device_id altera_jtaguart_match[] = {
 	{},
 };
 MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
-#else
-#define altera_jtaguart_match NULL
 #endif /* CONFIG_OF */
 
 static struct platform_driver altera_jtaguart_platform_driver = {
@@ -482,7 +480,7 @@ static struct platform_driver altera_jtaguart_platform_driver = {
 	.driver	= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
-		.of_match_table	= altera_jtaguart_match,
+		.of_match_table	= of_match_ptr(altera_jtaguart_match),
 	},
 };
 
drivers/tty/serial/altera_uart.c +1 -3
index 50bc5a5..0abd31d 100644
@@ -616,8 +616,6 @@ static struct of_device_id altera_uart_match[] = {
 	{},
 };
 MODULE_DEVICE_TABLE(of, altera_uart_match);
-#else
-#define altera_uart_match NULL
 #endif /* CONFIG_OF */
 
 static struct platform_driver altera_uart_platform_driver = {
@@ -626,7 +624,7 @@ static struct platform_driver altera_uart_platform_driver = {
 	.driver	= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
-		.of_match_table	= altera_uart_match,
+		.of_match_table	= of_match_ptr(altera_uart_match),
 	},
 };
 
drivers/tty/serial/uartlite.c +1 -3
index 8af1ed8..0aed022 100644
@@ -568,8 +568,6 @@ static struct of_device_id ulite_of_match[] __devinitdata = {
 	{}
 };
 MODULE_DEVICE_TABLE(of, ulite_of_match);
-#else /* CONFIG_OF */
-#define ulite_of_match NULL
 #endif /* CONFIG_OF */
 
 static int __devinit ulite_probe(struct platform_device *pdev)
@@ -609,7 +607,7 @@ static struct platform_driver ulite_platform_driver = {
 	.driver = {
 		.owner = THIS_MODULE,
 		.name  = "uartlite",
-		.of_match_table = ulite_of_match,
+		.of_match_table = of_match_ptr(ulite_of_match),
 	},
 };
 
Signature · 1 line
1.7.1

A message that is not in the archive (sent off-list or not yet received): 1312362703-10189-3-git-send-email-ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org

#5 lore raw

Re: [PATCH 2/2] tty: use of_match_ptr() for of_match_table entry

Quoted 4 lines · Ben Dooks

Use the new of_match_ptr() macro for the of_match_table pointer entry to avoid having to #dfine match NULL

Took me a while, but applied both, thanks.

g.

Quoted 75 lines
---
 drivers/tty/serial/altera_jtaguart.c |    4 +---
 drivers/tty/serial/altera_uart.c     |    4 +---
 drivers/tty/serial/uartlite.c        |    4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)
drivers/tty/serial/altera_jtaguart.c +1 -3
index 60e049b..2075200 100644
@@ -472,8 +472,6 @@ static struct of_device_id altera_jtaguart_match[] = {
 	{},
 };
 MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
-#else
-#define altera_jtaguart_match NULL
 #endif /* CONFIG_OF */
 
 static struct platform_driver altera_jtaguart_platform_driver = {
@@ -482,7 +480,7 @@ static struct platform_driver altera_jtaguart_platform_driver = {
 	.driver	= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
-		.of_match_table	= altera_jtaguart_match,
+		.of_match_table	= of_match_ptr(altera_jtaguart_match),
 	},
 };
 
drivers/tty/serial/altera_uart.c +1 -3
index 50bc5a5..0abd31d 100644
@@ -616,8 +616,6 @@ static struct of_device_id altera_uart_match[] = {
 	{},
 };
 MODULE_DEVICE_TABLE(of, altera_uart_match);
-#else
-#define altera_uart_match NULL
 #endif /* CONFIG_OF */
 
 static struct platform_driver altera_uart_platform_driver = {
@@ -626,7 +624,7 @@ static struct platform_driver altera_uart_platform_driver = {
 	.driver	= {
 		.name		= DRV_NAME,
 		.owner		= THIS_MODULE,
-		.of_match_table	= altera_uart_match,
+		.of_match_table	= of_match_ptr(altera_uart_match),
 	},
 };
 
drivers/tty/serial/uartlite.c +1 -3
index 8af1ed8..0aed022 100644
@@ -568,8 +568,6 @@ static struct of_device_id ulite_of_match[] __devinitdata = {
 	{}
 };
 MODULE_DEVICE_TABLE(of, ulite_of_match);
-#else /* CONFIG_OF */
-#define ulite_of_match NULL
 #endif /* CONFIG_OF */
 
 static int __devinit ulite_probe(struct platform_device *pdev)
@@ -609,7 +607,7 @@ static struct platform_driver ulite_platform_driver = {
 	.driver = {
 		.owner = THIS_MODULE,
 		.name  = "uartlite",
-		.of_match_table = ulite_of_match,
+		.of_match_table = of_match_ptr(ulite_of_match),
 	},
 };
 
Signature · 1 line
1.7.1