Skip to contentSkip to conversation

staging: board: replace macro with function

PATCH In review Aarushi Mehta 3 participants 3 messages Mar 9, 2019 – Mar 11, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: board: replace macro with function

From b0da5fe54699fd2b4b627344fa5a118d6d985853 Mon Sep 17 00:00:00 2001
From: Aarushi Mehta <[email protected]>
Date: Sat, 9 Mar 2019 22:16:42 +0530
Subject: [PATCH 51/51] staging: board: replace macro with function

---
 drivers/staging/board/board.h | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/staging/board/board.h +10 -11
index 5609daf4d869..a2119ae1bac1 100644
@@ -31,16 +31,15 @@ int board_staging_register_clock(const struct board_staging_clk *bsc);
 int board_staging_register_device(const struct board_staging_dev *dev);
 void board_staging_register_devices(const struct board_staging_dev *devs,
 				    unsigned int ndevs);
-
-#define board_staging(str, fn)			\
-static int __init runtime_board_check(void)	\
-{						\
-	if (of_machine_is_compatible(str))	\
-		fn();				\
-						\
-	return 0;				\
-}						\
-						\
-device_initcall(runtime_board_check)
+static void board_staging(str, fn)
+{
+	static inline int __init runtime_board_check(void)
+	{
+		if (of_machine_is_compatible(str))
+			fn();
+		return 0;
+	}
+	device_initcall(runtime_board_check)
+}
 
 #endif /* __BOARD_H__ */
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Aarushi Mehta

From b0da5fe54699fd2b4b627344fa5a118d6d985853 Mon Sep 17 00:00:00 2001
From: Aarushi Mehta <[email protected]>
Date: Sat, 9 Mar 2019 22:16:42 +0530
Subject: [PATCH 51/51] staging: board: replace macro with function

What is this?

You need to put a log message.

Quoted 15 lines
---
 drivers/staging/board/board.h | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/staging/board/board.h +0 -1
index 5609daf4d869..a2119ae1bac1 100644
@@ -31,16 +31,15 @@ int board_staging_register_clock(const struct board_staging_clk *bsc);
 int board_staging_register_device(const struct board_staging_dev *dev);
 void board_staging_register_devices(const struct board_staging_dev *devs,
 				    unsigned int ndevs);
-

drivers/staging/board/board.h int board_staging_register_clock(const struct board_staging_clk *bsc); · line 44

Quoted 10 lines
drivers/staging/board/board.h +0 -10
-#define board_staging(str, fn)			\
-static int __init runtime_board_check(void)	\
-{						\
-	if (of_machine_is_compatible(str))	\
-		fn();				\
-						\
-	return 0;				\
-}						\
-						\
-device_initcall(runtime_board_check)

The above macro should generate a new function definition. It can't be rewritten as a function.

julia

Quoted 23 lines
drivers/staging/board/board.h +10 -1
+static void board_staging(str, fn)
+{
+	static inline int __init runtime_board_check(void)
+	{
+		if (of_machine_is_compatible(str))
+			fn();
+		return 0;
+	}
+	device_initcall(runtime_board_check)
+}
 
 #endif /* __BOARD_H__ */
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/0ce45d3e104e179cbf124d6c41aee442d6ed03cb.camel%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

maintainer
#2 lore raw
In reply to Aarushi Mehta
Quoted 29 lines · Aarushi Mehta
Quoted 1 line

From b0da5fe54699fd2b4b627344fa5a118d6d985853 Mon Sep 17 00:00:00 2001

From: Aarushi Mehta <[email protected]>
Date: Sat, 9 Mar 2019 22:16:42 +0530
Subject: [PATCH 51/51] staging: board: replace macro with function

---
 drivers/staging/board/board.h | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/staging/board/board.h +0 -11
index 5609daf4d869..a2119ae1bac1 100644
@@ -31,16 +31,15 @@ int board_staging_register_clock(const struct board_staging_clk *bsc);
 int board_staging_register_device(const struct board_staging_dev *dev);
 void board_staging_register_devices(const struct board_staging_dev *devs,
 				    unsigned int ndevs);
-
-#define board_staging(str, fn)			\
-static int __init runtime_board_check(void)	\
-{						\
-	if (of_machine_is_compatible(str))	\
-		fn();				\
-						\
-	return 0;				\
-}						\
-						\
-device_initcall(runtime_board_check)

drivers/staging/board/board.h int board_staging_register_clock(const struct board_staging_clk *bsc); · line 43

Quoted 10 lines
drivers/staging/board/board.h +10 -0
+static void board_staging(str, fn)
+{
+	static inline int __init runtime_board_check(void)
+	{
+		if (of_machine_is_compatible(str))
+			fn();
+		return 0;
+	}
+	device_initcall(runtime_board_check)
+}

This will not build properly with some compilers, and really isn't correct code at all :(

thanks,

greg k-h