Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2206ef1c authored by Dmitry Eremin-Solenikov's avatar Dmitry Eremin-Solenikov
Browse files

[MTD] sharpsl_nand: make drvdata non-static



Merge mtd_info and nand_chip info special struct and
make it drvdata instead of plain static variable.

Signed-off-by: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
parent 26615249
Loading
Loading
Loading
Loading
+29 −24
Original line number Original line Diff line number Diff line
@@ -26,6 +26,11 @@
#include <mach/hardware.h>
#include <mach/hardware.h>
#include <asm/mach-types.h>
#include <asm/mach-types.h>


struct sharpsl_nand {
	struct mtd_info		mtd;
	struct nand_chip	chip;
};

static void __iomem *sharpsl_io_base;
static void __iomem *sharpsl_io_base;


/* register offset */
/* register offset */
@@ -45,11 +50,6 @@ static void __iomem *sharpsl_io_base;
#define FLCLE		(1 << 1)
#define FLCLE		(1 << 1)
#define FLCE0		(1 << 0)
#define FLCE0		(1 << 0)


/*
 * MTD structure for SharpSL
 */
static struct mtd_info *sharpsl_mtd = NULL;

/*
/*
 * Define partitions for flash device
 * Define partitions for flash device
 */
 */
@@ -157,10 +157,11 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
	struct mtd_partition *sharpsl_partition_info;
	struct mtd_partition *sharpsl_partition_info;
	struct resource *r;
	struct resource *r;
	int err = 0;
	int err = 0;
	struct sharpsl_nand *sharpsl;


	/* Allocate memory for MTD device structure and private data */
	/* Allocate memory for MTD device structure and private data */
	sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
	sharpsl = kzalloc(sizeof(struct sharpsl_nand), GFP_KERNEL);
	if (!sharpsl_mtd) {
	if (!sharpsl) {
		printk("Unable to allocate SharpSL NAND MTD device structure.\n");
		printk("Unable to allocate SharpSL NAND MTD device structure.\n");
		return -ENOMEM;
		return -ENOMEM;
	}
	}
@@ -176,20 +177,18 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
	sharpsl_io_base = ioremap(r->start, resource_size(r));
	sharpsl_io_base = ioremap(r->start, resource_size(r));
	if (!sharpsl_io_base) {
	if (!sharpsl_io_base) {
		printk("ioremap to access Sharp SL NAND chip failed\n");
		printk("ioremap to access Sharp SL NAND chip failed\n");
		kfree(sharpsl_mtd);
		err = -EIO;
		return -EIO;
		goto err_ioremap;
	}
	}


	/* Get pointer to private data */
	/* Get pointer to private data */
	this = (struct nand_chip *)(&sharpsl_mtd[1]);
	this = (struct nand_chip *)(&sharpsl->chip);

	/* Initialize structures */
	memset(sharpsl_mtd, 0, sizeof(struct mtd_info));
	memset(this, 0, sizeof(struct nand_chip));


	/* Link the private data with the MTD structure */
	/* Link the private data with the MTD structure */
	sharpsl_mtd->priv = this;
	sharpsl->mtd.priv = this;
	sharpsl_mtd->owner = THIS_MODULE;
	sharpsl->mtd.owner = THIS_MODULE;

	platform_set_drvdata(pdev, sharpsl);


	/*
	/*
	 * PXA initialize
	 * PXA initialize
@@ -218,16 +217,17 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
	this->ecc.correct = nand_correct_data;
	this->ecc.correct = nand_correct_data;


	/* Scan to find existence of the device */
	/* Scan to find existence of the device */
	err = nand_scan(sharpsl_mtd, 1);
	err = nand_scan(&sharpsl->mtd, 1);
	if (err) {
	if (err) {
		platform_set_drvdata(pdev, NULL);
		iounmap(sharpsl_io_base);
		iounmap(sharpsl_io_base);
		kfree(sharpsl_mtd);
		kfree(sharpsl);
		return err;
		return err;
	}
	}


	/* Register the partitions */
	/* Register the partitions */
	sharpsl_mtd->name = "sharpsl-nand";
	sharpsl->mtd.name = "sharpsl-nand";
	nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0);
	nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0);


	if (nr_partitions <= 0) {
	if (nr_partitions <= 0) {
		nr_partitions = DEFAULT_NUM_PARTITIONS;
		nr_partitions = DEFAULT_NUM_PARTITIONS;
@@ -247,13 +247,14 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
		}
		}
	}
	}


	add_mtd_partitions(sharpsl_mtd, sharpsl_partition_info, nr_partitions);
	add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions);


	/* Return happy */
	/* Return happy */
	return 0;
	return 0;


err_ioremap:
err_get_res:
err_get_res:
	kfree(sharpsl_mtd);
	kfree(sharpsl);
	return err;
	return err;
}
}


@@ -262,13 +263,17 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
 */
 */
static int __devexit sharpsl_nand_remove(struct platform_device *pdev)
static int __devexit sharpsl_nand_remove(struct platform_device *pdev)
{
{
	struct sharpsl_nand *sharpsl = platform_get_drvdata(pdev);

	/* Release resources, unregister device */
	/* Release resources, unregister device */
	nand_release(sharpsl_mtd);
	nand_release(&sharpsl->mtd);

	platform_set_drvdata(pdev, NULL);


	iounmap(sharpsl_io_base);
	iounmap(sharpsl_io_base);


	/* Free the MTD device structure */
	/* Free the MTD device structure */
	kfree(sharpsl_mtd);
	kfree(sharpsl);


	return 0;
	return 0;
}
}