diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 915b64e23797..050aa8ecb240 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"); | |||
40 | static const int debug = 0; | 40 | static 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 | ||
@@ -100,7 +97,9 @@ module_param(mem_type, int, 0); | |||
100 | MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); | 97 | MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); |
101 | 98 | ||
102 | 99 | ||
103 | /* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */ | 100 | /* read/write{8,16} copy_{from,to} routines with window remapping |
101 | * to access whole card | ||
102 | */ | ||
104 | static caddr_t remap_window(struct map_info *map, unsigned long to) | 103 | static caddr_t remap_window(struct map_info *map, unsigned long to) |
105 | { | 104 | { |
106 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 105 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
@@ -245,7 +244,8 @@ static map_word pcmcia_read8(struct map_info *map, unsigned long ofs) | |||
245 | return d; | 244 | return d; |
246 | 245 | ||
247 | d.x[0] = readb(win_base + ofs); | 246 | d.x[0] = readb(win_base + ofs); |
248 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx", ofs, win_base + ofs, d.x[0]); | 247 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx", |
248 | ofs, win_base + ofs, d.x[0]); | ||
249 | return d; | 249 | return d; |
250 | } | 250 | } |
251 | 251 | ||
@@ -259,7 +259,8 @@ static map_word pcmcia_read16(struct map_info *map, unsigned long ofs) | |||
259 | return d; | 259 | return d; |
260 | 260 | ||
261 | d.x[0] = readw(win_base + ofs); | 261 | d.x[0] = readw(win_base + ofs); |
262 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx", ofs, win_base + ofs, d.x[0]); | 262 | DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx", |
263 | ofs, win_base + ofs, d.x[0]); | ||
263 | return d; | 264 | return d; |
264 | } | 265 | } |
265 | 266 | ||
@@ -283,7 +284,8 @@ static void pcmcia_write8(struct map_info *map, map_word d, unsigned long adr) | |||
283 | if(DEV_REMOVED(map)) | 284 | if(DEV_REMOVED(map)) |
284 | return; | 285 | return; |
285 | 286 | ||
286 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx", adr, win_base + adr, d.x[0]); | 287 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx", |
288 | adr, win_base + adr, d.x[0]); | ||
287 | writeb(d.x[0], win_base + adr); | 289 | writeb(d.x[0], win_base + adr); |
288 | } | 290 | } |
289 | 291 | ||
@@ -295,7 +297,8 @@ static void pcmcia_write16(struct map_info *map, map_word d, unsigned long adr) | |||
295 | if(DEV_REMOVED(map)) | 297 | if(DEV_REMOVED(map)) |
296 | return; | 298 | return; |
297 | 299 | ||
298 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx", adr, win_base + adr, d.x[0]); | 300 | DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx", |
301 | adr, win_base + adr, d.x[0]); | ||
299 | writew(d.x[0], win_base + adr); | 302 | writew(d.x[0], win_base + adr); |
300 | } | 303 | } |
301 | 304 | ||
@@ -376,7 +379,8 @@ static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev, | |||
376 | if (!pcmcia_parse_tuple(tuple, &parse)) { | 379 | if (!pcmcia_parse_tuple(tuple, &parse)) { |
377 | cistpl_jedec_t *t = &parse.jedec; | 380 | cistpl_jedec_t *t = &parse.jedec; |
378 | for (i = 0; i < t->nid; i++) | 381 | for (i = 0; i < t->nid; i++) |
379 | DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); | 382 | DEBUG(2, "JEDEC: 0x%02x 0x%02x", |
383 | t->id[i].mfr, t->id[i].info); | ||
380 | } | 384 | } |
381 | return -ENOSPC; | 385 | return -ENOSPC; |
382 | } | 386 | } |
@@ -477,7 +481,8 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *p_dev | |||
477 | } | 481 | } |
478 | 482 | ||
479 | DEBUG(1, "Device: Size: %lu Width:%d Name: %s", | 483 | DEBUG(1, "Device: Size: %lu Width:%d Name: %s", |
480 | dev->pcmcia_map.size, dev->pcmcia_map.bankwidth << 3, dev->mtd_name); | 484 | dev->pcmcia_map.size, |
485 | dev->pcmcia_map.bankwidth << 3, dev->mtd_name); | ||
481 | } | 486 | } |
482 | 487 | ||
483 | 488 | ||
@@ -513,9 +518,11 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
513 | if(setvpp == 1) | 518 | if(setvpp == 1) |
514 | dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; | 519 | dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; |
515 | 520 | ||
516 | /* Request a memory window for PCMCIA. Some architeures can map windows upto the maximum | 521 | /* 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 | 522 | * upto the maximum that PCMCIA can support (64MiB) - this is ideal and |
518 | whole card - otherwise we try smaller windows until we succeed */ | 523 | * we aim for a window the size of the whole card - otherwise we try |
524 | * smaller windows until we succeed | ||
525 | */ | ||
519 | 526 | ||
520 | req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; | 527 | req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; |
521 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; | 528 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; |
@@ -543,7 +550,7 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
543 | DEBUG(2, "dev->win_size = %d", dev->win_size); | 550 | DEBUG(2, "dev->win_size = %d", dev->win_size); |
544 | 551 | ||
545 | if(!dev->win_size) { | 552 | if(!dev->win_size) { |
546 | err("Cant allocate memory window"); | 553 | dev_err(&dev->p_dev->dev, "Cannot allocate memory window\n"); |
547 | pcmciamtd_release(link); | 554 | pcmciamtd_release(link); |
548 | return -ENODEV; | 555 | return -ENODEV; |
549 | } | 556 | } |
@@ -553,7 +560,8 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
553 | DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); | 560 | DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); |
554 | dev->win_base = ioremap(req.Base, req.Size); | 561 | dev->win_base = ioremap(req.Base, req.Size); |
555 | if(!dev->win_base) { | 562 | if(!dev->win_base) { |
556 | err("ioremap(%lu, %u) failed", req.Base, req.Size); | 563 | dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n", |
564 | req.Base, req.Size); | ||
557 | pcmciamtd_release(link); | 565 | pcmciamtd_release(link); |
558 | return -ENODEV; | 566 | return -ENODEV; |
559 | } | 567 | } |
@@ -600,7 +608,7 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
600 | } | 608 | } |
601 | 609 | ||
602 | if(!mtd) { | 610 | if(!mtd) { |
603 | DEBUG(1, "Cant find an MTD"); | 611 | DEBUG(1, "Can not find an MTD"); |
604 | pcmciamtd_release(link); | 612 | pcmciamtd_release(link); |
605 | return -ENODEV; | 613 | return -ENODEV; |
606 | } | 614 | } |
@@ -611,8 +619,9 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
611 | if(new_name) { | 619 | if(new_name) { |
612 | int size = 0; | 620 | int size = 0; |
613 | char unit = ' '; | 621 | char unit = ' '; |
614 | /* Since we are using a default name, make it better by adding in the | 622 | /* Since we are using a default name, make it better by adding |
615 | size */ | 623 | * in the size |
624 | */ | ||
616 | if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ | 625 | if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ |
617 | size = mtd->size >> 10; | 626 | size = mtd->size >> 10; |
618 | unit = 'K'; | 627 | unit = 'K'; |
@@ -642,16 +651,17 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
642 | if(add_mtd_device(mtd)) { | 651 | if(add_mtd_device(mtd)) { |
643 | map_destroy(mtd); | 652 | map_destroy(mtd); |
644 | dev->mtd_info = NULL; | 653 | dev->mtd_info = NULL; |
645 | err("Couldnt register MTD device"); | 654 | dev_err(&dev->p_dev->dev, |
655 | "Could not register the MTD device\n"); | ||
646 | pcmciamtd_release(link); | 656 | pcmciamtd_release(link); |
647 | return -ENODEV; | 657 | return -ENODEV; |
648 | } | 658 | } |
649 | snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); | 659 | snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); |
650 | info("mtd%d: %s", mtd->index, mtd->name); | 660 | dev_info(&dev->p_dev->dev, "mtd%d: %s\n", mtd->index, mtd->name); |
651 | link->dev_node = &dev->node; | 661 | link->dev_node = &dev->node; |
652 | return 0; | 662 | return 0; |
653 | 663 | ||
654 | err("CS Error, exiting"); | 664 | dev_err(&dev->p_dev->dev, "CS Error, exiting\n"); |
655 | pcmciamtd_release(link); | 665 | pcmciamtd_release(link); |
656 | return -ENODEV; | 666 | return -ENODEV; |
657 | } | 667 | } |
@@ -690,7 +700,8 @@ static void pcmciamtd_detach(struct pcmcia_device *link) | |||
690 | 700 | ||
691 | if(dev->mtd_info) { | 701 | if(dev->mtd_info) { |
692 | del_mtd_device(dev->mtd_info); | 702 | del_mtd_device(dev->mtd_info); |
693 | info("mtd%d: Removing", dev->mtd_info->index); | 703 | dev_info(&dev->p_dev->dev, "mtd%d: Removing\n", |
704 | dev->mtd_info->index); | ||
694 | map_destroy(dev->mtd_info); | 705 | map_destroy(dev->mtd_info); |
695 | } | 706 | } |
696 | 707 | ||