aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/bat_sysfs.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-07 03:37:13 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-07 03:37:13 -0500
commitb8cec4a415e807a2f8679efa89558a040a7003de (patch)
tree1a5fc7c31c4f8b55ea850599bb7309871165f48e /net/batman-adv/bat_sysfs.c
parent5e2b61f78411be25f0b84f97d5b5d312f184dfd1 (diff)
parente44d8fe2b5c27ecc230f886d4cc49fcbd86f87a0 (diff)
Merge branch 'batman-adv/next' of git://git.open-mesh.org/ecsv/linux-merge
Diffstat (limited to 'net/batman-adv/bat_sysfs.c')
-rw-r--r--net/batman-adv/bat_sysfs.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
index f7b93a0805fe..e449bf6353e0 100644
--- a/net/batman-adv/bat_sysfs.c
+++ b/net/batman-adv/bat_sysfs.c
@@ -441,16 +441,16 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
441 char *buff) 441 char *buff)
442{ 442{
443 struct net_device *net_dev = kobj_to_netdev(kobj); 443 struct net_device *net_dev = kobj_to_netdev(kobj);
444 struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); 444 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
445 ssize_t length; 445 ssize_t length;
446 446
447 if (!batman_if) 447 if (!hard_iface)
448 return 0; 448 return 0;
449 449
450 length = sprintf(buff, "%s\n", batman_if->if_status == IF_NOT_IN_USE ? 450 length = sprintf(buff, "%s\n", hard_iface->if_status == IF_NOT_IN_USE ?
451 "none" : batman_if->soft_iface->name); 451 "none" : hard_iface->soft_iface->name);
452 452
453 kref_put(&batman_if->refcount, hardif_free_ref); 453 hardif_free_ref(hard_iface);
454 454
455 return length; 455 return length;
456} 456}
@@ -459,11 +459,11 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
459 char *buff, size_t count) 459 char *buff, size_t count)
460{ 460{
461 struct net_device *net_dev = kobj_to_netdev(kobj); 461 struct net_device *net_dev = kobj_to_netdev(kobj);
462 struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); 462 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
463 int status_tmp = -1; 463 int status_tmp = -1;
464 int ret; 464 int ret = count;
465 465
466 if (!batman_if) 466 if (!hard_iface)
467 return count; 467 return count;
468 468
469 if (buff[count - 1] == '\n') 469 if (buff[count - 1] == '\n')
@@ -472,7 +472,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
472 if (strlen(buff) >= IFNAMSIZ) { 472 if (strlen(buff) >= IFNAMSIZ) {
473 pr_err("Invalid parameter for 'mesh_iface' setting received: " 473 pr_err("Invalid parameter for 'mesh_iface' setting received: "
474 "interface name too long '%s'\n", buff); 474 "interface name too long '%s'\n", buff);
475 kref_put(&batman_if->refcount, hardif_free_ref); 475 hardif_free_ref(hard_iface);
476 return -EINVAL; 476 return -EINVAL;
477 } 477 }
478 478
@@ -481,30 +481,31 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
481 else 481 else
482 status_tmp = IF_I_WANT_YOU; 482 status_tmp = IF_I_WANT_YOU;
483 483
484 if ((batman_if->if_status == status_tmp) || ((batman_if->soft_iface) && 484 if (hard_iface->if_status == status_tmp)
485 (strncmp(batman_if->soft_iface->name, buff, IFNAMSIZ) == 0))) { 485 goto out;
486 kref_put(&batman_if->refcount, hardif_free_ref); 486
487 return count; 487 if ((hard_iface->soft_iface) &&
488 } 488 (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
489 goto out;
489 490
490 if (status_tmp == IF_NOT_IN_USE) { 491 if (status_tmp == IF_NOT_IN_USE) {
491 rtnl_lock(); 492 rtnl_lock();
492 hardif_disable_interface(batman_if); 493 hardif_disable_interface(hard_iface);
493 rtnl_unlock(); 494 rtnl_unlock();
494 kref_put(&batman_if->refcount, hardif_free_ref); 495 goto out;
495 return count;
496 } 496 }
497 497
498 /* if the interface already is in use */ 498 /* if the interface already is in use */
499 if (batman_if->if_status != IF_NOT_IN_USE) { 499 if (hard_iface->if_status != IF_NOT_IN_USE) {
500 rtnl_lock(); 500 rtnl_lock();
501 hardif_disable_interface(batman_if); 501 hardif_disable_interface(hard_iface);
502 rtnl_unlock(); 502 rtnl_unlock();
503 } 503 }
504 504
505 ret = hardif_enable_interface(batman_if, buff); 505 ret = hardif_enable_interface(hard_iface, buff);
506 kref_put(&batman_if->refcount, hardif_free_ref);
507 506
507out:
508 hardif_free_ref(hard_iface);
508 return ret; 509 return ret;
509} 510}
510 511
@@ -512,13 +513,13 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
512 char *buff) 513 char *buff)
513{ 514{
514 struct net_device *net_dev = kobj_to_netdev(kobj); 515 struct net_device *net_dev = kobj_to_netdev(kobj);
515 struct batman_if *batman_if = get_batman_if_by_netdev(net_dev); 516 struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
516 ssize_t length; 517 ssize_t length;
517 518
518 if (!batman_if) 519 if (!hard_iface)
519 return 0; 520 return 0;
520 521
521 switch (batman_if->if_status) { 522 switch (hard_iface->if_status) {
522 case IF_TO_BE_REMOVED: 523 case IF_TO_BE_REMOVED:
523 length = sprintf(buff, "disabling\n"); 524 length = sprintf(buff, "disabling\n");
524 break; 525 break;
@@ -537,7 +538,7 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
537 break; 538 break;
538 } 539 }
539 540
540 kref_put(&batman_if->refcount, hardif_free_ref); 541 hardif_free_ref(hard_iface);
541 542
542 return length; 543 return length;
543} 544}