X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=drivers%2Fpcmcia%2Fpcmcia_resource.c;h=89022ad5b5207eeac9b90898478f8e49b4088174;hb=881787a7d379a4a4474e94fce87b511a7f641595;hp=c01dc6bf15267fc78ec7e50ad5920012521e83f8;hpb=61998bcb4bf0efa0276e88c7853091e482a826f4;p=powerpc.git diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index c01dc6bf15..89022ad5b5 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -23,7 +23,6 @@ #include #define IN_CARD_SERVICES -#include #include #include #include @@ -42,6 +41,7 @@ module_param(io_speed, int, 0444); #ifdef CONFIG_PCMCIA_PROBE +#include /* mask of IRQs already reserved by other cards, we should avoid using them */ static u8 pcmcia_used_irq[NR_IRQS]; #endif @@ -202,14 +202,11 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, return CS_SUCCESS; } /* pccard_access_configuration_register */ -int pcmcia_access_configuration_register(client_handle_t handle, +int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg) { - struct pcmcia_socket *s; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - return pccard_access_configuration_register(s, handle->Function, reg); + return pccard_access_configuration_register(p_dev->socket, + p_dev->func, reg); } EXPORT_SYMBOL(pcmcia_access_configuration_register); @@ -271,17 +268,11 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, return CS_SUCCESS; } /* pccard_get_configuration_info */ -int pcmcia_get_configuration_info(client_handle_t handle, +int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, config_info_t *config) { - struct pcmcia_socket *s; - - if ((CHECK_HANDLE(handle)) || !config) - return CS_BAD_HANDLE; - s = SOCKET(handle); - if (!s) - return CS_BAD_HANDLE; - return pccard_get_configuration_info(s, handle->Function, config); + return pccard_get_configuration_info(p_dev->socket, p_dev->func, + config); } EXPORT_SYMBOL(pcmcia_get_configuration_info); @@ -382,10 +373,8 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, int pcmcia_get_status(client_handle_t handle, cs_status_t *status) { struct pcmcia_socket *s; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; s = SOCKET(handle); - return pccard_get_status(s, handle->Function, status); + return pccard_get_status(s, handle->func, status); } EXPORT_SYMBOL(pcmcia_get_status); @@ -426,16 +415,14 @@ EXPORT_SYMBOL(pcmcia_map_mem_page); * * Modify a locked socket configuration */ -int pcmcia_modify_configuration(client_handle_t handle, +int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod) { struct pcmcia_socket *s; config_t *c; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - c = CONFIG(handle); + s = p_dev->socket; + c = CONFIG(p_dev); if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; if (!(c->state & CONFIG_LOCKED)) @@ -460,7 +447,7 @@ int pcmcia_modify_configuration(client_handle_t handle, (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { if (mod->Vpp1 != mod->Vpp2) return CS_BAD_VPP; - c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; + s->socket.Vpp = mod->Vpp1; if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || @@ -472,25 +459,18 @@ int pcmcia_modify_configuration(client_handle_t handle, EXPORT_SYMBOL(pcmcia_modify_configuration); -int pcmcia_release_configuration(client_handle_t handle) +int pcmcia_release_configuration(struct pcmcia_device *p_dev) { pccard_io_map io = { 0, 0, 0, 0, 1 }; - struct pcmcia_socket *s; + struct pcmcia_socket *s = p_dev->socket; int i; - if (CHECK_HANDLE(handle) || - !(handle->state & CLIENT_CONFIG_LOCKED)) + if (!(p_dev->state & CLIENT_CONFIG_LOCKED)) return CS_BAD_HANDLE; - handle->state &= ~CLIENT_CONFIG_LOCKED; - s = SOCKET(handle); - -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_SUCCESS; -#endif + p_dev->state &= ~CLIENT_CONFIG_LOCKED; - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); + if (!(p_dev->state & CLIENT_STALE)) { + config_t *c = CONFIG(p_dev); if (--(s->lock_count) == 0) { s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ s->socket.Vpp = 0; @@ -523,22 +503,16 @@ EXPORT_SYMBOL(pcmcia_release_configuration); * don't bother checking the port ranges against the current socket * values. */ -int pcmcia_release_io(client_handle_t handle, io_req_t *req) +int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) { - struct pcmcia_socket *s; + struct pcmcia_socket *s = p_dev->socket; - if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) + if (!(p_dev->state & CLIENT_IO_REQ)) return CS_BAD_HANDLE; - handle->state &= ~CLIENT_IO_REQ; - s = SOCKET(handle); - -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_SUCCESS; -#endif + p_dev->state &= ~CLIENT_IO_REQ; - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); + if (!(p_dev->state & CLIENT_STALE)) { + config_t *c = CONFIG(p_dev); if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; if ((c->io.BasePort1 != req->BasePort1) || @@ -558,16 +532,15 @@ int pcmcia_release_io(client_handle_t handle, io_req_t *req) EXPORT_SYMBOL(pcmcia_release_io); -int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) +int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) { - struct pcmcia_socket *s; - if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) + struct pcmcia_socket *s = p_dev->socket; + if (!(p_dev->state & CLIENT_IRQ_REQ)) return CS_BAD_HANDLE; - handle->state &= ~CLIENT_IRQ_REQ; - s = SOCKET(handle); + p_dev->state &= ~CLIENT_IRQ_REQ; - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); + if (!(p_dev->state & CLIENT_STALE)) { + config_t *c = CONFIG(p_dev); if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; if (c->irq.Attributes != req->Attributes) @@ -623,29 +596,21 @@ int pcmcia_release_window(window_handle_t win) EXPORT_SYMBOL(pcmcia_release_window); -int pcmcia_request_configuration(client_handle_t handle, +int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req) { int i; u_int base; - struct pcmcia_socket *s; + struct pcmcia_socket *s = p_dev->socket; config_t *c; pccard_io_map iomap; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_UNSUPPORTED_MODE; -#endif - if (req->IntType & INT_CARDBUS) return CS_UNSUPPORTED_MODE; - c = CONFIG(handle); + c = CONFIG(p_dev); if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; @@ -658,8 +623,6 @@ int pcmcia_request_configuration(client_handle_t handle, if (s->ops->set_socket(s, &s->socket)) return CS_BAD_VPP; - c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; - /* Pick memory or I/O card, DMA mode, interrupt */ c->IntType = req->IntType; c->Attributes = req->Attributes; @@ -746,7 +709,7 @@ int pcmcia_request_configuration(client_handle_t handle, } c->state |= CONFIG_LOCKED; - handle->state |= CLIENT_CONFIG_LOCKED; + p_dev->state |= CLIENT_CONFIG_LOCKED; return CS_SUCCESS; } /* pcmcia_request_configuration */ EXPORT_SYMBOL(pcmcia_request_configuration); @@ -757,29 +720,17 @@ EXPORT_SYMBOL(pcmcia_request_configuration); * Request_io() reserves ranges of port addresses for a socket. * I have not implemented range sharing or alias addressing. */ -int pcmcia_request_io(client_handle_t handle, io_req_t *req) +int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) { - struct pcmcia_socket *s; + struct pcmcia_socket *s = p_dev->socket; config_t *c; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; - if (handle->state & CLIENT_CARDBUS) { -#ifdef CONFIG_CARDBUS - handle->state |= CLIENT_IO_REQ; - return CS_SUCCESS; -#else - return CS_UNSUPPORTED_FUNCTION; -#endif - } - if (!req) return CS_UNSUPPORTED_MODE; - c = CONFIG(handle); + c = CONFIG(p_dev); if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; if (c->state & CONFIG_IO_REQ) @@ -804,7 +755,7 @@ int pcmcia_request_io(client_handle_t handle, io_req_t *req) c->io = *req; c->state |= CONFIG_IO_REQ; - handle->state |= CLIENT_IO_REQ; + p_dev->state |= CLIENT_IO_REQ; return CS_SUCCESS; } /* pcmcia_request_io */ EXPORT_SYMBOL(pcmcia_request_io); @@ -827,19 +778,15 @@ static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs) } #endif -int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) +int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) { - struct pcmcia_socket *s; + struct pcmcia_socket *s = p_dev->socket; config_t *c; int ret = CS_IN_USE, irq = 0; - struct pcmcia_device *p_dev = handle_to_pdev(handle); - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; - c = CONFIG(handle); + c = CONFIG(p_dev); if (c->state & CONFIG_LOCKED) return CS_CONFIGURATION_LOCKED; if (c->state & CONFIG_IRQ_REQ) @@ -852,7 +799,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) } else { int try; u32 mask = s->irq_mask; - void *data = NULL; + void *data = &p_dev->dev.driver; /* something unique to this device */ for (try = 0; try < 64; try++) { irq = try % 32; @@ -873,7 +820,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, + p_dev->devname, (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); if (!ret) { if (!(req->Attributes & IRQ_HANDLE_PRESENT)) @@ -883,7 +830,8 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) } } #endif - if (ret) { + /* only assign PCI irq if no IRQ already assigned */ + if (ret && !s->irq.AssignedIRQ) { if (!s->pci_irq) return ret; irq = s->pci_irq; @@ -894,7 +842,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || (s->functions > 1) || (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, req->Instance)) + p_dev->devname, req->Instance)) return CS_IN_USE; } @@ -903,7 +851,7 @@ int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) s->irq.Config++; c->state |= CONFIG_IRQ_REQ; - handle->state |= CLIENT_IRQ_REQ; + p_dev->state |= CLIENT_IRQ_REQ; #ifdef CONFIG_PCMCIA_PROBE pcmcia_used_irq[irq]++; @@ -919,16 +867,13 @@ EXPORT_SYMBOL(pcmcia_request_irq); * Request_window() establishes a mapping between card memory space * and system memory space. */ -int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) +int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh) { - struct pcmcia_socket *s; + struct pcmcia_socket *s = (*p_dev)->socket; window_t *win; u_long align; int w; - if (CHECK_HANDLE(*handle)) - return CS_BAD_HANDLE; - s = (*handle)->Socket; if (!(s->state & SOCKET_PRESENT)) return CS_NO_CARD; 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 win = &s->win[w]; win->magic = WINDOW_MAGIC; win->index = w; - win->handle = *handle; + win->handle = *p_dev; win->sock = s; 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 if (!win->ctl.res) return CS_IN_USE; } - (*handle)->state |= CLIENT_WIN_REQ(w); + (*p_dev)->state |= CLIENT_WIN_REQ(w); /* Configure the socket controller */ win->ctl.map = w+1;