000-4.5-05-mtd-drop-unnecessary-partition-parser-data.patch 6.4 KB

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