aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-10-05 04:37:11 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-03-24 15:56:37 -0400
commitd67cfb9613f373d76daa2c8d209629601424ca12 (patch)
tree64d5633a8531fd1b978bef2104c6eee5303d3d8c /drivers/firewire
parentcf417e5494582453c033d8cac9e1352e74215435 (diff)
firewire: convert client_list_lock to mutex
So far it is only taken in non-atomic contexts. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/fw-cdev.c20
-rw-r--r--drivers/firewire/fw-device.c3
-rw-r--r--drivers/firewire/fw-device.h7
3 files changed, 14 insertions, 16 deletions
diff --git a/drivers/firewire/fw-cdev.c b/drivers/firewire/fw-cdev.c
index 40cc9732dc28..75bbd66f852e 100644
--- a/drivers/firewire/fw-cdev.c
+++ b/drivers/firewire/fw-cdev.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.h>
27#include <linux/mutex.h>
27#include <linux/poll.h> 28#include <linux/poll.h>
28#include <linux/preempt.h> 29#include <linux/preempt.h>
29#include <linux/time.h> 30#include <linux/time.h>
@@ -108,7 +109,6 @@ static int fw_device_op_open(struct inode *inode, struct file *file)
108{ 109{
109 struct fw_device *device; 110 struct fw_device *device;
110 struct client *client; 111 struct client *client;
111 unsigned long flags;
112 112
113 device = fw_device_get_by_devt(inode->i_rdev); 113 device = fw_device_get_by_devt(inode->i_rdev);
114 if (device == NULL) 114 if (device == NULL)
@@ -133,9 +133,9 @@ static int fw_device_op_open(struct inode *inode, struct file *file)
133 133
134 file->private_data = client; 134 file->private_data = client;
135 135
136 spin_lock_irqsave(&device->client_list_lock, flags); 136 mutex_lock(&device->client_list_mutex);
137 list_add_tail(&client->link, &device->client_list); 137 list_add_tail(&client->link, &device->client_list);
138 spin_unlock_irqrestore(&device->client_list_lock, flags); 138 mutex_unlock(&device->client_list_mutex);
139 139
140 return 0; 140 return 0;
141} 141}
@@ -232,14 +232,11 @@ for_each_client(struct fw_device *device,
232 void (*callback)(struct client *client)) 232 void (*callback)(struct client *client))
233{ 233{
234 struct client *c; 234 struct client *c;
235 unsigned long flags;
236
237 spin_lock_irqsave(&device->client_list_lock, flags);
238 235
236 mutex_lock(&device->client_list_mutex);
239 list_for_each_entry(c, &device->client_list, link) 237 list_for_each_entry(c, &device->client_list, link)
240 callback(c); 238 callback(c);
241 239 mutex_unlock(&device->client_list_mutex);
242 spin_unlock_irqrestore(&device->client_list_lock, flags);
243} 240}
244 241
245static void 242static void
@@ -247,7 +244,7 @@ queue_bus_reset_event(struct client *client)
247{ 244{
248 struct bus_reset *bus_reset; 245 struct bus_reset *bus_reset;
249 246
250 bus_reset = kzalloc(sizeof(*bus_reset), GFP_ATOMIC); 247 bus_reset = kzalloc(sizeof(*bus_reset), GFP_KERNEL);
251 if (bus_reset == NULL) { 248 if (bus_reset == NULL) {
252 fw_notify("Out of memory when allocating bus reset event\n"); 249 fw_notify("Out of memory when allocating bus reset event\n");
253 return; 250 return;
@@ -988,7 +985,6 @@ static int fw_device_op_release(struct inode *inode, struct file *file)
988 struct client *client = file->private_data; 985 struct client *client = file->private_data;
989 struct event *e, *next_e; 986 struct event *e, *next_e;
990 struct client_resource *r, *next_r; 987 struct client_resource *r, *next_r;
991 unsigned long flags;
992 988
993 if (client->buffer.pages) 989 if (client->buffer.pages)
994 fw_iso_buffer_destroy(&client->buffer, client->device->card); 990 fw_iso_buffer_destroy(&client->buffer, client->device->card);
@@ -1007,9 +1003,9 @@ static int fw_device_op_release(struct inode *inode, struct file *file)
1007 list_for_each_entry_safe(e, next_e, &client->event_list, link) 1003 list_for_each_entry_safe(e, next_e, &client->event_list, link)
1008 kfree(e); 1004 kfree(e);
1009 1005
1010 spin_lock_irqsave(&client->device->client_list_lock, flags); 1006 mutex_lock(&client->device->client_list_mutex);
1011 list_del(&client->link); 1007 list_del(&client->link);
1012 spin_unlock_irqrestore(&client->device->client_list_lock, flags); 1008 mutex_unlock(&client->device->client_list_mutex);
1013 1009
1014 fw_device_put(client->device); 1010 fw_device_put(client->device);
1015 kfree(client); 1011 kfree(client);
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index ffde1bed46b2..2de3dd5ebc4b 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -27,6 +27,7 @@
27#include <linux/idr.h> 27#include <linux/idr.h>
28#include <linux/jiffies.h> 28#include <linux/jiffies.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/mutex.h>
30#include <linux/rwsem.h> 31#include <linux/rwsem.h>
31#include <linux/semaphore.h> 32#include <linux/semaphore.h>
32#include <linux/spinlock.h> 33#include <linux/spinlock.h>
@@ -1005,7 +1006,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
1005 device->node = fw_node_get(node); 1006 device->node = fw_node_get(node);
1006 device->node_id = node->node_id; 1007 device->node_id = node->node_id;
1007 device->generation = card->generation; 1008 device->generation = card->generation;
1008 spin_lock_init(&device->client_list_lock); 1009 mutex_init(&device->client_list_mutex);
1009 INIT_LIST_HEAD(&device->client_list); 1010 INIT_LIST_HEAD(&device->client_list);
1010 1011
1011 /* 1012 /*
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 008a7908a865..655d7e838012 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -23,7 +23,7 @@
23#include <linux/cdev.h> 23#include <linux/cdev.h>
24#include <linux/idr.h> 24#include <linux/idr.h>
25#include <linux/rwsem.h> 25#include <linux/rwsem.h>
26#include <linux/spinlock.h> 26#include <linux/mutex.h>
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28 28
29enum fw_device_state { 29enum fw_device_state {
@@ -65,9 +65,10 @@ struct fw_device {
65 bool cmc; 65 bool cmc;
66 struct fw_card *card; 66 struct fw_card *card;
67 struct device device; 67 struct device device;
68 /* to prevent deadlocks, never take this lock with card->lock held */ 68
69 spinlock_t client_list_lock; 69 struct mutex client_list_mutex;
70 struct list_head client_list; 70 struct list_head client_list;
71
71 u32 *config_rom; 72 u32 *config_rom;
72 size_t config_rom_length; 73 size_t config_rom_length;
73 int config_rom_retries; 74 int config_rom_retries;