]> err.no Git - linux-2.6/blobdiff - drivers/pnp/pnpacpi/rsparser.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hpa/linux...
[linux-2.6] / drivers / pnp / pnpacpi / rsparser.c
index ce5027feb3da88cd5e32ced586a85c666358ea7c..3c5eb374adf8bbcc0a1d0a7dbb85ab6f55587a7d 100644 (file)
  */
 static int irq_flags(int triggering, int polarity)
 {
-       int flag;
        if (triggering == ACPI_LEVEL_SENSITIVE) {
                if (polarity == ACPI_ACTIVE_LOW)
-                       flag = IORESOURCE_IRQ_LOWLEVEL;
+                       return IORESOURCE_IRQ_LOWLEVEL;
                else
-                       flag = IORESOURCE_IRQ_HIGHLEVEL;
+                       return IORESOURCE_IRQ_HIGHLEVEL;
        } else {
                if (polarity == ACPI_ACTIVE_LOW)
-                       flag = IORESOURCE_IRQ_LOWEDGE;
+                       return IORESOURCE_IRQ_LOWEDGE;
                else
-                       flag = IORESOURCE_IRQ_HIGHEDGE;
+                       return IORESOURCE_IRQ_HIGHEDGE;
        }
-       return flag;
 }
 
 static void decode_irq_flags(int flag, int *triggering, int *polarity)
@@ -77,6 +75,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
 {
        int i = 0;
        int irq;
+       int p, t;
 
        if (!valid_IRQ(gsi))
                return;
@@ -84,8 +83,27 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
        while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
               i < PNP_MAX_IRQ)
                i++;
-       if (i >= PNP_MAX_IRQ)
+       if (i >= PNP_MAX_IRQ) {
+               printk(KERN_ERR "pnpacpi: exceeded the max number of IRQ "
+                               "resources: %d \n", PNP_MAX_IRQ);
                return;
+       }
+       /*
+        * in IO-APIC mode, use overrided attribute. Two reasons:
+        * 1. BIOS bug in DSDT
+        * 2. BIOS uses IO-APIC mode Interrupt Source Override
+        */
+       if (!acpi_get_override_irq(gsi, &t, &p)) {
+               t = t ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
+               p = p ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
+
+               if (triggering != t || polarity != p) {
+                       pnp_warn("IRQ %d override to %s, %s",
+                               gsi, t ? "edge":"level", p ? "low":"high");
+                       triggering = t;
+                       polarity = p;
+               }
+       }
 
        res->irq_resource[i].flags = IORESOURCE_IRQ;    // Also clears _UNSET flag
        res->irq_resource[i].flags |= irq_flags(triggering, polarity);
@@ -165,6 +183,9 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
                }
                res->dma_resource[i].start = dma;
                res->dma_resource[i].end = dma;
+       } else {
+               printk(KERN_ERR "pnpacpi: exceeded the max number of DMA "
+                               "resources: %d \n", PNP_MAX_DMA);
        }
 }
 
@@ -186,6 +207,9 @@ static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
                }
                res->port_resource[i].start = io;
                res->port_resource[i].end = io + len - 1;
+       } else {
+               printk(KERN_ERR "pnpacpi: exceeded the max number of IO "
+                               "resources: %d \n", PNP_MAX_PORT);
        }
 }
 
@@ -209,6 +233,9 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
 
                res->mem_resource[i].start = mem;
                res->mem_resource[i].end = mem + len - 1;
+       } else {
+               printk(KERN_ERR "pnpacpi: exceeded the max number of mem "
+                               "resources: %d\n", PNP_MAX_MEM);
        }
 }
 
@@ -242,8 +269,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res
 static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
                                              void *data)
 {
-       struct pnp_resource_table *res_table =
-           (struct pnp_resource_table *)data;
+       struct pnp_resource_table *res_table = data;
        int i;
 
        switch (res->type) {
@@ -566,8 +592,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
                                           void *data)
 {
        int priority = 0;
-       struct acpipnp_parse_option_s *parse_data =
-           (struct acpipnp_parse_option_s *)data;
+       struct acpipnp_parse_option_s *parse_data = data;
        struct pnp_dev *dev = parse_data->dev;
        struct pnp_option *option = parse_data->option;
 
@@ -705,7 +730,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res)
 static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
                                           void *data)
 {
-       int *res_cnt = (int *)data;
+       int *res_cnt = data;
 
        if (pnpacpi_supported_resource(res))
                (*res_cnt)++;
@@ -714,7 +739,7 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
 
 static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
 {
-       struct acpi_resource **resource = (struct acpi_resource **)data;
+       struct acpi_resource **resource = data;
 
        if (pnpacpi_supported_resource(res)) {
                (*resource)->type = res->type;
@@ -886,8 +911,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
        int i = 0;
        /* pnpacpi_build_resource_template allocates extra mem */
        int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
-       struct acpi_resource *resource =
-           (struct acpi_resource *)buffer->pointer;
+       struct acpi_resource *resource = buffer->pointer;
        int port = 0, irq = 0, dma = 0, mem = 0;
 
        pnp_dbg("res cnt %d", res_cnt);