X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fpnp%2Fmanager.c;h=c6b3d4e63ccc62a9ae6e4df684c016eb598fe184;hb=628edcde87592a7ac6e72b555bb03ea265bcfbd2;hp=3bda513a6bd36cb92ea092ef3fd4ae13c7a6ad19;hpb=9f5577d8158d8190174d95cbf21713251cc8a044;p=linux-2.6 diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 3bda513a6b..c6b3d4e63c 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -1,7 +1,7 @@ /* * manager.c - Resource Management, Conflict Resolution, Activation and Disabling of Devices * - * based on isapnp.c resource management (c) Jaroslav Kysela + * based on isapnp.c resource management (c) Jaroslav Kysela * Copyright 2003 Adam Belay */ @@ -21,12 +21,8 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) resource_size_t *start, *end; unsigned long *flags; - if (!dev || !rule) - return -EINVAL; - if (idx >= PNP_MAX_PORT) { - pnp_err - ("More than 4 ports is incompatible with pnp specifications."); + dev_err(&dev->dev, "too many I/O port resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } @@ -66,12 +62,8 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) resource_size_t *start, *end; unsigned long *flags; - if (!dev || !rule) - return -EINVAL; - if (idx >= PNP_MAX_MEM) { - pnp_err - ("More than 8 mems is incompatible with pnp specifications."); + dev_err(&dev->dev, "too many memory resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } @@ -127,12 +119,8 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 }; - if (!dev || !rule) - return -EINVAL; - if (idx >= PNP_MAX_IRQ) { - pnp_err - ("More than 2 irqs is incompatible with pnp specifications."); + dev_err(&dev->dev, "too many IRQ resources\n"); /* pretend we were successful so at least the manager won't try again */ return 1; } @@ -170,7 +158,7 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) return 0; } -static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) +static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) { resource_size_t *start, *end; unsigned long *flags; @@ -181,19 +169,14 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) 1, 3, 5, 6, 7, 0, 2, 4 }; - if (!dev || !rule) - return -EINVAL; - if (idx >= PNP_MAX_DMA) { - pnp_err - ("More than 2 dmas is incompatible with pnp specifications."); - /* pretend we were successful so at least the manager won't try again */ - return 1; + dev_err(&dev->dev, "too many DMA resources\n"); + return; } /* check if this resource has been manually set, if so skip */ if (!(dev->res.dma_resource[idx].flags & IORESOURCE_AUTO)) - return 1; + return; start = &dev->res.dma_resource[idx].start; end = &dev->res.dma_resource[idx].end; @@ -203,19 +186,17 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) *flags |= rule->flags | IORESOURCE_DMA; *flags &= ~IORESOURCE_UNSET; - if (!rule->map) { - *flags |= IORESOURCE_DISABLED; - return 1; /* skip disabled resource requests */ - } - for (i = 0; i < 8; i++) { if (rule->map & (1 << xtab[i])) { *start = *end = xtab[i]; if (pnp_check_dma(dev, idx)) - return 1; + return; } } - return 0; +#ifdef MAX_DMA_CHANNELS + *start = *end = MAX_DMA_CHANNELS; +#endif + *flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; } /** @@ -342,8 +323,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) irq = irq->next; } while (dma) { - if (!pnp_assign_dma(dev, dma, ndma)) - goto fail; + pnp_assign_dma(dev, dma, ndma); ndma++; dma = dma->next; } @@ -379,8 +359,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) irq = irq->next; } while (dma) { - if (!pnp_assign_dma(dev, dma, ndma)) - goto fail; + pnp_assign_dma(dev, dma, ndma); ndma++; dma = dma->next; } @@ -390,7 +369,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum) up(&pnp_res_mutex); return 1; - fail: +fail: pnp_clean_resource_table(&dev->res); up(&pnp_res_mutex); return 0; @@ -410,8 +389,6 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int i; struct pnp_resource_table *bak; - if (!dev || !res) - return -EINVAL; if (!pnp_can_configure(dev)) return -ENODEV; bak = pnp_alloc(sizeof(struct pnp_resource_table)); @@ -444,7 +421,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, kfree(bak); return 0; - fail: +fail: dev->res = *bak; up(&pnp_res_mutex); kfree(bak); @@ -460,12 +437,8 @@ int pnp_auto_config_dev(struct pnp_dev *dev) struct pnp_option *dep; int i = 1; - if (!dev) - return -EINVAL; - if (!pnp_can_configure(dev)) { - pnp_dbg("Device %s does not support resource configuration.", - dev->dev.bus_id); + dev_dbg(&dev->dev, "configuration not supported\n"); return -ENODEV; } @@ -482,7 +455,7 @@ int pnp_auto_config_dev(struct pnp_dev *dev) } while (dep); } - pnp_err("Unable to assign resources to device %s.", dev->dev.bus_id); + dev_err(&dev->dev, "unable to assign resources\n"); return -EBUSY; } @@ -495,17 +468,16 @@ int pnp_auto_config_dev(struct pnp_dev *dev) int pnp_start_dev(struct pnp_dev *dev) { if (!pnp_can_write(dev)) { - pnp_dbg("Device %s does not support activation.", - dev->dev.bus_id); + dev_dbg(&dev->dev, "activation not supported\n"); return -EINVAL; } if (dev->protocol->set(dev, &dev->res) < 0) { - pnp_err("Failed to activate device %s.", dev->dev.bus_id); + dev_err(&dev->dev, "activation failed\n"); return -EIO; } - pnp_info("Device %s activated.", dev->dev.bus_id); + dev_info(&dev->dev, "activated\n"); return 0; } @@ -518,16 +490,15 @@ int pnp_start_dev(struct pnp_dev *dev) int pnp_stop_dev(struct pnp_dev *dev) { if (!pnp_can_disable(dev)) { - pnp_dbg("Device %s does not support disabling.", - dev->dev.bus_id); + dev_dbg(&dev->dev, "disabling not supported\n"); return -EINVAL; } if (dev->protocol->disable(dev) < 0) { - pnp_err("Failed to disable device %s.", dev->dev.bus_id); + dev_err(&dev->dev, "disable failed\n"); return -EIO; } - pnp_info("Device %s disabled.", dev->dev.bus_id); + dev_info(&dev->dev, "disabled\n"); return 0; } @@ -541,8 +512,6 @@ int pnp_activate_dev(struct pnp_dev *dev) { int error; - if (!dev) - return -EINVAL; if (dev->active) return 0; /* the device is already active */ @@ -568,8 +537,6 @@ int pnp_disable_dev(struct pnp_dev *dev) { int error; - if (!dev) - return -EINVAL; if (!dev->active) return 0; /* the device is already disabled */ @@ -596,8 +563,6 @@ int pnp_disable_dev(struct pnp_dev *dev) void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { - if (resource == NULL) - return; resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET); resource->start = start; resource->end = start + size - 1;