/* when the resource already exists, set its resource bits from rule */ if (res) {
res->flags &= ~IORESOURCE_BITS;
res->flags |= rule & IORESOURCE_BITS;
}
/** * pnp_assign_resources - assigns resources to the device based on the specified dependent number * @dev: pointer to the desired device * @set: the dependent function number
*/ staticint pnp_assign_resources(struct pnp_dev *dev, int set)
{ struct pnp_option *option; int nport = 0, nmem = 0, nirq = 0; int ndma __maybe_unused = 0; int ret = 0;
pnp_dbg(&dev->dev, "pnp_assign_resources, try dependent set %d\n", set);
mutex_lock(&pnp_res_mutex);
pnp_clean_resource_table(dev);
switch (option->type) { case IORESOURCE_IO:
ret = pnp_assign_port(dev, &option->u.port, nport++); break; case IORESOURCE_MEM:
ret = pnp_assign_mem(dev, &option->u.mem, nmem++); break; case IORESOURCE_IRQ:
ret = pnp_assign_irq(dev, &option->u.irq, nirq++); break; #ifdef CONFIG_ISA_DMA_API case IORESOURCE_DMA:
ret = pnp_assign_dma(dev, &option->u.dma, ndma++); break; #endif default:
ret = -EINVAL; break;
} if (ret < 0) break;
}
/** * pnp_auto_config_dev - automatically assigns resources to a device * @dev: pointer to the desired device
*/ int pnp_auto_config_dev(struct pnp_dev *dev)
{ int i, ret;
if (!pnp_can_configure(dev)) {
pnp_dbg(&dev->dev, "configuration not supported\n"); return -ENODEV;
}
ret = pnp_assign_resources(dev, 0); if (ret == 0) return 0;
for (i = 1; i < dev->num_dependent_sets; i++) {
ret = pnp_assign_resources(dev, i); if (ret == 0) return 0;
}
dev_err(&dev->dev, "unable to assign resources\n"); return ret;
}
/** * pnp_start_dev - low-level start of the PnP device * @dev: pointer to the desired device * * assumes that resources have already been allocated
*/ int pnp_start_dev(struct pnp_dev *dev)
{ if (!pnp_can_write(dev)) {
pnp_dbg(&dev->dev, "activation not supported\n"); return -EINVAL;
}
/** * pnp_stop_dev - low-level disable of the PnP device * @dev: pointer to the desired device * * does not free resources
*/ int pnp_stop_dev(struct pnp_dev *dev)
{ if (!pnp_can_disable(dev)) {
pnp_dbg(&dev->dev, "disabling not supported\n"); return -EINVAL;
} if (dev->protocol->disable(dev) < 0) {
dev_err(&dev->dev, "disable failed\n"); return -EIO;
}
/** * pnp_activate_dev - activates a PnP device for use * @dev: pointer to the desired device * * does not validate or set resources so be careful.
*/ int pnp_activate_dev(struct pnp_dev *dev)
{ int error;
if (dev->active) return 0;
/* ensure resources are allocated */ if (pnp_auto_config_dev(dev)) return -EBUSY;
error = pnp_start_dev(dev); if (error) return error;
/** * pnp_disable_dev - disables device * @dev: pointer to the desired device * * inform the correct pnp protocol so that resources can be used by other devices
*/ int pnp_disable_dev(struct pnp_dev *dev)
{ int error;
if (!dev->active) return 0;
error = pnp_stop_dev(dev); if (error) return error;
dev->active = 0;
/* release the resources so that other devices can use them */
mutex_lock(&pnp_res_mutex);
pnp_clean_resource_table(dev);
mutex_unlock(&pnp_res_mutex);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.