brcm63xx: enhance dt partitions support to match upstream more closely
[openwrt/openwrt.git] / target / linux / brcm63xx / patches-4.4 / 000-4.5-06-mtd-nand-drop-unnecessary-partition-parser-data.patch
1 From a61ae81a1907af1987ad4c77300508327bc48b23 Mon Sep 17 00:00:00 2001
2 From: Brian Norris <computersforpeace@gmail.com>
3 Date: Fri, 30 Oct 2015 20:33:25 -0700
4 Subject: [PATCH 06/11] mtd: nand: drop unnecessary partition parser data
5
6 All of these drivers set up a parser data struct just to communicate DT
7 partition data. This field has been deprecated and is instead supported
8 by telling nand_scan_ident() about the 'flash_node'.
9
10 This patch:
11 * sets chip->flash_node for those drivers that didn't already (but used
12 OF partitioning)
13 * drops the parser data
14 * switches to the simpler mtd_device_register() where possible, now
15 that we've eliminated one of the auxiliary parameters
16
17 Now that we've assigned chip->flash_node for these drivers, we can
18 probably rely on nand_dt_init() to do more of the DT parsing for us, but
19 for now, I don't want to fiddle with each of these drivers. The parsing
20 is done in duplicate for now on some drivers. I don't think this should
21 break things. (Famous last words.)
22
23 (Rolled in some changes by Boris Brezillon)
24
25 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
26 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
27 ---
28 drivers/mtd/nand/atmel_nand.c | 7 +++----
29 drivers/mtd/nand/brcmnand/brcmnand.c | 3 +--
30 drivers/mtd/nand/davinci_nand.c | 10 +++-------
31 drivers/mtd/nand/fsl_elbc_nand.c | 5 ++---
32 drivers/mtd/nand/fsl_ifc_nand.c | 5 ++---
33 drivers/mtd/nand/fsl_upm.c | 5 ++---
34 drivers/mtd/nand/fsmc_nand.c | 7 +++----
35 drivers/mtd/nand/gpio.c | 8 +++-----
36 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 5 ++---
37 drivers/mtd/nand/hisi504_nand.c | 5 ++---
38 drivers/mtd/nand/lpc32xx_mlc.c | 7 +++----
39 drivers/mtd/nand/lpc32xx_slc.c | 7 +++----
40 drivers/mtd/nand/mpc5121_nfc.c | 5 ++---
41 drivers/mtd/nand/mxc_nand.c | 5 ++---
42 drivers/mtd/nand/ndfc.c | 5 ++---
43 drivers/mtd/nand/omap2.c | 6 ++----
44 drivers/mtd/nand/orion_nand.c | 6 ++----
45 drivers/mtd/nand/plat_nand.c | 5 ++---
46 drivers/mtd/nand/pxa3xx_nand.c | 10 +++++-----
47 drivers/mtd/nand/sh_flctl.c | 6 ++----
48 drivers/mtd/nand/socrates_nand.c | 5 ++---
49 drivers/mtd/nand/sunxi_nand.c | 4 +---
50 drivers/mtd/nand/vf610_nfc.c | 6 +-----
51 drivers/staging/mt29f_spinand/mt29f_spinand.c | 5 ++---
52 24 files changed, 54 insertions(+), 88 deletions(-)
53
54 --- a/drivers/mtd/nand/atmel_nand.c
55 +++ b/drivers/mtd/nand/atmel_nand.c
56 @@ -2093,7 +2093,6 @@ static int atmel_nand_probe(struct platf
57 struct mtd_info *mtd;
58 struct nand_chip *nand_chip;
59 struct resource *mem;
60 - struct mtd_part_parser_data ppdata = {};
61 int res, irq;
62
63 /* Allocate memory for the device structure (and zero it) */
64 @@ -2117,6 +2116,7 @@ static int atmel_nand_probe(struct platf
65 nand_chip = &host->nand_chip;
66 host->dev = &pdev->dev;
67 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
68 + nand_set_flash_node(nand_chip, pdev->dev.of_node);
69 /* Only when CONFIG_OF is enabled of_node can be parsed */
70 res = atmel_of_init_port(host, pdev->dev.of_node);
71 if (res)
72 @@ -2259,9 +2259,8 @@ static int atmel_nand_probe(struct platf
73 }
74
75 mtd->name = "atmel_nand";
76 - ppdata.of_node = pdev->dev.of_node;
77 - res = mtd_device_parse_register(mtd, NULL, &ppdata,
78 - host->board.parts, host->board.num_parts);
79 + res = mtd_device_register(mtd, host->board.parts,
80 + host->board.num_parts);
81 if (!res)
82 return res;
83
84 --- a/drivers/mtd/nand/brcmnand/brcmnand.c
85 +++ b/drivers/mtd/nand/brcmnand/brcmnand.c
86 @@ -1946,7 +1946,6 @@ static int brcmnand_init_cs(struct brcmn
87 struct nand_chip *chip;
88 int ret;
89 u16 cfg_offs;
90 - struct mtd_part_parser_data ppdata = { .of_node = dn };
91
92 ret = of_property_read_u32(dn, "reg", &host->cs);
93 if (ret) {
94 @@ -2025,7 +2024,7 @@ static int brcmnand_init_cs(struct brcmn
95 if (nand_scan_tail(mtd))
96 return -ENXIO;
97
98 - return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
99 + return mtd_device_register(mtd, NULL, 0);
100 }
101
102 static void brcmnand_save_restore_cs_config(struct brcmnand_host *host,
103 --- a/drivers/mtd/nand/davinci_nand.c
104 +++ b/drivers/mtd/nand/davinci_nand.c
105 @@ -687,6 +687,7 @@ static int nand_davinci_probe(struct pla
106
107 info->mtd.priv = &info->chip;
108 info->mtd.dev.parent = &pdev->dev;
109 + nand_set_flash_node(&info->chip, pdev->dev.of_node);
110
111 info->chip.IO_ADDR_R = vaddr;
112 info->chip.IO_ADDR_W = vaddr;
113 @@ -842,13 +843,8 @@ syndrome_done:
114 if (pdata->parts)
115 ret = mtd_device_parse_register(&info->mtd, NULL, NULL,
116 pdata->parts, pdata->nr_parts);
117 - else {
118 - struct mtd_part_parser_data ppdata;
119 -
120 - ppdata.of_node = pdev->dev.of_node;
121 - ret = mtd_device_parse_register(&info->mtd, NULL, &ppdata,
122 - NULL, 0);
123 - }
124 + else
125 + ret = mtd_device_register(&info->mtd, NULL, 0);
126 if (ret < 0)
127 goto err;
128
129 --- a/drivers/mtd/nand/fsl_elbc_nand.c
130 +++ b/drivers/mtd/nand/fsl_elbc_nand.c
131 @@ -748,6 +748,7 @@ static int fsl_elbc_chip_init(struct fsl
132 /* Fill in fsl_elbc_mtd structure */
133 priv->mtd.priv = chip;
134 priv->mtd.dev.parent = priv->dev;
135 + nand_set_flash_node(chip, priv->dev->of_node);
136
137 /* set timeout to maximum */
138 priv->fmr = 15 << FMR_CWTO_SHIFT;
139 @@ -823,9 +824,7 @@ static int fsl_elbc_nand_probe(struct pl
140 int bank;
141 struct device *dev;
142 struct device_node *node = pdev->dev.of_node;
143 - struct mtd_part_parser_data ppdata;
144
145 - ppdata.of_node = pdev->dev.of_node;
146 if (!fsl_lbc_ctrl_dev || !fsl_lbc_ctrl_dev->regs)
147 return -ENODEV;
148 lbc = fsl_lbc_ctrl_dev->regs;
149 @@ -911,7 +910,7 @@ static int fsl_elbc_nand_probe(struct pl
150
151 /* First look for RedBoot table or partitions on the command
152 * line, these take precedence over device tree information */
153 - mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata,
154 + mtd_device_parse_register(&priv->mtd, part_probe_types, NULL,
155 NULL, 0);
156
157 printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
158 --- a/drivers/mtd/nand/fsl_ifc_nand.c
159 +++ b/drivers/mtd/nand/fsl_ifc_nand.c
160 @@ -883,6 +883,7 @@ static int fsl_ifc_chip_init(struct fsl_
161 /* Fill in fsl_ifc_mtd structure */
162 priv->mtd.priv = chip;
163 priv->mtd.dev.parent = priv->dev;
164 + nand_set_flash_node(chip, priv->dev->of_node);
165
166 /* fill in nand_chip structure */
167 /* set up function call table */
168 @@ -1030,9 +1031,7 @@ static int fsl_ifc_nand_probe(struct pla
169 int ret;
170 int bank;
171 struct device_node *node = dev->dev.of_node;
172 - struct mtd_part_parser_data ppdata;
173
174 - ppdata.of_node = dev->dev.of_node;
175 if (!fsl_ifc_ctrl_dev || !fsl_ifc_ctrl_dev->regs)
176 return -ENODEV;
177 ifc = fsl_ifc_ctrl_dev->regs;
178 @@ -1128,7 +1127,7 @@ static int fsl_ifc_nand_probe(struct pla
179
180 /* First look for RedBoot table or partitions on the command
181 * line, these take precedence over device tree information */
182 - mtd_device_parse_register(&priv->mtd, part_probe_types, &ppdata,
183 + mtd_device_parse_register(&priv->mtd, part_probe_types, NULL,
184 NULL, 0);
185
186 dev_info(priv->dev, "IFC NAND device at 0x%llx, bank %d\n",
187 --- a/drivers/mtd/nand/fsl_upm.c
188 +++ b/drivers/mtd/nand/fsl_upm.c
189 @@ -159,7 +159,6 @@ static int fun_chip_init(struct fsl_upm_
190 {
191 int ret;
192 struct device_node *flash_np;
193 - struct mtd_part_parser_data ppdata;
194
195 fun->chip.IO_ADDR_R = fun->io_base;
196 fun->chip.IO_ADDR_W = fun->io_base;
197 @@ -182,6 +181,7 @@ static int fun_chip_init(struct fsl_upm_
198 if (!flash_np)
199 return -ENODEV;
200
201 + nand_set_flash_node(&fun->chip, flash_np);
202 fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start,
203 flash_np->name);
204 if (!fun->mtd.name) {
205 @@ -193,8 +193,7 @@ static int fun_chip_init(struct fsl_upm_
206 if (ret)
207 goto err;
208
209 - ppdata.of_node = flash_np;
210 - ret = mtd_device_parse_register(&fun->mtd, NULL, &ppdata, NULL, 0);
211 + ret = mtd_device_register(&fun->mtd, NULL, 0);
212 err:
213 of_node_put(flash_np);
214 if (ret)
215 --- a/drivers/mtd/nand/fsmc_nand.c
216 +++ b/drivers/mtd/nand/fsmc_nand.c
217 @@ -926,7 +926,6 @@ static int __init fsmc_nand_probe(struct
218 {
219 struct fsmc_nand_platform_data *pdata = dev_get_platdata(&pdev->dev);
220 struct device_node __maybe_unused *np = pdev->dev.of_node;
221 - struct mtd_part_parser_data ppdata = {};
222 struct fsmc_nand_data *host;
223 struct mtd_info *mtd;
224 struct nand_chip *nand;
225 @@ -1016,6 +1015,7 @@ static int __init fsmc_nand_probe(struct
226 nand = &host->nand;
227 mtd->priv = nand;
228 nand->priv = host;
229 + nand_set_flash_node(nand, np);
230
231 host->mtd.dev.parent = &pdev->dev;
232 nand->IO_ADDR_R = host->data_va;
233 @@ -1175,9 +1175,8 @@ static int __init fsmc_nand_probe(struct
234 * Check for partition info passed
235 */
236 host->mtd.name = "nand";
237 - ppdata.of_node = np;
238 - ret = mtd_device_parse_register(&host->mtd, NULL, &ppdata,
239 - host->partitions, host->nr_partitions);
240 + ret = mtd_device_register(&host->mtd, host->partitions,
241 + host->nr_partitions);
242 if (ret)
243 goto err_probe;
244
245 --- a/drivers/mtd/nand/gpio.c
246 +++ b/drivers/mtd/nand/gpio.c
247 @@ -209,7 +209,6 @@ static int gpio_nand_probe(struct platfo
248 struct gpiomtd *gpiomtd;
249 struct nand_chip *chip;
250 struct resource *res;
251 - struct mtd_part_parser_data ppdata = {};
252 int ret = 0;
253
254 if (!pdev->dev.of_node && !dev_get_platdata(&pdev->dev))
255 @@ -268,6 +267,7 @@ static int gpio_nand_probe(struct platfo
256 chip->dev_ready = gpio_nand_devready;
257 }
258
259 + nand_set_flash_node(chip, pdev->dev.of_node);
260 chip->IO_ADDR_W = chip->IO_ADDR_R;
261 chip->ecc.mode = NAND_ECC_SOFT;
262 chip->options = gpiomtd->plat.options;
263 @@ -291,10 +291,8 @@ static int gpio_nand_probe(struct platfo
264 gpiomtd->plat.adjust_parts(&gpiomtd->plat,
265 gpiomtd->mtd_info.size);
266
267 - ppdata.of_node = pdev->dev.of_node;
268 - ret = mtd_device_parse_register(&gpiomtd->mtd_info, NULL, &ppdata,
269 - gpiomtd->plat.parts,
270 - gpiomtd->plat.num_parts);
271 + ret = mtd_device_register(&gpiomtd->mtd_info, gpiomtd->plat.parts,
272 + gpiomtd->plat.num_parts);
273 if (!ret)
274 return 0;
275
276 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
277 +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
278 @@ -1888,7 +1888,6 @@ static int gpmi_nand_init(struct gpmi_na
279 {
280 struct mtd_info *mtd = &this->mtd;
281 struct nand_chip *chip = &this->nand;
282 - struct mtd_part_parser_data ppdata = {};
283 int ret;
284
285 /* init current chip */
286 @@ -1901,6 +1900,7 @@ static int gpmi_nand_init(struct gpmi_na
287
288 /* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */
289 chip->priv = this;
290 + nand_set_flash_node(chip, this->pdev->dev.of_node);
291 chip->select_chip = gpmi_select_chip;
292 chip->cmd_ctrl = gpmi_cmd_ctrl;
293 chip->dev_ready = gpmi_dev_ready;
294 @@ -1954,8 +1954,7 @@ static int gpmi_nand_init(struct gpmi_na
295 if (ret)
296 goto err_out;
297
298 - ppdata.of_node = this->pdev->dev.of_node;
299 - ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
300 + ret = mtd_device_register(mtd, NULL, 0);
301 if (ret)
302 goto err_out;
303 return 0;
304 --- a/drivers/mtd/nand/hisi504_nand.c
305 +++ b/drivers/mtd/nand/hisi504_nand.c
306 @@ -704,7 +704,6 @@ static int hisi_nfc_probe(struct platfor
307 struct mtd_info *mtd;
308 struct resource *res;
309 struct device_node *np = dev->of_node;
310 - struct mtd_part_parser_data ppdata;
311
312 host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
313 if (!host)
314 @@ -742,6 +741,7 @@ static int hisi_nfc_probe(struct platfor
315 mtd->dev.parent = &pdev->dev;
316
317 chip->priv = host;
318 + nand_set_flash_node(chip, np);
319 chip->cmdfunc = hisi_nfc_cmdfunc;
320 chip->select_chip = hisi_nfc_select_chip;
321 chip->read_byte = hisi_nfc_read_byte;
322 @@ -805,8 +805,7 @@ static int hisi_nfc_probe(struct platfor
323 goto err_res;
324 }
325
326 - ppdata.of_node = np;
327 - ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
328 + ret = mtd_device_register(mtd, NULL, 0);
329 if (ret) {
330 dev_err(dev, "Err MTD partition=%d\n", ret);
331 goto err_mtd;
332 --- a/drivers/mtd/nand/lpc32xx_mlc.c
333 +++ b/drivers/mtd/nand/lpc32xx_mlc.c
334 @@ -647,7 +647,6 @@ static int lpc32xx_nand_probe(struct pla
335 struct nand_chip *nand_chip;
336 struct resource *rc;
337 int res;
338 - struct mtd_part_parser_data ppdata = {};
339
340 /* Allocate memory for the device structure (and zero it) */
341 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
342 @@ -682,6 +681,7 @@ static int lpc32xx_nand_probe(struct pla
343 host->pdata = dev_get_platdata(&pdev->dev);
344
345 nand_chip->priv = host; /* link the private data structures */
346 + nand_set_flash_node(nand_chip, pdev->dev.of_node);
347 mtd->priv = nand_chip;
348 mtd->dev.parent = &pdev->dev;
349
350 @@ -786,9 +786,8 @@ static int lpc32xx_nand_probe(struct pla
351
352 mtd->name = DRV_NAME;
353
354 - ppdata.of_node = pdev->dev.of_node;
355 - res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts,
356 - host->ncfg->num_parts);
357 + res = mtd_device_register(mtd, host->ncfg->parts,
358 + host->ncfg->num_parts);
359 if (!res)
360 return res;
361
362 --- a/drivers/mtd/nand/lpc32xx_slc.c
363 +++ b/drivers/mtd/nand/lpc32xx_slc.c
364 @@ -763,7 +763,6 @@ static int lpc32xx_nand_probe(struct pla
365 struct mtd_info *mtd;
366 struct nand_chip *chip;
367 struct resource *rc;
368 - struct mtd_part_parser_data ppdata = {};
369 int res;
370
371 rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
372 @@ -803,6 +802,7 @@ static int lpc32xx_nand_probe(struct pla
373 mtd = &host->mtd;
374 chip = &host->nand_chip;
375 chip->priv = host;
376 + nand_set_flash_node(chip, pdev->dev.of_node);
377 mtd->priv = chip;
378 mtd->owner = THIS_MODULE;
379 mtd->dev.parent = &pdev->dev;
380 @@ -908,9 +908,8 @@ static int lpc32xx_nand_probe(struct pla
381 }
382
383 mtd->name = "nxp_lpc3220_slc";
384 - ppdata.of_node = pdev->dev.of_node;
385 - res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts,
386 - host->ncfg->num_parts);
387 + res = mtd_device_register(mtd, host->ncfg->parts,
388 + host->ncfg->num_parts);
389 if (!res)
390 return res;
391
392 --- a/drivers/mtd/nand/mpc5121_nfc.c
393 +++ b/drivers/mtd/nand/mpc5121_nfc.c
394 @@ -639,7 +639,6 @@ static int mpc5121_nfc_probe(struct plat
395 int resettime = 0;
396 int retval = 0;
397 int rev, len;
398 - struct mtd_part_parser_data ppdata;
399
400 /*
401 * Check SoC revision. This driver supports only NFC
402 @@ -661,6 +660,7 @@ static int mpc5121_nfc_probe(struct plat
403 mtd->priv = chip;
404 mtd->dev.parent = dev;
405 chip->priv = prv;
406 + nand_set_flash_node(chip, dn);
407 prv->dev = dev;
408
409 /* Read NFC configuration from Reset Config Word */
410 @@ -703,7 +703,6 @@ static int mpc5121_nfc_probe(struct plat
411 }
412
413 mtd->name = "MPC5121 NAND";
414 - ppdata.of_node = dn;
415 chip->dev_ready = mpc5121_nfc_dev_ready;
416 chip->cmdfunc = mpc5121_nfc_command;
417 chip->read_byte = mpc5121_nfc_read_byte;
418 @@ -815,7 +814,7 @@ static int mpc5121_nfc_probe(struct plat
419 dev_set_drvdata(dev, mtd);
420
421 /* Register device in MTD */
422 - retval = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
423 + retval = mtd_device_register(mtd, NULL, 0);
424 if (retval) {
425 dev_err(dev, "Error adding MTD device!\n");
426 goto error;
427 --- a/drivers/mtd/nand/mxc_nand.c
428 +++ b/drivers/mtd/nand/mxc_nand.c
429 @@ -1524,6 +1524,7 @@ static int mxcnd_probe(struct platform_d
430 this->chip_delay = 5;
431
432 this->priv = host;
433 + nand_set_flash_node(this, pdev->dev.of_node),
434 this->dev_ready = mxc_nand_dev_ready;
435 this->cmdfunc = mxc_nand_command;
436 this->read_byte = mxc_nand_read_byte;
437 @@ -1683,9 +1684,7 @@ static int mxcnd_probe(struct platform_d
438
439 /* Register the partitions */
440 mtd_device_parse_register(mtd, part_probes,
441 - &(struct mtd_part_parser_data){
442 - .of_node = pdev->dev.of_node,
443 - },
444 + NULL,
445 host->pdata.parts,
446 host->pdata.nr_parts);
447
448 --- a/drivers/mtd/nand/ndfc.c
449 +++ b/drivers/mtd/nand/ndfc.c
450 @@ -147,7 +147,6 @@ static int ndfc_chip_init(struct ndfc_co
451 {
452 struct device_node *flash_np;
453 struct nand_chip *chip = &ndfc->chip;
454 - struct mtd_part_parser_data ppdata;
455 int ret;
456
457 chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA;
458 @@ -174,8 +173,8 @@ static int ndfc_chip_init(struct ndfc_co
459 flash_np = of_get_next_child(node, NULL);
460 if (!flash_np)
461 return -ENODEV;
462 + nand_set_flash_node(chip, flash_np);
463
464 - ppdata.of_node = flash_np;
465 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
466 dev_name(&ndfc->ofdev->dev), flash_np->name);
467 if (!ndfc->mtd.name) {
468 @@ -187,7 +186,7 @@ static int ndfc_chip_init(struct ndfc_co
469 if (ret)
470 goto err;
471
472 - ret = mtd_device_parse_register(&ndfc->mtd, NULL, &ppdata, NULL, 0);
473 + ret = mtd_device_register(&ndfc->mtd, NULL, 0);
474
475 err:
476 of_node_put(flash_np);
477 --- a/drivers/mtd/nand/omap2.c
478 +++ b/drivers/mtd/nand/omap2.c
479 @@ -1663,7 +1663,6 @@ static int omap_nand_probe(struct platfo
480 unsigned sig;
481 unsigned oob_index;
482 struct resource *res;
483 - struct mtd_part_parser_data ppdata = {};
484
485 pdata = dev_get_platdata(&pdev->dev);
486 if (pdata == NULL) {
487 @@ -1688,6 +1687,7 @@ static int omap_nand_probe(struct platfo
488 mtd->dev.parent = &pdev->dev;
489 nand_chip = &info->nand;
490 nand_chip->ecc.priv = NULL;
491 + nand_set_flash_node(nand_chip, pdata->of_node);
492
493 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
494 nand_chip->IO_ADDR_R = devm_ioremap_resource(&pdev->dev, res);
495 @@ -2037,9 +2037,7 @@ scan_tail:
496 goto return_error;
497 }
498
499 - ppdata.of_node = pdata->of_node;
500 - mtd_device_parse_register(mtd, NULL, &ppdata, pdata->parts,
501 - pdata->nr_parts);
502 + mtd_device_register(mtd, pdata->parts, pdata->nr_parts);
503
504 platform_set_drvdata(pdev, mtd);
505
506 --- a/drivers/mtd/nand/orion_nand.c
507 +++ b/drivers/mtd/nand/orion_nand.c
508 @@ -76,7 +76,6 @@ static void orion_nand_read_buf(struct m
509 static int __init orion_nand_probe(struct platform_device *pdev)
510 {
511 struct mtd_info *mtd;
512 - struct mtd_part_parser_data ppdata = {};
513 struct nand_chip *nc;
514 struct orion_nand_data *board;
515 struct resource *res;
516 @@ -127,6 +126,7 @@ static int __init orion_nand_probe(struc
517 mtd->dev.parent = &pdev->dev;
518
519 nc->priv = board;
520 + nand_set_flash_node(nc, pdev->dev.of_node);
521 nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
522 nc->cmd_ctrl = orion_nand_cmd_ctrl;
523 nc->read_buf = orion_nand_read_buf;
524 @@ -161,9 +161,7 @@ static int __init orion_nand_probe(struc
525 }
526
527 mtd->name = "orion_nand";
528 - ppdata.of_node = pdev->dev.of_node;
529 - ret = mtd_device_parse_register(mtd, NULL, &ppdata,
530 - board->parts, board->nr_parts);
531 + ret = mtd_device_register(mtd, board->parts, board->nr_parts);
532 if (ret) {
533 nand_release(mtd);
534 goto no_dev;
535 --- a/drivers/mtd/nand/plat_nand.c
536 +++ b/drivers/mtd/nand/plat_nand.c
537 @@ -30,7 +30,6 @@ struct plat_nand_data {
538 static int plat_nand_probe(struct platform_device *pdev)
539 {
540 struct platform_nand_data *pdata = dev_get_platdata(&pdev->dev);
541 - struct mtd_part_parser_data ppdata;
542 struct plat_nand_data *data;
543 struct resource *res;
544 const char **part_types;
545 @@ -58,6 +57,7 @@ static int plat_nand_probe(struct platfo
546 return PTR_ERR(data->io_base);
547
548 data->chip.priv = &data;
549 + nand_set_flash_node(&data->chip, pdev->dev.of_node);
550 data->mtd.priv = &data->chip;
551 data->mtd.dev.parent = &pdev->dev;
552
553 @@ -105,8 +105,7 @@ static int plat_nand_probe(struct platfo
554
555 part_types = pdata->chip.part_probe_types;
556
557 - ppdata.of_node = pdev->dev.of_node;
558 - err = mtd_device_parse_register(&data->mtd, part_types, &ppdata,
559 + err = mtd_device_parse_register(&data->mtd, part_types, NULL,
560 pdata->chip.partitions,
561 pdata->chip.nr_partitions);
562
563 --- a/drivers/mtd/nand/pxa3xx_nand.c
564 +++ b/drivers/mtd/nand/pxa3xx_nand.c
565 @@ -1697,6 +1697,7 @@ KEEP_CONFIG:
566
567 static int alloc_nand_resource(struct platform_device *pdev)
568 {
569 + struct device_node *np = pdev->dev.of_node;
570 struct pxa3xx_nand_platform_data *pdata;
571 struct pxa3xx_nand_info *info;
572 struct pxa3xx_nand_host *host;
573 @@ -1725,6 +1726,8 @@ static int alloc_nand_resource(struct pl
574 host->info_data = info;
575 mtd->priv = host;
576 mtd->dev.parent = &pdev->dev;
577 + /* FIXME: all chips use the same device tree partitions */
578 + nand_set_flash_node(chip, np);
579
580 chip->ecc.read_page = pxa3xx_nand_read_page_hwecc;
581 chip->ecc.write_page = pxa3xx_nand_write_page_hwecc;
582 @@ -1886,7 +1889,6 @@ static int pxa3xx_nand_probe_dt(struct p
583 static int pxa3xx_nand_probe(struct platform_device *pdev)
584 {
585 struct pxa3xx_nand_platform_data *pdata;
586 - struct mtd_part_parser_data ppdata = {};
587 struct pxa3xx_nand_info *info;
588 int ret, cs, probe_success, dma_available;
589
590 @@ -1933,10 +1935,8 @@ static int pxa3xx_nand_probe(struct plat
591 continue;
592 }
593
594 - ppdata.of_node = pdev->dev.of_node;
595 - ret = mtd_device_parse_register(mtd, NULL,
596 - &ppdata, pdata->parts[cs],
597 - pdata->nr_parts[cs]);
598 + ret = mtd_device_register(mtd, pdata->parts[cs],
599 + pdata->nr_parts[cs]);
600 if (!ret)
601 probe_success = 1;
602 }
603 --- a/drivers/mtd/nand/sh_flctl.c
604 +++ b/drivers/mtd/nand/sh_flctl.c
605 @@ -1086,7 +1086,6 @@ static int flctl_probe(struct platform_d
606 struct sh_flctl_platform_data *pdata;
607 int ret;
608 int irq;
609 - struct mtd_part_parser_data ppdata = {};
610
611 flctl = devm_kzalloc(&pdev->dev, sizeof(struct sh_flctl), GFP_KERNEL);
612 if (!flctl)
613 @@ -1123,6 +1122,7 @@ static int flctl_probe(struct platform_d
614 platform_set_drvdata(pdev, flctl);
615 flctl_mtd = &flctl->mtd;
616 nand = &flctl->chip;
617 + nand_set_flash_node(nand, pdev->dev.of_node);
618 flctl_mtd->priv = nand;
619 flctl_mtd->dev.parent = &pdev->dev;
620 flctl->pdev = pdev;
621 @@ -1163,9 +1163,7 @@ static int flctl_probe(struct platform_d
622 if (ret)
623 goto err_chip;
624
625 - ppdata.of_node = pdev->dev.of_node;
626 - ret = mtd_device_parse_register(flctl_mtd, NULL, &ppdata, pdata->parts,
627 - pdata->nr_parts);
628 + ret = mtd_device_register(flctl_mtd, pdata->parts, pdata->nr_parts);
629
630 return 0;
631
632 --- a/drivers/mtd/nand/socrates_nand.c
633 +++ b/drivers/mtd/nand/socrates_nand.c
634 @@ -147,7 +147,6 @@ static int socrates_nand_probe(struct pl
635 struct mtd_info *mtd;
636 struct nand_chip *nand_chip;
637 int res;
638 - struct mtd_part_parser_data ppdata;
639
640 /* Allocate memory for the device structure (and zero it) */
641 host = devm_kzalloc(&ofdev->dev, sizeof(*host), GFP_KERNEL);
642 @@ -165,10 +164,10 @@ static int socrates_nand_probe(struct pl
643 host->dev = &ofdev->dev;
644
645 nand_chip->priv = host; /* link the private data structures */
646 + nand_set_flash_node(nand_chip, ofdev->dev.of_node);
647 mtd->priv = nand_chip;
648 mtd->name = "socrates_nand";
649 mtd->dev.parent = &ofdev->dev;
650 - ppdata.of_node = ofdev->dev.of_node;
651
652 /*should never be accessed directly */
653 nand_chip->IO_ADDR_R = (void *)0xdeadbeef;
654 @@ -200,7 +199,7 @@ static int socrates_nand_probe(struct pl
655 goto out;
656 }
657
658 - res = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
659 + res = mtd_device_register(mtd, NULL, 0);
660 if (!res)
661 return res;
662
663 --- a/drivers/mtd/nand/sunxi_nand.c
664 +++ b/drivers/mtd/nand/sunxi_nand.c
665 @@ -1232,7 +1232,6 @@ static int sunxi_nand_chip_init(struct d
666 {
667 const struct nand_sdr_timings *timings;
668 struct sunxi_nand_chip *chip;
669 - struct mtd_part_parser_data ppdata;
670 struct mtd_info *mtd;
671 struct nand_chip *nand;
672 int nsels;
673 @@ -1366,8 +1365,7 @@ static int sunxi_nand_chip_init(struct d
674 return ret;
675 }
676
677 - ppdata.of_node = np;
678 - ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
679 + ret = mtd_device_register(mtd, NULL, 0);
680 if (ret) {
681 dev_err(dev, "failed to register mtd device: %d\n", ret);
682 nand_release(mtd);
683 --- a/drivers/mtd/nand/vf610_nfc.c
684 +++ b/drivers/mtd/nand/vf610_nfc.c
685 @@ -811,11 +811,7 @@ static int vf610_nfc_probe(struct platfo
686 platform_set_drvdata(pdev, mtd);
687
688 /* Register device in MTD */
689 - return mtd_device_parse_register(mtd, NULL,
690 - &(struct mtd_part_parser_data){
691 - .of_node = chip->flash_node,
692 - },
693 - NULL, 0);
694 + return mtd_device_register(mtd, NULL, 0);
695
696 error:
697 of_node_put(chip->flash_node);
698 --- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
699 +++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
700 @@ -850,7 +850,6 @@ static int spinand_probe(struct spi_devi
701 struct nand_chip *chip;
702 struct spinand_info *info;
703 struct spinand_state *state;
704 - struct mtd_part_parser_data ppdata;
705
706 info = devm_kzalloc(&spi_nand->dev, sizeof(struct spinand_info),
707 GFP_KERNEL);
708 @@ -894,6 +893,7 @@ static int spinand_probe(struct spi_devi
709 pr_info("%s: disable ecc failed!\n", __func__);
710 #endif
711
712 + nand_set_flash_node(chip, spi_nand->dev.of_node);
713 chip->priv = info;
714 chip->read_buf = spinand_read_buf;
715 chip->write_buf = spinand_write_buf;
716 @@ -916,8 +916,7 @@ static int spinand_probe(struct spi_devi
717 if (nand_scan(mtd, 1))
718 return -ENXIO;
719
720 - ppdata.of_node = spi_nand->dev.of_node;
721 - return mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
722 + return mtd_device_register(mtd, NULL, 0);
723 }
724
725 /*