aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/eth1394.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-01 20:14:45 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-04-29 18:00:31 -0400
commitd06c1ddad9055eef55456abbae795279d6b1bbcf (patch)
tree4a72f4bf6ca738fd77bc9f16791c6175d7e65e5f /drivers/ieee1394/eth1394.c
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>
Diffstat (limited to 'drivers/ieee1394/eth1394.c')
-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 e1fdfb5c175d..66c4cca134db 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,
340 return NULL; 340 return NULL;
341} 341}
342 342
343static int eth1394_probe(struct device *dev) 343static int eth1394_new_node(struct eth1394_host_info *hi,
344 struct unit_directory *ud)
344{ 345{
345 struct unit_directory *ud;
346 struct eth1394_host_info *hi;
347 struct eth1394_priv *priv; 346 struct eth1394_priv *priv;
348 struct eth1394_node_ref *new_node; 347 struct eth1394_node_ref *new_node;
349 struct eth1394_node_info *node_info; 348 struct eth1394_node_info *node_info;
350 349
351 ud = container_of(dev, struct unit_directory, device);
352
353 hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
354 if (!hi)
355 return -ENOENT;
356
357 new_node = kmalloc(sizeof(*new_node), GFP_KERNEL); 350 new_node = kmalloc(sizeof(*new_node), GFP_KERNEL);
358 if (!new_node) 351 if (!new_node)
359 return -ENOMEM; 352 return -ENOMEM;
@@ -374,10 +367,22 @@ static int eth1394_probe(struct device *dev)
374 367
375 priv = netdev_priv(hi->dev); 368 priv = netdev_priv(hi->dev);
376 list_add_tail(&new_node->list, &priv->ip_node_list); 369 list_add_tail(&new_node->list, &priv->ip_node_list);
377
378 return 0; 370 return 0;
379} 371}
380 372
373static int eth1394_probe(struct device *dev)
374{
375 struct unit_directory *ud;
376 struct eth1394_host_info *hi;
377
378 ud = container_of(dev, struct unit_directory, device);
379 hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
380 if (!hi)
381 return -ENOENT;
382
383 return eth1394_new_node(hi, ud);
384}
385
381static int eth1394_remove(struct device *dev) 386static int eth1394_remove(struct device *dev)
382{ 387{
383 struct unit_directory *ud; 388 struct unit_directory *ud;
@@ -421,38 +426,17 @@ static int eth1394_update(struct unit_directory *ud)
421 struct eth1394_host_info *hi; 426 struct eth1394_host_info *hi;
422 struct eth1394_priv *priv; 427 struct eth1394_priv *priv;
423 struct eth1394_node_ref *node; 428 struct eth1394_node_ref *node;
424 struct eth1394_node_info *node_info;
425 429
426 hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host); 430 hi = hpsb_get_hostinfo(&eth1394_highlevel, ud->ne->host);
427 if (!hi) 431 if (!hi)
428 return -ENOENT; 432 return -ENOENT;
429 433
430 priv = netdev_priv(hi->dev); 434 priv = netdev_priv(hi->dev);
431
432 node = eth1394_find_node(&priv->ip_node_list, ud); 435 node = eth1394_find_node(&priv->ip_node_list, ud);
433 if (node) 436 if (node)
434 return 0; 437 return 0;
435 438
436 node = kmalloc(sizeof(*node), GFP_KERNEL); 439 return eth1394_new_node(hi, ud);
437 if (!node)
438 return -ENOMEM;
439
440 node_info = kmalloc(sizeof(*node_info), GFP_KERNEL);
441 if (!node_info) {
442 kfree(node);
443 return -ENOMEM;
444 }
445
446 spin_lock_init(&node_info->pdg.lock);
447 INIT_LIST_HEAD(&node_info->pdg.list);
448 node_info->pdg.sz = 0;
449
450 ud->device.driver_data = node_info;
451 node->ud = ud;
452
453 priv = netdev_priv(hi->dev);
454 list_add_tail(&node->list, &priv->ip_node_list);
455 return 0;
456} 440}
457 441
458static struct ieee1394_device_id eth1394_id_table[] = { 442static struct ieee1394_device_id eth1394_id_table[] = {