diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2002-04-09 15:14:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-02-07 13:37:11 -0500 |
commit | 43cb76d91ee85f579a69d42bc8efc08bac560278 (patch) | |
tree | f5c4766a6639fee3685dbbfc9110bb334af9e6dd /drivers/net/bonding | |
parent | 2943ecf2ed32632473c06f1975db47a7aa98c10f (diff) |
Network: convert network devices to use struct device instead of class_device
This lets the network core have the ability to handle suspend/resume
issues, if it wants to.
Thanks to Frederik Deweerdt <frederik.deweerdt@gmail.com> for the arm
driver fixes.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 287 |
1 files changed, 174 insertions, 113 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index ced9ed8f995a..0e610aa1fdf9 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -39,8 +39,7 @@ | |||
39 | 39 | ||
40 | /* #define BONDING_DEBUG 1 */ | 40 | /* #define BONDING_DEBUG 1 */ |
41 | #include "bonding.h" | 41 | #include "bonding.h" |
42 | #define to_class_dev(obj) container_of(obj,struct class_device,kobj) | 42 | #define to_dev(obj) container_of(obj,struct device,kobj) |
43 | #define to_net_dev(class) container_of(class, struct net_device, class_dev) | ||
44 | #define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) | 43 | #define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) |
45 | 44 | ||
46 | /*---------------------------- Declarations -------------------------------*/ | 45 | /*---------------------------- Declarations -------------------------------*/ |
@@ -154,7 +153,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t | |||
154 | * If it's > expected, then there's a file open, | 153 | * If it's > expected, then there's a file open, |
155 | * and we have to fail. | 154 | * and we have to fail. |
156 | */ | 155 | */ |
157 | if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount) | 156 | if (atomic_read(&bond->dev->dev.kobj.kref.refcount) |
158 | > expected_refcount){ | 157 | > expected_refcount){ |
159 | rtnl_unlock(); | 158 | rtnl_unlock(); |
160 | printk(KERN_INFO DRV_NAME | 159 | printk(KERN_INFO DRV_NAME |
@@ -201,13 +200,13 @@ int bond_create_slave_symlinks(struct net_device *master, struct net_device *sla | |||
201 | int ret = 0; | 200 | int ret = 0; |
202 | 201 | ||
203 | /* first, create a link from the slave back to the master */ | 202 | /* first, create a link from the slave back to the master */ |
204 | ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj), | 203 | ret = sysfs_create_link(&(slave->dev.kobj), &(master->dev.kobj), |
205 | "master"); | 204 | "master"); |
206 | if (ret) | 205 | if (ret) |
207 | return ret; | 206 | return ret; |
208 | /* next, create a link from the master to the slave */ | 207 | /* next, create a link from the master to the slave */ |
209 | sprintf(linkname,"slave_%s",slave->name); | 208 | sprintf(linkname,"slave_%s",slave->name); |
210 | ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj), | 209 | ret = sysfs_create_link(&(master->dev.kobj), &(slave->dev.kobj), |
211 | linkname); | 210 | linkname); |
212 | return ret; | 211 | return ret; |
213 | 212 | ||
@@ -217,20 +216,21 @@ void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *s | |||
217 | { | 216 | { |
218 | char linkname[IFNAMSIZ+7]; | 217 | char linkname[IFNAMSIZ+7]; |
219 | 218 | ||
220 | sysfs_remove_link(&(slave->class_dev.kobj), "master"); | 219 | sysfs_remove_link(&(slave->dev.kobj), "master"); |
221 | sprintf(linkname,"slave_%s",slave->name); | 220 | sprintf(linkname,"slave_%s",slave->name); |
222 | sysfs_remove_link(&(master->class_dev.kobj), linkname); | 221 | sysfs_remove_link(&(master->dev.kobj), linkname); |
223 | } | 222 | } |
224 | 223 | ||
225 | 224 | ||
226 | /* | 225 | /* |
227 | * Show the slaves in the current bond. | 226 | * Show the slaves in the current bond. |
228 | */ | 227 | */ |
229 | static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) | 228 | static ssize_t bonding_show_slaves(struct device *d, |
229 | struct device_attribute *attr, char *buf) | ||
230 | { | 230 | { |
231 | struct slave *slave; | 231 | struct slave *slave; |
232 | int i, res = 0; | 232 | int i, res = 0; |
233 | struct bonding *bond = to_bond(cd); | 233 | struct bonding *bond = to_bond(d); |
234 | 234 | ||
235 | read_lock_bh(&bond->lock); | 235 | read_lock_bh(&bond->lock); |
236 | bond_for_each_slave(bond, slave, i) { | 236 | bond_for_each_slave(bond, slave, i) { |
@@ -254,14 +254,16 @@ static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) | |||
254 | * up for this to succeed. | 254 | * up for this to succeed. |
255 | * This function is largely the same flow as bonding_update_bonds(). | 255 | * This function is largely the same flow as bonding_update_bonds(). |
256 | */ | 256 | */ |
257 | static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count) | 257 | static ssize_t bonding_store_slaves(struct device *d, |
258 | struct device_attribute *attr, | ||
259 | const char *buffer, size_t count) | ||
258 | { | 260 | { |
259 | char command[IFNAMSIZ + 1] = { 0, }; | 261 | char command[IFNAMSIZ + 1] = { 0, }; |
260 | char *ifname; | 262 | char *ifname; |
261 | int i, res, found, ret = count; | 263 | int i, res, found, ret = count; |
262 | struct slave *slave; | 264 | struct slave *slave; |
263 | struct net_device *dev = NULL; | 265 | struct net_device *dev = NULL; |
264 | struct bonding *bond = to_bond(cd); | 266 | struct bonding *bond = to_bond(d); |
265 | 267 | ||
266 | /* Quick sanity check -- is the bond interface up? */ | 268 | /* Quick sanity check -- is the bond interface up? */ |
267 | if (!(bond->dev->flags & IFF_UP)) { | 269 | if (!(bond->dev->flags & IFF_UP)) { |
@@ -387,25 +389,28 @@ out: | |||
387 | return ret; | 389 | return ret; |
388 | } | 390 | } |
389 | 391 | ||
390 | static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); | 392 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); |
391 | 393 | ||
392 | /* | 394 | /* |
393 | * Show and set the bonding mode. The bond interface must be down to | 395 | * Show and set the bonding mode. The bond interface must be down to |
394 | * change the mode. | 396 | * change the mode. |
395 | */ | 397 | */ |
396 | static ssize_t bonding_show_mode(struct class_device *cd, char *buf) | 398 | static ssize_t bonding_show_mode(struct device *d, |
399 | struct device_attribute *attr, char *buf) | ||
397 | { | 400 | { |
398 | struct bonding *bond = to_bond(cd); | 401 | struct bonding *bond = to_bond(d); |
399 | 402 | ||
400 | return sprintf(buf, "%s %d\n", | 403 | return sprintf(buf, "%s %d\n", |
401 | bond_mode_tbl[bond->params.mode].modename, | 404 | bond_mode_tbl[bond->params.mode].modename, |
402 | bond->params.mode) + 1; | 405 | bond->params.mode) + 1; |
403 | } | 406 | } |
404 | 407 | ||
405 | static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count) | 408 | static ssize_t bonding_store_mode(struct device *d, |
409 | struct device_attribute *attr, | ||
410 | const char *buf, size_t count) | ||
406 | { | 411 | { |
407 | int new_value, ret = count; | 412 | int new_value, ret = count; |
408 | struct bonding *bond = to_bond(cd); | 413 | struct bonding *bond = to_bond(d); |
409 | 414 | ||
410 | if (bond->dev->flags & IFF_UP) { | 415 | if (bond->dev->flags & IFF_UP) { |
411 | printk(KERN_ERR DRV_NAME | 416 | printk(KERN_ERR DRV_NAME |
@@ -438,16 +443,18 @@ static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size | |||
438 | out: | 443 | out: |
439 | return ret; | 444 | return ret; |
440 | } | 445 | } |
441 | static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); | 446 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); |
442 | 447 | ||
443 | /* | 448 | /* |
444 | * Show and set the bonding transmit hash method. The bond interface must be down to | 449 | * Show and set the bonding transmit hash method. The bond interface must be down to |
445 | * change the xmit hash policy. | 450 | * change the xmit hash policy. |
446 | */ | 451 | */ |
447 | static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) | 452 | static ssize_t bonding_show_xmit_hash(struct device *d, |
453 | struct device_attribute *attr, | ||
454 | char *buf) | ||
448 | { | 455 | { |
449 | int count; | 456 | int count; |
450 | struct bonding *bond = to_bond(cd); | 457 | struct bonding *bond = to_bond(d); |
451 | 458 | ||
452 | if ((bond->params.mode != BOND_MODE_XOR) && | 459 | if ((bond->params.mode != BOND_MODE_XOR) && |
453 | (bond->params.mode != BOND_MODE_8023AD)) { | 460 | (bond->params.mode != BOND_MODE_8023AD)) { |
@@ -462,10 +469,12 @@ static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) | |||
462 | return count; | 469 | return count; |
463 | } | 470 | } |
464 | 471 | ||
465 | static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count) | 472 | static ssize_t bonding_store_xmit_hash(struct device *d, |
473 | struct device_attribute *attr, | ||
474 | const char *buf, size_t count) | ||
466 | { | 475 | { |
467 | int new_value, ret = count; | 476 | int new_value, ret = count; |
468 | struct bonding *bond = to_bond(cd); | 477 | struct bonding *bond = to_bond(d); |
469 | 478 | ||
470 | if (bond->dev->flags & IFF_UP) { | 479 | if (bond->dev->flags & IFF_UP) { |
471 | printk(KERN_ERR DRV_NAME | 480 | printk(KERN_ERR DRV_NAME |
@@ -501,24 +510,28 @@ static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, | |||
501 | out: | 510 | out: |
502 | return ret; | 511 | return ret; |
503 | } | 512 | } |
504 | static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); | 513 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); |
505 | 514 | ||
506 | /* | 515 | /* |
507 | * Show and set arp_validate. | 516 | * Show and set arp_validate. |
508 | */ | 517 | */ |
509 | static ssize_t bonding_show_arp_validate(struct class_device *cd, char *buf) | 518 | static ssize_t bonding_show_arp_validate(struct device *d, |
519 | struct device_attribute *attr, | ||
520 | char *buf) | ||
510 | { | 521 | { |
511 | struct bonding *bond = to_bond(cd); | 522 | struct bonding *bond = to_bond(d); |
512 | 523 | ||
513 | return sprintf(buf, "%s %d\n", | 524 | return sprintf(buf, "%s %d\n", |
514 | arp_validate_tbl[bond->params.arp_validate].modename, | 525 | arp_validate_tbl[bond->params.arp_validate].modename, |
515 | bond->params.arp_validate) + 1; | 526 | bond->params.arp_validate) + 1; |
516 | } | 527 | } |
517 | 528 | ||
518 | static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *buf, size_t count) | 529 | static ssize_t bonding_store_arp_validate(struct device *d, |
530 | struct device_attribute *attr, | ||
531 | const char *buf, size_t count) | ||
519 | { | 532 | { |
520 | int new_value; | 533 | int new_value; |
521 | struct bonding *bond = to_bond(cd); | 534 | struct bonding *bond = to_bond(d); |
522 | 535 | ||
523 | new_value = bond_parse_parm((char *)buf, arp_validate_tbl); | 536 | new_value = bond_parse_parm((char *)buf, arp_validate_tbl); |
524 | if (new_value < 0) { | 537 | if (new_value < 0) { |
@@ -548,7 +561,7 @@ static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *b | |||
548 | return count; | 561 | return count; |
549 | } | 562 | } |
550 | 563 | ||
551 | static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); | 564 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate); |
552 | 565 | ||
553 | /* | 566 | /* |
554 | * Show and set the arp timer interval. There are two tricky bits | 567 | * Show and set the arp timer interval. There are two tricky bits |
@@ -556,17 +569,21 @@ static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_valid | |||
556 | * MII monitoring. Second, if the ARP timer isn't running, we must | 569 | * MII monitoring. Second, if the ARP timer isn't running, we must |
557 | * start it. | 570 | * start it. |
558 | */ | 571 | */ |
559 | static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf) | 572 | static ssize_t bonding_show_arp_interval(struct device *d, |
573 | struct device_attribute *attr, | ||
574 | char *buf) | ||
560 | { | 575 | { |
561 | struct bonding *bond = to_bond(cd); | 576 | struct bonding *bond = to_bond(d); |
562 | 577 | ||
563 | return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; | 578 | return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; |
564 | } | 579 | } |
565 | 580 | ||
566 | static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count) | 581 | static ssize_t bonding_store_arp_interval(struct device *d, |
582 | struct device_attribute *attr, | ||
583 | const char *buf, size_t count) | ||
567 | { | 584 | { |
568 | int new_value, ret = count; | 585 | int new_value, ret = count; |
569 | struct bonding *bond = to_bond(cd); | 586 | struct bonding *bond = to_bond(d); |
570 | 587 | ||
571 | if (sscanf(buf, "%d", &new_value) != 1) { | 588 | if (sscanf(buf, "%d", &new_value) != 1) { |
572 | printk(KERN_ERR DRV_NAME | 589 | printk(KERN_ERR DRV_NAME |
@@ -638,15 +655,17 @@ static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *b | |||
638 | out: | 655 | out: |
639 | return ret; | 656 | return ret; |
640 | } | 657 | } |
641 | static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); | 658 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); |
642 | 659 | ||
643 | /* | 660 | /* |
644 | * Show and set the arp targets. | 661 | * Show and set the arp targets. |
645 | */ | 662 | */ |
646 | static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) | 663 | static ssize_t bonding_show_arp_targets(struct device *d, |
664 | struct device_attribute *attr, | ||
665 | char *buf) | ||
647 | { | 666 | { |
648 | int i, res = 0; | 667 | int i, res = 0; |
649 | struct bonding *bond = to_bond(cd); | 668 | struct bonding *bond = to_bond(d); |
650 | 669 | ||
651 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { | 670 | for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { |
652 | if (bond->params.arp_targets[i]) | 671 | if (bond->params.arp_targets[i]) |
@@ -660,11 +679,13 @@ static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) | |||
660 | return res; | 679 | return res; |
661 | } | 680 | } |
662 | 681 | ||
663 | static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count) | 682 | static ssize_t bonding_store_arp_targets(struct device *d, |
683 | struct device_attribute *attr, | ||
684 | const char *buf, size_t count) | ||
664 | { | 685 | { |
665 | u32 newtarget; | 686 | u32 newtarget; |
666 | int i = 0, done = 0, ret = count; | 687 | int i = 0, done = 0, ret = count; |
667 | struct bonding *bond = to_bond(cd); | 688 | struct bonding *bond = to_bond(d); |
668 | u32 *targets; | 689 | u32 *targets; |
669 | 690 | ||
670 | targets = bond->params.arp_targets; | 691 | targets = bond->params.arp_targets; |
@@ -742,24 +763,28 @@ static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *bu | |||
742 | out: | 763 | out: |
743 | return ret; | 764 | return ret; |
744 | } | 765 | } |
745 | static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); | 766 | static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); |
746 | 767 | ||
747 | /* | 768 | /* |
748 | * Show and set the up and down delays. These must be multiples of the | 769 | * Show and set the up and down delays. These must be multiples of the |
749 | * MII monitoring value, and are stored internally as the multiplier. | 770 | * MII monitoring value, and are stored internally as the multiplier. |
750 | * Thus, we must translate to MS for the real world. | 771 | * Thus, we must translate to MS for the real world. |
751 | */ | 772 | */ |
752 | static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf) | 773 | static ssize_t bonding_show_downdelay(struct device *d, |
774 | struct device_attribute *attr, | ||
775 | char *buf) | ||
753 | { | 776 | { |
754 | struct bonding *bond = to_bond(cd); | 777 | struct bonding *bond = to_bond(d); |
755 | 778 | ||
756 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; | 779 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; |
757 | } | 780 | } |
758 | 781 | ||
759 | static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count) | 782 | static ssize_t bonding_store_downdelay(struct device *d, |
783 | struct device_attribute *attr, | ||
784 | const char *buf, size_t count) | ||
760 | { | 785 | { |
761 | int new_value, ret = count; | 786 | int new_value, ret = count; |
762 | struct bonding *bond = to_bond(cd); | 787 | struct bonding *bond = to_bond(d); |
763 | 788 | ||
764 | if (!(bond->params.miimon)) { | 789 | if (!(bond->params.miimon)) { |
765 | printk(KERN_ERR DRV_NAME | 790 | printk(KERN_ERR DRV_NAME |
@@ -800,20 +825,24 @@ static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, | |||
800 | out: | 825 | out: |
801 | return ret; | 826 | return ret; |
802 | } | 827 | } |
803 | static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); | 828 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); |
804 | 829 | ||
805 | static ssize_t bonding_show_updelay(struct class_device *cd, char *buf) | 830 | static ssize_t bonding_show_updelay(struct device *d, |
831 | struct device_attribute *attr, | ||
832 | char *buf) | ||
806 | { | 833 | { |
807 | struct bonding *bond = to_bond(cd); | 834 | struct bonding *bond = to_bond(d); |
808 | 835 | ||
809 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; | 836 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; |
810 | 837 | ||
811 | } | 838 | } |
812 | 839 | ||
813 | static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count) | 840 | static ssize_t bonding_store_updelay(struct device *d, |
841 | struct device_attribute *attr, | ||
842 | const char *buf, size_t count) | ||
814 | { | 843 | { |
815 | int new_value, ret = count; | 844 | int new_value, ret = count; |
816 | struct bonding *bond = to_bond(cd); | 845 | struct bonding *bond = to_bond(d); |
817 | 846 | ||
818 | if (!(bond->params.miimon)) { | 847 | if (!(bond->params.miimon)) { |
819 | printk(KERN_ERR DRV_NAME | 848 | printk(KERN_ERR DRV_NAME |
@@ -854,25 +883,29 @@ static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, s | |||
854 | out: | 883 | out: |
855 | return ret; | 884 | return ret; |
856 | } | 885 | } |
857 | static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); | 886 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); |
858 | 887 | ||
859 | /* | 888 | /* |
860 | * Show and set the LACP interval. Interface must be down, and the mode | 889 | * Show and set the LACP interval. Interface must be down, and the mode |
861 | * must be set to 802.3ad mode. | 890 | * must be set to 802.3ad mode. |
862 | */ | 891 | */ |
863 | static ssize_t bonding_show_lacp(struct class_device *cd, char *buf) | 892 | static ssize_t bonding_show_lacp(struct device *d, |
893 | struct device_attribute *attr, | ||
894 | char *buf) | ||
864 | { | 895 | { |
865 | struct bonding *bond = to_bond(cd); | 896 | struct bonding *bond = to_bond(d); |
866 | 897 | ||
867 | return sprintf(buf, "%s %d\n", | 898 | return sprintf(buf, "%s %d\n", |
868 | bond_lacp_tbl[bond->params.lacp_fast].modename, | 899 | bond_lacp_tbl[bond->params.lacp_fast].modename, |
869 | bond->params.lacp_fast) + 1; | 900 | bond->params.lacp_fast) + 1; |
870 | } | 901 | } |
871 | 902 | ||
872 | static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count) | 903 | static ssize_t bonding_store_lacp(struct device *d, |
904 | struct device_attribute *attr, | ||
905 | const char *buf, size_t count) | ||
873 | { | 906 | { |
874 | int new_value, ret = count; | 907 | int new_value, ret = count; |
875 | struct bonding *bond = to_bond(cd); | 908 | struct bonding *bond = to_bond(d); |
876 | 909 | ||
877 | if (bond->dev->flags & IFF_UP) { | 910 | if (bond->dev->flags & IFF_UP) { |
878 | printk(KERN_ERR DRV_NAME | 911 | printk(KERN_ERR DRV_NAME |
@@ -906,7 +939,7 @@ static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size | |||
906 | out: | 939 | out: |
907 | return ret; | 940 | return ret; |
908 | } | 941 | } |
909 | static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); | 942 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); |
910 | 943 | ||
911 | /* | 944 | /* |
912 | * Show and set the MII monitor interval. There are two tricky bits | 945 | * Show and set the MII monitor interval. There are two tricky bits |
@@ -914,17 +947,21 @@ static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bondin | |||
914 | * ARP monitoring. Second, if the timer isn't running, we must | 947 | * ARP monitoring. Second, if the timer isn't running, we must |
915 | * start it. | 948 | * start it. |
916 | */ | 949 | */ |
917 | static ssize_t bonding_show_miimon(struct class_device *cd, char *buf) | 950 | static ssize_t bonding_show_miimon(struct device *d, |
951 | struct device_attribute *attr, | ||
952 | char *buf) | ||
918 | { | 953 | { |
919 | struct bonding *bond = to_bond(cd); | 954 | struct bonding *bond = to_bond(d); |
920 | 955 | ||
921 | return sprintf(buf, "%d\n", bond->params.miimon) + 1; | 956 | return sprintf(buf, "%d\n", bond->params.miimon) + 1; |
922 | } | 957 | } |
923 | 958 | ||
924 | static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count) | 959 | static ssize_t bonding_store_miimon(struct device *d, |
960 | struct device_attribute *attr, | ||
961 | const char *buf, size_t count) | ||
925 | { | 962 | { |
926 | int new_value, ret = count; | 963 | int new_value, ret = count; |
927 | struct bonding *bond = to_bond(cd); | 964 | struct bonding *bond = to_bond(d); |
928 | 965 | ||
929 | if (sscanf(buf, "%d", &new_value) != 1) { | 966 | if (sscanf(buf, "%d", &new_value) != 1) { |
930 | printk(KERN_ERR DRV_NAME | 967 | printk(KERN_ERR DRV_NAME |
@@ -1000,7 +1037,7 @@ static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, si | |||
1000 | out: | 1037 | out: |
1001 | return ret; | 1038 | return ret; |
1002 | } | 1039 | } |
1003 | static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); | 1040 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); |
1004 | 1041 | ||
1005 | /* | 1042 | /* |
1006 | * Show and set the primary slave. The store function is much | 1043 | * Show and set the primary slave. The store function is much |
@@ -1009,10 +1046,12 @@ static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding | |||
1009 | * The bond must be a mode that supports a primary for this be | 1046 | * The bond must be a mode that supports a primary for this be |
1010 | * set. | 1047 | * set. |
1011 | */ | 1048 | */ |
1012 | static ssize_t bonding_show_primary(struct class_device *cd, char *buf) | 1049 | static ssize_t bonding_show_primary(struct device *d, |
1050 | struct device_attribute *attr, | ||
1051 | char *buf) | ||
1013 | { | 1052 | { |
1014 | int count = 0; | 1053 | int count = 0; |
1015 | struct bonding *bond = to_bond(cd); | 1054 | struct bonding *bond = to_bond(d); |
1016 | 1055 | ||
1017 | if (bond->primary_slave) | 1056 | if (bond->primary_slave) |
1018 | count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; | 1057 | count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; |
@@ -1022,11 +1061,13 @@ static ssize_t bonding_show_primary(struct class_device *cd, char *buf) | |||
1022 | return count; | 1061 | return count; |
1023 | } | 1062 | } |
1024 | 1063 | ||
1025 | static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count) | 1064 | static ssize_t bonding_store_primary(struct device *d, |
1065 | struct device_attribute *attr, | ||
1066 | const char *buf, size_t count) | ||
1026 | { | 1067 | { |
1027 | int i; | 1068 | int i; |
1028 | struct slave *slave; | 1069 | struct slave *slave; |
1029 | struct bonding *bond = to_bond(cd); | 1070 | struct bonding *bond = to_bond(d); |
1030 | 1071 | ||
1031 | write_lock_bh(&bond->lock); | 1072 | write_lock_bh(&bond->lock); |
1032 | if (!USES_PRIMARY(bond->params.mode)) { | 1073 | if (!USES_PRIMARY(bond->params.mode)) { |
@@ -1065,22 +1106,26 @@ out: | |||
1065 | write_unlock_bh(&bond->lock); | 1106 | write_unlock_bh(&bond->lock); |
1066 | return count; | 1107 | return count; |
1067 | } | 1108 | } |
1068 | static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); | 1109 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); |
1069 | 1110 | ||
1070 | /* | 1111 | /* |
1071 | * Show and set the use_carrier flag. | 1112 | * Show and set the use_carrier flag. |
1072 | */ | 1113 | */ |
1073 | static ssize_t bonding_show_carrier(struct class_device *cd, char *buf) | 1114 | static ssize_t bonding_show_carrier(struct device *d, |
1115 | struct device_attribute *attr, | ||
1116 | char *buf) | ||
1074 | { | 1117 | { |
1075 | struct bonding *bond = to_bond(cd); | 1118 | struct bonding *bond = to_bond(d); |
1076 | 1119 | ||
1077 | return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; | 1120 | return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; |
1078 | } | 1121 | } |
1079 | 1122 | ||
1080 | static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count) | 1123 | static ssize_t bonding_store_carrier(struct device *d, |
1124 | struct device_attribute *attr, | ||
1125 | const char *buf, size_t count) | ||
1081 | { | 1126 | { |
1082 | int new_value, ret = count; | 1127 | int new_value, ret = count; |
1083 | struct bonding *bond = to_bond(cd); | 1128 | struct bonding *bond = to_bond(d); |
1084 | 1129 | ||
1085 | 1130 | ||
1086 | if (sscanf(buf, "%d", &new_value) != 1) { | 1131 | if (sscanf(buf, "%d", &new_value) != 1) { |
@@ -1102,16 +1147,18 @@ static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, s | |||
1102 | out: | 1147 | out: |
1103 | return count; | 1148 | return count; |
1104 | } | 1149 | } |
1105 | static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); | 1150 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); |
1106 | 1151 | ||
1107 | 1152 | ||
1108 | /* | 1153 | /* |
1109 | * Show and set currently active_slave. | 1154 | * Show and set currently active_slave. |
1110 | */ | 1155 | */ |
1111 | static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) | 1156 | static ssize_t bonding_show_active_slave(struct device *d, |
1157 | struct device_attribute *attr, | ||
1158 | char *buf) | ||
1112 | { | 1159 | { |
1113 | struct slave *curr; | 1160 | struct slave *curr; |
1114 | struct bonding *bond = to_bond(cd); | 1161 | struct bonding *bond = to_bond(d); |
1115 | int count; | 1162 | int count; |
1116 | 1163 | ||
1117 | 1164 | ||
@@ -1126,13 +1173,15 @@ static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) | |||
1126 | return count; | 1173 | return count; |
1127 | } | 1174 | } |
1128 | 1175 | ||
1129 | static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count) | 1176 | static ssize_t bonding_store_active_slave(struct device *d, |
1177 | struct device_attribute *attr, | ||
1178 | const char *buf, size_t count) | ||
1130 | { | 1179 | { |
1131 | int i; | 1180 | int i; |
1132 | struct slave *slave; | 1181 | struct slave *slave; |
1133 | struct slave *old_active = NULL; | 1182 | struct slave *old_active = NULL; |
1134 | struct slave *new_active = NULL; | 1183 | struct slave *new_active = NULL; |
1135 | struct bonding *bond = to_bond(cd); | 1184 | struct bonding *bond = to_bond(d); |
1136 | 1185 | ||
1137 | write_lock_bh(&bond->lock); | 1186 | write_lock_bh(&bond->lock); |
1138 | if (!USES_PRIMARY(bond->params.mode)) { | 1187 | if (!USES_PRIMARY(bond->params.mode)) { |
@@ -1194,16 +1243,18 @@ out: | |||
1194 | return count; | 1243 | return count; |
1195 | 1244 | ||
1196 | } | 1245 | } |
1197 | static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); | 1246 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); |
1198 | 1247 | ||
1199 | 1248 | ||
1200 | /* | 1249 | /* |
1201 | * Show link status of the bond interface. | 1250 | * Show link status of the bond interface. |
1202 | */ | 1251 | */ |
1203 | static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) | 1252 | static ssize_t bonding_show_mii_status(struct device *d, |
1253 | struct device_attribute *attr, | ||
1254 | char *buf) | ||
1204 | { | 1255 | { |
1205 | struct slave *curr; | 1256 | struct slave *curr; |
1206 | struct bonding *bond = to_bond(cd); | 1257 | struct bonding *bond = to_bond(d); |
1207 | 1258 | ||
1208 | read_lock(&bond->curr_slave_lock); | 1259 | read_lock(&bond->curr_slave_lock); |
1209 | curr = bond->curr_active_slave; | 1260 | curr = bond->curr_active_slave; |
@@ -1211,16 +1262,18 @@ static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) | |||
1211 | 1262 | ||
1212 | return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; | 1263 | return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; |
1213 | } | 1264 | } |
1214 | static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); | 1265 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); |
1215 | 1266 | ||
1216 | 1267 | ||
1217 | /* | 1268 | /* |
1218 | * Show current 802.3ad aggregator ID. | 1269 | * Show current 802.3ad aggregator ID. |
1219 | */ | 1270 | */ |
1220 | static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) | 1271 | static ssize_t bonding_show_ad_aggregator(struct device *d, |
1272 | struct device_attribute *attr, | ||
1273 | char *buf) | ||
1221 | { | 1274 | { |
1222 | int count = 0; | 1275 | int count = 0; |
1223 | struct bonding *bond = to_bond(cd); | 1276 | struct bonding *bond = to_bond(d); |
1224 | 1277 | ||
1225 | if (bond->params.mode == BOND_MODE_8023AD) { | 1278 | if (bond->params.mode == BOND_MODE_8023AD) { |
1226 | struct ad_info ad_info; | 1279 | struct ad_info ad_info; |
@@ -1231,16 +1284,18 @@ static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) | |||
1231 | 1284 | ||
1232 | return count; | 1285 | return count; |
1233 | } | 1286 | } |
1234 | static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); | 1287 | static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); |
1235 | 1288 | ||
1236 | 1289 | ||
1237 | /* | 1290 | /* |
1238 | * Show number of active 802.3ad ports. | 1291 | * Show number of active 802.3ad ports. |
1239 | */ | 1292 | */ |
1240 | static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) | 1293 | static ssize_t bonding_show_ad_num_ports(struct device *d, |
1294 | struct device_attribute *attr, | ||
1295 | char *buf) | ||
1241 | { | 1296 | { |
1242 | int count = 0; | 1297 | int count = 0; |
1243 | struct bonding *bond = to_bond(cd); | 1298 | struct bonding *bond = to_bond(d); |
1244 | 1299 | ||
1245 | if (bond->params.mode == BOND_MODE_8023AD) { | 1300 | if (bond->params.mode == BOND_MODE_8023AD) { |
1246 | struct ad_info ad_info; | 1301 | struct ad_info ad_info; |
@@ -1251,16 +1306,18 @@ static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) | |||
1251 | 1306 | ||
1252 | return count; | 1307 | return count; |
1253 | } | 1308 | } |
1254 | static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); | 1309 | static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); |
1255 | 1310 | ||
1256 | 1311 | ||
1257 | /* | 1312 | /* |
1258 | * Show current 802.3ad actor key. | 1313 | * Show current 802.3ad actor key. |
1259 | */ | 1314 | */ |
1260 | static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) | 1315 | static ssize_t bonding_show_ad_actor_key(struct device *d, |
1316 | struct device_attribute *attr, | ||
1317 | char *buf) | ||
1261 | { | 1318 | { |
1262 | int count = 0; | 1319 | int count = 0; |
1263 | struct bonding *bond = to_bond(cd); | 1320 | struct bonding *bond = to_bond(d); |
1264 | 1321 | ||
1265 | if (bond->params.mode == BOND_MODE_8023AD) { | 1322 | if (bond->params.mode == BOND_MODE_8023AD) { |
1266 | struct ad_info ad_info; | 1323 | struct ad_info ad_info; |
@@ -1271,16 +1328,18 @@ static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) | |||
1271 | 1328 | ||
1272 | return count; | 1329 | return count; |
1273 | } | 1330 | } |
1274 | static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); | 1331 | static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); |
1275 | 1332 | ||
1276 | 1333 | ||
1277 | /* | 1334 | /* |
1278 | * Show current 802.3ad partner key. | 1335 | * Show current 802.3ad partner key. |
1279 | */ | 1336 | */ |
1280 | static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) | 1337 | static ssize_t bonding_show_ad_partner_key(struct device *d, |
1338 | struct device_attribute *attr, | ||
1339 | char *buf) | ||
1281 | { | 1340 | { |
1282 | int count = 0; | 1341 | int count = 0; |
1283 | struct bonding *bond = to_bond(cd); | 1342 | struct bonding *bond = to_bond(d); |
1284 | 1343 | ||
1285 | if (bond->params.mode == BOND_MODE_8023AD) { | 1344 | if (bond->params.mode == BOND_MODE_8023AD) { |
1286 | struct ad_info ad_info; | 1345 | struct ad_info ad_info; |
@@ -1291,16 +1350,18 @@ static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) | |||
1291 | 1350 | ||
1292 | return count; | 1351 | return count; |
1293 | } | 1352 | } |
1294 | static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); | 1353 | static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); |
1295 | 1354 | ||
1296 | 1355 | ||
1297 | /* | 1356 | /* |
1298 | * Show current 802.3ad partner mac. | 1357 | * Show current 802.3ad partner mac. |
1299 | */ | 1358 | */ |
1300 | static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) | 1359 | static ssize_t bonding_show_ad_partner_mac(struct device *d, |
1360 | struct device_attribute *attr, | ||
1361 | char *buf) | ||
1301 | { | 1362 | { |
1302 | int count = 0; | 1363 | int count = 0; |
1303 | struct bonding *bond = to_bond(cd); | 1364 | struct bonding *bond = to_bond(d); |
1304 | 1365 | ||
1305 | if (bond->params.mode == BOND_MODE_8023AD) { | 1366 | if (bond->params.mode == BOND_MODE_8023AD) { |
1306 | struct ad_info ad_info; | 1367 | struct ad_info ad_info; |
@@ -1319,30 +1380,30 @@ static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) | |||
1319 | 1380 | ||
1320 | return count; | 1381 | return count; |
1321 | } | 1382 | } |
1322 | static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); | 1383 | static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); |
1323 | 1384 | ||
1324 | 1385 | ||
1325 | 1386 | ||
1326 | static struct attribute *per_bond_attrs[] = { | 1387 | static struct attribute *per_bond_attrs[] = { |
1327 | &class_device_attr_slaves.attr, | 1388 | &dev_attr_slaves.attr, |
1328 | &class_device_attr_mode.attr, | 1389 | &dev_attr_mode.attr, |
1329 | &class_device_attr_arp_validate.attr, | 1390 | &dev_attr_arp_validate.attr, |
1330 | &class_device_attr_arp_interval.attr, | 1391 | &dev_attr_arp_interval.attr, |
1331 | &class_device_attr_arp_ip_target.attr, | 1392 | &dev_attr_arp_ip_target.attr, |
1332 | &class_device_attr_downdelay.attr, | 1393 | &dev_attr_downdelay.attr, |
1333 | &class_device_attr_updelay.attr, | 1394 | &dev_attr_updelay.attr, |
1334 | &class_device_attr_lacp_rate.attr, | 1395 | &dev_attr_lacp_rate.attr, |
1335 | &class_device_attr_xmit_hash_policy.attr, | 1396 | &dev_attr_xmit_hash_policy.attr, |
1336 | &class_device_attr_miimon.attr, | 1397 | &dev_attr_miimon.attr, |
1337 | &class_device_attr_primary.attr, | 1398 | &dev_attr_primary.attr, |
1338 | &class_device_attr_use_carrier.attr, | 1399 | &dev_attr_use_carrier.attr, |
1339 | &class_device_attr_active_slave.attr, | 1400 | &dev_attr_active_slave.attr, |
1340 | &class_device_attr_mii_status.attr, | 1401 | &dev_attr_mii_status.attr, |
1341 | &class_device_attr_ad_aggregator.attr, | 1402 | &dev_attr_ad_aggregator.attr, |
1342 | &class_device_attr_ad_num_ports.attr, | 1403 | &dev_attr_ad_num_ports.attr, |
1343 | &class_device_attr_ad_actor_key.attr, | 1404 | &dev_attr_ad_actor_key.attr, |
1344 | &class_device_attr_ad_partner_key.attr, | 1405 | &dev_attr_ad_partner_key.attr, |
1345 | &class_device_attr_ad_partner_mac.attr, | 1406 | &dev_attr_ad_partner_mac.attr, |
1346 | NULL, | 1407 | NULL, |
1347 | }; | 1408 | }; |
1348 | 1409 | ||
@@ -1367,7 +1428,7 @@ int bond_create_sysfs(void) | |||
1367 | if (!firstbond) | 1428 | if (!firstbond) |
1368 | return -ENODEV; | 1429 | return -ENODEV; |
1369 | 1430 | ||
1370 | netdev_class = firstbond->dev->class_dev.class; | 1431 | netdev_class = firstbond->dev->dev.class; |
1371 | if (!netdev_class) | 1432 | if (!netdev_class) |
1372 | return -ENODEV; | 1433 | return -ENODEV; |
1373 | 1434 | ||
@@ -1395,13 +1456,13 @@ int bond_create_sysfs_entry(struct bonding *bond) | |||
1395 | struct net_device *dev = bond->dev; | 1456 | struct net_device *dev = bond->dev; |
1396 | int err; | 1457 | int err; |
1397 | 1458 | ||
1398 | err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group); | 1459 | err = sysfs_create_group(&(dev->dev.kobj), &bonding_group); |
1399 | if (err) { | 1460 | if (err) { |
1400 | printk(KERN_EMERG "eek! didn't create group!\n"); | 1461 | printk(KERN_EMERG "eek! didn't create group!\n"); |
1401 | } | 1462 | } |
1402 | 1463 | ||
1403 | if (expected_refcount < 1) | 1464 | if (expected_refcount < 1) |
1404 | expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount); | 1465 | expected_refcount = atomic_read(&bond->dev->dev.kobj.kref.refcount); |
1405 | 1466 | ||
1406 | return err; | 1467 | return err; |
1407 | } | 1468 | } |
@@ -1412,6 +1473,6 @@ void bond_destroy_sysfs_entry(struct bonding *bond) | |||
1412 | { | 1473 | { |
1413 | struct net_device *dev = bond->dev; | 1474 | struct net_device *dev = bond->dev; |
1414 | 1475 | ||
1415 | sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group); | 1476 | sysfs_remove_group(&(dev->dev.kobj), &bonding_group); |
1416 | } | 1477 | } |
1417 | 1478 | ||