aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-22 05:56:38 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2010-07-27 05:04:10 -0400
commit55e77c06c6017a70630cf599770369b8ba07c841 (patch)
tree5fe5940bd0e0326afad0898b521490b53c894adf
parent685c3f80b6d88478a6428676f9daab59faf3cd4b (diff)
firewire: nosy: unroll some simple functions
nosy_start/stop_snoop() and nosy_add/remove_client() are simple enough to be inlined into their callers. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--drivers/firewire/nosy.c75
1 files changed, 29 insertions, 46 deletions
diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 2357e170e930..57a1100f8f4e 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -260,68 +260,44 @@ set_phy_reg(struct pcilynx *lynx, int addr, int val)
260 return 0; 260 return 0;
261} 261}
262 262
263static void 263static int
264nosy_start_snoop(struct client *client) 264nosy_open(struct inode *inode, struct file *file)
265{
266 spin_lock_irq(&client->lynx->client_list_lock);
267 list_add_tail(&client->link, &client->lynx->client_list);
268 spin_unlock_irq(&client->lynx->client_list_lock);
269}
270
271static void
272nosy_stop_snoop(struct client *client)
273{
274 spin_lock_irq(&client->lynx->client_list_lock);
275 list_del_init(&client->link);
276 spin_unlock_irq(&client->lynx->client_list_lock);
277}
278
279static struct client *
280nosy_add_client(struct pcilynx *lynx)
281{ 265{
266 int minor = iminor(inode);
282 struct client *client; 267 struct client *client;
283 268
269 if (minor > MAX_MINORS || minors[minor] == NULL)
270 return -ENODEV;
271
284 client = kmalloc(sizeof *client, GFP_KERNEL); 272 client = kmalloc(sizeof *client, GFP_KERNEL);
273 if (client == NULL)
274 return -ENOMEM;
275
285 client->tcode_mask = ~0; 276 client->tcode_mask = ~0;
286 client->lynx = lynx; 277 client->lynx = minors[minor];
287 INIT_LIST_HEAD(&client->link); 278 INIT_LIST_HEAD(&client->link);
288 279
289 if (packet_buffer_init(&client->buffer, 128 * 1024) < 0) { 280 if (packet_buffer_init(&client->buffer, 128 * 1024) < 0) {
290 kfree(client); 281 kfree(client);
291 debug("Failed to allocate packet buffer\n"); 282 return -ENOMEM;
292 return NULL;
293 } 283 }
294 284
295 return client; 285 file->private_data = client;
296}
297 286
298static void 287 return 0;
299nosy_remove_client(struct client *client)
300{
301 nosy_stop_snoop(client);
302 packet_buffer_destroy(&client->buffer);
303 kfree(client);
304} 288}
305 289
306static int 290static int
307nosy_open(struct inode *inode, struct file *file) 291nosy_release(struct inode *inode, struct file *file)
308{ 292{
309 int minor = iminor(inode); 293 struct client *client = file->private_data;
310
311 if (minor > MAX_MINORS || minors[minor] == NULL)
312 return -ENODEV;
313 294
314 file->private_data = nosy_add_client(minors[minor]); 295 spin_lock_irq(&client->lynx->client_list_lock);
315 if (file->private_data == NULL) 296 list_del_init(&client->link);
316 return -ENOMEM; 297 spin_unlock_irq(&client->lynx->client_list_lock);
317 else
318 return 0;
319}
320 298
321static int 299 packet_buffer_destroy(&client->buffer);
322nosy_release(struct inode *inode, struct file *file) 300 kfree(client);
323{
324 nosy_remove_client(file->private_data);
325 301
326 return 0; 302 return 0;
327} 303}
@@ -367,17 +343,24 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
367 return 0; 343 return 0;
368 344
369 case NOSY_IOC_START: 345 case NOSY_IOC_START:
370 nosy_start_snoop(client); 346 spin_lock_irq(client_list_lock);
347 list_add_tail(&client->link, &client->lynx->client_list);
348 spin_unlock_irq(client_list_lock);
349
371 return 0; 350 return 0;
372 351
373 case NOSY_IOC_STOP: 352 case NOSY_IOC_STOP:
374 nosy_stop_snoop(client); 353 spin_lock_irq(client_list_lock);
354 list_del_init(&client->link);
355 spin_unlock_irq(client_list_lock);
356
375 return 0; 357 return 0;
376 358
377 case NOSY_IOC_FILTER: 359 case NOSY_IOC_FILTER:
378 spin_lock_irq(client_list_lock); 360 spin_lock_irq(client_list_lock);
379 client->tcode_mask = arg; 361 client->tcode_mask = arg;
380 spin_unlock_irq(client_list_lock); 362 spin_unlock_irq(client_list_lock);
363
381 return 0; 364 return 0;
382 365
383 default: 366 default: