From 03dd4cb26d967f9588437b0fc9cc0e8353322bb7 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 25 Mar 2016 03:53:42 -0300 Subject: Linux-libre 4.5-gnu --- drivers/mtd/devices/m25p80.c | 44 ++++++++++++++----------------------- drivers/mtd/devices/mtd_dataflash.c | 5 ++--- drivers/mtd/devices/spear_smi.c | 6 ++--- drivers/mtd/devices/st_spi_fsm.c | 5 ++--- 4 files changed, 22 insertions(+), 38 deletions(-) (limited to 'drivers/mtd/devices') diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index fe9ceb7b5..c9c3b7fa3 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -152,22 +152,6 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len, return 0; } -static int m25p80_erase(struct spi_nor *nor, loff_t offset) -{ - struct m25p *flash = nor->priv; - - dev_dbg(nor->dev, "%dKiB at 0x%08x\n", - flash->spi_nor.mtd.erasesize / 1024, (u32)offset); - - /* Set up command buffer. */ - flash->command[0] = nor->erase_opcode; - m25p_addr2cmd(nor, offset, flash->command); - - spi_write(flash->spi, flash->command, m25p_cmdsz(nor)); - - return 0; -} - /* * board specific setup should have ensured the SPI clock used here * matches what the READ command supports, at least until this driver @@ -175,12 +159,11 @@ static int m25p80_erase(struct spi_nor *nor, loff_t offset) */ static int m25p_probe(struct spi_device *spi) { - struct mtd_part_parser_data ppdata; struct flash_platform_data *data; struct m25p *flash; struct spi_nor *nor; enum read_mode mode = SPI_NOR_NORMAL; - char *flash_name = NULL; + char *flash_name; int ret; data = dev_get_platdata(&spi->dev); @@ -194,12 +177,11 @@ static int m25p_probe(struct spi_device *spi) /* install the hooks */ nor->read = m25p80_read; nor->write = m25p80_write; - nor->erase = m25p80_erase; nor->write_reg = m25p80_write_reg; nor->read_reg = m25p80_read_reg; nor->dev = &spi->dev; - nor->flash_node = spi->dev.of_node; + spi_nor_set_flash_node(nor, spi->dev.of_node); nor->priv = flash; spi_set_drvdata(spi, flash); @@ -220,6 +202,8 @@ static int m25p_probe(struct spi_device *spi) */ if (data && data->type) flash_name = data->type; + else if (!strcmp(spi->modalias, "spi-nor")) + flash_name = NULL; /* auto-detect */ else flash_name = spi->modalias; @@ -227,11 +211,8 @@ static int m25p_probe(struct spi_device *spi) if (ret) return ret; - ppdata.of_node = spi->dev.of_node; - - return mtd_device_parse_register(&nor->mtd, NULL, &ppdata, - data ? data->parts : NULL, - data ? data->nr_parts : 0); + return mtd_device_register(&nor->mtd, data ? data->parts : NULL, + data ? data->nr_parts : 0); } @@ -256,15 +237,22 @@ static int m25p_remove(struct spi_device *spi) * keep them available as module aliases for existing platforms. */ static const struct spi_device_id m25p_ids[] = { + /* + * Allow non-DT platform devices to bind to the "spi-nor" modalias, and + * hack around the fact that the SPI core does not provide uevent + * matching for .of_match_table + */ + {"spi-nor"}, + /* * Entries not used in DTs that should be safe to drop after replacing - * them with "nor-jedec" in platform data. + * them with "spi-nor" in platform data. */ {"s25sl064a"}, {"w25x16"}, {"m25p10"}, {"m25px64"}, /* - * Entries that were used in DTs without "nor-jedec" fallback and should - * be kept for backward compatibility. + * Entries that were used in DTs without "jedec,spi-nor" fallback and + * should be kept for backward compatibility. */ {"at25df321a"}, {"at25df641"}, {"at26df081a"}, {"mr25h256"}, diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index e4a88715a..f9e9bd1cf 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c @@ -624,7 +624,6 @@ static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages, { struct dataflash *priv; struct mtd_info *device; - struct mtd_part_parser_data ppdata; struct flash_platform_data *pdata = dev_get_platdata(&spi->dev); char *otp_tag = ""; 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->dev.parent = &spi->dev; + mtd_set_of_node(device, spi->dev.of_node); if (revision >= 'c') 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); spi_set_drvdata(spi, priv); - ppdata.of_node = spi->dev.of_node; - err = mtd_device_parse_register(device, NULL, &ppdata, + err = mtd_device_register(device, pdata ? pdata->parts : NULL, pdata ? pdata->nr_parts : 0); diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index 64c745834..dd5069876 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c @@ -810,7 +810,6 @@ static int spear_smi_setup_banks(struct platform_device *pdev, u32 bank, struct device_node *np) { struct spear_smi *dev = platform_get_drvdata(pdev); - struct mtd_part_parser_data ppdata = {}; struct spear_smi_flash_info *flash_info; struct spear_smi_plat_data *pdata; 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.dev.parent = &pdev->dev; + mtd_set_of_node(&flash->mtd, np); flash->mtd.type = MTD_NORFLASH; flash->mtd.writesize = 1; 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; } #endif - ppdata.of_node = np; - ret = mtd_device_parse_register(&flash->mtd, NULL, &ppdata, parts, - count); + ret = mtd_device_register(&flash->mtd, parts, count); if (ret) { dev_err(&dev->pdev->dev, "Err MTD partition=%d\n", ret); return ret; diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 3060025c8..5454b4113 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -2025,7 +2025,6 @@ boot_device_fail: static int stfsm_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct mtd_part_parser_data ppdata; struct flash_info *info; struct resource *res; struct stfsm *fsm; @@ -2035,7 +2034,6 @@ static int stfsm_probe(struct platform_device *pdev) dev_err(&pdev->dev, "No DT found\n"); return -EINVAL; } - ppdata.of_node = np; fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL); if (!fsm) @@ -2106,6 +2104,7 @@ static int stfsm_probe(struct platform_device *pdev) fsm->mtd.name = info->name; fsm->mtd.dev.parent = &pdev->dev; + mtd_set_of_node(&fsm->mtd, np); fsm->mtd.type = MTD_NORFLASH; fsm->mtd.writesize = 4; 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), 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) -- cgit v1.2.3-54-g00ecf