[PATCH] fix hrtimer percpu usage typo
[pandora-kernel.git] / drivers / pnp / manager.c
index 2616686..5026b34 100644 (file)
@@ -6,7 +6,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -20,7 +19,8 @@ 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;
@@ -63,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;
@@ -116,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 */
@@ -168,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 */
@@ -469,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
@@ -477,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) {
@@ -487,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;
 }
@@ -511,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);
@@ -544,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,6 +600,8 @@ 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);