aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
commitcf9b59e9d3e008591d1f54830f570982bb307a0d (patch)
tree113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/mtd/maps
parent44504b2bebf8b5823c59484e73096a7d6574471d (diff)
parentf4b87dee923342505e1ddba8d34ce9de33e75050 (diff)
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and build failures in vio.c after merge. Conflicts: drivers/i2c/busses/i2c-cpm.c drivers/i2c/busses/i2c-mpc.c drivers/net/gianfar.c Also fixed up one line in arch/powerpc/kernel/vio.c to use the correct node pointer. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/mtd/maps')
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/maps/bfin-async-flash.c16
-rw-r--r--drivers/mtd/maps/ceiva.c2
-rw-r--r--drivers/mtd/maps/ixp2000.c3
-rw-r--r--drivers/mtd/maps/ixp4xx.c7
-rw-r--r--drivers/mtd/maps/pcmciamtd.c91
-rw-r--r--drivers/mtd/maps/physmap.c7
-rw-r--r--drivers/mtd/maps/physmap_of.c55
-rw-r--r--drivers/mtd/maps/pismo.c8
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c3
10 files changed, 126 insertions, 68 deletions
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index aa2807d0ce72..f22bc9f05ddb 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -435,7 +435,7 @@ config MTD_PCI
435 435
436config MTD_PCMCIA 436config MTD_PCMCIA
437 tristate "PCMCIA MTD driver" 437 tristate "PCMCIA MTD driver"
438 depends on PCMCIA && MTD_COMPLEX_MAPPINGS && BROKEN 438 depends on PCMCIA && MTD_COMPLEX_MAPPINGS
439 help 439 help
440 Map driver for accessing PCMCIA linear flash memory cards. These 440 Map driver for accessing PCMCIA linear flash memory cards. These
441 cards are usually around 4-16MiB in size. This does not include 441 cards are usually around 4-16MiB in size. This does not include
diff --git a/drivers/mtd/maps/bfin-async-flash.c b/drivers/mtd/maps/bfin-async-flash.c
index c0fd99b0c525..85dd18193cf2 100644
--- a/drivers/mtd/maps/bfin-async-flash.c
+++ b/drivers/mtd/maps/bfin-async-flash.c
@@ -70,7 +70,7 @@ static void switch_back(struct async_state *state)
70 local_irq_restore(state->irq_flags); 70 local_irq_restore(state->irq_flags);
71} 71}
72 72
73static map_word bfin_read(struct map_info *map, unsigned long ofs) 73static map_word bfin_flash_read(struct map_info *map, unsigned long ofs)
74{ 74{
75 struct async_state *state = (struct async_state *)map->map_priv_1; 75 struct async_state *state = (struct async_state *)map->map_priv_1;
76 uint16_t word; 76 uint16_t word;
@@ -86,7 +86,7 @@ static map_word bfin_read(struct map_info *map, unsigned long ofs)
86 return test; 86 return test;
87} 87}
88 88
89static void bfin_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len) 89static void bfin_flash_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
90{ 90{
91 struct async_state *state = (struct async_state *)map->map_priv_1; 91 struct async_state *state = (struct async_state *)map->map_priv_1;
92 92
@@ -97,7 +97,7 @@ static void bfin_copy_from(struct map_info *map, void *to, unsigned long from, s
97 switch_back(state); 97 switch_back(state);
98} 98}
99 99
100static void bfin_write(struct map_info *map, map_word d1, unsigned long ofs) 100static void bfin_flash_write(struct map_info *map, map_word d1, unsigned long ofs)
101{ 101{
102 struct async_state *state = (struct async_state *)map->map_priv_1; 102 struct async_state *state = (struct async_state *)map->map_priv_1;
103 uint16_t d; 103 uint16_t d;
@@ -112,7 +112,7 @@ static void bfin_write(struct map_info *map, map_word d1, unsigned long ofs)
112 switch_back(state); 112 switch_back(state);
113} 113}
114 114
115static void bfin_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len) 115static void bfin_flash_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
116{ 116{
117 struct async_state *state = (struct async_state *)map->map_priv_1; 117 struct async_state *state = (struct async_state *)map->map_priv_1;
118 118
@@ -141,10 +141,10 @@ static int __devinit bfin_flash_probe(struct platform_device *pdev)
141 return -ENOMEM; 141 return -ENOMEM;
142 142
143 state->map.name = DRIVER_NAME; 143 state->map.name = DRIVER_NAME;
144 state->map.read = bfin_read; 144 state->map.read = bfin_flash_read;
145 state->map.copy_from = bfin_copy_from; 145 state->map.copy_from = bfin_flash_copy_from;
146 state->map.write = bfin_write; 146 state->map.write = bfin_flash_write;
147 state->map.copy_to = bfin_copy_to; 147 state->map.copy_to = bfin_flash_copy_to;
148 state->map.bankwidth = pdata->width; 148 state->map.bankwidth = pdata->width;
149 state->map.size = memory->end - memory->start + 1; 149 state->map.size = memory->end - memory->start + 1;
150 state->map.virt = (void __iomem *)memory->start; 150 state->map.virt = (void __iomem *)memory->start;
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c
index d41f34766e53..c09f4f57093e 100644
--- a/drivers/mtd/maps/ceiva.c
+++ b/drivers/mtd/maps/ceiva.c
@@ -253,7 +253,7 @@ static void __exit clps_destroy_mtd(struct clps_info *clps, struct mtd_info *mtd
253 253
254static int __init clps_setup_flash(void) 254static int __init clps_setup_flash(void)
255{ 255{
256 int nr; 256 int nr = 0;
257 257
258#ifdef CONFIG_ARCH_CEIVA 258#ifdef CONFIG_ARCH_CEIVA
259 if (machine_is_ceiva()) { 259 if (machine_is_ceiva()) {
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 1bdf0ee6d0b6..9639d83a9d6c 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -165,12 +165,11 @@ static int ixp2000_flash_probe(struct platform_device *dev)
165 return -EIO; 165 return -EIO;
166 } 166 }
167 167
168 info = kmalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL); 168 info = kzalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL);
169 if(!info) { 169 if(!info) {
170 err = -ENOMEM; 170 err = -ENOMEM;
171 goto Error; 171 goto Error;
172 } 172 }
173 memset(info, 0, sizeof(struct ixp2000_flash_info));
174 173
175 platform_set_drvdata(dev, info); 174 platform_set_drvdata(dev, info);
176 175
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 7b0515297411..e0a5e0426ead 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -107,8 +107,8 @@ static void ixp4xx_copy_from(struct map_info *map, void *to,
107 return; 107 return;
108 108
109 if (from & 1) { 109 if (from & 1) {
110 *dest++ = BYTE1(flash_read16(src)); 110 *dest++ = BYTE1(flash_read16(src-1));
111 src++; 111 src++;
112 --len; 112 --len;
113 } 113 }
114 114
@@ -196,12 +196,11 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
196 return err; 196 return err;
197 } 197 }
198 198
199 info = kmalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL); 199 info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
200 if(!info) { 200 if(!info) {
201 err = -ENOMEM; 201 err = -ENOMEM;
202 goto Error; 202 goto Error;
203 } 203 }
204 memset(info, 0, sizeof(struct ixp4xx_flash_info));
205 204
206 platform_set_drvdata(dev, info); 205 platform_set_drvdata(dev, info);
207 206
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 689d6a79ffc0..e699e6ac23df 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -40,10 +40,7 @@ MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy");
40static const int debug = 0; 40static const int debug = 0;
41#endif 41#endif
42 42
43#define err(format, arg...) printk(KERN_ERR "pcmciamtd: " format "\n" , ## arg)
44#define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg) 43#define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg)
45#define warn(format, arg...) printk(KERN_WARNING "pcmciamtd: " format "\n" , ## arg)
46
47 44
48#define DRIVER_DESC "PCMCIA Flash memory card driver" 45#define DRIVER_DESC "PCMCIA Flash memory card driver"
49 46
@@ -52,7 +49,6 @@ static const int debug = 0;
52 49
53struct pcmciamtd_dev { 50struct pcmciamtd_dev {
54 struct pcmcia_device *p_dev; 51 struct pcmcia_device *p_dev;
55 dev_node_t node; /* device node */
56 caddr_t win_base; /* ioremapped address of PCMCIA window */ 52 caddr_t win_base; /* ioremapped address of PCMCIA window */
57 unsigned int win_size; /* size of window */ 53 unsigned int win_size; /* size of window */
58 unsigned int offset; /* offset into card the window currently points at */ 54 unsigned int offset; /* offset into card the window currently points at */
@@ -100,7 +96,9 @@ module_param(mem_type, int, 0);
100MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); 96MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
101 97
102 98
103/* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */ 99/* read/write{8,16} copy_{from,to} routines with window remapping
100 * to access whole card
101 */
104static caddr_t remap_window(struct map_info *map, unsigned long to) 102static caddr_t remap_window(struct map_info *map, unsigned long to)
105{ 103{
106 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 104 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
@@ -137,7 +135,7 @@ static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
137 return d; 135 return d;
138 136
139 d.x[0] = readb(addr); 137 d.x[0] = readb(addr);
140 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d.x[0]); 138 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx", ofs, addr, d.x[0]);
141 return d; 139 return d;
142} 140}
143 141
@@ -152,7 +150,7 @@ static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
152 return d; 150 return d;
153 151
154 d.x[0] = readw(addr); 152 d.x[0] = readw(addr);
155 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d.x[0]); 153 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx", ofs, addr, d.x[0]);
156 return d; 154 return d;
157} 155}
158 156
@@ -162,7 +160,7 @@ static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long
162 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 160 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
163 unsigned long win_size = dev->win_size; 161 unsigned long win_size = dev->win_size;
164 162
165 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 163 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
166 while(len) { 164 while(len) {
167 int toread = win_size - (from & (win_size-1)); 165 int toread = win_size - (from & (win_size-1));
168 caddr_t addr; 166 caddr_t addr;
@@ -190,7 +188,7 @@ static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long
190 if(!addr) 188 if(!addr)
191 return; 189 return;
192 190
193 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d.x[0]); 191 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx", adr, addr, d.x[0]);
194 writeb(d.x[0], addr); 192 writeb(d.x[0], addr);
195} 193}
196 194
@@ -201,7 +199,7 @@ static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long
201 if(!addr) 199 if(!addr)
202 return; 200 return;
203 201
204 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d.x[0]); 202 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx", adr, addr, d.x[0]);
205 writew(d.x[0], addr); 203 writew(d.x[0], addr);
206} 204}
207 205
@@ -211,7 +209,7 @@ static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const v
211 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 209 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
212 unsigned long win_size = dev->win_size; 210 unsigned long win_size = dev->win_size;
213 211
214 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 212 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
215 while(len) { 213 while(len) {
216 int towrite = win_size - (to & (win_size-1)); 214 int towrite = win_size - (to & (win_size-1));
217 caddr_t addr; 215 caddr_t addr;
@@ -245,7 +243,8 @@ static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
245 return d; 243 return d;
246 244
247 d.x[0] = readb(win_base + ofs); 245 d.x[0] = readb(win_base + ofs);
248 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d.x[0]); 246 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx",
247 ofs, win_base + ofs, d.x[0]);
249 return d; 248 return d;
250} 249}
251 250
@@ -259,7 +258,8 @@ static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
259 return d; 258 return d;
260 259
261 d.x[0] = readw(win_base + ofs); 260 d.x[0] = readw(win_base + ofs);
262 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d.x[0]); 261 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx",
262 ofs, win_base + ofs, d.x[0]);
263 return d; 263 return d;
264} 264}
265 265
@@ -271,32 +271,34 @@ static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from,
271 if(DEV_REMOVED(map)) 271 if(DEV_REMOVED(map))
272 return; 272 return;
273 273
274 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 274 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
275 memcpy_fromio(to, win_base + from, len); 275 memcpy_fromio(to, win_base + from, len);
276} 276}
277 277
278 278
279static void pcmcia_write8(struct map_info *map, u8 d, unsigned long adr) 279static void pcmcia_write8(struct map_info *map, map_word d, unsigned long adr)
280{ 280{
281 caddr_t win_base = (caddr_t)map->map_priv_2; 281 caddr_t win_base = (caddr_t)map->map_priv_2;
282 282
283 if(DEV_REMOVED(map)) 283 if(DEV_REMOVED(map))
284 return; 284 return;
285 285
286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d); 286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx",
287 writeb(d, win_base + adr); 287 adr, win_base + adr, d.x[0]);
288 writeb(d.x[0], win_base + adr);
288} 289}
289 290
290 291
291static void pcmcia_write16(struct map_info *map, u16 d, unsigned long adr) 292static void pcmcia_write16(struct map_info *map, map_word d, unsigned long adr)
292{ 293{
293 caddr_t win_base = (caddr_t)map->map_priv_2; 294 caddr_t win_base = (caddr_t)map->map_priv_2;
294 295
295 if(DEV_REMOVED(map)) 296 if(DEV_REMOVED(map))
296 return; 297 return;
297 298
298 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d); 299 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx",
299 writew(d, win_base + adr); 300 adr, win_base + adr, d.x[0]);
301 writew(d.x[0], win_base + adr);
300} 302}
301 303
302 304
@@ -307,7 +309,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
307 if(DEV_REMOVED(map)) 309 if(DEV_REMOVED(map))
308 return; 310 return;
309 311
310 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 312 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
311 memcpy_toio(win_base + to, from, len); 313 memcpy_toio(win_base + to, from, len);
312} 314}
313 315
@@ -376,7 +378,8 @@ static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev,
376 if (!pcmcia_parse_tuple(tuple, &parse)) { 378 if (!pcmcia_parse_tuple(tuple, &parse)) {
377 cistpl_jedec_t *t = &parse.jedec; 379 cistpl_jedec_t *t = &parse.jedec;
378 for (i = 0; i < t->nid; i++) 380 for (i = 0; i < t->nid; i++)
379 DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); 381 DEBUG(2, "JEDEC: 0x%02x 0x%02x",
382 t->id[i].mfr, t->id[i].info);
380 } 383 }
381 return -ENOSPC; 384 return -ENOSPC;
382} 385}
@@ -432,7 +435,7 @@ static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev,
432} 435}
433 436
434 437
435static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) 438static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *p_dev, int *new_name)
436{ 439{
437 int i; 440 int i;
438 441
@@ -477,7 +480,8 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
477 } 480 }
478 481
479 DEBUG(1, "Device: Size: %lu Width:%d Name: %s", 482 DEBUG(1, "Device: Size: %lu Width:%d Name: %s",
480 dev->pcmcia_map.size, dev->pcmcia_map.bankwidth << 3, dev->mtd_name); 483 dev->pcmcia_map.size,
484 dev->pcmcia_map.bankwidth << 3, dev->mtd_name);
481} 485}
482 486
483 487
@@ -490,7 +494,6 @@ static int pcmciamtd_config(struct pcmcia_device *link)
490{ 494{
491 struct pcmciamtd_dev *dev = link->priv; 495 struct pcmciamtd_dev *dev = link->priv;
492 struct mtd_info *mtd = NULL; 496 struct mtd_info *mtd = NULL;
493 cs_status_t status;
494 win_req_t req; 497 win_req_t req;
495 int ret; 498 int ret;
496 int i; 499 int i;
@@ -514,9 +517,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
514 if(setvpp == 1) 517 if(setvpp == 1)
515 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; 518 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
516 519
517 /* Request a memory window for PCMCIA. Some architeures can map windows upto the maximum 520 /* Request a memory window for PCMCIA. Some architeures can map windows
518 that PCMCIA can support (64MiB) - this is ideal and we aim for a window the size of the 521 * upto the maximum that PCMCIA can support (64MiB) - this is ideal and
519 whole card - otherwise we try smaller windows until we succeed */ 522 * we aim for a window the size of the whole card - otherwise we try
523 * smaller windows until we succeed
524 */
520 525
521 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; 526 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE;
522 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; 527 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16;
@@ -544,7 +549,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
544 DEBUG(2, "dev->win_size = %d", dev->win_size); 549 DEBUG(2, "dev->win_size = %d", dev->win_size);
545 550
546 if(!dev->win_size) { 551 if(!dev->win_size) {
547 err("Cant allocate memory window"); 552 dev_err(&dev->p_dev->dev, "Cannot allocate memory window\n");
548 pcmciamtd_release(link); 553 pcmciamtd_release(link);
549 return -ENODEV; 554 return -ENODEV;
550 } 555 }
@@ -554,7 +559,8 @@ static int pcmciamtd_config(struct pcmcia_device *link)
554 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); 559 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win);
555 dev->win_base = ioremap(req.Base, req.Size); 560 dev->win_base = ioremap(req.Base, req.Size);
556 if(!dev->win_base) { 561 if(!dev->win_base) {
557 err("ioremap(%lu, %u) failed", req.Base, req.Size); 562 dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n",
563 req.Base, req.Size);
558 pcmciamtd_release(link); 564 pcmciamtd_release(link);
559 return -ENODEV; 565 return -ENODEV;
560 } 566 }
@@ -565,7 +571,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
565 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 571 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
566 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 572 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
567 573
568 dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; 574 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp;
569 link->conf.Attributes = 0; 575 link->conf.Attributes = 0;
570 if(setvpp == 2) { 576 if(setvpp == 2) {
571 link->conf.Vpp = dev->vpp; 577 link->conf.Vpp = dev->vpp;
@@ -601,7 +607,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
601 } 607 }
602 608
603 if(!mtd) { 609 if(!mtd) {
604 DEBUG(1, "Cant find an MTD"); 610 DEBUG(1, "Can not find an MTD");
605 pcmciamtd_release(link); 611 pcmciamtd_release(link);
606 return -ENODEV; 612 return -ENODEV;
607 } 613 }
@@ -612,8 +618,9 @@ static int pcmciamtd_config(struct pcmcia_device *link)
612 if(new_name) { 618 if(new_name) {
613 int size = 0; 619 int size = 0;
614 char unit = ' '; 620 char unit = ' ';
615 /* Since we are using a default name, make it better by adding in the 621 /* Since we are using a default name, make it better by adding
616 size */ 622 * in the size
623 */
617 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ 624 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
618 size = mtd->size >> 10; 625 size = mtd->size >> 10;
619 unit = 'K'; 626 unit = 'K';
@@ -643,17 +650,15 @@ static int pcmciamtd_config(struct pcmcia_device *link)
643 if(add_mtd_device(mtd)) { 650 if(add_mtd_device(mtd)) {
644 map_destroy(mtd); 651 map_destroy(mtd);
645 dev->mtd_info = NULL; 652 dev->mtd_info = NULL;
646 err("Couldnt register MTD device"); 653 dev_err(&dev->p_dev->dev,
654 "Could not register the MTD device\n");
647 pcmciamtd_release(link); 655 pcmciamtd_release(link);
648 return -ENODEV; 656 return -ENODEV;
649 } 657 }
650 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); 658 dev_info(&dev->p_dev->dev, "mtd%d: %s\n", mtd->index, mtd->name);
651 info("mtd%d: %s", mtd->index, mtd->name);
652 link->dev_node = &dev->node;
653 return 0; 659 return 0;
654 660
655 failed: 661 dev_err(&dev->p_dev->dev, "CS Error, exiting\n");
656 err("CS Error, exiting");
657 pcmciamtd_release(link); 662 pcmciamtd_release(link);
658 return -ENODEV; 663 return -ENODEV;
659} 664}
@@ -692,8 +697,9 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
692 697
693 if(dev->mtd_info) { 698 if(dev->mtd_info) {
694 del_mtd_device(dev->mtd_info); 699 del_mtd_device(dev->mtd_info);
700 dev_info(&dev->p_dev->dev, "mtd%d: Removing\n",
701 dev->mtd_info->index);
695 map_destroy(dev->mtd_info); 702 map_destroy(dev->mtd_info);
696 info("mtd%d: Removed", dev->mtd_info->index);
697 } 703 }
698 704
699 pcmciamtd_release(link); 705 pcmciamtd_release(link);
@@ -737,8 +743,11 @@ static struct pcmcia_device_id pcmciamtd_ids[] = {
737 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), 743 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8),
738 PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c), 744 PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c),
739 PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0), 745 PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0),
746 PCMCIA_DEVICE_PROD_ID123("M-Systems", "M-SYS Flash Memory Card", "(c) M-Systems", 0x7ed2ad87, 0x675dc3fb, 0x7aef3965),
747 PCMCIA_DEVICE_PROD_ID12("PRETEC", " 2MB SRAM CARD", 0xebf91155, 0x805360ca),
740 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), 748 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b),
741 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad), 749 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad),
750 PCMCIA_DEVICE_PROD_ID12("SMART Modular Technologies", " 4MB FLASH Card", 0x96fd8277, 0x737a5b05),
742 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), 751 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca),
743 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), 752 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944),
744 /* the following was commented out in pcmcia-cs-3.2.7 */ 753 /* the following was commented out in pcmcia-cs-3.2.7 */
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index d9603f7f9652..426461a5f0d4 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -264,8 +264,11 @@ static int __init physmap_init(void)
264 264
265 err = platform_driver_register(&physmap_flash_driver); 265 err = platform_driver_register(&physmap_flash_driver);
266#ifdef CONFIG_MTD_PHYSMAP_COMPAT 266#ifdef CONFIG_MTD_PHYSMAP_COMPAT
267 if (err == 0) 267 if (err == 0) {
268 platform_device_register(&physmap_flash); 268 err = platform_device_register(&physmap_flash);
269 if (err)
270 platform_driver_unregister(&physmap_flash_driver);
271 }
269#endif 272#endif
270 273
271 return err; 274 return err;
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 4147fe328c55..ba124baa646d 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -173,12 +173,53 @@ static struct mtd_info * __devinit obsolete_probe(struct of_device *dev,
173 } 173 }
174} 174}
175 175
176#ifdef CONFIG_MTD_PARTITIONS
177/* When partitions are set we look for a linux,part-probe property which
178 specifies the list of partition probers to use. If none is given then the
179 default is use. These take precedence over other device tree
180 information. */
181static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot", NULL };
182static const char ** __devinit of_get_probes(struct device_node *dp)
183{
184 const char *cp;
185 int cplen;
186 unsigned int l;
187 unsigned int count;
188 const char **res;
189
190 cp = of_get_property(dp, "linux,part-probe", &cplen);
191 if (cp == NULL)
192 return part_probe_types_def;
193
194 count = 0;
195 for (l = 0; l != cplen; l++)
196 if (cp[l] == 0)
197 count++;
198
199 res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
200 count = 0;
201 while (cplen > 0) {
202 res[count] = cp;
203 l = strlen(cp) + 1;
204 cp += l;
205 cplen -= l;
206 count++;
207 }
208 return res;
209}
210
211static void __devinit of_free_probes(const char **probes)
212{
213 if (probes != part_probe_types_def)
214 kfree(probes);
215}
216#endif
217
176static int __devinit of_flash_probe(struct of_device *dev, 218static int __devinit of_flash_probe(struct of_device *dev,
177 const struct of_device_id *match) 219 const struct of_device_id *match)
178{ 220{
179#ifdef CONFIG_MTD_PARTITIONS 221#ifdef CONFIG_MTD_PARTITIONS
180 static const char *part_probe_types[] 222 const char **part_probe_types;
181 = { "cmdlinepart", "RedBoot", NULL };
182#endif 223#endif
183 struct device_node *dp = dev->dev.of_node; 224 struct device_node *dp = dev->dev.of_node;
184 struct resource res; 225 struct resource res;
@@ -218,7 +259,7 @@ static int __devinit of_flash_probe(struct of_device *dev,
218 259
219 dev_set_drvdata(&dev->dev, info); 260 dev_set_drvdata(&dev->dev, info);
220 261
221 mtd_list = kzalloc(sizeof(struct mtd_info) * count, GFP_KERNEL); 262 mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL);
222 if (!mtd_list) 263 if (!mtd_list)
223 goto err_flash_remove; 264 goto err_flash_remove;
224 265
@@ -307,12 +348,14 @@ static int __devinit of_flash_probe(struct of_device *dev,
307 goto err_out; 348 goto err_out;
308 349
309#ifdef CONFIG_MTD_PARTITIONS 350#ifdef CONFIG_MTD_PARTITIONS
310 /* First look for RedBoot table or partitions on the command 351 part_probe_types = of_get_probes(dp);
311 * line, these take precedence over device tree information */
312 err = parse_mtd_partitions(info->cmtd, part_probe_types, 352 err = parse_mtd_partitions(info->cmtd, part_probe_types,
313 &info->parts, 0); 353 &info->parts, 0);
314 if (err < 0) 354 if (err < 0) {
355 of_free_probes(part_probe_types);
315 return err; 356 return err;
357 }
358 of_free_probes(part_probe_types);
316 359
317#ifdef CONFIG_MTD_OF_PARTS 360#ifdef CONFIG_MTD_OF_PARTS
318 if (err == 0) { 361 if (err == 0) {
diff --git a/drivers/mtd/maps/pismo.c b/drivers/mtd/maps/pismo.c
index 60c068db452d..eb476b7f8d11 100644
--- a/drivers/mtd/maps/pismo.c
+++ b/drivers/mtd/maps/pismo.c
@@ -234,6 +234,7 @@ static int __devexit pismo_remove(struct i2c_client *client)
234 /* FIXME: set_vpp needs saner arguments */ 234 /* FIXME: set_vpp needs saner arguments */
235 pismo_setvpp_remove_fix(pismo); 235 pismo_setvpp_remove_fix(pismo);
236 236
237 i2c_set_clientdata(client, NULL);
237 kfree(pismo); 238 kfree(pismo);
238 239
239 return 0; 240 return 0;
@@ -272,7 +273,7 @@ static int __devinit pismo_probe(struct i2c_client *client,
272 ret = pismo_eeprom_read(client, &eeprom, 0, sizeof(eeprom)); 273 ret = pismo_eeprom_read(client, &eeprom, 0, sizeof(eeprom));
273 if (ret < 0) { 274 if (ret < 0) {
274 dev_err(&client->dev, "error reading EEPROM: %d\n", ret); 275 dev_err(&client->dev, "error reading EEPROM: %d\n", ret);
275 return ret; 276 goto exit_free;
276 } 277 }
277 278
278 dev_info(&client->dev, "%.15s board found\n", eeprom.board); 279 dev_info(&client->dev, "%.15s board found\n", eeprom.board);
@@ -283,6 +284,11 @@ static int __devinit pismo_probe(struct i2c_client *client,
283 pdata->cs_addrs[i]); 284 pdata->cs_addrs[i]);
284 285
285 return 0; 286 return 0;
287
288 exit_free:
289 i2c_set_clientdata(client, NULL);
290 kfree(pismo);
291 return ret;
286} 292}
287 293
288static const struct i2c_device_id pismo_id[] = { 294static const struct i2c_device_id pismo_id[] = {
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index 91dc6331053f..dd90880048cf 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -63,11 +63,10 @@ static int __init pxa2xx_flash_probe(struct platform_device *pdev)
63 if (!res) 63 if (!res)
64 return -ENODEV; 64 return -ENODEV;
65 65
66 info = kmalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL); 66 info = kzalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
67 if (!info) 67 if (!info)
68 return -ENOMEM; 68 return -ENOMEM;
69 69
70 memset(info, 0, sizeof(struct pxa2xx_flash_info));
71 info->map.name = (char *) flash->name; 70 info->map.name = (char *) flash->name;
72 info->map.bankwidth = flash->width; 71 info->map.bankwidth = flash->width;
73 info->map.phys = res->start; 72 info->map.phys = res->start;