git.openpandora.org
/
pandora-kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'linus' into cpus4096
[pandora-kernel.git]
/
drivers
/
macintosh
/
adb.c
diff --git
a/drivers/macintosh/adb.c
b/drivers/macintosh/adb.c
index
2097820
..
40c70ba
100644
(file)
--- a/
drivers/macintosh/adb.c
+++ b/
drivers/macintosh/adb.c
@@
-37,7
+37,7
@@
#include <linux/device.h>
#include <linux/kthread.h>
#include <linux/platform_device.h>
#include <linux/device.h>
#include <linux/kthread.h>
#include <linux/platform_device.h>
-#include <linux/
semaphore
.h>
+#include <linux/
mutex
.h>
#include <asm/uaccess.h>
#ifdef CONFIG_PPC
#include <asm/uaccess.h>
#ifdef CONFIG_PPC
@@
-102,7
+102,7
@@
static struct adb_handler {
} adb_handler[16];
/*
} adb_handler[16];
/*
- * The adb_handler_
sem
mutex protects all accesses to the original_address
+ * The adb_handler_
mutex
mutex protects all accesses to the original_address
* and handler_id fields of adb_handler[i] for all i, and changes to the
* handler field.
* Accesses to the handler field are protected by the adb_handler_lock
* and handler_id fields of adb_handler[i] for all i, and changes to the
* handler field.
* Accesses to the handler field are protected by the adb_handler_lock
@@
-110,7
+110,7
@@
static struct adb_handler {
* time adb_unregister returns, we know that the old handler isn't being
* called.
*/
* time adb_unregister returns, we know that the old handler isn't being
* called.
*/
-static DE
CLARE_MUTEX(adb_handler_sem
);
+static DE
FINE_MUTEX(adb_handler_mutex
);
static DEFINE_RWLOCK(adb_handler_lock);
#if 0
static DEFINE_RWLOCK(adb_handler_lock);
#if 0
@@
-334,7
+334,7
@@
int __init adb_init(void)
return 0;
}
return 0;
}
-
_
_initcall(adb_init);
+
device
_initcall(adb_init);
static int
do_adb_reset_bus(void)
static int
do_adb_reset_bus(void)
@@
-355,7
+355,7
@@
do_adb_reset_bus(void)
msleep(500);
}
msleep(500);
}
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
write_lock_irq(&adb_handler_lock);
memset(adb_handler, 0, sizeof(adb_handler));
write_unlock_irq(&adb_handler_lock);
write_lock_irq(&adb_handler_lock);
memset(adb_handler, 0, sizeof(adb_handler));
write_unlock_irq(&adb_handler_lock);
@@
-376,7
+376,7
@@
do_adb_reset_bus(void)
if (adb_controller->autopoll)
adb_controller->autopoll(autopoll_devs);
}
if (adb_controller->autopoll)
adb_controller->autopoll(autopoll_devs);
}
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
blocking_notifier_call_chain(&adb_client_list,
ADB_MSG_POST_RESET, NULL);
blocking_notifier_call_chain(&adb_client_list,
ADB_MSG_POST_RESET, NULL);
@@
-454,7
+454,7
@@
adb_register(int default_id, int handler_id, struct adb_ids *ids,
{
int i;
{
int i;
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
ids->nids = 0;
for (i = 1; i < 16; i++) {
if ((adb_handler[i].original_address == default_id) &&
ids->nids = 0;
for (i = 1; i < 16; i++) {
if ((adb_handler[i].original_address == default_id) &&
@@
-472,7
+472,7
@@
adb_register(int default_id, int handler_id, struct adb_ids *ids,
ids->id[ids->nids++] = i;
}
}
ids->id[ids->nids++] = i;
}
}
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
return ids->nids;
}
return ids->nids;
}
@@
-481,7
+481,7
@@
adb_unregister(int index)
{
int ret = -ENODEV;
{
int ret = -ENODEV;
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
write_lock_irq(&adb_handler_lock);
if (adb_handler[index].handler) {
while(adb_handler[index].busy) {
write_lock_irq(&adb_handler_lock);
if (adb_handler[index].handler) {
while(adb_handler[index].busy) {
@@
-493,7
+493,7
@@
adb_unregister(int index)
adb_handler[index].handler = NULL;
}
write_unlock_irq(&adb_handler_lock);
adb_handler[index].handler = NULL;
}
write_unlock_irq(&adb_handler_lock);
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
return ret;
}
return ret;
}
@@
-557,19
+557,19
@@
adb_try_handler_change(int address, int new_id)
{
int ret;
{
int ret;
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
ret = try_handler_change(address, new_id);
ret = try_handler_change(address, new_id);
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
return ret;
}
int
adb_get_infos(int address, int *original_address, int *handler_id)
{
return ret;
}
int
adb_get_infos(int address, int *original_address, int *handler_id)
{
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
*original_address = adb_handler[address].original_address;
*handler_id = adb_handler[address].handler_id;
*original_address = adb_handler[address].original_address;
*handler_id = adb_handler[address].handler_id;
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
return (*original_address != 0);
}
return (*original_address != 0);
}
@@
-628,10
+628,10
@@
do_adb_query(struct adb_request *req)
case ADB_QUERY_GETDEVINFO:
if (req->nbytes < 3)
break;
case ADB_QUERY_GETDEVINFO:
if (req->nbytes < 3)
break;
-
down(&adb_handler_sem
);
+
mutex_lock(&adb_handler_mutex
);
req->reply[0] = adb_handler[req->data[2]].original_address;
req->reply[1] = adb_handler[req->data[2]].handler_id;
req->reply[0] = adb_handler[req->data[2]].original_address;
req->reply[1] = adb_handler[req->data[2]].handler_id;
-
up(&adb_handler_sem
);
+
mutex_unlock(&adb_handler_mutex
);
req->complete = 1;
req->reply_len = 2;
adb_write_done(req);
req->complete = 1;
req->reply_len = 2;
adb_write_done(req);
@@
-644,12
+644,18
@@
do_adb_query(struct adb_request *req)
static int adb_open(struct inode *inode, struct file *file)
{
struct adbdev_state *state;
static int adb_open(struct inode *inode, struct file *file)
{
struct adbdev_state *state;
+ int ret = 0;
- if (iminor(inode) > 0 || adb_controller == NULL)
- return -ENXIO;
+ lock_kernel();
+ if (iminor(inode) > 0 || adb_controller == NULL) {
+ ret = -ENXIO;
+ goto out;
+ }
state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL);
- if (state == 0)
- return -ENOMEM;
+ if (state == 0) {
+ ret = -ENOMEM;
+ goto out;
+ }
file->private_data = state;
spin_lock_init(&state->lock);
atomic_set(&state->n_pending, 0);
file->private_data = state;
spin_lock_init(&state->lock);
atomic_set(&state->n_pending, 0);
@@
-657,7
+663,9
@@
static int adb_open(struct inode *inode, struct file *file)
init_waitqueue_head(&state->wait_queue);
state->inuse = 1;
init_waitqueue_head(&state->wait_queue);
state->inuse = 1;
- return 0;
+out:
+ unlock_kernel();
+ return ret;
}
static int adb_release(struct inode *inode, struct file *file)
}
static int adb_release(struct inode *inode, struct file *file)