aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-02 02:14:45 +0200
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-30 00:00:31 +0200
commitd06c1ddad9055eef55456abbae795279d6b1bbcf (patch)
tree4a72f4bf6ca738fd77bc9f16791c6175d7e65e5f
parent5e7abccd38f7f2ce838eb49a657eea70b22f0803 (diff)
ieee1394: eth1394: refactor .probe and .update
Move common code into an extra function. This implicitly adds a missing node_info->fifo = CSR1212_INVALID_ADDR_SPACE; to .update. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--drivers/ieee1394/eth1394.c48
1 files changed, 16 insertions, 32 deletions
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index e1fdfb5c175..66c4cca134d 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -340,20 +340,13 @@ static struct eth1394_node_ref *eth1394_find_node_nodeid(struct list_head *inl,
return NULL;
}
-static int eth1394_probe(struct device *dev)
+static int eth1394_new_node(struct eth1394_host_info *hi,
+ struct unit_directory *ud)
{
- struct unit_directory *ud;
- struct eth1394_host_info *hi;
struct eth1394_priv *priv;
struct eth1394_node_ref *new_node;
struct eth1394_node_info *node_info;
- ud = container_of(dev, struct unit_directory, device);
-
- hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
- if (!hi)
- return -ENOENT;
-
new_node = kmalloc(sizeof(*new_node), GFP_KERNEL);
if (!new_node)
return -ENOMEM;
@@ -374,10 +367,22 @@ static int eth1394_probe(struct device *dev)
priv = netdev_priv(hi->dev);
list_add_tail(&new_node->list, &priv->ip_node_list);
-
return 0;
}
+static int eth1394_probe(struct device *dev)
+{
+ struct unit_directory *ud;
+ struct eth1394_host_info *hi;
+
+ ud = container_of(dev, struct unit_directory, device);
+ hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
+ if (!hi)
+ return -ENOENT;
+
+ return eth1394_new_node(hi, ud);
+}
+
static int eth1394_remove(struct device *dev)
{
struct unit_directory *ud;
@@ -421,38 +426,17 @@ static int eth1394_update(struct unit_directory *ud)
struct eth1394_host_info *hi;
struct eth1394_priv *priv;
struct eth1394_node_ref *node;
- struct eth1394_node_info *node_info;
hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
if (!hi)
return -ENOENT;
priv = netdev_priv(hi->dev);
-
node = eth1394_find_node(&priv->ip_node_list, ud);
if (node)
return 0;
- node = kmalloc(sizeof(*node), GFP_KERNEL);
- if (!node)
- return -ENOMEM;
-
- node_info = kmalloc(sizeof(*node_info), GFP_KERNEL);
- if (!node_info) {
- kfree(node);
- return -ENOMEM;
- }
-
- spin_lock_init(&node_info->pdg.lock);
- INIT_LIST_HEAD(&node_info->pdg.list);
- node_info->pdg.sz = 0;
-
- ud->device.driver_data = node_info;
- node->ud = ud;
-
- priv = netdev_priv(hi->dev);
- list_add_tail(&node->list, &priv->ip_node_list);
- return 0;
+ return eth1394_new_node(hi, ud);
}
static struct ieee1394_device_id eth1394_id_table[] = {