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.c143
1 files changed, 44 insertions, 99 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index c01dc6bf1526..184f4f88b2a0 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -23,7 +23,6 @@
23#include <linux/device.h> 23#include <linux/device.h>
24 24
25#define IN_CARD_SERVICES 25#define IN_CARD_SERVICES
26#include <pcmcia/version.h>
27#include <pcmcia/cs_types.h> 26#include <pcmcia/cs_types.h>
28#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
29#include <pcmcia/cs.h> 28#include <pcmcia/cs.h>
@@ -202,14 +201,11 @@ int pccard_access_configuration_register(struct pcmcia_socket *s,
202 return CS_SUCCESS; 201 return CS_SUCCESS;
203} /* pccard_access_configuration_register */ 202} /* pccard_access_configuration_register */
204 203
205int pcmcia_access_configuration_register(client_handle_t handle, 204int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
206 conf_reg_t *reg) 205 conf_reg_t *reg)
207{ 206{
208 struct pcmcia_socket *s; 207 return pccard_access_configuration_register(p_dev->socket,
209 if (CHECK_HANDLE(handle)) 208 p_dev->func, reg);
210 return CS_BAD_HANDLE;
211 s = SOCKET(handle);
212 return pccard_access_configuration_register(s, handle->Function, reg);
213} 209}
214EXPORT_SYMBOL(pcmcia_access_configuration_register); 210EXPORT_SYMBOL(pcmcia_access_configuration_register);
215 211
@@ -271,17 +267,11 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
271 return CS_SUCCESS; 267 return CS_SUCCESS;
272} /* pccard_get_configuration_info */ 268} /* pccard_get_configuration_info */
273 269
274int pcmcia_get_configuration_info(client_handle_t handle, 270int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
275 config_info_t *config) 271 config_info_t *config)
276{ 272{
277 struct pcmcia_socket *s; 273 return pccard_get_configuration_info(p_dev->socket, p_dev->func,
278 274 config);
279 if ((CHECK_HANDLE(handle)) || !config)
280 return CS_BAD_HANDLE;
281 s = SOCKET(handle);
282 if (!s)
283 return CS_BAD_HANDLE;
284 return pccard_get_configuration_info(s, handle->Function, config);
285} 275}
286EXPORT_SYMBOL(pcmcia_get_configuration_info); 276EXPORT_SYMBOL(pcmcia_get_configuration_info);
287 277
@@ -382,10 +372,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
382int pcmcia_get_status(client_handle_t handle, cs_status_t *status) 372int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
383{ 373{
384 struct pcmcia_socket *s; 374 struct pcmcia_socket *s;
385 if (CHECK_HANDLE(handle))
386 return CS_BAD_HANDLE;
387 s = SOCKET(handle); 375 s = SOCKET(handle);
388 return pccard_get_status(s, handle->Function, status); 376 return pccard_get_status(s, handle->func, status);
389} 377}
390EXPORT_SYMBOL(pcmcia_get_status); 378EXPORT_SYMBOL(pcmcia_get_status);
391 379
@@ -426,16 +414,14 @@ EXPORT_SYMBOL(pcmcia_map_mem_page);
426 * 414 *
427 * Modify a locked socket configuration 415 * Modify a locked socket configuration
428 */ 416 */
429int pcmcia_modify_configuration(client_handle_t handle, 417int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
430 modconf_t *mod) 418 modconf_t *mod)
431{ 419{
432 struct pcmcia_socket *s; 420 struct pcmcia_socket *s;
433 config_t *c; 421 config_t *c;
434 422
435 if (CHECK_HANDLE(handle)) 423 s = p_dev->socket;
436 return CS_BAD_HANDLE; 424 c = CONFIG(p_dev);
437 s = SOCKET(handle);
438 c = CONFIG(handle);
439 if (!(s->state & SOCKET_PRESENT)) 425 if (!(s->state & SOCKET_PRESENT))
440 return CS_NO_CARD; 426 return CS_NO_CARD;
441 if (!(c->state & CONFIG_LOCKED)) 427 if (!(c->state & CONFIG_LOCKED))
@@ -472,25 +458,18 @@ int pcmcia_modify_configuration(client_handle_t handle,
472EXPORT_SYMBOL(pcmcia_modify_configuration); 458EXPORT_SYMBOL(pcmcia_modify_configuration);
473 459
474 460
475int pcmcia_release_configuration(client_handle_t handle) 461int pcmcia_release_configuration(struct pcmcia_device *p_dev)
476{ 462{
477 pccard_io_map io = { 0, 0, 0, 0, 1 }; 463 pccard_io_map io = { 0, 0, 0, 0, 1 };
478 struct pcmcia_socket *s; 464 struct pcmcia_socket *s = p_dev->socket;
479 int i; 465 int i;
480 466
481 if (CHECK_HANDLE(handle) || 467 if (!(p_dev->state & CLIENT_CONFIG_LOCKED))
482 !(handle->state & CLIENT_CONFIG_LOCKED))
483 return CS_BAD_HANDLE; 468 return CS_BAD_HANDLE;
484 handle->state &= ~CLIENT_CONFIG_LOCKED; 469 p_dev->state &= ~CLIENT_CONFIG_LOCKED;
485 s = SOCKET(handle);
486
487#ifdef CONFIG_CARDBUS
488 if (handle->state & CLIENT_CARDBUS)
489 return CS_SUCCESS;
490#endif
491 470
492 if (!(handle->state & CLIENT_STALE)) { 471 if (!(p_dev->state & CLIENT_STALE)) {
493 config_t *c = CONFIG(handle); 472 config_t *c = CONFIG(p_dev);
494 if (--(s->lock_count) == 0) { 473 if (--(s->lock_count) == 0) {
495 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 474 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
496 s->socket.Vpp = 0; 475 s->socket.Vpp = 0;
@@ -523,22 +502,16 @@ EXPORT_SYMBOL(pcmcia_release_configuration);
523 * don't bother checking the port ranges against the current socket 502 * don't bother checking the port ranges against the current socket
524 * values. 503 * values.
525 */ 504 */
526int pcmcia_release_io(client_handle_t handle, io_req_t *req) 505int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
527{ 506{
528 struct pcmcia_socket *s; 507 struct pcmcia_socket *s = p_dev->socket;
529 508
530 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) 509 if (!(p_dev->state & CLIENT_IO_REQ))
531 return CS_BAD_HANDLE; 510 return CS_BAD_HANDLE;
532 handle->state &= ~CLIENT_IO_REQ; 511 p_dev->state &= ~CLIENT_IO_REQ;
533 s = SOCKET(handle);
534
535#ifdef CONFIG_CARDBUS
536 if (handle->state & CLIENT_CARDBUS)
537 return CS_SUCCESS;
538#endif
539 512
540 if (!(handle->state & CLIENT_STALE)) { 513 if (!(p_dev->state & CLIENT_STALE)) {
541 config_t *c = CONFIG(handle); 514 config_t *c = CONFIG(p_dev);
542 if (c->state & CONFIG_LOCKED) 515 if (c->state & CONFIG_LOCKED)
543 return CS_CONFIGURATION_LOCKED; 516 return CS_CONFIGURATION_LOCKED;
544 if ((c->io.BasePort1 != req->BasePort1) || 517 if ((c->io.BasePort1 != req->BasePort1) ||
@@ -558,16 +531,15 @@ int pcmcia_release_io(client_handle_t handle, io_req_t *req)
558EXPORT_SYMBOL(pcmcia_release_io); 531EXPORT_SYMBOL(pcmcia_release_io);
559 532
560 533
561int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) 534int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
562{ 535{
563 struct pcmcia_socket *s; 536 struct pcmcia_socket *s = p_dev->socket;
564 if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) 537 if (!(p_dev->state & CLIENT_IRQ_REQ))
565 return CS_BAD_HANDLE; 538 return CS_BAD_HANDLE;
566 handle->state &= ~CLIENT_IRQ_REQ; 539 p_dev->state &= ~CLIENT_IRQ_REQ;
567 s = SOCKET(handle);
568 540
569 if (!(handle->state & CLIENT_STALE)) { 541 if (!(p_dev->state & CLIENT_STALE)) {
570 config_t *c = CONFIG(handle); 542 config_t *c = CONFIG(p_dev);
571 if (c->state & CONFIG_LOCKED) 543 if (c->state & CONFIG_LOCKED)
572 return CS_CONFIGURATION_LOCKED; 544 return CS_CONFIGURATION_LOCKED;
573 if (c->irq.Attributes != req->Attributes) 545 if (c->irq.Attributes != req->Attributes)
@@ -623,29 +595,21 @@ int pcmcia_release_window(window_handle_t win)
623EXPORT_SYMBOL(pcmcia_release_window); 595EXPORT_SYMBOL(pcmcia_release_window);
624 596
625 597
626int pcmcia_request_configuration(client_handle_t handle, 598int pcmcia_request_configuration(struct pcmcia_device *p_dev,
627 config_req_t *req) 599 config_req_t *req)
628{ 600{
629 int i; 601 int i;
630 u_int base; 602 u_int base;
631 struct pcmcia_socket *s; 603 struct pcmcia_socket *s = p_dev->socket;
632 config_t *c; 604 config_t *c;
633 pccard_io_map iomap; 605 pccard_io_map iomap;
634 606
635 if (CHECK_HANDLE(handle))
636 return CS_BAD_HANDLE;
637 s = SOCKET(handle);
638 if (!(s->state & SOCKET_PRESENT)) 607 if (!(s->state & SOCKET_PRESENT))
639 return CS_NO_CARD; 608 return CS_NO_CARD;
640 609
641#ifdef CONFIG_CARDBUS
642 if (handle->state & CLIENT_CARDBUS)
643 return CS_UNSUPPORTED_MODE;
644#endif
645
646 if (req->IntType & INT_CARDBUS) 610 if (req->IntType & INT_CARDBUS)
647 return CS_UNSUPPORTED_MODE; 611 return CS_UNSUPPORTED_MODE;
648 c = CONFIG(handle); 612 c = CONFIG(p_dev);
649 if (c->state & CONFIG_LOCKED) 613 if (c->state & CONFIG_LOCKED)
650 return CS_CONFIGURATION_LOCKED; 614 return CS_CONFIGURATION_LOCKED;
651 615
@@ -746,7 +710,7 @@ int pcmcia_request_configuration(client_handle_t handle,
746 } 710 }
747 711
748 c->state |= CONFIG_LOCKED; 712 c->state |= CONFIG_LOCKED;
749 handle->state |= CLIENT_CONFIG_LOCKED; 713 p_dev->state |= CLIENT_CONFIG_LOCKED;
750 return CS_SUCCESS; 714 return CS_SUCCESS;
751} /* pcmcia_request_configuration */ 715} /* pcmcia_request_configuration */
752EXPORT_SYMBOL(pcmcia_request_configuration); 716EXPORT_SYMBOL(pcmcia_request_configuration);
@@ -757,29 +721,17 @@ EXPORT_SYMBOL(pcmcia_request_configuration);
757 * Request_io() reserves ranges of port addresses for a socket. 721 * Request_io() reserves ranges of port addresses for a socket.
758 * I have not implemented range sharing or alias addressing. 722 * I have not implemented range sharing or alias addressing.
759 */ 723 */
760int pcmcia_request_io(client_handle_t handle, io_req_t *req) 724int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
761{ 725{
762 struct pcmcia_socket *s; 726 struct pcmcia_socket *s = p_dev->socket;
763 config_t *c; 727 config_t *c;
764 728
765 if (CHECK_HANDLE(handle))
766 return CS_BAD_HANDLE;
767 s = SOCKET(handle);
768 if (!(s->state & SOCKET_PRESENT)) 729 if (!(s->state & SOCKET_PRESENT))
769 return CS_NO_CARD; 730 return CS_NO_CARD;
770 731
771 if (handle->state & CLIENT_CARDBUS) {
772#ifdef CONFIG_CARDBUS
773 handle->state |= CLIENT_IO_REQ;
774 return CS_SUCCESS;
775#else
776 return CS_UNSUPPORTED_FUNCTION;
777#endif
778 }
779
780 if (!req) 732 if (!req)
781 return CS_UNSUPPORTED_MODE; 733 return CS_UNSUPPORTED_MODE;
782 c = CONFIG(handle); 734 c = CONFIG(p_dev);
783 if (c->state & CONFIG_LOCKED) 735 if (c->state & CONFIG_LOCKED)
784 return CS_CONFIGURATION_LOCKED; 736 return CS_CONFIGURATION_LOCKED;
785 if (c->state & CONFIG_IO_REQ) 737 if (c->state & CONFIG_IO_REQ)
@@ -804,7 +756,7 @@ int pcmcia_request_io(client_handle_t handle, io_req_t *req)
804 756
805 c->io = *req; 757 c->io = *req;
806 c->state |= CONFIG_IO_REQ; 758 c->state |= CONFIG_IO_REQ;
807 handle->state |= CLIENT_IO_REQ; 759 p_dev->state |= CLIENT_IO_REQ;
808 return CS_SUCCESS; 760 return CS_SUCCESS;
809} /* pcmcia_request_io */ 761} /* pcmcia_request_io */
810EXPORT_SYMBOL(pcmcia_request_io); 762EXPORT_SYMBOL(pcmcia_request_io);
@@ -827,19 +779,15 @@ static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs)
827} 779}
828#endif 780#endif
829 781
830int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) 782int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
831{ 783{
832 struct pcmcia_socket *s; 784 struct pcmcia_socket *s = p_dev->socket;
833 config_t *c; 785 config_t *c;
834 int ret = CS_IN_USE, irq = 0; 786 int ret = CS_IN_USE, irq = 0;
835 struct pcmcia_device *p_dev = handle_to_pdev(handle);
836 787
837 if (CHECK_HANDLE(handle))
838 return CS_BAD_HANDLE;
839 s = SOCKET(handle);
840 if (!(s->state & SOCKET_PRESENT)) 788 if (!(s->state & SOCKET_PRESENT))
841 return CS_NO_CARD; 789 return CS_NO_CARD;
842 c = CONFIG(handle); 790 c = CONFIG(p_dev);
843 if (c->state & CONFIG_LOCKED) 791 if (c->state & CONFIG_LOCKED)
844 return CS_CONFIGURATION_LOCKED; 792 return CS_CONFIGURATION_LOCKED;
845 if (c->state & CONFIG_IRQ_REQ) 793 if (c->state & CONFIG_IRQ_REQ)
@@ -903,7 +851,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req)
903 s->irq.Config++; 851 s->irq.Config++;
904 852
905 c->state |= CONFIG_IRQ_REQ; 853 c->state |= CONFIG_IRQ_REQ;
906 handle->state |= CLIENT_IRQ_REQ; 854 p_dev->state |= CLIENT_IRQ_REQ;
907 855
908#ifdef CONFIG_PCMCIA_PROBE 856#ifdef CONFIG_PCMCIA_PROBE
909 pcmcia_used_irq[irq]++; 857 pcmcia_used_irq[irq]++;
@@ -919,16 +867,13 @@ EXPORT_SYMBOL(pcmcia_request_irq);
919 * Request_window() establishes a mapping between card memory space 867 * Request_window() establishes a mapping between card memory space
920 * and system memory space. 868 * and system memory space.
921 */ 869 */
922int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) 870int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh)
923{ 871{
924 struct pcmcia_socket *s; 872 struct pcmcia_socket *s = (*p_dev)->socket;
925 window_t *win; 873 window_t *win;
926 u_long align; 874 u_long align;
927 int w; 875 int w;
928 876
929 if (CHECK_HANDLE(*handle))
930 return CS_BAD_HANDLE;
931 s = (*handle)->Socket;
932 if (!(s->state & SOCKET_PRESENT)) 877 if (!(s->state & SOCKET_PRESENT))
933 return CS_NO_CARD; 878 return CS_NO_CARD;
934 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 879 if (req->Attributes & (WIN_PAGED | WIN_SHARED))
@@ -957,7 +902,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
957 win = &s->win[w]; 902 win = &s->win[w];
958 win->magic = WINDOW_MAGIC; 903 win->magic = WINDOW_MAGIC;
959 win->index = w; 904 win->index = w;
960 win->handle = *handle; 905 win->handle = *p_dev;
961 win->sock = s; 906 win->sock = s;
962 907
963 if (!(s->features & SS_CAP_STATIC_MAP)) { 908 if (!(s->features & SS_CAP_STATIC_MAP)) {
@@ -966,7 +911,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle
966 if (!win->ctl.res) 911 if (!win->ctl.res)
967 return CS_IN_USE; 912 return CS_IN_USE;
968 } 913 }
969 (*handle)->state |= CLIENT_WIN_REQ(w); 914 (*p_dev)->state |= CLIENT_WIN_REQ(w);
970 915
971 /* Configure the socket controller */ 916 /* Configure the socket controller */
972 win->ctl.map = w+1; 917 win->ctl.map = w+1;