Skip to content

Commit

Permalink
Merge tag 'mtd/for-5.20' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/mtd/linux

Pull MTD updates from Richard Weinberger:
 "MTD core changes:

   - Dynamic partition support

   - Fix deadlock in sm_ftl

   - Various refcount fixes in maps, partitions and parser code

   - Integer overflow fixes in mtdchar

   - Support for Sercomm partitions

  NAND driver changes:

   - Clockrate fix for arasan

   - Add ATO25D1GA support

   - Double free fix for meson driver

   - Fix probe/remove methods in cafe NAND

   - Support unprotected spare data pages in qcom_nandc

  SPI NOR core changes:

   - move SECT_4K_PMC flag out of the core as it's a vendor specific
     flag

   - s/addr_width/addr_nbytes/g: address width means the number of IO
     lines used for the address, whereas in the code it is used as the
     number of address bytes.

   - do not change nor->addr_nbytes at SFDP parsing time. At the SFDP
     parsing time we should not change members of struct spi_nor, but
     instead fill members of struct spi_nor_flash_parameters which could
     later on be used by the callers.

   - track flash's internal address mode so that we can use 4B opcodes
     together with opcodes that don't have a 4B opcode correspondent.

  SPI NOR manufacturer drivers changes:

   - esmt: Rename "f25l32qa" flash name to "f25l32qa-2s".

   - micron-st: Skip FSR reading if SPI controller does not support it
     to allow flashes that support FSR to work even when attached to
     such SPI controllers.

   - spansion: Add s25hl-t/s25hs-t IDs and fixups"

* tag 'mtd/for-5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux: (53 commits)
  mtd: core: check partition before dereference
  mtd: spi-nor: fix spi_nor_spimem_setup_op() call in spi_nor_erase_{sector,chip}()
  mtd: spi-nor: spansion: Add s25hl-t/s25hs-t IDs and fixups
  mtd: spi-nor: spansion: Add local function to discover page size
  mtd: spi-nor: core: Track flash's internal address mode
  mtd: spi-nor: core: Return error code from set_4byte_addr_mode()
  mtd: spi-nor: Do not change nor->addr_nbytes at SFDP parsing time
  mtd: spi-nor: core: Shrink the storage size of the flash_info's addr_nbytes
  mtd: spi-nor: s/addr_width/addr_nbytes
  mtd: spi-nor: esmt: Use correct name of f25l32qa
  mtd: spi-nor: micron-st: Skip FSR reading if SPI controller does not support it
  MAINTAINERS: Use my kernel.org email
  mtd: rawnand: arasan: Fix clock rate in NV-DDR
  mtd: rawnand: arasan: Update NAND bus clock instead of system clock
  mtd: core: introduce of support for dynamic partitions
  dt-bindings: mtd: partitions: add additional example for qcom,smem-part
  dt-bindings: mtd: partitions: support label/name only partition
  mtd: spi-nor: move SECT_4K_PMC special handling
  mtd: dataflash: Add SPI ID table
  mtd: hyperbus: rpc-if: Fix RPM imbalance in probe error path
  ...
  • Loading branch information
torvalds committed Aug 5, 2022
2 parents 79b7e67 + 7ec4cdb commit 74cae21
Show file tree
Hide file tree
Showing 50 changed files with 1,108 additions and 250 deletions.
2 changes: 0 additions & 2 deletions Documentation/devicetree/bindings/mtd/mxc-nand.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@ examples:
compatible = "fsl,imx27-nand";
reg = <0xd8000000 0x1000>;
interrupts = <29>;
nand-bus-width = <8>;
nand-ecc-mode = "hw";
};
20 changes: 18 additions & 2 deletions Documentation/devicetree/bindings/mtd/partitions/partition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ description: |
relative offset and size specified. Depending on partition function extra
properties can be used.
A partition may be dynamically allocated by a specific parser at runtime.
In this specific case, a specific suffix is required to the node name.
Everything after 'partition-' will be used as the partition name to compare
with the one dynamically allocated by the specific parser.
If the partition contains invalid char a label can be provided that will
be used instead of the node name to make the comparison.
This is used to assign an OF node to the dynamiccally allocated partition
so that subsystem like NVMEM can provide an OF node and declare NVMEM cells.
The OF node will be assigned only if the partition label declared match the
one assigned by the parser at runtime.
maintainers:
- Rafał Miłecki <[email protected]>

Expand Down Expand Up @@ -41,7 +52,12 @@ properties:
immune to paired-pages corruptions
type: boolean

required:
- reg
if:
not:
required: [ reg ]
then:
properties:
$nodename:
pattern: '^partition-.*$'

additionalProperties: true
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ properties:
compatible:
const: qcom,smem-part

patternProperties:
"^partition-[0-9a-z]+$":
$ref: partition.yaml#

required:
- compatible

Expand All @@ -31,3 +35,26 @@ examples:
compatible = "qcom,smem-part";
};
};
- |
/* Example declaring dynamic partition */
flash {
partitions {
compatible = "qcom,smem-part";
partition-art {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
label = "0:art";
macaddr_art_0: macaddr@0 {
reg = <0x0 0x6>;
};
macaddr_art_6: macaddr@6 {
reg = <0x6 0x6>;
};
};
};
};
27 changes: 27 additions & 0 deletions Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ allOf:
- const: rx
- const: cmd

- if:
properties:
compatible:
contains:
enum:
- qcom,ipq806x-nand

then:
properties:
qcom,boot-partitions:
$ref: /schemas/types.yaml#/definitions/uint32-matrix
items:
items:
- description: offset
- description: size
description:
Boot partition use a different layout where the 4 bytes of spare
data are not protected by ECC. Use this to declare these special
partitions by defining first the offset and then the size.

It's in the form of <offset1 size1 offset2 size2 offset3 ...>
and should be declared in ascending order.

Refer to the ipq8064 example on how to use this special binding.

required:
- compatible
- reg
Expand Down Expand Up @@ -135,6 +160,8 @@ examples:
nand-ecc-strength = <4>;
nand-bus-width = <8>;
qcom,boot-partitions = <0x0 0x58a0000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -19130,7 +19130,7 @@ F: drivers/pinctrl/spear/

SPI NOR SUBSYSTEM
M: Tudor Ambarus <[email protected]>
M: Pratyush Yadav <[email protected]>
M: Pratyush Yadav <[email protected]>
R: Michael Walle <[email protected]>
L: [email protected]
S: Maintained
Expand Down
8 changes: 8 additions & 0 deletions drivers/mtd/devices/mtd_dataflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ static const struct of_device_id dataflash_dt_ids[] = {
MODULE_DEVICE_TABLE(of, dataflash_dt_ids);
#endif

static const struct spi_device_id dataflash_spi_ids[] = {
{ .name = "at45", },
{ .name = "dataflash", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(spi, dataflash_spi_ids);

/* ......................................................................... */

/*
Expand Down Expand Up @@ -936,6 +943,7 @@ static struct spi_driver dataflash_driver = {

.probe = dataflash_probe,
.remove = dataflash_remove,
.id_table = dataflash_spi_ids,

/* FIXME: investigate suspend and resume... */
};
Expand Down
4 changes: 3 additions & 1 deletion drivers/mtd/devices/powernv_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ static int powernv_flash_release(struct platform_device *pdev)
struct powernv_flash *data = dev_get_drvdata(&(pdev->dev));

/* All resources should be freed automatically */
return mtd_device_unregister(&(data->mtd));
WARN_ON(mtd_device_unregister(&data->mtd));

return 0;
}

static const struct of_device_id powernv_flash_match[] = {
Expand Down
10 changes: 2 additions & 8 deletions drivers/mtd/devices/spear_smi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,13 +1045,9 @@ static int spear_smi_remove(struct platform_device *pdev)
{
struct spear_smi *dev;
struct spear_snor_flash *flash;
int ret, i;
int i;

dev = platform_get_drvdata(pdev);
if (!dev) {
dev_err(&pdev->dev, "dev is null\n");
return -ENODEV;
}

/* clean up for all nor flash */
for (i = 0; i < dev->num_flashes; i++) {
Expand All @@ -1060,9 +1056,7 @@ static int spear_smi_remove(struct platform_device *pdev)
continue;

/* clean up mtd stuff */
ret = mtd_device_unregister(&flash->mtd);
if (ret)
dev_err(&pdev->dev, "error removing mtd\n");
WARN_ON(mtd_device_unregister(&flash->mtd));
}

clk_disable_unprepare(dev->clk);
Expand Down
23 changes: 12 additions & 11 deletions drivers/mtd/devices/st_spi_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2084,15 +2084,12 @@ static int stfsm_probe(struct platform_device *pdev)
* Configure READ/WRITE/ERASE sequences according to platform and
* device flags.
*/
if (info->config) {
if (info->config)
ret = info->config(fsm);
if (ret)
goto err_clk_unprepare;
} else {
else
ret = stfsm_prepare_rwe_seqs_default(fsm);
if (ret)
goto err_clk_unprepare;
}
if (ret)
goto err_clk_unprepare;

fsm->mtd.name = info->name;
fsm->mtd.dev.parent = &pdev->dev;
Expand All @@ -2115,20 +2112,24 @@ 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_register(&fsm->mtd, NULL, 0);

ret = mtd_device_register(&fsm->mtd, NULL, 0);
if (ret) {
err_clk_unprepare:
clk_disable_unprepare(fsm->clk);
clk_disable_unprepare(fsm->clk);
}

return ret;
}

static int stfsm_remove(struct platform_device *pdev)
{
struct stfsm *fsm = platform_get_drvdata(pdev);

WARN_ON(mtd_device_unregister(&fsm->mtd));

clk_disable_unprepare(fsm->clk);

return mtd_device_unregister(&fsm->mtd);
return 0;
}

#ifdef CONFIG_PM_SLEEP
Expand Down
6 changes: 3 additions & 3 deletions drivers/mtd/hyperbus/hbmc-am654.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,16 @@ static int am654_hbmc_remove(struct platform_device *pdev)
{
struct am654_hbmc_priv *priv = platform_get_drvdata(pdev);
struct am654_hbmc_device_priv *dev_priv = priv->hbdev.priv;
int ret;

ret = hyperbus_unregister_device(&priv->hbdev);
hyperbus_unregister_device(&priv->hbdev);

if (priv->mux_ctrl)
mux_control_deselect(priv->mux_ctrl);

if (dev_priv->rx_chan)
dma_release_channel(dev_priv->rx_chan);

return ret;
return 0;
}

static const struct of_device_id am654_hbmc_dt_ids[] = {
Expand Down
8 changes: 2 additions & 6 deletions drivers/mtd/hyperbus/hyperbus-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,12 @@ int hyperbus_register_device(struct hyperbus_device *hbdev)
}
EXPORT_SYMBOL_GPL(hyperbus_register_device);

int hyperbus_unregister_device(struct hyperbus_device *hbdev)
void hyperbus_unregister_device(struct hyperbus_device *hbdev)
{
int ret = 0;

if (hbdev && hbdev->mtd) {
ret = mtd_device_unregister(hbdev->mtd);
WARN_ON(mtd_device_unregister(hbdev->mtd));
map_destroy(hbdev->mtd);
}

return ret;
}
EXPORT_SYMBOL_GPL(hyperbus_unregister_device);

Expand Down
13 changes: 9 additions & 4 deletions drivers/mtd/hyperbus/rpc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static int rpcif_hb_probe(struct platform_device *pdev)

error = rpcif_hw_init(&hyperbus->rpc, true);
if (error)
return error;
goto out_disable_rpm;

hyperbus->hbdev.map.size = hyperbus->rpc.size;
hyperbus->hbdev.map.virt = hyperbus->rpc.dirmap;
Expand All @@ -145,19 +145,24 @@ static int rpcif_hb_probe(struct platform_device *pdev)
hyperbus->hbdev.np = of_get_next_child(pdev->dev.parent->of_node, NULL);
error = hyperbus_register_device(&hyperbus->hbdev);
if (error)
rpcif_disable_rpm(&hyperbus->rpc);
goto out_disable_rpm;

return 0;

out_disable_rpm:
rpcif_disable_rpm(&hyperbus->rpc);
return error;
}

static int rpcif_hb_remove(struct platform_device *pdev)
{
struct rpcif_hyperbus *hyperbus = platform_get_drvdata(pdev);
int error = hyperbus_unregister_device(&hyperbus->hbdev);

hyperbus_unregister_device(&hyperbus->hbdev);

rpcif_disable_rpm(&hyperbus->rpc);

return error;
return 0;
}

static struct platform_driver rpcif_platform_driver = {
Expand Down
4 changes: 3 additions & 1 deletion drivers/mtd/lpddr/lpddr2_nvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
*/
static int lpddr2_nvm_remove(struct platform_device *pdev)
{
return mtd_device_unregister(dev_get_drvdata(&pdev->dev));
WARN_ON(mtd_device_unregister(dev_get_drvdata(&pdev->dev)));

return 0;
}

/* Initialize platform_driver data structure for lpddr2_nvm */
Expand Down
13 changes: 3 additions & 10 deletions drivers/mtd/maps/physmap-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,12 @@ static int physmap_flash_remove(struct platform_device *dev)
{
struct physmap_flash_info *info;
struct physmap_flash_data *physmap_data;
int i, err = 0;
int i;

info = platform_get_drvdata(dev);
if (!info) {
err = -EINVAL;
goto out;
}

if (info->cmtd) {
err = mtd_device_unregister(info->cmtd);
if (err)
goto out;
WARN_ON(mtd_device_unregister(info->cmtd));

if (info->cmtd != info->mtds[0])
mtd_concat_destroy(info->cmtd);
Expand All @@ -92,10 +86,9 @@ static int physmap_flash_remove(struct platform_device *dev)
if (physmap_data && physmap_data->exit)
physmap_data->exit(dev);

out:
pm_runtime_put(&dev->dev);
pm_runtime_disable(&dev->dev);
return err;
return 0;
}

static void physmap_set_vpp(struct map_info *map, int state)
Expand Down
2 changes: 2 additions & 0 deletions drivers/mtd/maps/physmap-versatile.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static int ap_flash_init(struct platform_device *pdev)
return -ENODEV;
}
ebi_base = of_iomap(ebi, 0);
of_node_put(ebi);
if (!ebi_base)
return -ENODEV;

Expand Down Expand Up @@ -207,6 +208,7 @@ int of_flash_probe_versatile(struct platform_device *pdev,

versatile_flashprot = (enum versatile_flashprot)devid->data;
rmap = syscon_node_to_regmap(sysnp);
of_node_put(sysnp);
if (IS_ERR(rmap))
return PTR_ERR(rmap);

Expand Down
Loading

0 comments on commit 74cae21

Please sign in to comment.