X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fmtd%2Fmaps%2Fbast-flash.c;h=51f962dd7e31c42054850e3344326f69acbf2752;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=44de3a81b2774e026d628dca870caf49b3e770b9;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c index 44de3a81b..51f962dd7 100644 --- a/drivers/mtd/maps/bast-flash.c +++ b/drivers/mtd/maps/bast-flash.c @@ -1,14 +1,15 @@ /* linux/drivers/mtd/maps/bast_flash.c * - * Copyright (c) 2004 Simtec Electronics - * Ben Dooks + * Copyright (c) 2004-2005 Simtec Electronics + * Ben Dooks * * Simtec Bast (EB2410ITX) NOR MTD Mapping driver * * Changelog: * 20-Sep-2004 BJD Initial version + * 17-Jan-2005 BJD Add whole device if no partitions found * - * $Id: bast-flash.c,v 1.1 2004/09/21 14:29:04 bjd Exp $ + * $Id: bast-flash.c,v 1.5 2005/11/07 11:14:26 gleixner Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,13 +33,13 @@ #include #include #include - +#include +#include #include #include #include #include -#include #include #include @@ -46,9 +47,9 @@ #include #ifdef CONFIG_MTD_BAST_MAXSIZE -#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * (1024*1024)) +#define AREA_MAXSIZE (CONFIG_MTD_BAST_MAXSIZE * SZ_1M) #else -#define AREA_MAXSIZE (32*1024*1024) +#define AREA_MAXSIZE (32 * SZ_1M) #endif #define PFX "bast-flash: " @@ -62,11 +63,6 @@ struct bast_flash_info { static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; -static struct bast_flash_info *to_bast_info(struct device *dev) -{ - return (struct bast_flash_info *)dev_get_drvdata(dev); -} - static void bast_flash_setrw(int to) { unsigned int val; @@ -74,7 +70,7 @@ static void bast_flash_setrw(int to) local_irq_save(flags); val = __raw_readb(BAST_VA_CTRL3); - + if (to) val |= BAST_CPLD_CTRL3_ROMWEN; else @@ -86,13 +82,13 @@ static void bast_flash_setrw(int to) local_irq_restore(flags); } -static int bast_flash_remove(struct device *dev) +static int bast_flash_remove(struct platform_device *pdev) { - struct bast_flash_info *info = to_bast_info(dev); + struct bast_flash_info *info = platform_get_drvdata(pdev); - dev_set_drvdata(dev, NULL); + platform_set_drvdata(pdev, NULL); - if (info == NULL) + if (info == NULL) return 0; if (info->map.virt != NULL) @@ -103,22 +99,20 @@ static int bast_flash_remove(struct device *dev) map_destroy(info->mtd); } - if (info->partitions) - kfree(info->partitions); + kfree(info->partitions); if (info->area) { release_resource(info->area); kfree(info->area); } - + kfree(info); return 0; } -static int bast_flash_probe(struct device *dev) +static int bast_flash_probe(struct platform_device *pdev) { - struct platform_device *pdev = to_platform_device(dev); struct bast_flash_info *info; struct resource *res; int err = 0; @@ -131,21 +125,21 @@ static int bast_flash_probe(struct device *dev) } memzero(info, sizeof(*info)); - dev_set_drvdata(dev, info); + platform_set_drvdata(pdev, info); res = pdev->resource; /* assume that the flash has one resource */ info->map.phys = res->start; info->map.size = res->end - res->start + 1; - info->map.name = dev->bus_id; + info->map.name = pdev->dev.bus_id; info->map.bankwidth = 2; - + if (info->map.size > AREA_MAXSIZE) info->map.size = AREA_MAXSIZE; pr_debug("%s: area %08lx, size %ld\n", __FUNCTION__, info->map.phys, info->map.size); - + info->area = request_mem_region(res->start, info->map.size, pdev->name); if (info->area == NULL) { @@ -162,7 +156,7 @@ static int bast_flash_probe(struct device *dev) err = -EIO; goto exit_error; } - + simple_map_init(&info->map); /* enable the write to the flash area */ @@ -187,8 +181,10 @@ static int bast_flash_probe(struct device *dev) err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0); if (err > 0) { err = add_mtd_partitions(info->mtd, info->partitions, err); - if (err) + if (err) printk(KERN_ERR PFX "cannot add/parse partitions\n"); + } else { + err = add_mtd_device(info->mtd); } if (err == 0) @@ -197,26 +193,28 @@ static int bast_flash_probe(struct device *dev) /* fall through to exit error */ exit_error: - bast_flash_remove(dev); + bast_flash_remove(pdev); return err; } -static struct device_driver bast_flash_driver = { - .name = "bast-nor", - .bus = &platform_bus_type, +static struct platform_driver bast_flash_driver = { .probe = bast_flash_probe, .remove = bast_flash_remove, + .driver = { + .name = "bast-nor", + .owner = THIS_MODULE, + }, }; static int __init bast_flash_init(void) { printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n"); - return driver_register(&bast_flash_driver); + return platform_driver_register(&bast_flash_driver); } static void __exit bast_flash_exit(void) { - driver_unregister(&bast_flash_driver); + platform_driver_unregister(&bast_flash_driver); } module_init(bast_flash_init);