aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/maps/bast-flash.c33
-rw-r--r--drivers/mtd/maps/integrator-flash.c23
-rw-r--r--drivers/mtd/maps/ixp2000.c25
-rw-r--r--drivers/mtd/maps/ixp4xx.c25
-rw-r--r--drivers/mtd/maps/omap_nor.c23
-rw-r--r--drivers/mtd/maps/plat-ram.c68
-rw-r--r--drivers/mtd/maps/sa1100-flash.c36
-rw-r--r--drivers/mtd/nand/s3c2410.c77
8 files changed, 151 insertions, 159 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
64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
65 65
66static struct bast_flash_info *to_bast_info(struct device *dev)
67{
68 return (struct bast_flash_info *)dev_get_drvdata(dev);
69}
70
71static void bast_flash_setrw(int to) 66static 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
90static int bast_flash_remove(struct device *dev) 85static 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
119static int bast_flash_probe(struct device *dev) 114static 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
206static struct device_driver bast_flash_driver = { 200static 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
214static int __init bast_flash_init(void) 209static 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
220static void __exit bast_flash_exit(void) 215static 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
225module_init(bast_flash_init); 220module_init(bast_flash_init);
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index fe738fd8d6f8..a3ba52fbd868 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -67,9 +67,8 @@ static void armflash_set_vpp(struct map_info *map, int on)
67 67
68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL }; 68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };
69 69
70static int armflash_probe(struct device *_dev) 70static int armflash_probe(struct platform_device *dev)
71{ 71{
72 struct platform_device *dev = to_platform_device(_dev);
73 struct flash_platform_data *plat = dev->dev.platform_data; 72 struct flash_platform_data *plat = dev->dev.platform_data;
74 struct resource *res = dev->resource; 73 struct resource *res = dev->resource;
75 unsigned int size = res->end - res->start + 1; 74 unsigned int size = res->end - res->start + 1;
@@ -138,7 +137,7 @@ static int armflash_probe(struct device *_dev)
138 } 137 }
139 138
140 if (err == 0) 139 if (err == 0)
141 dev_set_drvdata(&dev->dev, info); 140 platform_set_drvdata(dev, info);
142 141
143 /* 142 /*
144 * If we got an error, free all resources. 143 * If we got an error, free all resources.
@@ -163,12 +162,11 @@ static int armflash_probe(struct device *_dev)
163 return err; 162 return err;
164} 163}
165 164
166static int armflash_remove(struct device *_dev) 165static int armflash_remove(struct platform_device *dev)
167{ 166{
168 struct platform_device *dev = to_platform_device(_dev); 167 struct armflash_info *info = platform_get_drvdata(dev);
169 struct armflash_info *info = dev_get_drvdata(&dev->dev);
170 168
171 dev_set_drvdata(&dev->dev, NULL); 169 platform_set_drvdata(dev, NULL);
172 170
173 if (info) { 171 if (info) {
174 if (info->mtd) { 172 if (info->mtd) {
@@ -190,21 +188,22 @@ static int armflash_remove(struct device *_dev)
190 return 0; 188 return 0;
191} 189}
192 190
193static struct device_driver armflash_driver = { 191static struct platform_driver armflash_driver = {
194 .name = "armflash",
195 .bus = &platform_bus_type,
196 .probe = armflash_probe, 192 .probe = armflash_probe,
197 .remove = armflash_remove, 193 .remove = armflash_remove,
194 .driver = {
195 .name = "armflash",
196 },
198}; 197};
199 198
200static int __init armflash_init(void) 199static int __init armflash_init(void)
201{ 200{
202 return driver_register(&armflash_driver); 201 return platform_driver_register(&armflash_driver);
203} 202}
204 203
205static void __exit armflash_exit(void) 204static void __exit armflash_exit(void)
206{ 205{
207 driver_unregister(&armflash_driver); 206 platform_driver_unregister(&armflash_driver);
208} 207}
209 208
210module_init(armflash_init); 209module_init(armflash_init);
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 641eb2b55e9f..fc7a78e31735 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -111,13 +111,12 @@ static void ixp2000_flash_copy_to(struct map_info *map, unsigned long to,
111} 111}
112 112
113 113
114static int ixp2000_flash_remove(struct device *_dev) 114static int ixp2000_flash_remove(struct platform_device *dev)
115{ 115{
116 struct platform_device *dev = to_platform_device(_dev);
117 struct flash_platform_data *plat = dev->dev.platform_data; 116 struct flash_platform_data *plat = dev->dev.platform_data;
118 struct ixp2000_flash_info *info = dev_get_drvdata(&dev->dev); 117 struct ixp2000_flash_info *info = platform_get_drvdata(dev);
119 118
120 dev_set_drvdata(&dev->dev, NULL); 119 platform_set_drvdata(dev, NULL);
121 120
122 if(!info) 121 if(!info)
123 return 0; 122 return 0;
@@ -143,10 +142,9 @@ static int ixp2000_flash_remove(struct device *_dev)
143} 142}
144 143
145 144
146static int ixp2000_flash_probe(struct device *_dev) 145static int ixp2000_flash_probe(struct platform_device *dev)
147{ 146{
148 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 147 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
149 struct platform_device *dev = to_platform_device(_dev);
150 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data; 148 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
151 struct flash_platform_data *plat; 149 struct flash_platform_data *plat;
152 struct ixp2000_flash_info *info; 150 struct ixp2000_flash_info *info;
@@ -177,7 +175,7 @@ static int ixp2000_flash_probe(struct device *_dev)
177 } 175 }
178 memzero(info, sizeof(struct ixp2000_flash_info)); 176 memzero(info, sizeof(struct ixp2000_flash_info));
179 177
180 dev_set_drvdata(&dev->dev, info); 178 platform_set_drvdata(dev, info);
181 179
182 /* 180 /*
183 * Tell the MTD layer we're not 1:1 mapped so that it does 181 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -248,25 +246,26 @@ static int ixp2000_flash_probe(struct device *_dev)
248 return 0; 246 return 0;
249 247
250Error: 248Error:
251 ixp2000_flash_remove(_dev); 249 ixp2000_flash_remove(dev);
252 return err; 250 return err;
253} 251}
254 252
255static struct device_driver ixp2000_flash_driver = { 253static struct platform_driver ixp2000_flash_driver = {
256 .name = "IXP2000-Flash",
257 .bus = &platform_bus_type,
258 .probe = &ixp2000_flash_probe, 254 .probe = &ixp2000_flash_probe,
259 .remove = &ixp2000_flash_remove 255 .remove = &ixp2000_flash_remove
256 .driver = {
257 .name = "IXP2000-Flash",
258 },
260}; 259};
261 260
262static int __init ixp2000_flash_init(void) 261static int __init ixp2000_flash_init(void)
263{ 262{
264 return driver_register(&ixp2000_flash_driver); 263 return platform_driver_register(&ixp2000_flash_driver);
265} 264}
266 265
267static void __exit ixp2000_flash_exit(void) 266static void __exit ixp2000_flash_exit(void)
268{ 267{
269 driver_unregister(&ixp2000_flash_driver); 268 platform_driver_unregister(&ixp2000_flash_driver);
270} 269}
271 270
272module_init(ixp2000_flash_init); 271module_init(ixp2000_flash_init);
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 56b3a355bf7b..a59f8027903c 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -99,13 +99,12 @@ struct ixp4xx_flash_info {
99 99
100static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 100static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
101 101
102static int ixp4xx_flash_remove(struct device *_dev) 102static int ixp4xx_flash_remove(struct platform_device *dev)
103{ 103{
104 struct platform_device *dev = to_platform_device(_dev);
105 struct flash_platform_data *plat = dev->dev.platform_data; 104 struct flash_platform_data *plat = dev->dev.platform_data;
106 struct ixp4xx_flash_info *info = dev_get_drvdata(&dev->dev); 105 struct ixp4xx_flash_info *info = platform_get_drvdata(dev);
107 106
108 dev_set_drvdata(&dev->dev, NULL); 107 platform_set_drvdata(dev, NULL);
109 108
110 if(!info) 109 if(!info)
111 return 0; 110 return 0;
@@ -130,9 +129,8 @@ static int ixp4xx_flash_remove(struct device *_dev)
130 return 0; 129 return 0;
131} 130}
132 131
133static int ixp4xx_flash_probe(struct device *_dev) 132static int ixp4xx_flash_probe(struct platform_device *dev)
134{ 133{
135 struct platform_device *dev = to_platform_device(_dev);
136 struct flash_platform_data *plat = dev->dev.platform_data; 134 struct flash_platform_data *plat = dev->dev.platform_data;
137 struct ixp4xx_flash_info *info; 135 struct ixp4xx_flash_info *info;
138 int err = -1; 136 int err = -1;
@@ -153,7 +151,7 @@ static int ixp4xx_flash_probe(struct device *_dev)
153 } 151 }
154 memzero(info, sizeof(struct ixp4xx_flash_info)); 152 memzero(info, sizeof(struct ixp4xx_flash_info));
155 153
156 dev_set_drvdata(&dev->dev, info); 154 platform_set_drvdata(dev, info);
157 155
158 /* 156 /*
159 * Tell the MTD layer we're not 1:1 mapped so that it does 157 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -214,25 +212,26 @@ static int ixp4xx_flash_probe(struct device *_dev)
214 return 0; 212 return 0;
215 213
216Error: 214Error:
217 ixp4xx_flash_remove(_dev); 215 ixp4xx_flash_remove(dev);
218 return err; 216 return err;
219} 217}
220 218
221static struct device_driver ixp4xx_flash_driver = { 219static struct platform_driver ixp4xx_flash_driver = {
222 .name = "IXP4XX-Flash",
223 .bus = &platform_bus_type,
224 .probe = ixp4xx_flash_probe, 220 .probe = ixp4xx_flash_probe,
225 .remove = ixp4xx_flash_remove, 221 .remove = ixp4xx_flash_remove,
222 .driver = {
223 .name = "IXP4XX-Flash",
224 },
226}; 225};
227 226
228static int __init ixp4xx_flash_init(void) 227static int __init ixp4xx_flash_init(void)
229{ 228{
230 return driver_register(&ixp4xx_flash_driver); 229 return platform_driver_register(&ixp4xx_flash_driver);
231} 230}
232 231
233static void __exit ixp4xx_flash_exit(void) 232static void __exit ixp4xx_flash_exit(void)
234{ 233{
235 driver_unregister(&ixp4xx_flash_driver); 234 platform_driver_unregister(&ixp4xx_flash_driver);
236} 235}
237 236
238 237
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index fd3b4a5fc207..418afffb2d80 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -70,11 +70,10 @@ static void omap_set_vpp(struct map_info *map, int enable)
70 } 70 }
71} 71}
72 72
73static int __devinit omapflash_probe(struct device *dev) 73static int __devinit omapflash_probe(struct platform_device *pdev)
74{ 74{
75 int err; 75 int err;
76 struct omapflash_info *info; 76 struct omapflash_info *info;
77 struct platform_device *pdev = to_platform_device(dev);
78 struct flash_platform_data *pdata = pdev->dev.platform_data; 77 struct flash_platform_data *pdata = pdev->dev.platform_data;
79 struct resource *res = pdev->resource; 78 struct resource *res = pdev->resource;
80 unsigned long size = res->end - res->start + 1; 79 unsigned long size = res->end - res->start + 1;
@@ -119,7 +118,7 @@ static int __devinit omapflash_probe(struct device *dev)
119#endif 118#endif
120 add_mtd_device(info->mtd); 119 add_mtd_device(info->mtd);
121 120
122 dev_set_drvdata(&pdev->dev, info); 121 platform_set_drvdata(pdev, info);
123 122
124 return 0; 123 return 0;
125 124
@@ -133,12 +132,11 @@ out_free_info:
133 return err; 132 return err;
134} 133}
135 134
136static int __devexit omapflash_remove(struct device *dev) 135static int __devexit omapflash_remove(struct platform_device *pdev)
137{ 136{
138 struct platform_device *pdev = to_platform_device(dev); 137 struct omapflash_info *info = platform_get_drvdata(pdev);
139 struct omapflash_info *info = dev_get_drvdata(&pdev->dev);
140 138
141 dev_set_drvdata(&pdev->dev, NULL); 139 platform_set_drvdata(pdev, NULL);
142 140
143 if (info) { 141 if (info) {
144 if (info->parts) { 142 if (info->parts) {
@@ -155,21 +153,22 @@ static int __devexit omapflash_remove(struct device *dev)
155 return 0; 153 return 0;
156} 154}
157 155
158static struct device_driver omapflash_driver = { 156static struct platform_driver omapflash_driver = {
159 .name = "omapflash",
160 .bus = &platform_bus_type,
161 .probe = omapflash_probe, 157 .probe = omapflash_probe,
162 .remove = __devexit_p(omapflash_remove), 158 .remove = __devexit_p(omapflash_remove),
159 .driver = {
160 .name = "omapflash",
161 },
163}; 162};
164 163
165static int __init omapflash_init(void) 164static int __init omapflash_init(void)
166{ 165{
167 return driver_register(&omapflash_driver); 166 return platform_driver_register(&omapflash_driver);
168} 167}
169 168
170static void __exit omapflash_exit(void) 169static void __exit omapflash_exit(void)
171{ 170{
172 driver_unregister(&omapflash_driver); 171 platform_driver_unregister(&omapflash_driver);
173} 172}
174 173
175module_init(omapflash_init); 174module_init(omapflash_init);
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);
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 9e8bb1782be0..5cefb015633c 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -356,9 +356,8 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
356 356
357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; 357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
358 358
359static int __init sa1100_mtd_probe(struct device *dev) 359static int __init sa1100_mtd_probe(struct platform_device *pdev)
360{ 360{
361 struct platform_device *pdev = to_platform_device(dev);
362 struct flash_platform_data *plat = pdev->dev.platform_data; 361 struct flash_platform_data *plat = pdev->dev.platform_data;
363 struct mtd_partition *parts; 362 struct mtd_partition *parts;
364 const char *part_type = NULL; 363 const char *part_type = NULL;
@@ -402,28 +401,28 @@ static int __init sa1100_mtd_probe(struct device *dev)
402 401
403 info->nr_parts = nr_parts; 402 info->nr_parts = nr_parts;
404 403
405 dev_set_drvdata(dev, info); 404 platform_set_drvdata(pdev, info);
406 err = 0; 405 err = 0;
407 406
408 out: 407 out:
409 return err; 408 return err;
410} 409}
411 410
412static int __exit sa1100_mtd_remove(struct device *dev) 411static int __exit sa1100_mtd_remove(struct platform_device *pdev)
413{ 412{
414 struct sa_info *info = dev_get_drvdata(dev); 413 struct sa_info *info = platform_get_drvdata(pdev);
415 struct flash_platform_data *plat = dev->platform_data; 414 struct flash_platform_data *plat = pdev->dev.platform_data;
416 415
417 dev_set_drvdata(dev, NULL); 416 platform_set_drvdata(pdev, NULL);
418 sa1100_destroy(info, plat); 417 sa1100_destroy(info, plat);
419 418
420 return 0; 419 return 0;
421} 420}
422 421
423#ifdef CONFIG_PM 422#ifdef CONFIG_PM
424static int sa1100_mtd_suspend(struct device *dev, pm_message_t state) 423static int sa1100_mtd_suspend(struct platform_device *dev, pm_message_t state)
425{ 424{
426 struct sa_info *info = dev_get_drvdata(dev); 425 struct sa_info *info = platform_get_drvdata(dev);
427 int ret = 0; 426 int ret = 0;
428 427
429 if (info) 428 if (info)
@@ -432,17 +431,17 @@ static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
432 return ret; 431 return ret;
433} 432}
434 433
435static int sa1100_mtd_resume(struct device *dev) 434static int sa1100_mtd_resume(struct platform_device *dev)
436{ 435{
437 struct sa_info *info = dev_get_drvdata(dev); 436 struct sa_info *info = platform_get_drvdata(dev);
438 if (info) 437 if (info)
439 info->mtd->resume(info->mtd); 438 info->mtd->resume(info->mtd);
440 return 0; 439 return 0;
441} 440}
442 441
443static void sa1100_mtd_shutdown(struct device *dev) 442static void sa1100_mtd_shutdown(struct platform_device *dev)
444{ 443{
445 struct sa_info *info = dev_get_drvdata(dev); 444 struct sa_info *info = platform_get_drvdata(dev);
446 if (info && info->mtd->suspend(info->mtd) == 0) 445 if (info && info->mtd->suspend(info->mtd) == 0)
447 info->mtd->resume(info->mtd); 446 info->mtd->resume(info->mtd);
448} 447}
@@ -452,24 +451,25 @@ static void sa1100_mtd_shutdown(struct device *dev)
452#define sa1100_mtd_shutdown NULL 451#define sa1100_mtd_shutdown NULL
453#endif 452#endif
454 453
455static struct device_driver sa1100_mtd_driver = { 454static struct platform_driver sa1100_mtd_driver = {
456 .name = "flash",
457 .bus = &platform_bus_type,
458 .probe = sa1100_mtd_probe, 455 .probe = sa1100_mtd_probe,
459 .remove = __exit_p(sa1100_mtd_remove), 456 .remove = __exit_p(sa1100_mtd_remove),
460 .suspend = sa1100_mtd_suspend, 457 .suspend = sa1100_mtd_suspend,
461 .resume = sa1100_mtd_resume, 458 .resume = sa1100_mtd_resume,
462 .shutdown = sa1100_mtd_shutdown, 459 .shutdown = sa1100_mtd_shutdown,
460 .driver = {
461 .name = "flash",
462 },
463}; 463};
464 464
465static int __init sa1100_mtd_init(void) 465static int __init sa1100_mtd_init(void)
466{ 466{
467 return driver_register(&sa1100_mtd_driver); 467 return platform_driver_register(&sa1100_mtd_driver);
468} 468}
469 469
470static void __exit sa1100_mtd_exit(void) 470static void __exit sa1100_mtd_exit(void)
471{ 471{
472 driver_unregister(&sa1100_mtd_driver); 472 platform_driver_unregister(&sa1100_mtd_driver);
473} 473}
474 474
475module_init(sa1100_mtd_init); 475module_init(sa1100_mtd_init);
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 97e9b7892d29..d209214b1318 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -125,14 +125,14 @@ static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd)
125 return s3c2410_nand_mtd_toours(mtd)->info; 125 return s3c2410_nand_mtd_toours(mtd)->info;
126} 126}
127 127
128static struct s3c2410_nand_info *to_nand_info(struct device *dev) 128static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev)
129{ 129{
130 return dev_get_drvdata(dev); 130 return platform_get_drvdata(dev);
131} 131}
132 132
133static struct s3c2410_platform_nand *to_nand_plat(struct device *dev) 133static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev)
134{ 134{
135 return dev->platform_data; 135 return dev->dev.platform_data;
136} 136}
137 137
138/* timing calculations */ 138/* timing calculations */
@@ -165,9 +165,9 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
165/* controller setup */ 165/* controller setup */
166 166
167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
168 struct device *dev) 168 struct platform_device *pdev)
169{ 169{
170 struct s3c2410_platform_nand *plat = to_nand_plat(dev); 170 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
171 unsigned long clkrate = clk_get_rate(info->clk); 171 unsigned long clkrate = clk_get_rate(info->clk);
172 int tacls, twrph0, twrph1; 172 int tacls, twrph0, twrph1;
173 unsigned long cfg; 173 unsigned long cfg;
@@ -430,11 +430,11 @@ static void s3c2410_nand_write_buf(struct mtd_info *mtd,
430 430
431/* device management functions */ 431/* device management functions */
432 432
433static int s3c2410_nand_remove(struct device *dev) 433static int s3c2410_nand_remove(struct platform_device *pdev)
434{ 434{
435 struct s3c2410_nand_info *info = to_nand_info(dev); 435 struct s3c2410_nand_info *info = to_nand_info(pdev);
436 436
437 dev_set_drvdata(dev, NULL); 437 platform_set_drvdata(pdev, NULL);
438 438
439 if (info == NULL) 439 if (info == NULL)
440 return 0; 440 return 0;
@@ -562,10 +562,9 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
562 * nand layer to look for devices 562 * nand layer to look for devices
563*/ 563*/
564 564
565static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) 565static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
566{ 566{
567 struct platform_device *pdev = to_platform_device(dev); 567 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
568 struct s3c2410_platform_nand *plat = to_nand_plat(dev);
569 struct s3c2410_nand_info *info; 568 struct s3c2410_nand_info *info;
570 struct s3c2410_nand_mtd *nmtd; 569 struct s3c2410_nand_mtd *nmtd;
571 struct s3c2410_nand_set *sets; 570 struct s3c2410_nand_set *sets;
@@ -575,26 +574,26 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
575 int nr_sets; 574 int nr_sets;
576 int setno; 575 int setno;
577 576
578 pr_debug("s3c2410_nand_probe(%p)\n", dev); 577 pr_debug("s3c2410_nand_probe(%p)\n", pdev);
579 578
580 info = kmalloc(sizeof(*info), GFP_KERNEL); 579 info = kmalloc(sizeof(*info), GFP_KERNEL);
581 if (info == NULL) { 580 if (info == NULL) {
582 dev_err(dev, "no memory for flash info\n"); 581 dev_err(&pdev->dev, "no memory for flash info\n");
583 err = -ENOMEM; 582 err = -ENOMEM;
584 goto exit_error; 583 goto exit_error;
585 } 584 }
586 585
587 memzero(info, sizeof(*info)); 586 memzero(info, sizeof(*info));
588 dev_set_drvdata(dev, info); 587 platform_set_drvdata(pdev, info);
589 588
590 spin_lock_init(&info->controller.lock); 589 spin_lock_init(&info->controller.lock);
591 init_waitqueue_head(&info->controller.wq); 590 init_waitqueue_head(&info->controller.wq);
592 591
593 /* get the clock source and enable it */ 592 /* get the clock source and enable it */
594 593
595 info->clk = clk_get(dev, "nand"); 594 info->clk = clk_get(&pdev->dev, "nand");
596 if (IS_ERR(info->clk)) { 595 if (IS_ERR(info->clk)) {
597 dev_err(dev, "failed to get clock"); 596 dev_err(&pdev->dev, "failed to get clock");
598 err = -ENOENT; 597 err = -ENOENT;
599 goto exit_error; 598 goto exit_error;
600 } 599 }
@@ -611,27 +610,27 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
611 info->area = request_mem_region(res->start, size, pdev->name); 610 info->area = request_mem_region(res->start, size, pdev->name);
612 611
613 if (info->area == NULL) { 612 if (info->area == NULL) {
614 dev_err(dev, "cannot reserve register region\n"); 613 dev_err(&pdev->dev, "cannot reserve register region\n");
615 err = -ENOENT; 614 err = -ENOENT;
616 goto exit_error; 615 goto exit_error;
617 } 616 }
618 617
619 info->device = dev; 618 info->device = &pdev->dev;
620 info->platform = plat; 619 info->platform = plat;
621 info->regs = ioremap(res->start, size); 620 info->regs = ioremap(res->start, size);
622 info->is_s3c2440 = is_s3c2440; 621 info->is_s3c2440 = is_s3c2440;
623 622
624 if (info->regs == NULL) { 623 if (info->regs == NULL) {
625 dev_err(dev, "cannot reserve register region\n"); 624 dev_err(&pdev->dev, "cannot reserve register region\n");
626 err = -EIO; 625 err = -EIO;
627 goto exit_error; 626 goto exit_error;
628 } 627 }
629 628
630 dev_dbg(dev, "mapped registers at %p\n", info->regs); 629 dev_dbg(&pdev->dev, "mapped registers at %p\n", info->regs);
631 630
632 /* initialise the hardware */ 631 /* initialise the hardware */
633 632
634 err = s3c2410_nand_inithw(info, dev); 633 err = s3c2410_nand_inithw(info, pdev);
635 if (err != 0) 634 if (err != 0)
636 goto exit_error; 635 goto exit_error;
637 636
@@ -645,7 +644,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
645 size = nr_sets * sizeof(*info->mtds); 644 size = nr_sets * sizeof(*info->mtds);
646 info->mtds = kmalloc(size, GFP_KERNEL); 645 info->mtds = kmalloc(size, GFP_KERNEL);
647 if (info->mtds == NULL) { 646 if (info->mtds == NULL) {
648 dev_err(dev, "failed to allocate mtd storage\n"); 647 dev_err(&pdev->dev, "failed to allocate mtd storage\n");
649 err = -ENOMEM; 648 err = -ENOMEM;
650 goto exit_error; 649 goto exit_error;
651 } 650 }
@@ -677,7 +676,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
677 return 0; 676 return 0;
678 677
679 exit_error: 678 exit_error:
680 s3c2410_nand_remove(dev); 679 s3c2410_nand_remove(pdev);
681 680
682 if (err == 0) 681 if (err == 0)
683 err = -EINVAL; 682 err = -EINVAL;
@@ -686,44 +685,46 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
686 685
687/* driver device registration */ 686/* driver device registration */
688 687
689static int s3c2410_nand_probe(struct device *dev) 688static int s3c2410_nand_probe(struct platform_device *dev)
690{ 689{
691 return s3c24xx_nand_probe(dev, 0); 690 return s3c24xx_nand_probe(dev, 0);
692} 691}
693 692
694static int s3c2440_nand_probe(struct device *dev) 693static int s3c2440_nand_probe(struct platform_device *dev)
695{ 694{
696 return s3c24xx_nand_probe(dev, 1); 695 return s3c24xx_nand_probe(dev, 1);
697} 696}
698 697
699static struct device_driver s3c2410_nand_driver = { 698static struct platform_driver s3c2410_nand_driver = {
700 .name = "s3c2410-nand",
701 .owner = THIS_MODULE,
702 .bus = &platform_bus_type,
703 .probe = s3c2410_nand_probe, 699 .probe = s3c2410_nand_probe,
704 .remove = s3c2410_nand_remove, 700 .remove = s3c2410_nand_remove,
701 .driver = {
702 .name = "s3c2410-nand",
703 .owner = THIS_MODULE,
704 },
705}; 705};
706 706
707static struct device_driver s3c2440_nand_driver = { 707static struct platform_driver s3c2440_nand_driver = {
708 .name = "s3c2440-nand",
709 .owner = THIS_MODULE,
710 .bus = &platform_bus_type,
711 .probe = s3c2440_nand_probe, 708 .probe = s3c2440_nand_probe,
712 .remove = s3c2410_nand_remove, 709 .remove = s3c2410_nand_remove,
710 .driver = {
711 .name = "s3c2440-nand",
712 .owner = THIS_MODULE,
713 },
713}; 714};
714 715
715static int __init s3c2410_nand_init(void) 716static int __init s3c2410_nand_init(void)
716{ 717{
717 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); 718 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
718 719
719 driver_register(&s3c2440_nand_driver); 720 platform_driver_register(&s3c2440_nand_driver);
720 return driver_register(&s3c2410_nand_driver); 721 return platform_driver_register(&s3c2410_nand_driver);
721} 722}
722 723
723static void __exit s3c2410_nand_exit(void) 724static void __exit s3c2410_nand_exit(void)
724{ 725{
725 driver_unregister(&s3c2440_nand_driver); 726 platform_driver_unregister(&s3c2440_nand_driver);
726 driver_unregister(&s3c2410_nand_driver); 727 platform_driver_unregister(&s3c2410_nand_driver);
727} 728}
728 729
729module_init(s3c2410_nand_init); 730module_init(s3c2410_nand_init);