aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-30 07:13:46 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-09-29 11:20:24 -0400
commit00990e7ce0b0e596fe41d9c64d6933ea70084003 (patch)
tree189e0dd92860feba84231c66955749574cac5d6d /drivers/bluetooth
parent440eed43e2a95bb842488755683716814da10f2b (diff)
pcmcia: use autoconfiguration feature for ioports and iomem
When CONF_AUTO_SET_IO or CONF_AUTO_SET_IOMEM are set, the corresponding fields in struct pcmcia_device *p_dev->resource[0,1,2] are set accordinly. Drivers wishing to override certain settings may do so in the callback function, but they no longer need to parse the CIS entries stored in cistpl_cftable_entry_t themselves. CC: netdev@vger.kernel.org CC: linux-wireless@vger.kernel.org CC: linux-ide@vger.kernel.org CC: linux-usb@vger.kernel.org CC: laforge@gnumonks.org CC: linux-mtd@lists.infradead.org CC: linux-bluetooth@vger.kernel.org CC: alsa-devel@alsa-project.org CC: linux-serial@vger.kernel.org CC: Jiri Kosina <jkosina@suse.cz> CC: linux-scsi@vger.kernel.org Tested-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/bt3c_cs.c53
-rw-r--r--drivers/bluetooth/btuart_cs.c51
-rw-r--r--drivers/bluetooth/dtl1_cs.c18
3 files changed, 59 insertions, 63 deletions
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 97338a3aae1a..8b8be35fe312 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -656,10 +656,8 @@ static int bt3c_probe(struct pcmcia_device *link)
656 info->p_dev = link; 656 info->p_dev = link;
657 link->priv = info; 657 link->priv = info;
658 658
659 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 659 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
660 link->resource[0]->end = 8; 660 CONF_AUTO_SET_IO;
661
662 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP;
663 661
664 return bt3c_config(link); 662 return bt3c_config(link);
665} 663}
@@ -673,38 +671,41 @@ static void bt3c_detach(struct pcmcia_device *link)
673 kfree(info); 671 kfree(info);
674} 672}
675 673
676static int bt3c_check_config(struct pcmcia_device *p_dev, 674static int bt3c_check_config(struct pcmcia_device *p_dev, void *priv_data)
677 cistpl_cftable_entry_t *cf,
678 cistpl_cftable_entry_t *dflt,
679 void *priv_data)
680{ 675{
681 unsigned long try = (unsigned long) priv_data; 676 int *try = priv_data;
682 p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
683 677
684 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 678 if (try == 0)
685 (cf->io.win[0].base != 0)) { 679 p_dev->io_lines = 16;
686 p_dev->resource[0]->start = cf->io.win[0].base; 680
687 if (!pcmcia_request_io(p_dev)) 681 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
688 return 0; 682 return -EINVAL;
689 } 683
690 return -ENODEV; 684 p_dev->resource[0]->end = 8;
685 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
686 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
687
688 return pcmcia_request_io(p_dev);
691} 689}
692 690
693static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev, 691static int bt3c_check_config_notpicky(struct pcmcia_device *p_dev,
694 cistpl_cftable_entry_t *cf,
695 cistpl_cftable_entry_t *dflt,
696 void *priv_data) 692 void *priv_data)
697{ 693{
698 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 694 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
699 int j; 695 int j;
700 696
701 if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 697 if (p_dev->io_lines > 3)
702 for (j = 0; j < 5; j++) { 698 return -ENODEV;
703 p_dev->resource[0]->start = base[j]; 699
704 p_dev->io_lines = base[j] ? 16 : 3; 700 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
705 if (!pcmcia_request_io(p_dev)) 701 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
706 return 0; 702 p_dev->resource[0]->end = 8;
707 } 703
704 for (j = 0; j < 5; j++) {
705 p_dev->resource[0]->start = base[j];
706 p_dev->io_lines = base[j] ? 16 : 3;
707 if (!pcmcia_request_io(p_dev))
708 return 0;
708 } 709 }
709 return -ENODEV; 710 return -ENODEV;
710} 711}
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 8a6864fc8c38..9f9bb69dc0a2 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -585,10 +585,8 @@ static int btuart_probe(struct pcmcia_device *link)
585 info->p_dev = link; 585 info->p_dev = link;
586 link->priv = info; 586 link->priv = info;
587 587
588 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 588 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
589 link->resource[0]->end = 8; 589 CONF_AUTO_SET_IO;
590
591 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP;
592 590
593 return btuart_config(link); 591 return btuart_config(link);
594} 592}
@@ -602,38 +600,41 @@ static void btuart_detach(struct pcmcia_device *link)
602 kfree(info); 600 kfree(info);
603} 601}
604 602
605static int btuart_check_config(struct pcmcia_device *p_dev, 603static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data)
606 cistpl_cftable_entry_t *cf,
607 cistpl_cftable_entry_t *dflt,
608 void *priv_data)
609{ 604{
610 int *try = priv_data; 605 int *try = priv_data;
611 p_dev->io_lines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK;
612 606
613 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && 607 if (try == 0)
614 (cf->io.win[0].base != 0)) { 608 p_dev->io_lines = 16;
615 p_dev->resource[0]->start = cf->io.win[0].base; 609
616 if (!pcmcia_request_io(p_dev)) 610 if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0))
617 return 0; 611 return -EINVAL;
618 } 612
619 return -ENODEV; 613 p_dev->resource[0]->end = 8;
614 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
615 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
616
617 return pcmcia_request_io(p_dev);
620} 618}
621 619
622static int btuart_check_config_notpicky(struct pcmcia_device *p_dev, 620static int btuart_check_config_notpicky(struct pcmcia_device *p_dev,
623 cistpl_cftable_entry_t *cf,
624 cistpl_cftable_entry_t *dflt,
625 void *priv_data) 621 void *priv_data)
626{ 622{
627 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 623 static unsigned int base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
628 int j; 624 int j;
629 625
630 if ((cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 626 if (p_dev->io_lines > 3)
631 for (j = 0; j < 5; j++) { 627 return -ENODEV;
632 p_dev->resource[0]->start = base[j]; 628
633 p_dev->io_lines = base[j] ? 16 : 3; 629 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
634 if (!pcmcia_request_io(p_dev)) 630 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
635 return 0; 631 p_dev->resource[0]->end = 8;
636 } 632
633 for (j = 0; j < 5; j++) {
634 p_dev->resource[0]->start = base[j];
635 p_dev->io_lines = base[j] ? 16 : 3;
636 if (!pcmcia_request_io(p_dev))
637 return 0;
637 } 638 }
638 return -ENODEV; 639 return -ENODEV;
639} 640}
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 4620cc398676..12cd177132fc 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -571,10 +571,7 @@ static int dtl1_probe(struct pcmcia_device *link)
571 info->p_dev = link; 571 info->p_dev = link;
572 link->priv = info; 572 link->priv = info;
573 573
574 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; 574 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO;
575 link->resource[0]->end = 8;
576
577 link->config_flags |= CONF_ENABLE_IRQ;
578 575
579 return dtl1_config(link); 576 return dtl1_config(link);
580} 577}
@@ -589,17 +586,14 @@ static void dtl1_detach(struct pcmcia_device *link)
589 kfree(info); 586 kfree(info);
590} 587}
591 588
592static int dtl1_confcheck(struct pcmcia_device *p_dev, 589static int dtl1_confcheck(struct pcmcia_device *p_dev, void *priv_data)
593 cistpl_cftable_entry_t *cf,
594 cistpl_cftable_entry_t *dflt,
595 void *priv_data)
596{ 590{
597 if ((cf->io.nwin != 1) || (cf->io.win[0].len <= 8)) 591 if ((p_dev->resource[1]->end) || (p_dev->resource[1]->end < 8))
598 return -ENODEV; 592 return -ENODEV;
599 593
600 p_dev->resource[0]->start = cf->io.win[0].base; 594 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
601 p_dev->resource[0]->end = cf->io.win[0].len; /*yo */ 595 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
602 p_dev->io_lines = cf->io.flags & CISTPL_IO_LINES_MASK; 596
603 return pcmcia_request_io(p_dev); 597 return pcmcia_request_io(p_dev);
604} 598}
605 599