- if (depnum) {
- struct pnp_option *dep;
- int i;
- for (i=1,dep=dev->dependent; i<depnum; i++, dep=dep->next)
- if(!dep)
- goto fail;
- port =dep->port;
- mem = dep->mem;
- irq = dep->irq;
- dma = dep->dma;
- while (port) {
- if (!pnp_assign_port(dev, port, nport))
- goto fail;
- nport++;
- port = port->next;
- }
- while (mem) {
- if (!pnp_assign_mem(dev, mem, nmem))
- goto fail;
- nmem++;
- mem = mem->next;
- }
- while (irq) {
- if (!pnp_assign_irq(dev, irq, nirq))
- goto fail;
- nirq++;
- irq = irq->next;
- }
- while (dma) {
- if (!pnp_assign_dma(dev, dma, ndma))
- goto fail;
- ndma++;
- dma = dma->next;
- }
- } else if (dev->dependent)
- goto fail;
-
- up(&pnp_res_mutex);
- return 1;
-
-fail:
- pnp_clean_resource_table(&dev->res);
- up(&pnp_res_mutex);
- return 0;
-}
-
-/**
- * pnp_manual_config_dev - Disables Auto Config and Manually sets the resource table
- * @dev: pointer to the desired device
- * @res: pointer to the new resource config
- * @mode: 0 or PNP_CONFIG_FORCE
- *
- * This function can be used by drivers that want to manually set thier resources.
- */
-int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, int mode)
-{
- 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));
- if (!bak)
- return -ENOMEM;
- *bak = dev->res;
-
- down(&pnp_res_mutex);
- dev->res = *res;
- if (!(mode & PNP_CONFIG_FORCE)) {
- for (i = 0; i < PNP_MAX_PORT; i++) {
- if(!pnp_check_port(dev,i))
- goto fail;
- }
- for (i = 0; i < PNP_MAX_MEM; i++) {
- if(!pnp_check_mem(dev,i))
- goto fail;
- }
- for (i = 0; i < PNP_MAX_IRQ; i++) {
- if(!pnp_check_irq(dev,i))
- goto fail;
- }
- for (i = 0; i < PNP_MAX_DMA; i++) {
- if(!pnp_check_dma(dev,i))
- goto fail;
- }
- }
- up(&pnp_res_mutex);
-
- kfree(bak);
- return 0;
-
-fail:
- dev->res = *bak;
- up(&pnp_res_mutex);
- kfree(bak);
- return -EINVAL;
+ mutex_unlock(&pnp_res_mutex);
+ if (ret < 0) {
+ pnp_dbg(&dev->dev, "pnp_assign_resources failed (%d)\n", ret);
+ pnp_clean_resource_table(dev);
+ } else
+ dbg_pnp_show_resources(dev, "pnp_assign_resources succeeded");
+ return ret;