#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
-
-#ifdef CONFIG_PNP_DEBUG
- #define DEBUG
-#else
- #undef DEBUG
-#endif
-
#include <linux/pnp.h>
+#include <linux/slab.h>
+#include <linux/bitmap.h>
#include "base.h"
DECLARE_MUTEX(pnp_res_mutex);
*flags |= rule->flags | IORESOURCE_IRQ;
*flags &= ~IORESOURCE_UNSET;
- if (!rule->map) {
+ if (bitmap_empty(rule->map, PNP_IRQ_NR)) {
*flags |= IORESOURCE_DISABLED;
return 1; /* skip disabled resource requests */
}
+ /* TBD: need check for >16 IRQ */
+ *start = find_next_bit(rule->map, PNP_IRQ_NR, 16);
+ if (*start < PNP_IRQ_NR) {
+ *end = *start;
+ return 1;
+ }
for (i = 0; i < 16; i++) {
- if(rule->map & (1<<xtab[i])) {
+ if(test_bit(xtab[i], rule->map)) {
*start = *end = xtab[i];
if(pnp_check_irq(dev, idx))
return 1;
/**
* 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)
*
* 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;
* 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.
*/
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
*/
int pnp_activate_dev(struct pnp_dev *dev)
{
+ int error;
+
if (!dev)
return -EINVAL;
if (dev->active) {
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;
}
*/
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);
}
-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);