aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2011-08-27 12:53:03 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2012-01-15 12:37:20 -0500
commit210762268466634ddbfaddb48fdf5181ce4b5f2d (patch)
tree8c07da360066158aa48f450dfeb593ed9ed76d0f /drivers/firewire
parent2ca526bf4953380abfe5dff455e356967b239c70 (diff)
firewire: move fw_device reference counting from drivers to core
fw_unit device drivers invariably need to talk to the fw_unit's parent (an fw_device) and grandparent (an fw_card). firewire-core already maintains an fw_card reference for the entire lifetime of an fw_device. Likewise, let firewire-core maintain an fw_device reference for the entire lifetime of an fw_unit so that fw_unit drivers don't have to. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/core-device.c2
-rw-r--r--drivers/firewire/core.h13
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index f3b890da1e87..4c6c7d8cdaf1 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -641,6 +641,7 @@ static void fw_unit_release(struct device *dev)
641{ 641{
642 struct fw_unit *unit = fw_unit(dev); 642 struct fw_unit *unit = fw_unit(dev);
643 643
644 fw_device_put(fw_parent_device(unit));
644 kfree(unit); 645 kfree(unit);
645} 646}
646 647
@@ -692,6 +693,7 @@ static void create_units(struct fw_device *device)
692 if (device_register(&unit->device) < 0) 693 if (device_register(&unit->device) < 0)
693 goto skip_unit; 694 goto skip_unit;
694 695
696 fw_device_get(device);
695 continue; 697 continue;
696 698
697 skip_unit: 699 skip_unit:
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
index b45be5767529..b5b34952cf16 100644
--- a/drivers/firewire/core.h
+++ b/drivers/firewire/core.h
@@ -1,6 +1,7 @@
1#ifndef _FIREWIRE_CORE_H 1#ifndef _FIREWIRE_CORE_H
2#define _FIREWIRE_CORE_H 2#define _FIREWIRE_CORE_H
3 3
4#include <linux/device.h>
4#include <linux/fs.h> 5#include <linux/fs.h>
5#include <linux/list.h> 6#include <linux/list.h>
6#include <linux/idr.h> 7#include <linux/idr.h>
@@ -141,6 +142,18 @@ extern struct rw_semaphore fw_device_rwsem;
141extern struct idr fw_device_idr; 142extern struct idr fw_device_idr;
142extern int fw_cdev_major; 143extern int fw_cdev_major;
143 144
145static inline struct fw_device *fw_device_get(struct fw_device *device)
146{
147 get_device(&device->device);
148
149 return device;
150}
151
152static inline void fw_device_put(struct fw_device *device)
153{
154 put_device(&device->device);
155}
156
144struct fw_device *fw_device_get_by_devt(dev_t devt); 157struct fw_device *fw_device_get_by_devt(dev_t devt);
145int fw_device_set_broadcast_channel(struct device *dev, void *gen); 158int fw_device_set_broadcast_channel(struct device *dev, void *gen);
146void fw_node_event(struct fw_card *card, struct fw_node *node, int event); 159void fw_node_event(struct fw_card *card, struct fw_node *node, int event);