mtd: drop unnecessary partition parser data
We should assign the MTD dev.of_node instead of the parser data field. This gets us the equivalent partition parser behavior with fewer special fields and parameter passing. Also convert several of these to mtd_device_register(), since we don't need the 2nd and 3rd parameters anymore. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Marek Vasut <marex@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This commit is contained in:
parent
30069af734
commit
004b5e6031
@ -624,7 +624,6 @@ static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
|
|||||||
{
|
{
|
||||||
struct dataflash *priv;
|
struct dataflash *priv;
|
||||||
struct mtd_info *device;
|
struct mtd_info *device;
|
||||||
struct mtd_part_parser_data ppdata;
|
|
||||||
struct flash_platform_data *pdata = dev_get_platdata(&spi->dev);
|
struct flash_platform_data *pdata = dev_get_platdata(&spi->dev);
|
||||||
char *otp_tag = "";
|
char *otp_tag = "";
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -656,6 +655,7 @@ static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
|
|||||||
device->priv = priv;
|
device->priv = priv;
|
||||||
|
|
||||||
device->dev.parent = &spi->dev;
|
device->dev.parent = &spi->dev;
|
||||||
|
mtd_set_of_node(device, spi->dev.of_node);
|
||||||
|
|
||||||
if (revision >= 'c')
|
if (revision >= 'c')
|
||||||
otp_tag = otp_setup(device, revision);
|
otp_tag = otp_setup(device, revision);
|
||||||
@ -665,8 +665,7 @@ static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
|
|||||||
pagesize, otp_tag);
|
pagesize, otp_tag);
|
||||||
spi_set_drvdata(spi, priv);
|
spi_set_drvdata(spi, priv);
|
||||||
|
|
||||||
ppdata.of_node = spi->dev.of_node;
|
err = mtd_device_register(device,
|
||||||
err = mtd_device_parse_register(device, NULL, &ppdata,
|
|
||||||
pdata ? pdata->parts : NULL,
|
pdata ? pdata->parts : NULL,
|
||||||
pdata ? pdata->nr_parts : 0);
|
pdata ? pdata->nr_parts : 0);
|
||||||
|
|
||||||
|
@ -810,7 +810,6 @@ static int spear_smi_setup_banks(struct platform_device *pdev,
|
|||||||
u32 bank, struct device_node *np)
|
u32 bank, struct device_node *np)
|
||||||
{
|
{
|
||||||
struct spear_smi *dev = platform_get_drvdata(pdev);
|
struct spear_smi *dev = platform_get_drvdata(pdev);
|
||||||
struct mtd_part_parser_data ppdata = {};
|
|
||||||
struct spear_smi_flash_info *flash_info;
|
struct spear_smi_flash_info *flash_info;
|
||||||
struct spear_smi_plat_data *pdata;
|
struct spear_smi_plat_data *pdata;
|
||||||
struct spear_snor_flash *flash;
|
struct spear_snor_flash *flash;
|
||||||
@ -855,6 +854,7 @@ static int spear_smi_setup_banks(struct platform_device *pdev,
|
|||||||
flash->mtd.name = flash_devices[flash_index].name;
|
flash->mtd.name = flash_devices[flash_index].name;
|
||||||
|
|
||||||
flash->mtd.dev.parent = &pdev->dev;
|
flash->mtd.dev.parent = &pdev->dev;
|
||||||
|
mtd_set_of_node(&flash->mtd, np);
|
||||||
flash->mtd.type = MTD_NORFLASH;
|
flash->mtd.type = MTD_NORFLASH;
|
||||||
flash->mtd.writesize = 1;
|
flash->mtd.writesize = 1;
|
||||||
flash->mtd.flags = MTD_CAP_NORFLASH;
|
flash->mtd.flags = MTD_CAP_NORFLASH;
|
||||||
@ -881,10 +881,8 @@ static int spear_smi_setup_banks(struct platform_device *pdev,
|
|||||||
count = flash_info->nr_partitions;
|
count = flash_info->nr_partitions;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ppdata.of_node = np;
|
|
||||||
|
|
||||||
ret = mtd_device_parse_register(&flash->mtd, NULL, &ppdata, parts,
|
ret = mtd_device_register(&flash->mtd, parts, count);
|
||||||
count);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&dev->pdev->dev, "Err MTD partition=%d\n", ret);
|
dev_err(&dev->pdev->dev, "Err MTD partition=%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2025,7 +2025,6 @@ static void stfsm_fetch_platform_configs(struct platform_device *pdev)
|
|||||||
static int stfsm_probe(struct platform_device *pdev)
|
static int stfsm_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct mtd_part_parser_data ppdata;
|
|
||||||
struct flash_info *info;
|
struct flash_info *info;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct stfsm *fsm;
|
struct stfsm *fsm;
|
||||||
@ -2035,7 +2034,6 @@ static int stfsm_probe(struct platform_device *pdev)
|
|||||||
dev_err(&pdev->dev, "No DT found\n");
|
dev_err(&pdev->dev, "No DT found\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
ppdata.of_node = np;
|
|
||||||
|
|
||||||
fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL);
|
fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL);
|
||||||
if (!fsm)
|
if (!fsm)
|
||||||
@ -2106,6 +2104,7 @@ static int stfsm_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
fsm->mtd.name = info->name;
|
fsm->mtd.name = info->name;
|
||||||
fsm->mtd.dev.parent = &pdev->dev;
|
fsm->mtd.dev.parent = &pdev->dev;
|
||||||
|
mtd_set_of_node(&fsm->mtd, np);
|
||||||
fsm->mtd.type = MTD_NORFLASH;
|
fsm->mtd.type = MTD_NORFLASH;
|
||||||
fsm->mtd.writesize = 4;
|
fsm->mtd.writesize = 4;
|
||||||
fsm->mtd.writebufsize = fsm->mtd.writesize;
|
fsm->mtd.writebufsize = fsm->mtd.writesize;
|
||||||
@ -2124,7 +2123,7 @@ static int stfsm_probe(struct platform_device *pdev)
|
|||||||
(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
|
(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
|
||||||
fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
|
fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
|
||||||
|
|
||||||
return mtd_device_parse_register(&fsm->mtd, NULL, &ppdata, NULL, 0);
|
return mtd_device_register(&fsm->mtd, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int stfsm_remove(struct platform_device *pdev)
|
static int stfsm_remove(struct platform_device *pdev)
|
||||||
|
@ -110,7 +110,6 @@ ltq_copy_to(struct map_info *map, unsigned long to,
|
|||||||
static int
|
static int
|
||||||
ltq_mtd_probe(struct platform_device *pdev)
|
ltq_mtd_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct mtd_part_parser_data ppdata;
|
|
||||||
struct ltq_mtd *ltq_mtd;
|
struct ltq_mtd *ltq_mtd;
|
||||||
struct cfi_private *cfi;
|
struct cfi_private *cfi;
|
||||||
int err;
|
int err;
|
||||||
@ -161,13 +160,13 @@ ltq_mtd_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ltq_mtd->mtd->dev.parent = &pdev->dev;
|
ltq_mtd->mtd->dev.parent = &pdev->dev;
|
||||||
|
mtd_set_of_node(ltq_mtd->mtd, pdev->dev.of_node);
|
||||||
|
|
||||||
cfi = ltq_mtd->map->fldrv_priv;
|
cfi = ltq_mtd->map->fldrv_priv;
|
||||||
cfi->addr_unlock1 ^= 1;
|
cfi->addr_unlock1 ^= 1;
|
||||||
cfi->addr_unlock2 ^= 1;
|
cfi->addr_unlock2 ^= 1;
|
||||||
|
|
||||||
ppdata.of_node = pdev->dev.of_node;
|
err = mtd_device_register(ltq_mtd->mtd, NULL, 0);
|
||||||
err = mtd_device_parse_register(ltq_mtd->mtd, NULL, &ppdata, NULL, 0);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "failed to add partitions\n");
|
dev_err(&pdev->dev, "failed to add partitions\n");
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
@ -166,7 +166,6 @@ static int of_flash_probe(struct platform_device *dev)
|
|||||||
int reg_tuple_size;
|
int reg_tuple_size;
|
||||||
struct mtd_info **mtd_list = NULL;
|
struct mtd_info **mtd_list = NULL;
|
||||||
resource_size_t res_size;
|
resource_size_t res_size;
|
||||||
struct mtd_part_parser_data ppdata;
|
|
||||||
bool map_indirect;
|
bool map_indirect;
|
||||||
const char *mtd_name = NULL;
|
const char *mtd_name = NULL;
|
||||||
|
|
||||||
@ -310,13 +309,13 @@ static int of_flash_probe(struct platform_device *dev)
|
|||||||
if (err)
|
if (err)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
ppdata.of_node = dp;
|
mtd_set_of_node(info->cmtd, dp);
|
||||||
part_probe_types = of_get_probes(dp);
|
part_probe_types = of_get_probes(dp);
|
||||||
if (!part_probe_types) {
|
if (!part_probe_types) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata,
|
mtd_device_parse_register(info->cmtd, part_probe_types, NULL,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
of_free_probes(part_probe_types);
|
of_free_probes(part_probe_types);
|
||||||
|
|
||||||
|
@ -614,7 +614,6 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
|||||||
struct onenand_chip *this;
|
struct onenand_chip *this;
|
||||||
int r;
|
int r;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct mtd_part_parser_data ppdata = {};
|
|
||||||
|
|
||||||
pdata = dev_get_platdata(&pdev->dev);
|
pdata = dev_get_platdata(&pdev->dev);
|
||||||
if (pdata == NULL) {
|
if (pdata == NULL) {
|
||||||
@ -713,6 +712,7 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
|||||||
c->mtd.priv = &c->onenand;
|
c->mtd.priv = &c->onenand;
|
||||||
|
|
||||||
c->mtd.dev.parent = &pdev->dev;
|
c->mtd.dev.parent = &pdev->dev;
|
||||||
|
mtd_set_of_node(&c->mtd, pdata->of_node);
|
||||||
|
|
||||||
this = &c->onenand;
|
this = &c->onenand;
|
||||||
if (c->dma_channel >= 0) {
|
if (c->dma_channel >= 0) {
|
||||||
@ -743,10 +743,8 @@ static int omap2_onenand_probe(struct platform_device *pdev)
|
|||||||
if ((r = onenand_scan(&c->mtd, 1)) < 0)
|
if ((r = onenand_scan(&c->mtd, 1)) < 0)
|
||||||
goto err_release_regulator;
|
goto err_release_regulator;
|
||||||
|
|
||||||
ppdata.of_node = pdata->of_node;
|
r = mtd_device_register(&c->mtd, pdata ? pdata->parts : NULL,
|
||||||
r = mtd_device_parse_register(&c->mtd, NULL, &ppdata,
|
pdata ? pdata->nr_parts : 0);
|
||||||
pdata ? pdata->parts : NULL,
|
|
||||||
pdata ? pdata->nr_parts : 0);
|
|
||||||
if (r)
|
if (r)
|
||||||
goto err_release_onenand;
|
goto err_release_onenand;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user