diff options
author | Divy Le Ray <divy@chelsio.com> | 2007-02-08 19:55:59 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-02-08 20:13:10 -0500 |
commit | 0ee8d33c64df9a719fd61ba693203e3b33b9e10a (patch) | |
tree | b865e67bf445f8e52dc897c782501a8b63feb67a /drivers/net/cxgb3 | |
parent | f3cc28c797604fa1cda4aef3f250f465de54a0ca (diff) |
cxgb3: sysfs attributes in -mm tree
This patch fixes the usage of sysfs attributes in cxgb3 for the -mm tree.
It is built against the driver commited in the -mm tree.
Signed-off-by: Divy Le Ray <divy@chelsio.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/cxgb3')
-rw-r--r-- | drivers/net/cxgb3/cxgb3_main.c | 86 |
1 files changed, 45 insertions, 41 deletions
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index dfa035a1ad45..c67f7d3c2f92 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -74,8 +74,6 @@ enum { | |||
74 | 74 | ||
75 | #define EEPROM_MAGIC 0x38E2F10C | 75 | #define EEPROM_MAGIC 0x38E2F10C |
76 | 76 | ||
77 | #define to_net_dev(class) container_of(class, struct net_device, class_dev) | ||
78 | |||
79 | #define CH_DEVICE(devid, ssid, idx) \ | 77 | #define CH_DEVICE(devid, ssid, idx) \ |
80 | { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx } | 78 | { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, ssid, 0, 0, idx } |
81 | 79 | ||
@@ -434,11 +432,12 @@ static int setup_sge_qsets(struct adapter *adap) | |||
434 | return 0; | 432 | return 0; |
435 | } | 433 | } |
436 | 434 | ||
437 | static ssize_t attr_show(struct class_device *cd, char *buf, | 435 | static ssize_t attr_show(struct device *d, struct device_attribute *attr, |
436 | char *buf, | ||
438 | ssize_t(*format) (struct adapter *, char *)) | 437 | ssize_t(*format) (struct adapter *, char *)) |
439 | { | 438 | { |
440 | ssize_t len; | 439 | ssize_t len; |
441 | struct adapter *adap = to_net_dev(cd)->priv; | 440 | struct adapter *adap = to_net_dev(d)->priv; |
442 | 441 | ||
443 | /* Synchronize with ioctls that may shut down the device */ | 442 | /* Synchronize with ioctls that may shut down the device */ |
444 | rtnl_lock(); | 443 | rtnl_lock(); |
@@ -447,14 +446,15 @@ static ssize_t attr_show(struct class_device *cd, char *buf, | |||
447 | return len; | 446 | return len; |
448 | } | 447 | } |
449 | 448 | ||
450 | static ssize_t attr_store(struct class_device *cd, const char *buf, size_t len, | 449 | static ssize_t attr_store(struct device *d, struct device_attribute *attr, |
450 | const char *buf, size_t len, | ||
451 | ssize_t(*set) (struct adapter *, unsigned int), | 451 | ssize_t(*set) (struct adapter *, unsigned int), |
452 | unsigned int min_val, unsigned int max_val) | 452 | unsigned int min_val, unsigned int max_val) |
453 | { | 453 | { |
454 | char *endp; | 454 | char *endp; |
455 | ssize_t ret; | 455 | ssize_t ret; |
456 | unsigned int val; | 456 | unsigned int val; |
457 | struct adapter *adap = to_net_dev(cd)->priv; | 457 | struct adapter *adap = to_net_dev(d)->priv; |
458 | 458 | ||
459 | if (!capable(CAP_NET_ADMIN)) | 459 | if (!capable(CAP_NET_ADMIN)) |
460 | return -EPERM; | 460 | return -EPERM; |
@@ -476,9 +476,10 @@ static ssize_t format_##name(struct adapter *adap, char *buf) \ | |||
476 | { \ | 476 | { \ |
477 | return sprintf(buf, "%u\n", val_expr); \ | 477 | return sprintf(buf, "%u\n", val_expr); \ |
478 | } \ | 478 | } \ |
479 | static ssize_t show_##name(struct class_device *cd, char *buf) \ | 479 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ |
480 | char *buf) \ | ||
480 | { \ | 481 | { \ |
481 | return attr_show(cd, buf, format_##name); \ | 482 | return attr_show(d, attr, buf, format_##name); \ |
482 | } | 483 | } |
483 | 484 | ||
484 | static ssize_t set_nfilters(struct adapter *adap, unsigned int val) | 485 | static ssize_t set_nfilters(struct adapter *adap, unsigned int val) |
@@ -493,10 +494,10 @@ static ssize_t set_nfilters(struct adapter *adap, unsigned int val) | |||
493 | return 0; | 494 | return 0; |
494 | } | 495 | } |
495 | 496 | ||
496 | static ssize_t store_nfilters(struct class_device *cd, const char *buf, | 497 | static ssize_t store_nfilters(struct device *d, struct device_attribute *attr, |
497 | size_t len) | 498 | const char *buf, size_t len) |
498 | { | 499 | { |
499 | return attr_store(cd, buf, len, set_nfilters, 0, ~0); | 500 | return attr_store(d, attr, buf, len, set_nfilters, 0, ~0); |
500 | } | 501 | } |
501 | 502 | ||
502 | static ssize_t set_nservers(struct adapter *adap, unsigned int val) | 503 | static ssize_t set_nservers(struct adapter *adap, unsigned int val) |
@@ -509,38 +510,39 @@ static ssize_t set_nservers(struct adapter *adap, unsigned int val) | |||
509 | return 0; | 510 | return 0; |
510 | } | 511 | } |
511 | 512 | ||
512 | static ssize_t store_nservers(struct class_device *cd, const char *buf, | 513 | static ssize_t store_nservers(struct device *d, struct device_attribute *attr, |
513 | size_t len) | 514 | const char *buf, size_t len) |
514 | { | 515 | { |
515 | return attr_store(cd, buf, len, set_nservers, 0, ~0); | 516 | return attr_store(d, attr, buf, len, set_nservers, 0, ~0); |
516 | } | 517 | } |
517 | 518 | ||
518 | #define CXGB3_ATTR_R(name, val_expr) \ | 519 | #define CXGB3_ATTR_R(name, val_expr) \ |
519 | CXGB3_SHOW(name, val_expr) \ | 520 | CXGB3_SHOW(name, val_expr) \ |
520 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | 521 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) |
521 | 522 | ||
522 | #define CXGB3_ATTR_RW(name, val_expr, store_method) \ | 523 | #define CXGB3_ATTR_RW(name, val_expr, store_method) \ |
523 | CXGB3_SHOW(name, val_expr) \ | 524 | CXGB3_SHOW(name, val_expr) \ |
524 | static CLASS_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_method) | 525 | static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_method) |
525 | 526 | ||
526 | CXGB3_ATTR_R(cam_size, t3_mc5_size(&adap->mc5)); | 527 | CXGB3_ATTR_R(cam_size, t3_mc5_size(&adap->mc5)); |
527 | CXGB3_ATTR_RW(nfilters, adap->params.mc5.nfilters, store_nfilters); | 528 | CXGB3_ATTR_RW(nfilters, adap->params.mc5.nfilters, store_nfilters); |
528 | CXGB3_ATTR_RW(nservers, adap->params.mc5.nservers, store_nservers); | 529 | CXGB3_ATTR_RW(nservers, adap->params.mc5.nservers, store_nservers); |
529 | 530 | ||
530 | static struct attribute *cxgb3_attrs[] = { | 531 | static struct attribute *cxgb3_attrs[] = { |
531 | &class_device_attr_cam_size.attr, | 532 | &dev_attr_cam_size.attr, |
532 | &class_device_attr_nfilters.attr, | 533 | &dev_attr_nfilters.attr, |
533 | &class_device_attr_nservers.attr, | 534 | &dev_attr_nservers.attr, |
534 | NULL | 535 | NULL |
535 | }; | 536 | }; |
536 | 537 | ||
537 | static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs }; | 538 | static struct attribute_group cxgb3_attr_group = {.attrs = cxgb3_attrs }; |
538 | 539 | ||
539 | static ssize_t tm_attr_show(struct class_device *cd, char *buf, int sched) | 540 | static ssize_t tm_attr_show(struct device *d, struct device_attribute *attr, |
541 | char *buf, int sched) | ||
540 | { | 542 | { |
541 | ssize_t len; | 543 | ssize_t len; |
542 | unsigned int v, addr, bpt, cpt; | 544 | unsigned int v, addr, bpt, cpt; |
543 | struct adapter *adap = to_net_dev(cd)->priv; | 545 | struct adapter *adap = to_net_dev(d)->priv; |
544 | 546 | ||
545 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; | 547 | addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; |
546 | rtnl_lock(); | 548 | rtnl_lock(); |
@@ -560,13 +562,13 @@ static ssize_t tm_attr_show(struct class_device *cd, char *buf, int sched) | |||
560 | return len; | 562 | return len; |
561 | } | 563 | } |
562 | 564 | ||
563 | static ssize_t tm_attr_store(struct class_device *cd, const char *buf, | 565 | static ssize_t tm_attr_store(struct device *d, struct device_attribute *attr, |
564 | size_t len, int sched) | 566 | const char *buf, size_t len, int sched) |
565 | { | 567 | { |
566 | char *endp; | 568 | char *endp; |
567 | ssize_t ret; | 569 | ssize_t ret; |
568 | unsigned int val; | 570 | unsigned int val; |
569 | struct adapter *adap = to_net_dev(cd)->priv; | 571 | struct adapter *adap = to_net_dev(d)->priv; |
570 | 572 | ||
571 | if (!capable(CAP_NET_ADMIN)) | 573 | if (!capable(CAP_NET_ADMIN)) |
572 | return -EPERM; | 574 | return -EPERM; |
@@ -584,15 +586,17 @@ static ssize_t tm_attr_store(struct class_device *cd, const char *buf, | |||
584 | } | 586 | } |
585 | 587 | ||
586 | #define TM_ATTR(name, sched) \ | 588 | #define TM_ATTR(name, sched) \ |
587 | static ssize_t show_##name(struct class_device *cd, char *buf) \ | 589 | static ssize_t show_##name(struct device *d, struct device_attribute *attr, \ |
590 | char *buf) \ | ||
588 | { \ | 591 | { \ |
589 | return tm_attr_show(cd, buf, sched); \ | 592 | return tm_attr_show(d, attr, buf, sched); \ |
590 | } \ | 593 | } \ |
591 | static ssize_t store_##name(struct class_device *cd, const char *buf, size_t len) \ | 594 | static ssize_t store_##name(struct device *d, struct device_attribute *attr, \ |
595 | const char *buf, size_t len) \ | ||
592 | { \ | 596 | { \ |
593 | return tm_attr_store(cd, buf, len, sched); \ | 597 | return tm_attr_store(d, attr, buf, len, sched); \ |
594 | } \ | 598 | } \ |
595 | static CLASS_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_##name) | 599 | static DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show_##name, store_##name) |
596 | 600 | ||
597 | TM_ATTR(sched0, 0); | 601 | TM_ATTR(sched0, 0); |
598 | TM_ATTR(sched1, 1); | 602 | TM_ATTR(sched1, 1); |
@@ -604,14 +608,14 @@ TM_ATTR(sched6, 6); | |||
604 | TM_ATTR(sched7, 7); | 608 | TM_ATTR(sched7, 7); |
605 | 609 | ||
606 | static struct attribute *offload_attrs[] = { | 610 | static struct attribute *offload_attrs[] = { |
607 | &class_device_attr_sched0.attr, | 611 | &dev_attr_sched0.attr, |
608 | &class_device_attr_sched1.attr, | 612 | &dev_attr_sched1.attr, |
609 | &class_device_attr_sched2.attr, | 613 | &dev_attr_sched2.attr, |
610 | &class_device_attr_sched3.attr, | 614 | &dev_attr_sched3.attr, |
611 | &class_device_attr_sched4.attr, | 615 | &dev_attr_sched4.attr, |
612 | &class_device_attr_sched5.attr, | 616 | &dev_attr_sched5.attr, |
613 | &class_device_attr_sched6.attr, | 617 | &dev_attr_sched6.attr, |
614 | &class_device_attr_sched7.attr, | 618 | &dev_attr_sched7.attr, |
615 | NULL | 619 | NULL |
616 | }; | 620 | }; |
617 | 621 | ||
@@ -836,7 +840,7 @@ static int offload_open(struct net_device *dev) | |||
836 | init_smt(adapter); | 840 | init_smt(adapter); |
837 | 841 | ||
838 | /* Never mind if the next step fails */ | 842 | /* Never mind if the next step fails */ |
839 | sysfs_create_group(&tdev->lldev->class_dev.kobj, &offload_attr_group); | 843 | sysfs_create_group(&tdev->lldev->dev.kobj, &offload_attr_group); |
840 | 844 | ||
841 | /* Call back all registered clients */ | 845 | /* Call back all registered clients */ |
842 | cxgb3_add_clients(tdev); | 846 | cxgb3_add_clients(tdev); |
@@ -861,7 +865,7 @@ static int offload_close(struct t3cdev *tdev) | |||
861 | /* Call back all registered clients */ | 865 | /* Call back all registered clients */ |
862 | cxgb3_remove_clients(tdev); | 866 | cxgb3_remove_clients(tdev); |
863 | 867 | ||
864 | sysfs_remove_group(&tdev->lldev->class_dev.kobj, &offload_attr_group); | 868 | sysfs_remove_group(&tdev->lldev->dev.kobj, &offload_attr_group); |
865 | 869 | ||
866 | tdev->lldev = NULL; | 870 | tdev->lldev = NULL; |
867 | cxgb3_set_dummy_ops(tdev); | 871 | cxgb3_set_dummy_ops(tdev); |
@@ -2420,7 +2424,7 @@ static int __devinit init_one(struct pci_dev *pdev, | |||
2420 | else if (msi > 0 && pci_enable_msi(pdev) == 0) | 2424 | else if (msi > 0 && pci_enable_msi(pdev) == 0) |
2421 | adapter->flags |= USING_MSI; | 2425 | adapter->flags |= USING_MSI; |
2422 | 2426 | ||
2423 | err = sysfs_create_group(&adapter->port[0]->class_dev.kobj, | 2427 | err = sysfs_create_group(&adapter->port[0]->dev.kobj, |
2424 | &cxgb3_attr_group); | 2428 | &cxgb3_attr_group); |
2425 | 2429 | ||
2426 | print_port_info(adapter, ai); | 2430 | print_port_info(adapter, ai); |
@@ -2452,7 +2456,7 @@ static void __devexit remove_one(struct pci_dev *pdev) | |||
2452 | struct adapter *adapter = dev->priv; | 2456 | struct adapter *adapter = dev->priv; |
2453 | 2457 | ||
2454 | t3_sge_stop(adapter); | 2458 | t3_sge_stop(adapter); |
2455 | sysfs_remove_group(&adapter->port[0]->class_dev.kobj, | 2459 | sysfs_remove_group(&adapter->port[0]->dev.kobj, |
2456 | &cxgb3_attr_group); | 2460 | &cxgb3_attr_group); |
2457 | 2461 | ||
2458 | for_each_port(adapter, i) | 2462 | for_each_port(adapter, i) |