aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2008-08-03 05:40:19 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2008-08-22 20:29:48 -0400
commitf958095ef4fc96e978c6eddcaca29100e5276c7f (patch)
tree16afbb0172e7d7851350d37784bbf1fb0493c90d /drivers/pcmcia
parent943f70f1b5182c5220641ccb7bb905005162e227 (diff)
pcmcia: deprecate CS_IN_USE
If a resource is already in use, mark it with -EBUSY. Same for cards already asleep. (includes a fix for a bug found by Larry Finger -- thanks!) Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/cs.c6
-rw-r--r--drivers/pcmcia/pcmcia_resource.c43
2 files changed, 32 insertions, 17 deletions
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f9424801b9c8..1c6c8c8f57c9 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -534,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt)
534static int socket_suspend(struct pcmcia_socket *skt) 534static int socket_suspend(struct pcmcia_socket *skt)
535{ 535{
536 if (skt->state & SOCKET_SUSPEND) 536 if (skt->state & SOCKET_SUSPEND)
537 return CS_IN_USE; 537 return -EBUSY;
538 538
539 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); 539 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW);
540 skt->socket = dead_socket; 540 skt->socket = dead_socket;
@@ -556,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt)
556 int ret; 556 int ret;
557 557
558 if (!(skt->state & SOCKET_SUSPEND)) 558 if (!(skt->state & SOCKET_SUSPEND))
559 return CS_IN_USE; 559 return -EBUSY;
560 560
561 skt->socket = dead_socket; 561 skt->socket = dead_socket;
562 skt->ops->init(skt); 562 skt->ops->init(skt);
@@ -765,7 +765,7 @@ int pccard_reset_card(struct pcmcia_socket *skt)
765 break; 765 break;
766 } 766 }
767 if (skt->state & SOCKET_SUSPEND) { 767 if (skt->state & SOCKET_SUSPEND) {
768 ret = CS_IN_USE; 768 ret = -EBUSY;
769 break; 769 break;
770 } 770 }
771 if (skt->state & SOCKET_CARDBUS) { 771 if (skt->state & SOCKET_CARDBUS) {
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 0ac3ea92a1c5..670465d4aac2 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -609,23 +609,30 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
609 c = p_dev->function_config; 609 c = p_dev->function_config;
610 if (c->state & CONFIG_LOCKED) 610 if (c->state & CONFIG_LOCKED)
611 return -EACCES; 611 return -EACCES;
612 if (c->state & CONFIG_IO_REQ) 612 if (c->state & CONFIG_IO_REQ) {
613 return CS_IN_USE; 613 ds_dbg(s, 0, "IO already configured\n");
614 return -EBUSY;
615 }
614 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) 616 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))
615 return CS_BAD_ATTRIBUTE; 617 return CS_BAD_ATTRIBUTE;
616 if ((req->NumPorts2 > 0) && 618 if ((req->NumPorts2 > 0) &&
617 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) 619 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)))
618 return CS_BAD_ATTRIBUTE; 620 return CS_BAD_ATTRIBUTE;
619 621
622 ds_dbg(s, 1, "trying to allocate resource 1\n");
620 if (alloc_io_space(s, req->Attributes1, &req->BasePort1, 623 if (alloc_io_space(s, req->Attributes1, &req->BasePort1,
621 req->NumPorts1, req->IOAddrLines)) 624 req->NumPorts1, req->IOAddrLines)) {
622 return CS_IN_USE; 625 ds_dbg(s, 0, "allocation of resource 1 failed\n");
626 return -EBUSY;
627 }
623 628
624 if (req->NumPorts2) { 629 if (req->NumPorts2) {
630 ds_dbg(s, 1, "trying to allocate resource 2\n");
625 if (alloc_io_space(s, req->Attributes2, &req->BasePort2, 631 if (alloc_io_space(s, req->Attributes2, &req->BasePort2,
626 req->NumPorts2, req->IOAddrLines)) { 632 req->NumPorts2, req->IOAddrLines)) {
633 ds_dbg(s, 0, "allocation of resource 2 failed\n");
627 release_io_space(s, req->BasePort1, req->NumPorts1); 634 release_io_space(s, req->BasePort1, req->NumPorts1);
628 return CS_IN_USE; 635 return -EBUSY;
629 } 636 }
630 } 637 }
631 638
@@ -658,7 +665,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
658{ 665{
659 struct pcmcia_socket *s = p_dev->socket; 666 struct pcmcia_socket *s = p_dev->socket;
660 config_t *c; 667 config_t *c;
661 int ret = CS_IN_USE, irq = 0; 668 int ret = -EINVAL, irq = 0;
662 int type; 669 int type;
663 670
664 if (!(s->state & SOCKET_PRESENT)) 671 if (!(s->state & SOCKET_PRESENT))
@@ -666,8 +673,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
666 c = p_dev->function_config; 673 c = p_dev->function_config;
667 if (c->state & CONFIG_LOCKED) 674 if (c->state & CONFIG_LOCKED)
668 return -EACCES; 675 return -EACCES;
669 if (c->state & CONFIG_IRQ_REQ) 676 if (c->state & CONFIG_IRQ_REQ) {
670 return CS_IN_USE; 677 ds_dbg(s, 0, "IRQ already configured\n");
678 return -EBUSY;
679 }
671 680
672 /* Decide what type of interrupt we are registering */ 681 /* Decide what type of interrupt we are registering */
673 type = 0; 682 type = 0;
@@ -730,8 +739,10 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
730 } 739 }
731 740
732 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { 741 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) {
733 if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance)) 742 ret = request_irq(irq, req->Handler, type,
734 return CS_IN_USE; 743 p_dev->devname, req->Instance);
744 if (ret)
745 return ret;
735 } 746 }
736 747
737 /* Make sure the fact the request type was overridden is passed back */ 748 /* Make sure the fact the request type was overridden is passed back */
@@ -792,8 +803,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
792 /* Allocate system memory window */ 803 /* Allocate system memory window */
793 for (w = 0; w < MAX_WIN; w++) 804 for (w = 0; w < MAX_WIN; w++)
794 if (!(s->state & SOCKET_WIN_REQ(w))) break; 805 if (!(s->state & SOCKET_WIN_REQ(w))) break;
795 if (w == MAX_WIN) 806 if (w == MAX_WIN) {
796 return CS_IN_USE; 807 ds_dbg(s, 0, "all windows are used already\n");
808 return -EINVAL;
809 }
797 810
798 win = &s->win[w]; 811 win = &s->win[w];
799 win->magic = WINDOW_MAGIC; 812 win->magic = WINDOW_MAGIC;
@@ -804,8 +817,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
804 if (!(s->features & SS_CAP_STATIC_MAP)) { 817 if (!(s->features & SS_CAP_STATIC_MAP)) {
805 win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, 818 win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align,
806 (req->Attributes & WIN_MAP_BELOW_1MB), s); 819 (req->Attributes & WIN_MAP_BELOW_1MB), s);
807 if (!win->ctl.res) 820 if (!win->ctl.res) {
808 return CS_IN_USE; 821 ds_dbg(s, 0, "allocating mem region failed\n");
822 return -EINVAL;
823 }
809 } 824 }
810 (*p_dev)->_win |= CLIENT_WIN_REQ(w); 825 (*p_dev)->_win |= CLIENT_WIN_REQ(w);
811 826