]> err.no Git - linux-2.6/commitdiff
ieee1394: eth1394: refactor .probe and .update
authorStefan Richter <stefanr@s5r6.in-berlin.de>
Mon, 2 Apr 2007 00:14:45 +0000 (02:14 +0200)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Sun, 29 Apr 2007 22:00:31 +0000 (00:00 +0200)
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>
drivers/ieee1394/eth1394.c

index e1fdfb5c175dd1fa2a572a1187b88a40b5360f93..66c4cca134dbf60a59e09e45892f75d7ca57a096 100644 (file)
@@ -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[] = {