14ad2d43b8d2788cfa75cf15f900fb94cc4dd1b8
[openwrt/staging/zorun.git] /
1 From 3b6521eab0386a4854d47b1a01947d7dc46ec98d Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Fri, 30 Oct 2015 20:33:21 -0700
4 Subject: [PATCH] mtd: ofpart: grab device tree node directly from master
5 device node
6
7 It seems more logical to use a device node directly associated with the
8 MTD master device (i.e., mtd->dev.of_node field) rather than requiring
9 auxiliary partition parser information to be passed in by the driver in
10 a separate struct.
11
12 This patch supports the mtd->dev.of_node field and deprecates the parser
13 data 'of_node' field
14
15 Driver conversions may now follow.
16
17 Additional side benefit to assigning mtd->dev.of_node rather than using
18 parser data: the driver core will automatically create a device -> node
19 symlink for us.
20
21 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
22 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
23 ---
24 drivers/mtd/ofpart.c | 18 ++++++++++--------
25 include/linux/mtd/partitions.h | 4 +++-
26 2 files changed, 13 insertions(+), 9 deletions(-)
27
28 --- a/drivers/mtd/ofpart.c
29 +++ b/drivers/mtd/ofpart.c
30 @@ -37,10 +37,11 @@ static int parse_ofpart_partitions(struc
31 bool dedicated = true;
32
33
34 - if (!data)
35 - return 0;
36 -
37 - mtd_node = data->of_node;
38 + /*
39 + * of_node can be provided through auxiliary parser data or (preferred)
40 + * by assigning the master device node
41 + */
42 + mtd_node = data && data->of_node ? data->of_node : mtd_get_of_node(master);
43 if (!mtd_node)
44 return 0;
45
46 @@ -157,10 +158,11 @@ static int parse_ofoldpart_partitions(st
47 } *part;
48 const char *names;
49
50 - if (!data)
51 - return 0;
52 -
53 - dp = data->of_node;
54 + /*
55 + * of_node can be provided through auxiliary parser data or (preferred)
56 + * by assigning the master device node
57 + */
58 + dp = data && data->of_node ? data->of_node : mtd_get_of_node(master);
59 if (!dp)
60 return 0;
61
62 --- a/include/linux/mtd/partitions.h
63 +++ b/include/linux/mtd/partitions.h
64 @@ -56,7 +56,9 @@ struct device_node;
65 /**
66 * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
67 * @origin: for RedBoot, start address of MTD device
68 - * @of_node: for OF parsers, device node containing partitioning information
69 + * @of_node: for OF parsers, device node containing partitioning information.
70 + * This field is deprecated, as the device node should simply be
71 + * assigned to the master struct device.
72 */
73 struct mtd_part_parser_data {
74 unsigned long origin;