.. | .. |
---|
494 | 494 | * Start of per-unit (or driver, in some cases, but replicated |
---|
495 | 495 | * per unit) functions (these get a device *) |
---|
496 | 496 | */ |
---|
497 | | -static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
---|
498 | | - char *buf) |
---|
| 497 | +static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr, |
---|
| 498 | + char *buf) |
---|
499 | 499 | { |
---|
500 | 500 | struct hfi1_ibdev *dev = |
---|
501 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 501 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
502 | 502 | |
---|
503 | 503 | return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev); |
---|
504 | 504 | } |
---|
| 505 | +static DEVICE_ATTR_RO(hw_rev); |
---|
505 | 506 | |
---|
506 | | -static ssize_t show_hfi(struct device *device, struct device_attribute *attr, |
---|
507 | | - char *buf) |
---|
| 507 | +static ssize_t board_id_show(struct device *device, |
---|
| 508 | + struct device_attribute *attr, char *buf) |
---|
508 | 509 | { |
---|
509 | 510 | struct hfi1_ibdev *dev = |
---|
510 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 511 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
511 | 512 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
512 | 513 | int ret; |
---|
513 | 514 | |
---|
.. | .. |
---|
517 | 518 | ret = scnprintf(buf, PAGE_SIZE, "%s\n", dd->boardname); |
---|
518 | 519 | return ret; |
---|
519 | 520 | } |
---|
| 521 | +static DEVICE_ATTR_RO(board_id); |
---|
520 | 522 | |
---|
521 | | -static ssize_t show_boardversion(struct device *device, |
---|
| 523 | +static ssize_t boardversion_show(struct device *device, |
---|
522 | 524 | struct device_attribute *attr, char *buf) |
---|
523 | 525 | { |
---|
524 | 526 | struct hfi1_ibdev *dev = |
---|
525 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 527 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
526 | 528 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
527 | 529 | |
---|
528 | 530 | /* The string printed here is already newline-terminated. */ |
---|
529 | 531 | return scnprintf(buf, PAGE_SIZE, "%s", dd->boardversion); |
---|
530 | 532 | } |
---|
| 533 | +static DEVICE_ATTR_RO(boardversion); |
---|
531 | 534 | |
---|
532 | | -static ssize_t show_nctxts(struct device *device, |
---|
| 535 | +static ssize_t nctxts_show(struct device *device, |
---|
533 | 536 | struct device_attribute *attr, char *buf) |
---|
534 | 537 | { |
---|
535 | 538 | struct hfi1_ibdev *dev = |
---|
536 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 539 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
537 | 540 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
538 | 541 | |
---|
539 | 542 | /* |
---|
.. | .. |
---|
546 | 549 | min(dd->num_user_contexts, |
---|
547 | 550 | (u32)dd->sc_sizes[SC_USER].count)); |
---|
548 | 551 | } |
---|
| 552 | +static DEVICE_ATTR_RO(nctxts); |
---|
549 | 553 | |
---|
550 | | -static ssize_t show_nfreectxts(struct device *device, |
---|
| 554 | +static ssize_t nfreectxts_show(struct device *device, |
---|
551 | 555 | struct device_attribute *attr, char *buf) |
---|
552 | 556 | { |
---|
553 | 557 | struct hfi1_ibdev *dev = |
---|
554 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 558 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
555 | 559 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
556 | 560 | |
---|
557 | 561 | /* Return the number of free user ports (contexts) available. */ |
---|
558 | 562 | return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts); |
---|
559 | 563 | } |
---|
| 564 | +static DEVICE_ATTR_RO(nfreectxts); |
---|
560 | 565 | |
---|
561 | | -static ssize_t show_serial(struct device *device, |
---|
| 566 | +static ssize_t serial_show(struct device *device, |
---|
562 | 567 | struct device_attribute *attr, char *buf) |
---|
563 | 568 | { |
---|
564 | 569 | struct hfi1_ibdev *dev = |
---|
565 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 570 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
566 | 571 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
567 | 572 | |
---|
568 | 573 | return scnprintf(buf, PAGE_SIZE, "%s", dd->serial); |
---|
569 | 574 | } |
---|
| 575 | +static DEVICE_ATTR_RO(serial); |
---|
570 | 576 | |
---|
571 | | -static ssize_t store_chip_reset(struct device *device, |
---|
| 577 | +static ssize_t chip_reset_store(struct device *device, |
---|
572 | 578 | struct device_attribute *attr, const char *buf, |
---|
573 | 579 | size_t count) |
---|
574 | 580 | { |
---|
575 | 581 | struct hfi1_ibdev *dev = |
---|
576 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 582 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
577 | 583 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
578 | 584 | int ret; |
---|
579 | 585 | |
---|
.. | .. |
---|
586 | 592 | bail: |
---|
587 | 593 | return ret < 0 ? ret : count; |
---|
588 | 594 | } |
---|
| 595 | +static DEVICE_ATTR_WO(chip_reset); |
---|
589 | 596 | |
---|
590 | 597 | /* |
---|
591 | 598 | * Convert the reported temperature from an integer (reported in |
---|
.. | .. |
---|
598 | 605 | /* |
---|
599 | 606 | * Dump tempsense values, in decimal, to ease shell-scripts. |
---|
600 | 607 | */ |
---|
601 | | -static ssize_t show_tempsense(struct device *device, |
---|
| 608 | +static ssize_t tempsense_show(struct device *device, |
---|
602 | 609 | struct device_attribute *attr, char *buf) |
---|
603 | 610 | { |
---|
604 | 611 | struct hfi1_ibdev *dev = |
---|
605 | | - container_of(device, struct hfi1_ibdev, rdi.ibdev.dev); |
---|
| 612 | + rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev); |
---|
606 | 613 | struct hfi1_devdata *dd = dd_from_dev(dev); |
---|
607 | 614 | struct hfi1_temp temp; |
---|
608 | 615 | int ret; |
---|
.. | .. |
---|
622 | 629 | } |
---|
623 | 630 | return ret; |
---|
624 | 631 | } |
---|
| 632 | +static DEVICE_ATTR_RO(tempsense); |
---|
625 | 633 | |
---|
626 | 634 | /* |
---|
627 | 635 | * end of per-unit (or driver, in some cases, but replicated |
---|
.. | .. |
---|
629 | 637 | */ |
---|
630 | 638 | |
---|
631 | 639 | /* start of per-unit file structures and support code */ |
---|
632 | | -static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
---|
633 | | -static DEVICE_ATTR(board_id, S_IRUGO, show_hfi, NULL); |
---|
634 | | -static DEVICE_ATTR(nctxts, S_IRUGO, show_nctxts, NULL); |
---|
635 | | -static DEVICE_ATTR(nfreectxts, S_IRUGO, show_nfreectxts, NULL); |
---|
636 | | -static DEVICE_ATTR(serial, S_IRUGO, show_serial, NULL); |
---|
637 | | -static DEVICE_ATTR(boardversion, S_IRUGO, show_boardversion, NULL); |
---|
638 | | -static DEVICE_ATTR(tempsense, S_IRUGO, show_tempsense, NULL); |
---|
639 | | -static DEVICE_ATTR(chip_reset, S_IWUSR, NULL, store_chip_reset); |
---|
| 640 | +static struct attribute *hfi1_attributes[] = { |
---|
| 641 | + &dev_attr_hw_rev.attr, |
---|
| 642 | + &dev_attr_board_id.attr, |
---|
| 643 | + &dev_attr_nctxts.attr, |
---|
| 644 | + &dev_attr_nfreectxts.attr, |
---|
| 645 | + &dev_attr_serial.attr, |
---|
| 646 | + &dev_attr_boardversion.attr, |
---|
| 647 | + &dev_attr_tempsense.attr, |
---|
| 648 | + &dev_attr_chip_reset.attr, |
---|
| 649 | + NULL, |
---|
| 650 | +}; |
---|
640 | 651 | |
---|
641 | | -static struct device_attribute *hfi1_attributes[] = { |
---|
642 | | - &dev_attr_hw_rev, |
---|
643 | | - &dev_attr_board_id, |
---|
644 | | - &dev_attr_nctxts, |
---|
645 | | - &dev_attr_nfreectxts, |
---|
646 | | - &dev_attr_serial, |
---|
647 | | - &dev_attr_boardversion, |
---|
648 | | - &dev_attr_tempsense, |
---|
649 | | - &dev_attr_chip_reset, |
---|
| 652 | +const struct attribute_group ib_hfi1_attr_group = { |
---|
| 653 | + .attrs = hfi1_attributes, |
---|
650 | 654 | }; |
---|
651 | 655 | |
---|
652 | 656 | int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num, |
---|
.. | .. |
---|
835 | 839 | struct device *class_dev = &dev->dev; |
---|
836 | 840 | int i, j, ret; |
---|
837 | 841 | |
---|
838 | | - for (i = 0; i < ARRAY_SIZE(hfi1_attributes); ++i) { |
---|
839 | | - ret = device_create_file(&dev->dev, hfi1_attributes[i]); |
---|
840 | | - if (ret) |
---|
841 | | - goto bail; |
---|
842 | | - } |
---|
843 | | - |
---|
844 | 842 | for (i = 0; i < dd->num_sdma; i++) { |
---|
845 | 843 | ret = kobject_init_and_add(&dd->per_sdma[i].kobj, |
---|
846 | 844 | &sde_ktype, &class_dev->kobj, |
---|
.. | .. |
---|
858 | 856 | |
---|
859 | 857 | return 0; |
---|
860 | 858 | bail: |
---|
861 | | - for (i = 0; i < ARRAY_SIZE(hfi1_attributes); ++i) |
---|
862 | | - device_remove_file(&dev->dev, hfi1_attributes[i]); |
---|
863 | | - |
---|
864 | 859 | /* |
---|
865 | 860 | * The function kobject_put() will call kobject_del() if the kobject |
---|
866 | 861 | * has been added successfully. The sysfs files created under the |
---|