aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps/plat-ram.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-11-09 17:32:44 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-09 17:32:44 -0500
commit3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 (patch)
treed8825be54cefb6ad6707478d719c8e30605bee7b /drivers/mtd/maps/plat-ram.c
parent00d3dcdd96646be6059cc21f2efa94c4edc1eda5 (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/plat-ram.c')
-rw-r--r--drivers/mtd/maps/plat-ram.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index a02eed94a231..5d3c75451ca2 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -56,9 +56,9 @@ struct platram_info {
56 * device private data to struct platram_info conversion 56 * device private data to struct platram_info conversion
57*/ 57*/
58 58
59static inline struct platram_info *to_platram_info(struct device *dev) 59static inline struct platram_info *to_platram_info(struct platform_device *dev)
60{ 60{
61 return (struct platram_info *)dev_get_drvdata(dev); 61 return (struct platram_info *)platform_get_drvdata(dev);
62} 62}
63 63
64/* platram_setrw 64/* platram_setrw
@@ -83,13 +83,13 @@ static inline void platram_setrw(struct platram_info *info, int to)
83 * called to remove the device from the driver's control 83 * called to remove the device from the driver's control
84*/ 84*/
85 85
86static int platram_remove(struct device *dev) 86static int platram_remove(struct platform_device *pdev)
87{ 87{
88 struct platram_info *info = to_platram_info(dev); 88 struct platram_info *info = to_platram_info(pdev);
89 89
90 dev_set_drvdata(dev, NULL); 90 platform_set_drvdata(pdev, NULL);
91 91
92 dev_dbg(dev, "removing device\n"); 92 dev_dbg(&pdev->dev, "removing device\n");
93 93
94 if (info == NULL) 94 if (info == NULL)
95 return 0; 95 return 0;
@@ -130,61 +130,60 @@ static int platram_remove(struct device *dev)
130 * driver is found. 130 * driver is found.
131*/ 131*/
132 132
133static int platram_probe(struct device *dev) 133static int platram_probe(struct platform_device *pdev)
134{ 134{
135 struct platform_device *pd = to_platform_device(dev);
136 struct platdata_mtd_ram *pdata; 135 struct platdata_mtd_ram *pdata;
137 struct platram_info *info; 136 struct platram_info *info;
138 struct resource *res; 137 struct resource *res;
139 int err = 0; 138 int err = 0;
140 139
141 dev_dbg(dev, "probe entered\n"); 140 dev_dbg(&pdev->dev, "probe entered\n");
142 141
143 if (dev->platform_data == NULL) { 142 if (pdev->dev.platform_data == NULL) {
144 dev_err(dev, "no platform data supplied\n"); 143 dev_err(&pdev->dev, "no platform data supplied\n");
145 err = -ENOENT; 144 err = -ENOENT;
146 goto exit_error; 145 goto exit_error;
147 } 146 }
148 147
149 pdata = dev->platform_data; 148 pdata = pdev->dev.platform_data;
150 149
151 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
152 if (info == NULL) { 151 if (info == NULL) {
153 dev_err(dev, "no memory for flash info\n"); 152 dev_err(&pdev->dev, "no memory for flash info\n");
154 err = -ENOMEM; 153 err = -ENOMEM;
155 goto exit_error; 154 goto exit_error;
156 } 155 }
157 156
158 memset(info, 0, sizeof(*info)); 157 memset(info, 0, sizeof(*info));
159 dev_set_drvdata(dev, info); 158 platform_set_drvdata(pdev, info);
160 159
161 info->dev = dev; 160 info->dev = &pdev->dev;
162 info->pdata = pdata; 161 info->pdata = pdata;
163 162
164 /* get the resource for the memory mapping */ 163 /* get the resource for the memory mapping */
165 164
166 res = platform_get_resource(pd, IORESOURCE_MEM, 0); 165 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
167 166
168 if (res == NULL) { 167 if (res == NULL) {
169 dev_err(dev, "no memory resource specified\n"); 168 dev_err(&pdev->dev, "no memory resource specified\n");
170 err = -ENOENT; 169 err = -ENOENT;
171 goto exit_free; 170 goto exit_free;
172 } 171 }
173 172
174 dev_dbg(dev, "got platform resource %p (0x%lx)\n", res, res->start); 173 dev_dbg(&pdev->dev, "got platform resource %p (0x%lx)\n", res, res->start);
175 174
176 /* setup map parameters */ 175 /* setup map parameters */
177 176
178 info->map.phys = res->start; 177 info->map.phys = res->start;
179 info->map.size = (res->end - res->start) + 1; 178 info->map.size = (res->end - res->start) + 1;
180 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pd->name; 179 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pdev->name;
181 info->map.bankwidth = pdata->bankwidth; 180 info->map.bankwidth = pdata->bankwidth;
182 181
183 /* register our usage of the memory area */ 182 /* register our usage of the memory area */
184 183
185 info->area = request_mem_region(res->start, info->map.size, pd->name); 184 info->area = request_mem_region(res->start, info->map.size, pdev->name);
186 if (info->area == NULL) { 185 if (info->area == NULL) {
187 dev_err(dev, "failed to request memory region\n"); 186 dev_err(&pdev->dev, "failed to request memory region\n");
188 err = -EIO; 187 err = -EIO;
189 goto exit_free; 188 goto exit_free;
190 } 189 }
@@ -192,23 +191,23 @@ static int platram_probe(struct device *dev)
192 /* remap the memory area */ 191 /* remap the memory area */
193 192
194 info->map.virt = ioremap(res->start, info->map.size); 193 info->map.virt = ioremap(res->start, info->map.size);
195 dev_dbg(dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size); 194 dev_dbg(&pdev->dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size);
196 195
197 if (info->map.virt == NULL) { 196 if (info->map.virt == NULL) {
198 dev_err(dev, "failed to ioremap() region\n"); 197 dev_err(&pdev->dev, "failed to ioremap() region\n");
199 err = -EIO; 198 err = -EIO;
200 goto exit_free; 199 goto exit_free;
201 } 200 }
202 201
203 simple_map_init(&info->map); 202 simple_map_init(&info->map);
204 203
205 dev_dbg(dev, "initialised map, probing for mtd\n"); 204 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n");
206 205
207 /* probe for the right mtd map driver */ 206 /* probe for the right mtd map driver */
208 207
209 info->mtd = do_map_probe("map_ram" , &info->map); 208 info->mtd = do_map_probe("map_ram" , &info->map);
210 if (info->mtd == NULL) { 209 if (info->mtd == NULL) {
211 dev_err(dev, "failed to probe for map_ram\n"); 210 dev_err(&pdev->dev, "failed to probe for map_ram\n");
212 err = -ENOMEM; 211 err = -ENOMEM;
213 goto exit_free; 212 goto exit_free;
214 } 213 }
@@ -237,27 +236,28 @@ static int platram_probe(struct device *dev)
237#endif /* CONFIG_MTD_PARTITIONS */ 236#endif /* CONFIG_MTD_PARTITIONS */
238 237
239 if (add_mtd_device(info->mtd)) { 238 if (add_mtd_device(info->mtd)) {
240 dev_err(dev, "add_mtd_device() failed\n"); 239 dev_err(&pdev->dev, "add_mtd_device() failed\n");
241 err = -ENOMEM; 240 err = -ENOMEM;
242 } 241 }
243 242
244 dev_info(dev, "registered mtd device\n"); 243 dev_info(&pdev->dev, "registered mtd device\n");
245 return err; 244 return err;
246 245
247 exit_free: 246 exit_free:
248 platram_remove(dev); 247 platram_remove(pdev);
249 exit_error: 248 exit_error:
250 return err; 249 return err;
251} 250}
252 251
253/* device driver info */ 252/* device driver info */
254 253
255static struct device_driver platram_driver = { 254static struct platform_driver platram_driver = {
256 .name = "mtd-ram",
257 .owner = THIS_MODULE,
258 .bus = &platform_bus_type,
259 .probe = platram_probe, 255 .probe = platram_probe,
260 .remove = platram_remove, 256 .remove = platram_remove,
257 .driver = {
258 .name = "mtd-ram",
259 .owner = THIS_MODULE,
260 },
261}; 261};
262 262
263/* module init/exit */ 263/* module init/exit */
@@ -265,12 +265,12 @@ static struct device_driver platram_driver = {
265static int __init platram_init(void) 265static int __init platram_init(void)
266{ 266{
267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n"); 267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n");
268 return driver_register(&platram_driver); 268 return platform_driver_register(&platram_driver);
269} 269}
270 270
271static void __exit platram_exit(void) 271static void __exit platram_exit(void)
272{ 272{
273 driver_unregister(&platram_driver); 273 platform_driver_unregister(&platram_driver);
274} 274}
275 275
276module_init(platram_init); 276module_init(platram_init);