aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pcmcia_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 104e73d5d86c..ef0c5f133691 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -301,7 +301,9 @@ static int pccard_get_status(struct pcmcia_socket *s,
301 (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { 301 (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
302 u_char reg; 302 u_char reg;
303 if (c->CardValues & PRESENT_PIN_REPLACE) { 303 if (c->CardValues & PRESENT_PIN_REPLACE) {
304 mutex_lock(&s->ops_mutex);
304 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg); 305 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg);
306 mutex_unlock(&s->ops_mutex);
305 status->CardState |= 307 status->CardState |=
306 (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0; 308 (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0;
307 status->CardState |= 309 status->CardState |=
@@ -315,7 +317,9 @@ static int pccard_get_status(struct pcmcia_socket *s,
315 status->CardState |= CS_EVENT_READY_CHANGE; 317 status->CardState |= CS_EVENT_READY_CHANGE;
316 } 318 }
317 if (c->CardValues & PRESENT_EXT_STATUS) { 319 if (c->CardValues & PRESENT_EXT_STATUS) {
320 mutex_lock(&s->ops_mutex);
318 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg); 321 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg);
322 mutex_unlock(&s->ops_mutex);
319 status->CardState |= 323 status->CardState |=
320 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; 324 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0;
321 } 325 }
@@ -351,7 +355,7 @@ static int pccard_get_configuration_info(struct pcmcia_socket *s,
351 if (s->state & SOCKET_CARDBUS_CONFIG) { 355 if (s->state & SOCKET_CARDBUS_CONFIG) {
352 config->Attributes = CONF_VALID_CLIENT; 356 config->Attributes = CONF_VALID_CLIENT;
353 config->IntType = INT_CARDBUS; 357 config->IntType = INT_CARDBUS;
354 config->AssignedIRQ = s->irq.AssignedIRQ; 358 config->AssignedIRQ = s->pcmcia_irq;
355 if (config->AssignedIRQ) 359 if (config->AssignedIRQ)
356 config->Attributes |= CONF_ENABLE_IRQ; 360 config->Attributes |= CONF_ENABLE_IRQ;
357 if (s->io[0].res) { 361 if (s->io[0].res) {
@@ -391,7 +395,7 @@ static int pccard_get_configuration_info(struct pcmcia_socket *s,
391 config->ExtStatus = c->ExtStatus; 395 config->ExtStatus = c->ExtStatus;
392 config->Present = config->CardValues = c->CardValues; 396 config->Present = config->CardValues = c->CardValues;
393 config->IRQAttributes = c->irq.Attributes; 397 config->IRQAttributes = c->irq.Attributes;
394 config->AssignedIRQ = s->irq.AssignedIRQ; 398 config->AssignedIRQ = s->pcmcia_irq;
395 config->BasePort1 = c->io.BasePort1; 399 config->BasePort1 = c->io.BasePort1;
396 config->NumPorts1 = c->io.NumPorts1; 400 config->NumPorts1 = c->io.NumPorts1;
397 config->Attributes1 = c->io.Attributes1; 401 config->Attributes1 = c->io.Attributes1;
@@ -571,7 +575,6 @@ static struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s)
571 575
572static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first) 576static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first)
573{ 577{
574 dev_node_t *node;
575 struct pcmcia_device *p_dev; 578 struct pcmcia_device *p_dev;
576 struct pcmcia_driver *p_drv; 579 struct pcmcia_driver *p_drv;
577 int ret = 0; 580 int ret = 0;
@@ -633,21 +636,13 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
633 goto err_put; 636 goto err_put;
634 } 637 }
635 638
636 if (first) 639 if (!first) {
637 node = p_dev->dev_node;
638 else
639 for (node = p_dev->dev_node; node; node = node->next)
640 if (node == bind_info->next)
641 break;
642 if (!node) {
643 ret = -ENODEV; 640 ret = -ENODEV;
644 goto err_put; 641 goto err_put;
645 } 642 }
646 643
647 strlcpy(bind_info->name, node->dev_name, DEV_NAME_LEN); 644 strlcpy(bind_info->name, dev_name(&p_dev->dev), DEV_NAME_LEN);
648 bind_info->major = node->major; 645 bind_info->next = NULL;
649 bind_info->minor = node->minor;
650 bind_info->next = node->next;
651 646
652 err_put: 647 err_put:
653 pcmcia_put_dev(p_dev); 648 pcmcia_put_dev(p_dev);
@@ -711,7 +706,7 @@ static int ds_open(struct inode *inode, struct file *file)
711 warning_printed = 1; 706 warning_printed = 1;
712 } 707 }
713 708
714 if (s->pcmcia_state.present) 709 if (atomic_read(&s->present))
715 queue_event(user, CS_EVENT_CARD_INSERTION); 710 queue_event(user, CS_EVENT_CARD_INSERTION);
716out: 711out:
717 unlock_kernel(); 712 unlock_kernel();
@@ -770,9 +765,6 @@ static ssize_t ds_read(struct file *file, char __user *buf,
770 return -EIO; 765 return -EIO;
771 766
772 s = user->socket; 767 s = user->socket;
773 if (s->pcmcia_state.dead)
774 return -EIO;
775
776 ret = wait_event_interruptible(s->queue, !queue_empty(user)); 768 ret = wait_event_interruptible(s->queue, !queue_empty(user));
777 if (ret == 0) 769 if (ret == 0)
778 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4; 770 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4;
@@ -838,8 +830,6 @@ static int ds_ioctl(struct inode *inode, struct file *file,
838 return -EIO; 830 return -EIO;
839 831
840 s = user->socket; 832 s = user->socket;
841 if (s->pcmcia_state.dead)
842 return -EIO;
843 833
844 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 834 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
845 if (size > sizeof(ds_ioctl_arg_t)) 835 if (size > sizeof(ds_ioctl_arg_t))