aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pcmcia_ioctl.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-01-10 14:48:59 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:01:58 -0500
commit855cdf134dfcf2ecb92ac4ad675cf655d8ceb678 (patch)
tree167a028b44e1bc043b544357d958a6a20529968b /drivers/pcmcia/pcmcia_ioctl.c
parentdbb22f0d65ccc2e9dfeb4c420942f2757a80f8d2 (diff)
[PATCH] pcmcia: always use device pointer to config_t
Update the remaining users using the static lookup table of the PCMCIA function configuration to use the struct pcmcia_device-contained pointer. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 80969f7e7a0b..56b625d171ae 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -70,10 +70,26 @@ extern int ds_pc_debug;
70#define ds_dbg(lvl, fmt, arg...) do { } while (0) 70#define ds_dbg(lvl, fmt, arg...) do { } while (0)
71#endif 71#endif
72 72
73static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s,
74 unsigned int function)
75{
76 struct pcmcia_device *p_dev = NULL;
77 unsigned long flags;
78
79 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
80 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
81 if (p_dev->func == function) {
82 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
83 return pcmcia_get_dev(p_dev);
84 }
85 }
86 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
87 return NULL;
88}
73 89
74/* backwards-compatible accessing of driver --- by name! */ 90/* backwards-compatible accessing of driver --- by name! */
75 91
76static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) 92static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info)
77{ 93{
78 struct device_driver *drv; 94 struct device_driver *drv;
79 struct pcmcia_driver *p_drv; 95 struct pcmcia_driver *p_drv;
@@ -583,9 +599,11 @@ static int ds_ioctl(struct inode * inode, struct file * file,
583 if (buf->config.Function && 599 if (buf->config.Function &&
584 (buf->config.Function >= s->functions)) 600 (buf->config.Function >= s->functions))
585 ret = CS_BAD_ARGS; 601 ret = CS_BAD_ARGS;
586 else 602 else {
587 ret = pccard_get_configuration_info(s, 603 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
588 buf->config.Function, &buf->config); 604 ret = pccard_get_configuration_info(s, p_dev, &buf->config);
605 pcmcia_put_dev(p_dev);
606 }
589 break; 607 break;
590 case DS_GET_FIRST_TUPLE: 608 case DS_GET_FIRST_TUPLE:
591 down(&s->skt_sem); 609 down(&s->skt_sem);
@@ -609,12 +627,15 @@ static int ds_ioctl(struct inode * inode, struct file * file,
609 ret = pccard_reset_card(s); 627 ret = pccard_reset_card(s);
610 break; 628 break;
611 case DS_GET_STATUS: 629 case DS_GET_STATUS:
612 if (buf->status.Function && 630 if (buf->status.Function &&
613 (buf->status.Function >= s->functions)) 631 (buf->status.Function >= s->functions))
614 ret = CS_BAD_ARGS; 632 ret = CS_BAD_ARGS;
615 else 633 else {
616 ret = pccard_get_status(s, buf->status.Function, &buf->status); 634 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
617 break; 635 ret = pccard_get_status(s, p_dev, &buf->status);
636 pcmcia_put_dev(p_dev);
637 }
638 break;
618 case DS_VALIDATE_CIS: 639 case DS_VALIDATE_CIS:
619 down(&s->skt_sem); 640 down(&s->skt_sem);
620 pcmcia_validate_mem(s); 641 pcmcia_validate_mem(s);
@@ -638,12 +659,16 @@ static int ds_ioctl(struct inode * inode, struct file * file,
638 err = -EPERM; 659 err = -EPERM;
639 goto free_out; 660 goto free_out;
640 } 661 }
641 if (buf->conf_reg.Function && 662
642 (buf->conf_reg.Function >= s->functions)) 663 ret = CS_BAD_ARGS;
643 ret = CS_BAD_ARGS; 664
644 else 665 if (!(buf->conf_reg.Function &&
645 ret = pccard_access_configuration_register(s, 666 (buf->conf_reg.Function >= s->functions))) {
646 buf->conf_reg.Function, &buf->conf_reg); 667 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function);
668 if (p_dev)
669 ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg);
670 pcmcia_put_dev(p_dev);
671 }
647 break; 672 break;
648 case DS_GET_FIRST_REGION: 673 case DS_GET_FIRST_REGION:
649 case DS_GET_NEXT_REGION: 674 case DS_GET_NEXT_REGION: