brcm63xx: register SPI controllers through DT
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.4 / 000-4.5-09-mtd-drop-unnecessary-partition-parser-data.patch
1 From 004b5e6031f4e9fd90d565fb213b74cd06d03718 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Fri, 30 Oct 2015 20:33:28 -0700
4 Subject: [PATCH] mtd: drop unnecessary partition parser data
5
6 We should assign the MTD dev.of_node instead of the parser data field.
7 This gets us the equivalent partition parser behavior with fewer special
8 fields and parameter passing.
9
10 Also convert several of these to mtd_device_register(), since we don't
11 need the 2nd and 3rd parameters anymore.
12
13 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
14 Reviewed-by: Marek Vasut <marex@denx.de>
15 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
16 ---
17 drivers/mtd/devices/mtd_dataflash.c | 5 ++---
18 drivers/mtd/devices/spear_smi.c | 6 ++----
19 drivers/mtd/devices/st_spi_fsm.c | 5 ++---
20 drivers/mtd/maps/lantiq-flash.c | 5 ++---
21 drivers/mtd/maps/physmap_of.c | 5 ++---
22 drivers/mtd/onenand/omap2.c | 8 +++-----
23 6 files changed, 13 insertions(+), 21 deletions(-)
24
25 --- a/drivers/mtd/devices/mtd_dataflash.c
26 +++ b/drivers/mtd/devices/mtd_dataflash.c
27 @@ -624,7 +624,6 @@ static int add_dataflash_otp(struct spi_
28 {
29 struct dataflash *priv;
30 struct mtd_info *device;
31 - struct mtd_part_parser_data ppdata;
32 struct flash_platform_data *pdata = dev_get_platdata(&spi->dev);
33 char *otp_tag = "";
34 int err = 0;
35 @@ -656,6 +655,7 @@ static int add_dataflash_otp(struct spi_
36 device->priv = priv;
37
38 device->dev.parent = &spi->dev;
39 + mtd_set_of_node(device, spi->dev.of_node);
40
41 if (revision >= 'c')
42 otp_tag = otp_setup(device, revision);
43 @@ -665,8 +665,7 @@ static int add_dataflash_otp(struct spi_
44 pagesize, otp_tag);
45 spi_set_drvdata(spi, priv);
46
47 - ppdata.of_node = spi->dev.of_node;
48 - err = mtd_device_parse_register(device, NULL, &ppdata,
49 + err = mtd_device_register(device,
50 pdata ? pdata->parts : NULL,
51 pdata ? pdata->nr_parts : 0);
52
53 --- a/drivers/mtd/devices/spear_smi.c
54 +++ b/drivers/mtd/devices/spear_smi.c
55 @@ -810,7 +810,6 @@ static int spear_smi_setup_banks(struct
56 u32 bank, struct device_node *np)
57 {
58 struct spear_smi *dev = platform_get_drvdata(pdev);
59 - struct mtd_part_parser_data ppdata = {};
60 struct spear_smi_flash_info *flash_info;
61 struct spear_smi_plat_data *pdata;
62 struct spear_snor_flash *flash;
63 @@ -855,6 +854,7 @@ static int spear_smi_setup_banks(struct
64 flash->mtd.name = flash_devices[flash_index].name;
65
66 flash->mtd.dev.parent = &pdev->dev;
67 + mtd_set_of_node(&flash->mtd, np);
68 flash->mtd.type = MTD_NORFLASH;
69 flash->mtd.writesize = 1;
70 flash->mtd.flags = MTD_CAP_NORFLASH;
71 @@ -881,10 +881,8 @@ static int spear_smi_setup_banks(struct
72 count = flash_info->nr_partitions;
73 }
74 #endif
75 - ppdata.of_node = np;
76
77 - ret = mtd_device_parse_register(&flash->mtd, NULL, &ppdata, parts,
78 - count);
79 + ret = mtd_device_register(&flash->mtd, parts, count);
80 if (ret) {
81 dev_err(&dev->pdev->dev, "Err MTD partition=%d\n", ret);
82 return ret;
83 --- a/drivers/mtd/devices/st_spi_fsm.c
84 +++ b/drivers/mtd/devices/st_spi_fsm.c
85 @@ -2025,7 +2025,6 @@ boot_device_fail:
86 static int stfsm_probe(struct platform_device *pdev)
87 {
88 struct device_node *np = pdev->dev.of_node;
89 - struct mtd_part_parser_data ppdata;
90 struct flash_info *info;
91 struct resource *res;
92 struct stfsm *fsm;
93 @@ -2035,7 +2034,6 @@ static int stfsm_probe(struct platform_d
94 dev_err(&pdev->dev, "No DT found\n");
95 return -EINVAL;
96 }
97 - ppdata.of_node = np;
98
99 fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL);
100 if (!fsm)
101 @@ -2106,6 +2104,7 @@ static int stfsm_probe(struct platform_d
102
103 fsm->mtd.name = info->name;
104 fsm->mtd.dev.parent = &pdev->dev;
105 + mtd_set_of_node(&fsm->mtd, np);
106 fsm->mtd.type = MTD_NORFLASH;
107 fsm->mtd.writesize = 4;
108 fsm->mtd.writebufsize = fsm->mtd.writesize;
109 @@ -2124,7 +2123,7 @@ static int stfsm_probe(struct platform_d
110 (long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
111 fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
112
113 - return mtd_device_parse_register(&fsm->mtd, NULL, &ppdata, NULL, 0);
114 + return mtd_device_register(&fsm->mtd, NULL, 0);
115 }
116
117 static int stfsm_remove(struct platform_device *pdev)
118 --- a/drivers/mtd/maps/lantiq-flash.c
119 +++ b/drivers/mtd/maps/lantiq-flash.c
120 @@ -110,7 +110,6 @@ ltq_copy_to(struct map_info *map, unsign
121 static int
122 ltq_mtd_probe(struct platform_device *pdev)
123 {
124 - struct mtd_part_parser_data ppdata;
125 struct ltq_mtd *ltq_mtd;
126 struct cfi_private *cfi;
127 int err;
128 @@ -161,13 +160,13 @@ ltq_mtd_probe(struct platform_device *pd
129 }
130
131 ltq_mtd->mtd->dev.parent = &pdev->dev;
132 + mtd_set_of_node(ltq_mtd->mtd, pdev->dev.of_node);
133
134 cfi = ltq_mtd->map->fldrv_priv;
135 cfi->addr_unlock1 ^= 1;
136 cfi->addr_unlock2 ^= 1;
137
138 - ppdata.of_node = pdev->dev.of_node;
139 - err = mtd_device_parse_register(ltq_mtd->mtd, NULL, &ppdata, NULL, 0);
140 + err = mtd_device_register(ltq_mtd->mtd, NULL, 0);
141 if (err) {
142 dev_err(&pdev->dev, "failed to add partitions\n");
143 goto err_destroy;
144 --- a/drivers/mtd/maps/physmap_of.c
145 +++ b/drivers/mtd/maps/physmap_of.c
146 @@ -128,7 +128,6 @@ static int of_flash_probe(struct platfor
147 int reg_tuple_size;
148 struct mtd_info **mtd_list = NULL;
149 resource_size_t res_size;
150 - struct mtd_part_parser_data ppdata;
151 bool map_indirect;
152 const char *mtd_name = NULL;
153
154 @@ -272,8 +271,8 @@ static int of_flash_probe(struct platfor
155 if (err)
156 goto err_out;
157
158 - ppdata.of_node = dp;
159 - mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
160 + mtd_set_of_node(info->cmtd, dp);
161 + mtd_device_parse_register(info->cmtd, part_probe_types_def, NULL,
162 NULL, 0);
163
164 kfree(mtd_list);
165 --- a/drivers/mtd/onenand/omap2.c
166 +++ b/drivers/mtd/onenand/omap2.c
167 @@ -614,7 +614,6 @@ static int omap2_onenand_probe(struct pl
168 struct onenand_chip *this;
169 int r;
170 struct resource *res;
171 - struct mtd_part_parser_data ppdata = {};
172
173 pdata = dev_get_platdata(&pdev->dev);
174 if (pdata == NULL) {
175 @@ -713,6 +712,7 @@ static int omap2_onenand_probe(struct pl
176 c->mtd.priv = &c->onenand;
177
178 c->mtd.dev.parent = &pdev->dev;
179 + mtd_set_of_node(&c->mtd, pdata->of_node);
180
181 this = &c->onenand;
182 if (c->dma_channel >= 0) {
183 @@ -743,10 +743,8 @@ static int omap2_onenand_probe(struct pl
184 if ((r = onenand_scan(&c->mtd, 1)) < 0)
185 goto err_release_regulator;
186
187 - ppdata.of_node = pdata->of_node;
188 - r = mtd_device_parse_register(&c->mtd, NULL, &ppdata,
189 - pdata ? pdata->parts : NULL,
190 - pdata ? pdata->nr_parts : 0);
191 + r = mtd_device_register(&c->mtd, pdata ? pdata->parts : NULL,
192 + pdata ? pdata->nr_parts : 0);
193 if (r)
194 goto err_release_onenand;
195