|
@@ -12,9 +12,10 @@
|
|
#include <linux/pnp.h>
|
|
#include <linux/pnp.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/bitmap.h>
|
|
#include <linux/bitmap.h>
|
|
|
|
+#include <linux/mutex.h>
|
|
#include "base.h"
|
|
#include "base.h"
|
|
|
|
|
|
-DECLARE_MUTEX(pnp_res_mutex);
|
|
|
|
|
|
+DEFINE_MUTEX(pnp_res_mutex);
|
|
|
|
|
|
static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
|
|
static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
|
|
{
|
|
{
|
|
@@ -297,7 +298,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
|
|
if (!pnp_can_configure(dev))
|
|
if (!pnp_can_configure(dev))
|
|
return -ENODEV;
|
|
return -ENODEV;
|
|
|
|
|
|
- down(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_lock(&pnp_res_mutex);
|
|
pnp_clean_resource_table(&dev->res); /* start with a fresh slate */
|
|
pnp_clean_resource_table(&dev->res); /* start with a fresh slate */
|
|
if (dev->independent) {
|
|
if (dev->independent) {
|
|
port = dev->independent->port;
|
|
port = dev->independent->port;
|
|
@@ -366,12 +367,12 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
|
|
} else if (dev->dependent)
|
|
} else if (dev->dependent)
|
|
goto fail;
|
|
goto fail;
|
|
|
|
|
|
- up(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_unlock(&pnp_res_mutex);
|
|
return 1;
|
|
return 1;
|
|
|
|
|
|
fail:
|
|
fail:
|
|
pnp_clean_resource_table(&dev->res);
|
|
pnp_clean_resource_table(&dev->res);
|
|
- up(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_unlock(&pnp_res_mutex);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -396,7 +397,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
*bak = dev->res;
|
|
*bak = dev->res;
|
|
|
|
|
|
- down(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_lock(&pnp_res_mutex);
|
|
dev->res = *res;
|
|
dev->res = *res;
|
|
if (!(mode & PNP_CONFIG_FORCE)) {
|
|
if (!(mode & PNP_CONFIG_FORCE)) {
|
|
for (i = 0; i < PNP_MAX_PORT; i++) {
|
|
for (i = 0; i < PNP_MAX_PORT; i++) {
|
|
@@ -416,14 +417,14 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
|
|
goto fail;
|
|
goto fail;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- up(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_unlock(&pnp_res_mutex);
|
|
|
|
|
|
kfree(bak);
|
|
kfree(bak);
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
fail:
|
|
fail:
|
|
dev->res = *bak;
|
|
dev->res = *bak;
|
|
- up(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_unlock(&pnp_res_mutex);
|
|
kfree(bak);
|
|
kfree(bak);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
@@ -547,9 +548,9 @@ int pnp_disable_dev(struct pnp_dev *dev)
|
|
dev->active = 0;
|
|
dev->active = 0;
|
|
|
|
|
|
/* release the resources so that other devices can use them */
|
|
/* release the resources so that other devices can use them */
|
|
- down(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_lock(&pnp_res_mutex);
|
|
pnp_clean_resource_table(&dev->res);
|
|
pnp_clean_resource_table(&dev->res);
|
|
- up(&pnp_res_mutex);
|
|
|
|
|
|
+ mutex_unlock(&pnp_res_mutex);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|