Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: onenand: make onenand/generic.c more generic

Remove the ARM dependency from the generic "onenand" platform device
driver. This change makes the driver useful for other architectures as
well. Needed for the SuperH kfr2r09 board.

Apart from the obvious Kconfig bits, the most important change is the move
away from ARM specific includes and platform data. Together with this
change the only in-tree board code gets an update, and the driver name is
also changed gracefully break potential out of tree drivers.

The driver is also updated to allow NULL as platform data together with a
few changes to make use of resource_size() and dev_name().

Signed-off-by: Magnus Damm <damm@igel.co.jp>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kyungmin Park <kmpark@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Magnus Damm and committed by
David Woodhouse
778dbcc1 f33dabbe

+24 -13
+2 -2
arch/arm/mach-omap2/board-apollon.c
··· 87 87 }, 88 88 }; 89 89 90 - static struct flash_platform_data apollon_flash_data = { 90 + static struct onenand_platform_data apollon_flash_data = { 91 91 .parts = apollon_partitions, 92 92 .nr_parts = ARRAY_SIZE(apollon_partitions), 93 93 }; ··· 99 99 }; 100 100 101 101 static struct platform_device apollon_onenand_device = { 102 - .name = "onenand", 102 + .name = "onenand-flash", 103 103 .id = -1, 104 104 .dev = { 105 105 .platform_data = &apollon_flash_data,
-1
drivers/mtd/onenand/Kconfig
··· 24 24 25 25 config MTD_ONENAND_GENERIC 26 26 tristate "OneNAND Flash device via platform device driver" 27 - depends on ARM 28 27 help 29 28 Support for OneNAND flash via platform device driver. 30 29
+14 -10
drivers/mtd/onenand/generic.c
··· 19 19 #include <linux/mtd/mtd.h> 20 20 #include <linux/mtd/onenand.h> 21 21 #include <linux/mtd/partitions.h> 22 - 23 22 #include <asm/io.h> 24 - #include <asm/mach/flash.h> 25 23 26 - #define DRIVER_NAME "onenand" 27 - 24 + /* 25 + * Note: Driver name and platform data format have been updated! 26 + * 27 + * This version of the driver is named "onenand-flash" and takes struct 28 + * onenand_platform_data as platform data. The old ARM-specific version 29 + * with the name "onenand" used to take struct flash_platform_data. 30 + */ 31 + #define DRIVER_NAME "onenand-flash" 28 32 29 33 #ifdef CONFIG_MTD_PARTITIONS 30 34 static const char *part_probes[] = { "cmdlinepart", NULL, }; ··· 43 39 static int __devinit generic_onenand_probe(struct platform_device *pdev) 44 40 { 45 41 struct onenand_info *info; 46 - struct flash_platform_data *pdata = pdev->dev.platform_data; 42 + struct onenand_platform_data *pdata = pdev->dev.platform_data; 47 43 struct resource *res = pdev->resource; 48 - unsigned long size = res->end - res->start + 1; 44 + unsigned long size = resource_size(res); 49 45 int err; 50 46 51 47 info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); 52 48 if (!info) 53 49 return -ENOMEM; 54 50 55 - if (!request_mem_region(res->start, size, pdev->dev.driver->name)) { 51 + if (!request_mem_region(res->start, size, dev_name(&pdev->dev))) { 56 52 err = -EBUSY; 57 53 goto out_free_info; 58 54 } ··· 63 59 goto out_release_mem_region; 64 60 } 65 61 66 - info->onenand.mmcontrol = pdata->mmcontrol; 62 + info->onenand.mmcontrol = pdata ? pdata->mmcontrol : 0; 67 63 info->onenand.irq = platform_get_irq(pdev, 0); 68 64 69 65 info->mtd.name = dev_name(&pdev->dev); ··· 79 75 err = parse_mtd_partitions(&info->mtd, part_probes, &info->parts, 0); 80 76 if (err > 0) 81 77 add_mtd_partitions(&info->mtd, info->parts, err); 82 - else if (err <= 0 && pdata->parts) 78 + else if (err <= 0 && pdata && pdata->parts) 83 79 add_mtd_partitions(&info->mtd, pdata->parts, pdata->nr_parts); 84 80 else 85 81 #endif ··· 103 99 { 104 100 struct onenand_info *info = platform_get_drvdata(pdev); 105 101 struct resource *res = pdev->resource; 106 - unsigned long size = res->end - res->start + 1; 102 + unsigned long size = resource_size(res); 107 103 108 104 platform_set_drvdata(pdev, NULL); 109 105
+8
include/linux/mtd/onenand.h
··· 214 214 loff_t onenand_addr(struct onenand_chip *this, int block); 215 215 int flexonenand_region(struct mtd_info *mtd, loff_t addr); 216 216 217 + struct mtd_partition; 218 + 219 + struct onenand_platform_data { 220 + void (*mmcontrol)(struct mtd_info *mtd, int sync_read); 221 + struct mtd_partition *parts; 222 + unsigned int nr_parts; 223 + }; 224 + 217 225 #endif /* __LINUX_MTD_ONENAND_H */