diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
commit | 3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 (patch) | |
tree | d8825be54cefb6ad6707478d719c8e30605bee7b /drivers/mtd/maps/bast-flash.c | |
parent | 00d3dcdd96646be6059cc21f2efa94c4edc1eda5 (diff) |
[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually
remove the use of the device_driver function pointer methods for
platform device drivers.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/mtd/maps/bast-flash.c')
-rw-r--r-- | drivers/mtd/maps/bast-flash.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c index b7858eb93534..51f962dd7e31 100644 --- a/drivers/mtd/maps/bast-flash.c +++ b/drivers/mtd/maps/bast-flash.c | |||
@@ -63,11 +63,6 @@ struct bast_flash_info { | |||
63 | 63 | ||
64 | static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; | 64 | static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; |
65 | 65 | ||
66 | static struct bast_flash_info *to_bast_info(struct device *dev) | ||
67 | { | ||
68 | return (struct bast_flash_info *)dev_get_drvdata(dev); | ||
69 | } | ||
70 | |||
71 | static void bast_flash_setrw(int to) | 66 | static void bast_flash_setrw(int to) |
72 | { | 67 | { |
73 | unsigned int val; | 68 | unsigned int val; |
@@ -87,11 +82,11 @@ static void bast_flash_setrw(int to) | |||
87 | local_irq_restore(flags); | 82 | local_irq_restore(flags); |
88 | } | 83 | } |
89 | 84 | ||
90 | static int bast_flash_remove(struct device *dev) | 85 | static int bast_flash_remove(struct platform_device *pdev) |
91 | { | 86 | { |
92 | struct bast_flash_info *info = to_bast_info(dev); | 87 | struct bast_flash_info *info = platform_get_drvdata(pdev); |
93 | 88 | ||
94 | dev_set_drvdata(dev, NULL); | 89 | platform_set_drvdata(pdev, NULL); |
95 | 90 | ||
96 | if (info == NULL) | 91 | if (info == NULL) |
97 | return 0; | 92 | return 0; |
@@ -116,9 +111,8 @@ static int bast_flash_remove(struct device *dev) | |||
116 | return 0; | 111 | return 0; |
117 | } | 112 | } |
118 | 113 | ||
119 | static int bast_flash_probe(struct device *dev) | 114 | static int bast_flash_probe(struct platform_device *pdev) |
120 | { | 115 | { |
121 | struct platform_device *pdev = to_platform_device(dev); | ||
122 | struct bast_flash_info *info; | 116 | struct bast_flash_info *info; |
123 | struct resource *res; | 117 | struct resource *res; |
124 | int err = 0; | 118 | int err = 0; |
@@ -131,13 +125,13 @@ static int bast_flash_probe(struct device *dev) | |||
131 | } | 125 | } |
132 | 126 | ||
133 | memzero(info, sizeof(*info)); | 127 | memzero(info, sizeof(*info)); |
134 | dev_set_drvdata(dev, info); | 128 | platform_set_drvdata(pdev, info); |
135 | 129 | ||
136 | res = pdev->resource; /* assume that the flash has one resource */ | 130 | res = pdev->resource; /* assume that the flash has one resource */ |
137 | 131 | ||
138 | info->map.phys = res->start; | 132 | info->map.phys = res->start; |
139 | info->map.size = res->end - res->start + 1; | 133 | info->map.size = res->end - res->start + 1; |
140 | info->map.name = dev->bus_id; | 134 | info->map.name = pdev->dev.bus_id; |
141 | info->map.bankwidth = 2; | 135 | info->map.bankwidth = 2; |
142 | 136 | ||
143 | if (info->map.size > AREA_MAXSIZE) | 137 | if (info->map.size > AREA_MAXSIZE) |
@@ -199,27 +193,28 @@ static int bast_flash_probe(struct device *dev) | |||
199 | /* fall through to exit error */ | 193 | /* fall through to exit error */ |
200 | 194 | ||
201 | exit_error: | 195 | exit_error: |
202 | bast_flash_remove(dev); | 196 | bast_flash_remove(pdev); |
203 | return err; | 197 | return err; |
204 | } | 198 | } |
205 | 199 | ||
206 | static struct device_driver bast_flash_driver = { | 200 | static struct platform_driver bast_flash_driver = { |
207 | .name = "bast-nor", | ||
208 | .owner = THIS_MODULE, | ||
209 | .bus = &platform_bus_type, | ||
210 | .probe = bast_flash_probe, | 201 | .probe = bast_flash_probe, |
211 | .remove = bast_flash_remove, | 202 | .remove = bast_flash_remove, |
203 | .driver = { | ||
204 | .name = "bast-nor", | ||
205 | .owner = THIS_MODULE, | ||
206 | }, | ||
212 | }; | 207 | }; |
213 | 208 | ||
214 | static int __init bast_flash_init(void) | 209 | static int __init bast_flash_init(void) |
215 | { | 210 | { |
216 | printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n"); | 211 | printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n"); |
217 | return driver_register(&bast_flash_driver); | 212 | return platform_driver_register(&bast_flash_driver); |
218 | } | 213 | } |
219 | 214 | ||
220 | static void __exit bast_flash_exit(void) | 215 | static void __exit bast_flash_exit(void) |
221 | { | 216 | { |
222 | driver_unregister(&bast_flash_driver); | 217 | platform_driver_unregister(&bast_flash_driver); |
223 | } | 218 | } |
224 | 219 | ||
225 | module_init(bast_flash_init); | 220 | module_init(bast_flash_init); |