isapnp driver semaphore to mutex
Changed the isapnp semaphore to a mutex. [akpm@linux-foundation.org: no externs-in-c] [akpm@linux-foundation.org: build fix] Signed-off-by: Daniel Walker <dwalker@mvista.com> Cc: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
2bb9a6b32f
commit
b3bd86e2fd
@@ -10,9 +10,12 @@
|
|||||||
#include <linux/errno.h>
|
#include <linux/errno.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#include <linux/pnp.h>
|
||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
|
||||||
#include "base.h"
|
#include "base.h"
|
||||||
@@ -315,8 +318,6 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct semaphore pnp_res_mutex;
|
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
|
pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
|
||||||
const char *ubuf, size_t count)
|
const char *ubuf, size_t count)
|
||||||
@@ -361,10 +362,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!strnicmp(buf, "get", 3)) {
|
if (!strnicmp(buf, "get", 3)) {
|
||||||
down(&pnp_res_mutex);
|
mutex_lock(&pnp_res_mutex);
|
||||||
if (pnp_can_read(dev))
|
if (pnp_can_read(dev))
|
||||||
dev->protocol->get(dev, &dev->res);
|
dev->protocol->get(dev, &dev->res);
|
||||||
up(&pnp_res_mutex);
|
mutex_unlock(&pnp_res_mutex);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!strnicmp(buf, "set", 3)) {
|
if (!strnicmp(buf, "set", 3)) {
|
||||||
@@ -373,7 +374,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
|
|||||||
goto done;
|
goto done;
|
||||||
buf += 3;
|
buf += 3;
|
||||||
pnp_init_resource_table(&dev->res);
|
pnp_init_resource_table(&dev->res);
|
||||||
down(&pnp_res_mutex);
|
mutex_lock(&pnp_res_mutex);
|
||||||
while (1) {
|
while (1) {
|
||||||
while (isspace(*buf))
|
while (isspace(*buf))
|
||||||
++buf;
|
++buf;
|
||||||
@@ -455,7 +456,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
up(&pnp_res_mutex);
|
mutex_unlock(&pnp_res_mutex);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -258,6 +258,7 @@ extern struct pnp_protocol isapnp_protocol;
|
|||||||
#else
|
#else
|
||||||
#define pnp_device_is_isapnp(dev) 0
|
#define pnp_device_is_isapnp(dev) 0
|
||||||
#endif
|
#endif
|
||||||
|
extern struct mutex pnp_res_mutex;
|
||||||
|
|
||||||
#ifdef CONFIG_PNPBIOS
|
#ifdef CONFIG_PNPBIOS
|
||||||
extern struct pnp_protocol pnpbios_protocol;
|
extern struct pnp_protocol pnpbios_protocol;
|
||||||
|
Reference in New Issue
Block a user