aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 10:25:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-21 10:25:43 -0400
commit05ec7dd8dd5aa42c22a49682e4a51cadd4166b7e (patch)
tree6370b43c0d8f324aa7421bbb5a647aa04ab5d747 /drivers/mtd/maps
parentc316ba3b518bc35ce5aef5421135220389f4eb98 (diff)
parent8046112818b70329e930b1d4557ef0876c1ad2bb (diff)
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6: (154 commits) mtd: cfi_cmdset_0002: use AMD standard command-set with Winbond flash chips mtd: cfi_cmdset_0002: Fix MODULE_ALIAS and linkage for new 0701 commandset ID mtd: mxc_nand: Remove duplicate NAND_CMD_RESET case value mtd: update gfp/slab.h includes jffs2: Stop triggering block erases from jffs2_write_super() jffs2: Rename jffs2_erase_pending_trigger() to jffs2_dirty_trigger() jffs2: Use jffs2_garbage_collect_trigger() to trigger pending erases jffs2: Require jffs2_garbage_collect_trigger() to be called with lock held jffs2: Wake GC thread when there are blocks to be erased jffs2: Erase pending blocks in GC pass, avoid invalid -EIO return jffs2: Add 'work_done' return value from jffs2_erase_pending_blocks() mtd: mtdchar: Do not corrupt backing device of device node inode mtd/maps/pcmciamtd: Fix printk format for ssize_t in debug messages drivers/mtd: Use kmemdup mtd: cfi_cmdset_0002: Fix argument order in bootloc warning mtd: nand: add Toshiba TC58NVG0 device ID pcmciamtd: add another ID pcmciamtd: coding style cleanups pcmciamtd: fixing obvious errors mtd: chips: add SST39WF160x NOR-flashes ... Trivial conflicts due to dev_node removal in drivers/mtd/maps/pcmciamtd.c
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.c88
-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, 65 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 87b2b8ff331e..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
@@ -99,7 +96,9 @@ module_param(mem_type, int, 0);
99MODULE_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)");
100 97
101 98
102/* 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 */
103static caddr_t remap_window(struct map_info *map, unsigned long to) 102static caddr_t remap_window(struct map_info *map, unsigned long to)
104{ 103{
105 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 104 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
@@ -136,7 +135,7 @@ static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
136 return d; 135 return d;
137 136
138 d.x[0] = readb(addr); 137 d.x[0] = readb(addr);
139 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]);
140 return d; 139 return d;
141} 140}
142 141
@@ -151,7 +150,7 @@ static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
151 return d; 150 return d;
152 151
153 d.x[0] = readw(addr); 152 d.x[0] = readw(addr);
154 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]);
155 return d; 154 return d;
156} 155}
157 156
@@ -161,7 +160,7 @@ static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long
161 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 160 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
162 unsigned long win_size = dev->win_size; 161 unsigned long win_size = dev->win_size;
163 162
164 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 163 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
165 while(len) { 164 while(len) {
166 int toread = win_size - (from & (win_size-1)); 165 int toread = win_size - (from & (win_size-1));
167 caddr_t addr; 166 caddr_t addr;
@@ -189,7 +188,7 @@ static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long
189 if(!addr) 188 if(!addr)
190 return; 189 return;
191 190
192 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]);
193 writeb(d.x[0], addr); 192 writeb(d.x[0], addr);
194} 193}
195 194
@@ -200,7 +199,7 @@ static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long
200 if(!addr) 199 if(!addr)
201 return; 200 return;
202 201
203 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]);
204 writew(d.x[0], addr); 203 writew(d.x[0], addr);
205} 204}
206 205
@@ -210,7 +209,7 @@ static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const v
210 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 209 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
211 unsigned long win_size = dev->win_size; 210 unsigned long win_size = dev->win_size;
212 211
213 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 212 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
214 while(len) { 213 while(len) {
215 int towrite = win_size - (to & (win_size-1)); 214 int towrite = win_size - (to & (win_size-1));
216 caddr_t addr; 215 caddr_t addr;
@@ -244,7 +243,8 @@ static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
244 return d; 243 return d;
245 244
246 d.x[0] = readb(win_base + ofs); 245 d.x[0] = readb(win_base + ofs);
247 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]);
248 return d; 248 return d;
249} 249}
250 250
@@ -258,7 +258,8 @@ static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
258 return d; 258 return d;
259 259
260 d.x[0] = readw(win_base + ofs); 260 d.x[0] = readw(win_base + ofs);
261 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]);
262 return d; 263 return d;
263} 264}
264 265
@@ -270,32 +271,34 @@ static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from,
270 if(DEV_REMOVED(map)) 271 if(DEV_REMOVED(map))
271 return; 272 return;
272 273
273 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 274 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
274 memcpy_fromio(to, win_base + from, len); 275 memcpy_fromio(to, win_base + from, len);
275} 276}
276 277
277 278
278static 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)
279{ 280{
280 caddr_t win_base = (caddr_t)map->map_priv_2; 281 caddr_t win_base = (caddr_t)map->map_priv_2;
281 282
282 if(DEV_REMOVED(map)) 283 if(DEV_REMOVED(map))
283 return; 284 return;
284 285
285 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d); 286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx",
286 writeb(d, win_base + adr); 287 adr, win_base + adr, d.x[0]);
288 writeb(d.x[0], win_base + adr);
287} 289}
288 290
289 291
290static 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)
291{ 293{
292 caddr_t win_base = (caddr_t)map->map_priv_2; 294 caddr_t win_base = (caddr_t)map->map_priv_2;
293 295
294 if(DEV_REMOVED(map)) 296 if(DEV_REMOVED(map))
295 return; 297 return;
296 298
297 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d); 299 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx",
298 writew(d, win_base + adr); 300 adr, win_base + adr, d.x[0]);
301 writew(d.x[0], win_base + adr);
299} 302}
300 303
301 304
@@ -306,7 +309,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
306 if(DEV_REMOVED(map)) 309 if(DEV_REMOVED(map))
307 return; 310 return;
308 311
309 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 312 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
310 memcpy_toio(win_base + to, from, len); 313 memcpy_toio(win_base + to, from, len);
311} 314}
312 315
@@ -375,7 +378,8 @@ static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev,
375 if (!pcmcia_parse_tuple(tuple, &parse)) { 378 if (!pcmcia_parse_tuple(tuple, &parse)) {
376 cistpl_jedec_t *t = &parse.jedec; 379 cistpl_jedec_t *t = &parse.jedec;
377 for (i = 0; i < t->nid; i++) 380 for (i = 0; i < t->nid; i++)
378 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);
379 } 383 }
380 return -ENOSPC; 384 return -ENOSPC;
381} 385}
@@ -431,7 +435,7 @@ static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev,
431} 435}
432 436
433 437
434static 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)
435{ 439{
436 int i; 440 int i;
437 441
@@ -476,7 +480,8 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
476 } 480 }
477 481
478 DEBUG(1, "Device: Size: %lu Width:%d Name: %s", 482 DEBUG(1, "Device: Size: %lu Width:%d Name: %s",
479 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);
480} 485}
481 486
482 487
@@ -489,7 +494,6 @@ static int pcmciamtd_config(struct pcmcia_device *link)
489{ 494{
490 struct pcmciamtd_dev *dev = link->priv; 495 struct pcmciamtd_dev *dev = link->priv;
491 struct mtd_info *mtd = NULL; 496 struct mtd_info *mtd = NULL;
492 cs_status_t status;
493 win_req_t req; 497 win_req_t req;
494 int ret; 498 int ret;
495 int i; 499 int i;
@@ -513,9 +517,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
513 if(setvpp == 1) 517 if(setvpp == 1)
514 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; 518 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
515 519
516 /* 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
517 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
518 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 */
519 525
520 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; 526 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE;
521 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;
@@ -543,7 +549,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
543 DEBUG(2, "dev->win_size = %d", dev->win_size); 549 DEBUG(2, "dev->win_size = %d", dev->win_size);
544 550
545 if(!dev->win_size) { 551 if(!dev->win_size) {
546 err("Cant allocate memory window"); 552 dev_err(&dev->p_dev->dev, "Cannot allocate memory window\n");
547 pcmciamtd_release(link); 553 pcmciamtd_release(link);
548 return -ENODEV; 554 return -ENODEV;
549 } 555 }
@@ -553,7 +559,8 @@ static int pcmciamtd_config(struct pcmcia_device *link)
553 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); 559 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win);
554 dev->win_base = ioremap(req.Base, req.Size); 560 dev->win_base = ioremap(req.Base, req.Size);
555 if(!dev->win_base) { 561 if(!dev->win_base) {
556 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);
557 pcmciamtd_release(link); 564 pcmciamtd_release(link);
558 return -ENODEV; 565 return -ENODEV;
559 } 566 }
@@ -564,7 +571,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
564 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 571 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
565 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 572 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
566 573
567 dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; 574 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp;
568 link->conf.Attributes = 0; 575 link->conf.Attributes = 0;
569 if(setvpp == 2) { 576 if(setvpp == 2) {
570 link->conf.Vpp = dev->vpp; 577 link->conf.Vpp = dev->vpp;
@@ -600,7 +607,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
600 } 607 }
601 608
602 if(!mtd) { 609 if(!mtd) {
603 DEBUG(1, "Cant find an MTD"); 610 DEBUG(1, "Can not find an MTD");
604 pcmciamtd_release(link); 611 pcmciamtd_release(link);
605 return -ENODEV; 612 return -ENODEV;
606 } 613 }
@@ -611,8 +618,9 @@ static int pcmciamtd_config(struct pcmcia_device *link)
611 if(new_name) { 618 if(new_name) {
612 int size = 0; 619 int size = 0;
613 char unit = ' '; 620 char unit = ' ';
614 /* 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
615 size */ 622 * in the size
623 */
616 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ 624 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
617 size = mtd->size >> 10; 625 size = mtd->size >> 10;
618 unit = 'K'; 626 unit = 'K';
@@ -642,15 +650,15 @@ static int pcmciamtd_config(struct pcmcia_device *link)
642 if(add_mtd_device(mtd)) { 650 if(add_mtd_device(mtd)) {
643 map_destroy(mtd); 651 map_destroy(mtd);
644 dev->mtd_info = NULL; 652 dev->mtd_info = NULL;
645 err("Couldnt register MTD device"); 653 dev_err(&dev->p_dev->dev,
654 "Could not register the MTD device\n");
646 pcmciamtd_release(link); 655 pcmciamtd_release(link);
647 return -ENODEV; 656 return -ENODEV;
648 } 657 }
649 info("mtd%d: %s", mtd->index, mtd->name); 658 dev_info(&dev->p_dev->dev, "mtd%d: %s\n", mtd->index, mtd->name);
650 return 0; 659 return 0;
651 660
652 failed: 661 dev_err(&dev->p_dev->dev, "CS Error, exiting\n");
653 err("CS Error, exiting");
654 pcmciamtd_release(link); 662 pcmciamtd_release(link);
655 return -ENODEV; 663 return -ENODEV;
656} 664}
@@ -689,8 +697,9 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
689 697
690 if(dev->mtd_info) { 698 if(dev->mtd_info) {
691 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);
692 map_destroy(dev->mtd_info); 702 map_destroy(dev->mtd_info);
693 info("mtd%d: Removed", dev->mtd_info->index);
694 } 703 }
695 704
696 pcmciamtd_release(link); 705 pcmciamtd_release(link);
@@ -734,8 +743,11 @@ static struct pcmcia_device_id pcmciamtd_ids[] = {
734 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), 743 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8),
735 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),
736 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),
737 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), 748 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b),
738 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),
739 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), 751 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca),
740 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), 752 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944),
741 /* 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 101ee6ead05c..36dbcee1ac29 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->node; 224 struct device_node *dp = dev->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;