aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pcmcia_resource.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r--drivers/pcmcia/pcmcia_resource.c125
1 files changed, 43 insertions, 82 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index ac5c3abe70c0..ec2abb37f407 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -202,12 +202,11 @@ int pccard_access_configuration_register(struct pcmcia_socket *s,
202 return CS_SUCCESS; 202 return CS_SUCCESS;
203} /* pccard_access_configuration_register */ 203} /* pccard_access_configuration_register */
204 204
205int pcmcia_access_configuration_register(client_handle_t handle, 205int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
206 conf_reg_t *reg) 206 conf_reg_t *reg)
207{ 207{
208 struct pcmcia_socket *s; 208 return pccard_access_configuration_register(p_dev->socket,
209 s = SOCKET(handle); 209 p_dev->func, reg);
210 return pccard_access_configuration_register(s, handle->func, reg);
211} 210}
212EXPORT_SYMBOL(pcmcia_access_configuration_register); 211EXPORT_SYMBOL(pcmcia_access_configuration_register);
213 212
@@ -269,17 +268,11 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
269 return CS_SUCCESS; 268 return CS_SUCCESS;
270} /* pccard_get_configuration_info */ 269} /* pccard_get_configuration_info */
271 270
272int pcmcia_get_configuration_info(client_handle_t handle, 271int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
273 config_info_t *config) 272 config_info_t *config)
274{ 273{
275 struct pcmcia_socket *s; 274 return pccard_get_configuration_info(p_dev->socket, p_dev->func,
276 275 config);
277 if (!config)
278 return CS_BAD_HANDLE;
279 s = SOCKET(handle);
280 if (!s)
281 return CS_BAD_HANDLE;
282 return pccard_get_configuration_info(s, handle->func, config);
283} 276}
284EXPORT_SYMBOL(pcmcia_get_configuration_info); 277EXPORT_SYMBOL(pcmcia_get_configuration_info);
285 278
@@ -422,14 +415,14 @@ EXPORT_SYMBOL(pcmcia_map_mem_page);
422 * 415 *
423 * Modify a locked socket configuration 416 * Modify a locked socket configuration
424 */ 417 */
425int pcmcia_modify_configuration(client_handle_t handle, 418int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
426 modconf_t *mod) 419 modconf_t *mod)
427{ 420{
428 struct pcmcia_socket *s; 421 struct pcmcia_socket *s;
429 config_t *c; 422 config_t *c;
430 423
431 s = SOCKET(handle); 424 s = p_dev->socket;
432 c = CONFIG(handle); 425 c = CONFIG(p_dev);
433 if (!(s->state & SOCKET_PRESENT)) 426 if (!(s->state & SOCKET_PRESENT))
434 return CS_NO_CARD; 427 return CS_NO_CARD;
435 if (!(c->state & CONFIG_LOCKED)) 428 if (!(c->state & CONFIG_LOCKED))
@@ -466,24 +459,18 @@ int pcmcia_modify_configuration(client_handle_t handle,
466EXPORT_SYMBOL(pcmcia_modify_configuration); 459EXPORT_SYMBOL(pcmcia_modify_configuration);
467 460
468 461
469int pcmcia_release_configuration(client_handle_t handle) 462int pcmcia_release_configuration(struct pcmcia_device *p_dev)
470{ 463{
471 pccard_io_map io = { 0, 0, 0, 0, 1 }; 464 pccard_io_map io = { 0, 0, 0, 0, 1 };
472 struct pcmcia_socket *s; 465 struct pcmcia_socket *s = p_dev->socket;
473 int i; 466 int i;
474 467
475 if (!(handle->state & CLIENT_CONFIG_LOCKED)) 468 if (!(p_dev->state & CLIENT_CONFIG_LOCKED))
476 return CS_BAD_HANDLE; 469 return CS_BAD_HANDLE;
477 handle->state &= ~CLIENT_CONFIG_LOCKED; 470 p_dev->state &= ~CLIENT_CONFIG_LOCKED;
478 s = SOCKET(handle);
479 471
480#ifdef CONFIG_CARDBUS 472 if (!(p_dev->state & CLIENT_STALE)) {
481 if (handle->state & CLIENT_CARDBUS) 473 config_t *c = CONFIG(p_dev);
482 return CS_SUCCESS;
483#endif
484
485 if (!(handle->state & CLIENT_STALE)) {
486 config_t *c = CONFIG(handle);
487 if (--(s->lock_count) == 0) { 474 if (--(s->lock_count) == 0) {
488 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 475 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
489 s->socket.Vpp = 0; 476 s->socket.Vpp = 0;
@@ -516,22 +503,16 @@ EXPORT_SYMBOL(pcmcia_release_configuration);
516 * don't bother checking the port ranges against the current socket 503 * don't bother checking the port ranges against the current socket
517 * values. 504 * values.
518 */ 505 */
519int pcmcia_release_io(client_handle_t handle, io_req_t *req) 506int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
520{ 507{
521 struct pcmcia_socket *s; 508 struct pcmcia_socket *s = p_dev->socket;
522 509
523 if (!(handle->state & CLIENT_IO_REQ)) 510 if (!(p_dev->state & CLIENT_IO_REQ))
524 return CS_BAD_HANDLE; 511 return CS_BAD_HANDLE;
525 handle->state &= ~CLIENT_IO_REQ; 512 p_dev->state &= ~CLIENT_IO_REQ;
526 s = SOCKET(handle);
527
528#ifdef CONFIG_CARDBUS
529 if (handle->state & CLIENT_CARDBUS)
530 return CS_SUCCESS;
531#endif
532 513
533 if (!(handle->state & CLIENT_STALE)) { 514 if (!(p_dev->state & CLIENT_STALE)) {
534 config_t *c = CONFIG(handle); 515 config_t *c = CONFIG(p_dev);
535 if (c->state & CONFIG_LOCKED) 516 if (c->state & CONFIG_LOCKED)
536 return CS_CONFIGURATION_LOCKED; 517 return CS_CONFIGURATION_LOCKED;
537 if ((c->io.BasePort1 != req->BasePort1) || 518 if ((c->io.BasePort1 != req->BasePort1) ||
@@ -551,16 +532,15 @@ int pcmcia_release_io(client_handle_t handle, io_req_t *req)
551EXPORT_SYMBOL(pcmcia_release_io); 532EXPORT_SYMBOL(pcmcia_release_io);
552 533
553 534
554int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) 535int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
555{ 536{
556 struct pcmcia_socket *s; 537 struct pcmcia_socket *s = p_dev->socket;
557 if (!(handle->state & CLIENT_IRQ_REQ)) 538 if (!(p_dev->state & CLIENT_IRQ_REQ))
558 return CS_BAD_HANDLE; 539 return CS_BAD_HANDLE;
559 handle->state &= ~CLIENT_IRQ_REQ; 540 p_dev->state &= ~CLIENT_IRQ_REQ;
560 s = SOCKET(handle);
561 541
562 if (!(handle->state & CLIENT_STALE)) { 542 if (!(p_dev->state & CLIENT_STALE)) {
563 config_t *c = CONFIG(handle); 543 config_t *c = CONFIG(p_dev);
564 if (c->state & CONFIG_LOCKED) 544 if (c->state & CONFIG_LOCKED)
565 return CS_CONFIGURATION_LOCKED; 545 return CS_CONFIGURATION_LOCKED;
566 if (c->irq.Attributes != req->Attributes) 546 if (c->irq.Attributes != req->Attributes)
@@ -616,27 +596,21 @@ int pcmcia_release_window(window_handle_t win)
616EXPORT_SYMBOL(pcmcia_release_window); 596EXPORT_SYMBOL(pcmcia_release_window);
617 597
618 598
619int pcmcia_request_configuration(client_handle_t handle, 599int pcmcia_request_configuration(struct pcmcia_device *p_dev,
620 config_req_t *req) 600 config_req_t *req)
621{ 601{
622 int i; 602 int i;
623 u_int base; 603 u_int base;
624 struct pcmcia_socket *s; 604 struct pcmcia_socket *s = p_dev->socket;
625 config_t *c; 605 config_t *c;
626 pccard_io_map iomap; 606 pccard_io_map iomap;
627 607
628 s = SOCKET(handle);
629 if (!(s->state & SOCKET_PRESENT)) 608 if (!(s->state & SOCKET_PRESENT))
630 return CS_NO_CARD; 609 return CS_NO_CARD;
631 610
632#ifdef CONFIG_CARDBUS
633 if (handle->state & CLIENT_CARDBUS)
634 return CS_UNSUPPORTED_MODE;
635#endif
636
637 if (req->IntType & INT_CARDBUS) 611 if (req->IntType & INT_CARDBUS)
638 return CS_UNSUPPORTED_MODE; 612 return CS_UNSUPPORTED_MODE;
639 c = CONFIG(handle); 613 c = CONFIG(p_dev);
640 if (c->state & CONFIG_LOCKED) 614 if (c->state & CONFIG_LOCKED)
641 return CS_CONFIGURATION_LOCKED; 615 return CS_CONFIGURATION_LOCKED;
642 616
@@ -737,7 +711,7 @@ int pcmcia_request_configuration(client_handle_t handle,
737 } 711 }
738 712
739 c->state |= CONFIG_LOCKED; 713 c->state |= CONFIG_LOCKED;
740 handle->state |= CLIENT_CONFIG_LOCKED; 714 p_dev->state |= CLIENT_CONFIG_LOCKED;
741 return CS_SUCCESS; 715 return CS_SUCCESS;
742} /* pcmcia_request_configuration */ 716} /* pcmcia_request_configuration */
743EXPORT_SYMBOL(pcmcia_request_configuration); 717EXPORT_SYMBOL(pcmcia_request_configuration);
@@ -748,27 +722,17 @@ EXPORT_SYMBOL(pcmcia_request_configuration);
748 * Request_io() reserves ranges of port addresses for a socket. 722 * Request_io() reserves ranges of port addresses for a socket.
749 * I have not implemented range sharing or alias addressing. 723 * I have not implemented range sharing or alias addressing.
750 */ 724 */
751int pcmcia_request_io(client_handle_t handle, io_req_t *req) 725int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
752{ 726{
753 struct pcmcia_socket *s; 727 struct pcmcia_socket *s = p_dev->socket;
754 config_t *c; 728 config_t *c;
755 729
756 s = SOCKET(handle);
757 if (!(s->state & SOCKET_PRESENT)) 730 if (!(s->state & SOCKET_PRESENT))
758 return CS_NO_CARD; 731 return CS_NO_CARD;
759 732
760 if (handle->state & CLIENT_CARDBUS) {
761#ifdef CONFIG_CARDBUS
762 handle->state |= CLIENT_IO_REQ;
763 return CS_SUCCESS;
764#else
765 return CS_UNSUPPORTED_FUNCTION;
766#endif
767 }
768
769 if (!req) 733 if (!req)
770 return CS_UNSUPPORTED_MODE; 734 return CS_UNSUPPORTED_MODE;
771 c = CONFIG(handle); 735 c = CONFIG(p_dev);
772 if (c->state & CONFIG_LOCKED) 736 if (c->state & CONFIG_LOCKED)
773 return CS_CONFIGURATION_LOCKED; 737 return CS_CONFIGURATION_LOCKED;
774 if (c->state & CONFIG_IO_REQ) 738 if (c->state & CONFIG_IO_REQ)
@@ -793,7 +757,7 @@ int pcmcia_request_io(client_handle_t handle, io_req_t *req)
793 757
794 c->io = *req; 758 c->io = *req;
795 c->state |= CONFIG_IO_REQ; 759 c->state |= CONFIG_IO_REQ;
796 handle->state |= CLIENT_IO_REQ; 760 p_dev->state |= CLIENT_IO_REQ;
797 return CS_SUCCESS; 761 return CS_SUCCESS;
798} /* pcmcia_request_io */ 762} /* pcmcia_request_io */
799EXPORT_SYMBOL(pcmcia_request_io); 763EXPORT_SYMBOL(pcmcia_request_io);
@@ -816,17 +780,15 @@ static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs)
816} 780}
817#endif 781#endif
818 782
819int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) 783int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
820{ 784{
821 struct pcmcia_socket *s; 785 struct pcmcia_socket *s = p_dev->socket;
822 config_t *c; 786 config_t *c;
823 int ret = CS_IN_USE, irq = 0; 787 int ret = CS_IN_USE, irq = 0;
824 struct pcmcia_device *p_dev = handle_to_pdev(handle);
825 788
826 s = SOCKET(handle);
827 if (!(s->state & SOCKET_PRESENT)) 789 if (!(s->state & SOCKET_PRESENT))
828 return CS_NO_CARD; 790 return CS_NO_CARD;
829 c = CONFIG(handle); 791 c = CONFIG(p_dev);
830 if (c->state & CONFIG_LOCKED) 792 if (c->state & CONFIG_LOCKED)
831 return CS_CONFIGURATION_LOCKED; 793 return CS_CONFIGURATION_LOCKED;
832 if (c->state & CONFIG_IRQ_REQ) 794 if (c->state & CONFIG_IRQ_REQ)
@@ -890,7 +852,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req)
890 s->irq.Config++; 852 s->irq.Config++;
891 853
892 c->state |= CONFIG_IRQ_REQ; 854 c->state |= CONFIG_IRQ_REQ;
893 handle->state |= CLIENT_IRQ_REQ; 855 p_dev->state |= CLIENT_IRQ_REQ;
894 856
895#ifdef CONFIG_PCMCIA_PROBE 857#ifdef CONFIG_PCMCIA_PROBE
896 pcmcia_used_irq[irq]++; 858 pcmcia_used_irq[irq]++;
@@ -906,14 +868,13 @@ EXPORT_SYMBOL(pcmcia_request_irq);
906 * Request_window() establishes a mapping between card memory space 868 * Request_window() establishes a mapping between card memory space
907 * and system memory space. 869 * and system memory space.
908 */ 870 */
909int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) 871int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh)
910{ 872{
911 struct pcmcia_socket *s; 873 struct pcmcia_socket *s = (*p_dev)->socket;
912 window_t *win; 874 window_t *win;
913 u_long align; 875 u_long align;
914 int w; 876 int w;
915 877
916 s = (*handle)->socket;
917 if (!(s->state & SOCKET_PRESENT)) 878 if (!(s->state & SOCKET_PRESENT))
918 return CS_NO_CARD; 879 return CS_NO_CARD;
919 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 880 if (req->Attributes & (WIN_PAGED | WIN_SHARED))
@@ -942,7 +903,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
942 win = &s->win[w]; 903 win = &s->win[w];
943 win->magic = WINDOW_MAGIC; 904 win->magic = WINDOW_MAGIC;
944 win->index = w; 905 win->index = w;
945 win->handle = *handle; 906 win->handle = *p_dev;
946 win->sock = s; 907 win->sock = s;
947 908
948 if (!(s->features & SS_CAP_STATIC_MAP)) { 909 if (!(s->features & SS_CAP_STATIC_MAP)) {
@@ -951,7 +912,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
951 if (!win->ctl.res) 912 if (!win->ctl.res)
952 return CS_IN_USE; 913 return CS_IN_USE;
953 } 914 }
954 (*handle)->state |= CLIENT_WIN_REQ(w); 915 (*p_dev)->state |= CLIENT_WIN_REQ(w);
955 916
956 /* Configure the socket controller */ 917 /* Configure the socket controller */
957 win->ctl.map = w+1; 918 win->ctl.map = w+1;