Re: [PATCH] AT91RM9200 NAND support

Thomas Gleixner
2006-06-20T07:08:01Z

On Tue, 2006-06-20 at 08:54 +0200, Andrew Victor wrote:
> This is a NAND drivers for the Atmel AT91RM9200 SoC.
>
> (No changes since it was committed to the MTD CVS on 21/02/2006)

As I pointed out in my previous mail, the driver needs to be updated to
work with the latest changes in the nand driver.

> +/*
> + * Hardware specific access to control-lines
> + */
> +static void at91_nand_hwcontrol(struct mtd_info *mtd, int cmd)

This function needs to be adjusted.

> +#ifdef CONFIG_MTD_PARTITIONS
> + if (host->board->partition_info)
> + partitions = host->board->partition_info(mtd->size, &num_partitions);
> +
> + if ((!partitions) || (num_partitions == 0)) {
> + printk(KERN_ERR "at91_nand: No parititions defined, or unsupported device.\n");
> + res = ENXIO;
> + goto out;
> + }
> +
> + res = add_mtd_partitions(mtd, partitions, num_partitions);
> +#else
> + res = add_mtd_device(mtd);
> +#endif
> +
> +out:

If you error out after a sucessful nand_scan() - i.e. chip was detected
- you have to call nand_release(). nand_scan() allocates memory which
gets freed inside nand_release()

> + if (res) {
> + at91_nand_disable(host);
> + platform_set_drvdata(pdev, NULL);
> +
> + iounmap(host->io_base);
> + kfree(host);
> + }
> +
> + return res;
> +}
> +
> +/*
> + * Remove a NAND device.
> + */
> +static int __devexit at91_nand_remove(struct platform_device *pdev)
> +{
> + struct at91_nand_host *host = platform_get_drvdata(pdev);
> + struct mtd_info *mtd = &host->mtd;
> +
> + del_mtd_partitions(mtd);
> + del_mtd_device(mtd);

nand_release() does this and you have to call it - otherwise you get a
memory leak !

tglx