diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-07-28 04:59:06 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-09-29 11:20:21 -0400 |
commit | cdb138080b78146d1cdadba9f5dadbeb97445b91 (patch) | |
tree | fae26f709ed0f19648db79059234faf9fa028051 /drivers/mtd | |
parent | 899611ee7d373e5eeda08e9a8632684e1ebbbf00 (diff) |
pcmcia: do not use win_req_t when calling pcmcia_request_window()
Instead of win_req_t, drivers are now requested to fill out
struct pcmcia_device *p_dev->resource[2,3,4,5] for up to four iomem
ranges. After a call to pcmcia_request_window(), the windows found there
are reserved and may be used until pcmcia_release_window() is called.
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: linux-mtd@lists.infradead.org
CC: Jiri Kosina <jkosina@suse.cz>
CC: linux-scsi@vger.kernel.org
Tested-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index e9ca5ba7d9d2..fb3c5380aa84 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -101,7 +101,7 @@ MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)") | |||
101 | static caddr_t remap_window(struct map_info *map, unsigned long to) | 101 | static caddr_t remap_window(struct map_info *map, unsigned long to) |
102 | { | 102 | { |
103 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 103 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
104 | window_handle_t win = (window_handle_t)map->map_priv_2; | 104 | struct resource *win = (struct resource *) map->map_priv_2; |
105 | unsigned int offset; | 105 | unsigned int offset; |
106 | int ret; | 106 | int ret; |
107 | 107 | ||
@@ -339,7 +339,7 @@ static void pcmciamtd_release(struct pcmcia_device *link) | |||
339 | 339 | ||
340 | DEBUG(3, "link = 0x%p", link); | 340 | DEBUG(3, "link = 0x%p", link); |
341 | 341 | ||
342 | if (link->win) { | 342 | if (link->resource[2]->end) { |
343 | if(dev->win_base) { | 343 | if(dev->win_base) { |
344 | iounmap(dev->win_base); | 344 | iounmap(dev->win_base); |
345 | dev->win_base = NULL; | 345 | dev->win_base = NULL; |
@@ -491,9 +491,8 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
491 | { | 491 | { |
492 | struct pcmciamtd_dev *dev = link->priv; | 492 | struct pcmciamtd_dev *dev = link->priv; |
493 | struct mtd_info *mtd = NULL; | 493 | struct mtd_info *mtd = NULL; |
494 | win_req_t req; | ||
495 | int ret; | 494 | int ret; |
496 | int i; | 495 | int i, j = 0; |
497 | static char *probes[] = { "jedec_probe", "cfi_probe" }; | 496 | static char *probes[] = { "jedec_probe", "cfi_probe" }; |
498 | int new_name = 0; | 497 | int new_name = 0; |
499 | 498 | ||
@@ -520,28 +519,34 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
520 | * smaller windows until we succeed | 519 | * smaller windows until we succeed |
521 | */ | 520 | */ |
522 | 521 | ||
523 | req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; | 522 | link->resource[2]->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE; |
524 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; | 523 | link->resource[2]->flags |= (dev->pcmcia_map.bankwidth == 1) ? |
525 | req.Base = 0; | 524 | WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; |
526 | req.AccessSpeed = mem_speed; | 525 | link->resource[2]->start = 0; |
527 | link->win = (window_handle_t)link; | 526 | link->resource[2]->end = (force_size) ? force_size << 20 : |
528 | req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; | 527 | MAX_PCMCIA_ADDR; |
529 | dev->win_size = 0; | 528 | dev->win_size = 0; |
530 | 529 | ||
531 | do { | 530 | do { |
532 | int ret; | 531 | int ret; |
533 | DEBUG(2, "requesting window with size = %dKiB memspeed = %d", | 532 | DEBUG(2, "requesting window with size = %luKiB memspeed = %d", |
534 | req.Size >> 10, req.AccessSpeed); | 533 | (unsigned long) resource_size(link->resource[2]) >> 10, |
535 | ret = pcmcia_request_window(link, &req, &link->win); | 534 | mem_speed); |
535 | ret = pcmcia_request_window(link, link->resource[2], mem_speed); | ||
536 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); | 536 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); |
537 | if(ret) { | 537 | if(ret) { |
538 | req.Size >>= 1; | 538 | j++; |
539 | link->resource[2]->start = 0; | ||
540 | link->resource[2]->end = (force_size) ? | ||
541 | force_size << 20 : MAX_PCMCIA_ADDR; | ||
542 | link->resource[2]->end >>= j; | ||
539 | } else { | 543 | } else { |
540 | DEBUG(2, "Got window of size %dKiB", req.Size >> 10); | 544 | DEBUG(2, "Got window of size %luKiB", (unsigned long) |
541 | dev->win_size = req.Size; | 545 | resource_size(link->resource[2]) >> 10); |
546 | dev->win_size = resource_size(link->resource[2]); | ||
542 | break; | 547 | break; |
543 | } | 548 | } |
544 | } while(req.Size >= 0x1000); | 549 | } while (link->resource[2]->end >= 0x1000); |
545 | 550 | ||
546 | DEBUG(2, "dev->win_size = %d", dev->win_size); | 551 | DEBUG(2, "dev->win_size = %d", dev->win_size); |
547 | 552 | ||
@@ -553,20 +558,20 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
553 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); | 558 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); |
554 | 559 | ||
555 | /* Get write protect status */ | 560 | /* Get write protect status */ |
556 | DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); | 561 | dev->win_base = ioremap(link->resource[2]->start, |
557 | dev->win_base = ioremap(req.Base, req.Size); | 562 | resource_size(link->resource[2])); |
558 | if(!dev->win_base) { | 563 | if(!dev->win_base) { |
559 | dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n", | 564 | dev_err(&dev->p_dev->dev, "ioremap(%pR) failed\n", |
560 | req.Base, req.Size); | 565 | link->resource[2]); |
561 | pcmciamtd_release(link); | 566 | pcmciamtd_release(link); |
562 | return -ENODEV; | 567 | return -ENODEV; |
563 | } | 568 | } |
564 | DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", | 569 | DEBUG(1, "mapped window dev = %p @ %pR, base = %p", |
565 | dev, req.Base, dev->win_base, req.Size); | 570 | dev, link->resource[2], dev->win_base); |
566 | 571 | ||
567 | dev->offset = 0; | 572 | dev->offset = 0; |
568 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; | 573 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; |
569 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; | 574 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->resource[2]; |
570 | 575 | ||
571 | dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp; | 576 | dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp; |
572 | link->conf.Attributes = 0; | 577 | link->conf.Attributes = 0; |