Patchwork mtd: Replace the dangerous mtd_to_flctl macro with an inline function

login
register
mail settings
Submitter Ferenc Wagner
Date March 23, 2010, 5:09 p.m.
Message ID <87eijb0xu2.fsf@tac.ki.iif.hu>
Download mbox | patch
Permalink /patch/48355/
State New
Headers show

Comments

Ferenc Wagner - March 23, 2010, 5:09 p.m.
The original macro worked only when applied to variables named 'mtd'.
While this could have been fixed by simply renaming the macro argument,
a more type-safe replacement is preferred.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
---
 include/linux/mtd/sh_flctl.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/include/linux/mtd/sh_flctl.h b/include/linux/mtd/sh_flctl.h
index ab77609..1278465 100644
--- a/include/linux/mtd/sh_flctl.h
+++ b/include/linux/mtd/sh_flctl.h
@@ -93,7 +93,10 @@ 
 #define INIT_FL4ECCRESULT_VAL	0x03FF03FF
 #define LOOP_TIMEOUT_MAX	0x00010000
 
-#define mtd_to_flctl(mtd)	container_of(mtd, struct sh_flctl, mtd)
+inline struct sh_flctl *mtd_to_flctl(struct mtd_info *mtdinfo)
+{
+	return container_of(mtdinfo, struct sh_flctl, mtd);
+}
 
 struct sh_flctl {
 	struct mtd_info		mtd;