aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/rsrc_nonstatic.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/rsrc_nonstatic.c')
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 4663b3fa9f96..559069a80a3b 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -596,19 +596,17 @@ struct pcmcia_align_data {
596 struct resource_map *map; 596 struct resource_map *map;
597}; 597};
598 598
599static resource_size_t 599static resource_size_t pcmcia_common_align(struct pcmcia_align_data *align_data,
600pcmcia_common_align(void *align_data, const struct resource *res, 600 resource_size_t start)
601 resource_size_t size, resource_size_t align)
602{ 601{
603 struct pcmcia_align_data *data = align_data; 602 resource_size_t ret;
604 resource_size_t start;
605 /* 603 /*
606 * Ensure that we have the correct start address 604 * Ensure that we have the correct start address
607 */ 605 */
608 start = (res->start & ~data->mask) + data->offset; 606 ret = (start & ~align_data->mask) + align_data->offset;
609 if (start < res->start) 607 if (ret < start)
610 start += data->mask + 1; 608 ret += align_data->mask + 1;
611 return start; 609 return ret;
612} 610}
613 611
614static resource_size_t 612static resource_size_t
@@ -619,29 +617,28 @@ pcmcia_align(void *align_data, const struct resource *res,
619 struct resource_map *m; 617 struct resource_map *m;
620 resource_size_t start; 618 resource_size_t start;
621 619
622 start = pcmcia_common_align(data, res, size, align); 620 start = pcmcia_common_align(data, res->start);
623 621
624 for (m = data->map->next; m != data->map; m = m->next) { 622 for (m = data->map->next; m != data->map; m = m->next) {
625 unsigned long start = m->base; 623 unsigned long map_start = m->base;
626 unsigned long end = m->base + m->num - 1; 624 unsigned long map_end = m->base + m->num - 1;
627 625
628 /* 626 /*
629 * If the lower resources are not available, try aligning 627 * If the lower resources are not available, try aligning
630 * to this entry of the resource database to see if it'll 628 * to this entry of the resource database to see if it'll
631 * fit here. 629 * fit here.
632 */ 630 */
633 if (res->start < start) { 631 if (start < map_start)
634 start = pcmcia_common_align(data, res, size, align); 632 start = pcmcia_common_align(data, map_start);
635 }
636 633
637 /* 634 /*
638 * If we're above the area which was passed in, there's 635 * If we're above the area which was passed in, there's
639 * no point proceeding. 636 * no point proceeding.
640 */ 637 */
641 if (res->start >= res->end) 638 if (start >= res->end)
642 break; 639 break;
643 640
644 if ((res->start + size - 1) <= end) 641 if ((start + size - 1) <= map_end)
645 break; 642 break;
646 } 643 }
647 644
@@ -810,6 +807,13 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
810 unsigned long size = end - start + 1; 807 unsigned long size = end - start + 1;
811 int ret = 0; 808 int ret = 0;
812 809
810#if defined(CONFIG_X86)
811 /* on x86, avoid anything < 0x100 for it is often used for
812 * legacy platform devices */
813 if (start < 0x100)
814 start = 0x100;
815#endif
816
813 if (end < start) 817 if (end < start)
814 return -EINVAL; 818 return -EINVAL;
815 819
@@ -867,10 +871,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
867 if (res == &ioport_resource) 871 if (res == &ioport_resource)
868 continue; 872 continue;
869 dev_printk(KERN_INFO, &s->cb_dev->dev, 873 dev_printk(KERN_INFO, &s->cb_dev->dev,
870 "pcmcia: parent PCI bridge I/O " 874 "pcmcia: parent PCI bridge window: %pR\n",
871 "window: 0x%llx - 0x%llx\n", 875 res);
872 (unsigned long long)res->start,
873 (unsigned long long)res->end);
874 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 876 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
875 done |= IORESOURCE_IO; 877 done |= IORESOURCE_IO;
876 878
@@ -880,10 +882,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
880 if (res == &iomem_resource) 882 if (res == &iomem_resource)
881 continue; 883 continue;
882 dev_printk(KERN_INFO, &s->cb_dev->dev, 884 dev_printk(KERN_INFO, &s->cb_dev->dev,
883 "pcmcia: parent PCI bridge Memory " 885 "pcmcia: parent PCI bridge window: %pR\n",
884 "window: 0x%llx - 0x%llx\n", 886 res);
885 (unsigned long long)res->start,
886 (unsigned long long)res->end);
887 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 887 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
888 done |= IORESOURCE_MEM; 888 done |= IORESOURCE_MEM;
889 } 889 }