X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fpnp%2Fmanager.c;h=5026b345cb30226c7ed3d13dc3cc664e41e75edd;hb=refs%2Fremotes%2Fvserver;hp=0cbdf9d414c49471905feed2a5a6b01a9e2d89d4;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 0cbdf9d41..5026b345c 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -6,26 +6,21 @@ * */ -#include #include #include #include #include - -#ifdef CONFIG_PNP_DEBUG - #define DEBUG -#else - #undef DEBUG -#endif - #include +#include +#include #include "base.h" DECLARE_MUTEX(pnp_res_mutex); static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) { - unsigned long *start, *end, *flags; + resource_size_t *start, *end; + unsigned long *flags; if (!dev || !rule) return -EINVAL; @@ -68,7 +63,8 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) { - unsigned long *start, *end, *flags; + resource_size_t *start, *end; + unsigned long *flags; if (!dev || !rule) return -EINVAL; @@ -121,7 +117,8 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) { - unsigned long *start, *end, *flags; + resource_size_t *start, *end; + unsigned long *flags; int i; /* IRQ priority: this table is good for i386 */ @@ -173,7 +170,8 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) { - unsigned long *start, *end, *flags; + resource_size_t *start, *end; + unsigned long *flags; int i; /* DMA priority: this table is good for i386 */ @@ -253,7 +251,7 @@ void pnp_init_resource_table(struct pnp_resource_table *table) /** * pnp_clean_resources - clears resources that were not manually set - * @res - the resources to clean + * @res: the resources to clean * */ static void pnp_clean_resource_table(struct pnp_resource_table * res) @@ -296,7 +294,7 @@ static void pnp_clean_resource_table(struct pnp_resource_table * res) * * Only set depnum to 0 if the device does not have dependent options. */ -int pnp_assign_resources(struct pnp_dev *dev, int depnum) +static int pnp_assign_resources(struct pnp_dev *dev, int depnum) { struct pnp_port *port; struct pnp_mem *mem; @@ -390,6 +388,7 @@ fail: * 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. */ @@ -473,6 +472,53 @@ int pnp_auto_config_dev(struct pnp_dev *dev) return -EBUSY; } +/** + * pnp_start_dev - low-level start of the PnP device + * @dev: pointer to the desired device + * + * assumes that resources have alread been allocated + */ + +int pnp_start_dev(struct pnp_dev *dev) +{ + if (!pnp_can_write(dev)) { + pnp_info("Device %s does not support activation.", dev->dev.bus_id); + return -EINVAL; + } + + if (dev->protocol->set(dev, &dev->res)<0) { + pnp_err("Failed to activate device %s.", dev->dev.bus_id); + return -EIO; + } + + pnp_info("Device %s activated.", dev->dev.bus_id); + + return 0; +} + +/** + * 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_info("Device %s does not support disabling.", dev->dev.bus_id); + return -EINVAL; + } + if (dev->protocol->disable(dev)<0) { + pnp_err("Failed to disable device %s.", dev->dev.bus_id); + return -EIO; + } + + pnp_info("Device %s disabled.", dev->dev.bus_id); + + return 0; +} + /** * pnp_activate_dev - activates a PnP device for use * @dev: pointer to the desired device @@ -481,6 +527,8 @@ int pnp_auto_config_dev(struct pnp_dev *dev) */ int pnp_activate_dev(struct pnp_dev *dev) { + int error; + if (!dev) return -EINVAL; if (dev->active) { @@ -491,18 +539,11 @@ int pnp_activate_dev(struct pnp_dev *dev) if (pnp_auto_config_dev(dev)) return -EBUSY; - if (!pnp_can_write(dev)) { - pnp_info("Device %s does not supported activation.", dev->dev.bus_id); - return -EINVAL; - } - - if (dev->protocol->set(dev, &dev->res)<0) { - pnp_err("Failed to activate device %s.", dev->dev.bus_id); - return -EIO; - } + error = pnp_start_dev(dev); + if (error) + return error; dev->active = 1; - pnp_info("Device %s activated.", dev->dev.bus_id); return 1; } @@ -515,23 +556,19 @@ int pnp_activate_dev(struct pnp_dev *dev) */ int pnp_disable_dev(struct pnp_dev *dev) { + int error; + if (!dev) return -EINVAL; if (!dev->active) { return 0; /* the device is already disabled */ } - if (!pnp_can_disable(dev)) { - pnp_info("Device %s does not supported disabling.", dev->dev.bus_id); - return -EINVAL; - } - if (dev->protocol->disable(dev)<0) { - pnp_err("Failed to disable device %s.", dev->dev.bus_id); - return -EIO; - } + error = pnp_stop_dev(dev); + if (error) + return error; dev->active = 0; - pnp_info("Device %s disabled.", dev->dev.bus_id); /* release the resources so that other devices can use them */ down(&pnp_res_mutex); @@ -548,7 +585,8 @@ int pnp_disable_dev(struct pnp_dev *dev) * @size: size of region * */ -void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) +void pnp_resource_change(struct resource *resource, resource_size_t start, + resource_size_t size) { if (resource == NULL) return; @@ -558,9 +596,12 @@ void pnp_resource_change(struct resource *resource, unsigned long start, unsigne } -EXPORT_SYMBOL(pnp_assign_resources); EXPORT_SYMBOL(pnp_manual_config_dev); +#if 0 EXPORT_SYMBOL(pnp_auto_config_dev); +#endif +EXPORT_SYMBOL(pnp_start_dev); +EXPORT_SYMBOL(pnp_stop_dev); EXPORT_SYMBOL(pnp_activate_dev); EXPORT_SYMBOL(pnp_disable_dev); EXPORT_SYMBOL(pnp_resource_change);