lkml.org 
[lkml]   [2014]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 01/27] mtd: nand: introduce function to fix a common bug in most nand-drivers not showing a device in sysfs
Date
Most nand drivers don't set a parent device for the mtd-device. The result
is that information in sysfs is missing (no folder device).

Comparing the output of

git grep mtd_device_parse_register drivers/mtd/nand/

with

git grep parent drivers/mtd/nand/ | cut -f 1 | sort -u

showed that this is a very common error. Looking at some of those drivers
a common pattern is visible which I put into a new inline function to
reduce source code size and to avoid future similiar errors.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
include/linux/mtd/mtd.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index a1b0b4c..2e24afe 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -23,7 +23,7 @@
#include <linux/types.h>
#include <linux/uio.h>
#include <linux/notifier.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>

#include <mtd/mtd-abi.h>

@@ -366,6 +366,15 @@ static inline int mtd_can_have_bb(const struct mtd_info *mtd)
struct mtd_partition;
struct mtd_part_parser_data;

+static inline void mtd_setup_common_members(struct mtd_info *mtd, void *priv,
+ struct platform_device *pdev)
+{
+ mtd->priv = priv;
+ mtd->owner = pdev->dev.driver->owner;
+ mtd->dev.parent = &pdev->dev;
+ mtd->name = pdev->dev.driver->name;
+}
+
extern int mtd_device_parse_register(struct mtd_info *mtd,
const char * const *part_probe_types,
struct mtd_part_parser_data *parser_data,
--
1.8.3.2


\
 
 \ /
  Last update: 2014-05-27 01:01    [W:0.227 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site