Skip to contentSkip to conversation

Staging: board: Fix macro code style error

PATCH In review Valentin Huebner 2 participants 3 messages Feb 20, 2017 – Feb 21, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: board: Fix macro code style error

Fixes a 'macro with flow control statement' checkpatch code style error by removing the board_staging() macro and replacing its two calls

---
 drivers/staging/board/armadillo800eva.c | 10 +++++++++-
 drivers/staging/board/board.h           | 11 -----------
 drivers/staging/board/kzm9d.c           | 10 +++++++++-
 3 files changed, 18 insertions(+), 13 deletions(-)
drivers/staging/board/armadillo800eva.c +9 -1
index 4de4fd0..2f1613a 100644
@@ -101,4 +101,12 @@ static void __init armadillo800eva_init(void)
 				       ARRAY_SIZE(armadillo800eva_devices));
 }
 
-board_staging("renesas,armadillo800eva", armadillo800eva_init);
+static int __init runtime_board_check(void)
+{
+	if (of_machine_is_compatible("renesas,armadillo800eva"))
+		armadillo800eva_init();
+
+	return 0;
+}
+
+device_initcall(runtime_board_check)
drivers/staging/board/board.h +0 -11
index 42ed125..0fa1197 100644
@@ -31,15 +31,4 @@ 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)
-
 #endif /* __BOARD_H__ */
drivers/staging/board/kzm9d.c +9 -1
index 05a6d43..662501c 100644
@@ -22,4 +22,12 @@ static void __init kzm9d_init(void)
 	}
 }
 
-board_staging("renesas,kzm9d", kzm9d_init);
+static int __init runtime_board_check(void)
+{
+	if (of_machine_is_compatible("renesas,kzm9d"))
+		kzm9d_init();
+
+	return 0;
+}
+
+device_initcall(runtime_board_check)
Signature · 1 line
2.7.4
#1 lore raw
Quoted 3 lines · Valentin Huebner

Fixes a 'macro with flow control statement' checkpatch code style error by removing the board_staging() macro and replacing its two calls

checkpatch is wrong here, you are now adding more lines than you remove:

Quoted 6 lines
---
 drivers/staging/board/armadillo800eva.c | 10 +++++++++-
 drivers/staging/board/board.h           | 11 -----------
 drivers/staging/board/kzm9d.c           | 10 +++++++++-
 3 files changed, 18 insertions(+), 13 deletions(-)

See?

There's nothing wrong with the macro as-is, it's like many other macros we have for module init sequences. checkpatch is just a hint, you still have to use your brain :)

sorry,

greg k-h

#2 lore raw
Quoted 1 line · Greg Kroah-Hartman

checkpatch is wrong here, you are now adding more lines than you remove:

I see, thank you!

Valentin