summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/raw/ams-delta.c
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jmkrzyszt@gmail.com>2020-02-12 01:39:17 +0100
committerMiquel Raynal <miquel.raynal@bootlin.com>2020-03-09 14:51:01 +0100
commit1698ea32133a884d6def357f90265e59799242e9 (patch)
tree040b52230030656eb9aade9e567e47d1868d30d3 /drivers/mtd/nand/raw/ams-delta.c
parentmtd: rawnand: ams-delta: Write protect device during probe (diff)
downloadlinux-1698ea32133a884d6def357f90265e59799242e9.tar.xz
linux-1698ea32133a884d6def357f90265e59799242e9.zip
mtd: rawnand: ams-delta: Use struct gpio_nand_platdata
In order to be able to move the hardcoded Amstrad Delta partition info from the driver code to the board file, reuse gpio_nand_platdata structure owned by "gpio-nand" driver and try to obtain information on device partitions from device platform data. Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20200212003929.6682-3-jmkrzyszt@gmail.com
Diffstat (limited to 'drivers/mtd/nand/raw/ams-delta.c')
-rw-r--r--drivers/mtd/nand/raw/ams-delta.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index 2501cfe00f43..fbab7cc14607 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -19,6 +19,7 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand-gpio.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
#include <linux/platform_device.h>
@@ -220,12 +221,20 @@ static const struct nand_controller_ops ams_delta_ops = {
*/
static int ams_delta_init(struct platform_device *pdev)
{
+ struct gpio_nand_platdata *pdata = dev_get_platdata(&pdev->dev);
+ const struct mtd_partition *partitions = partition_info;
+ int num_partitions = ARRAY_SIZE(partition_info);
struct ams_delta_nand *priv;
struct nand_chip *this;
struct mtd_info *mtd;
struct gpio_descs *data_gpiods;
int err = 0;
+ if (pdata) {
+ partitions = pdata->parts;
+ num_partitions = pdata->num_parts;
+ }
+
/* Allocate memory for MTD device structure and private data */
priv = devm_kzalloc(&pdev->dev, sizeof(struct ams_delta_nand),
GFP_KERNEL);
@@ -326,8 +335,7 @@ static int ams_delta_init(struct platform_device *pdev)
return err;
/* Register the partitions */
- err = mtd_device_register(mtd, partition_info,
- ARRAY_SIZE(partition_info));
+ err = mtd_device_register(mtd, partitions, num_partitions);
if (err)
goto err_nand_cleanup;