Skip to content

Commit

Permalink
mtd: rawnand: ams-delta: Use struct gpio_nand_platdata
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Miquel Raynal <[email protected]>
Link: https://lore.kernel.org/linux-mtd/[email protected]
  • Loading branch information
jkrzyszt authored and miquelraynal committed Mar 9, 2020
1 parent 91a1abf commit 1698ea3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions drivers/mtd/nand/raw/ams-delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 1698ea3

Please sign in to comment.