diff options
| author | Christoph Hellwig <hch@lst.de> | 2015-10-03 09:32:55 -0400 |
|---|---|---|
| committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-10-14 01:17:49 -0400 |
| commit | 2eafd72939fda6118e27d3ee859684987f43921b (patch) | |
| tree | a00a1f5686ec852e04b52ea5fb1ce37c05564dc9 /drivers/infiniband/ulp/srpt | |
| parent | 64c6be0e6df5b5804613863ca4fb05961948c999 (diff) | |
target: use per-attribute show and store methods
This also allows to remove the target-specific old configfs macros, and
gets rid of the target_core_fabric_configfs.h header which only had one
function declaration left that could be moved to a better place.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Acked-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband/ulp/srpt')
| -rw-r--r-- | drivers/infiniband/ulp/srpt/ib_srpt.c | 78 |
1 files changed, 34 insertions, 44 deletions
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index f6fe0414139b..231d29cc0419 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c | |||
| @@ -43,9 +43,7 @@ | |||
| 43 | #include <linux/atomic.h> | 43 | #include <linux/atomic.h> |
| 44 | #include <scsi/scsi_proto.h> | 44 | #include <scsi/scsi_proto.h> |
| 45 | #include <scsi/scsi_tcq.h> | 45 | #include <scsi/scsi_tcq.h> |
| 46 | #include <target/configfs_macros.h> | ||
| 47 | #include <target/target_core_base.h> | 46 | #include <target/target_core_base.h> |
| 48 | #include <target/target_core_fabric_configfs.h> | ||
| 49 | #include <target/target_core_fabric.h> | 47 | #include <target/target_core_fabric.h> |
| 50 | #include "ib_srpt.h" | 48 | #include "ib_srpt.h" |
| 51 | 49 | ||
| @@ -3545,20 +3543,19 @@ static void srpt_cleanup_nodeacl(struct se_node_acl *se_nacl) | |||
| 3545 | spin_unlock_irq(&sport->port_acl_lock); | 3543 | spin_unlock_irq(&sport->port_acl_lock); |
| 3546 | } | 3544 | } |
| 3547 | 3545 | ||
| 3548 | static ssize_t srpt_tpg_attrib_show_srp_max_rdma_size( | 3546 | static ssize_t srpt_tpg_attrib_srp_max_rdma_size_show(struct config_item *item, |
| 3549 | struct se_portal_group *se_tpg, | 3547 | char *page) |
| 3550 | char *page) | ||
| 3551 | { | 3548 | { |
| 3549 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3552 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3550 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3553 | 3551 | ||
| 3554 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size); | 3552 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size); |
| 3555 | } | 3553 | } |
| 3556 | 3554 | ||
| 3557 | static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size( | 3555 | static ssize_t srpt_tpg_attrib_srp_max_rdma_size_store(struct config_item *item, |
| 3558 | struct se_portal_group *se_tpg, | 3556 | const char *page, size_t count) |
| 3559 | const char *page, | ||
| 3560 | size_t count) | ||
| 3561 | { | 3557 | { |
| 3558 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3562 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3559 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3563 | unsigned long val; | 3560 | unsigned long val; |
| 3564 | int ret; | 3561 | int ret; |
| @@ -3583,22 +3580,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size( | |||
| 3583 | return count; | 3580 | return count; |
| 3584 | } | 3581 | } |
| 3585 | 3582 | ||
| 3586 | TF_TPG_ATTRIB_ATTR(srpt, srp_max_rdma_size, S_IRUGO | S_IWUSR); | 3583 | static ssize_t srpt_tpg_attrib_srp_max_rsp_size_show(struct config_item *item, |
| 3587 | 3584 | char *page) | |
| 3588 | static ssize_t srpt_tpg_attrib_show_srp_max_rsp_size( | ||
| 3589 | struct se_portal_group *se_tpg, | ||
| 3590 | char *page) | ||
| 3591 | { | 3585 | { |
| 3586 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3592 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3587 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3593 | 3588 | ||
| 3594 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size); | 3589 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size); |
| 3595 | } | 3590 | } |
| 3596 | 3591 | ||
| 3597 | static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size( | 3592 | static ssize_t srpt_tpg_attrib_srp_max_rsp_size_store(struct config_item *item, |
| 3598 | struct se_portal_group *se_tpg, | 3593 | const char *page, size_t count) |
| 3599 | const char *page, | ||
| 3600 | size_t count) | ||
| 3601 | { | 3594 | { |
| 3595 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3602 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3596 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3603 | unsigned long val; | 3597 | unsigned long val; |
| 3604 | int ret; | 3598 | int ret; |
| @@ -3623,22 +3617,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size( | |||
| 3623 | return count; | 3617 | return count; |
| 3624 | } | 3618 | } |
| 3625 | 3619 | ||
| 3626 | TF_TPG_ATTRIB_ATTR(srpt, srp_max_rsp_size, S_IRUGO | S_IWUSR); | 3620 | static ssize_t srpt_tpg_attrib_srp_sq_size_show(struct config_item *item, |
| 3627 | 3621 | char *page) | |
| 3628 | static ssize_t srpt_tpg_attrib_show_srp_sq_size( | ||
| 3629 | struct se_portal_group *se_tpg, | ||
| 3630 | char *page) | ||
| 3631 | { | 3622 | { |
| 3623 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3632 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3624 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3633 | 3625 | ||
| 3634 | return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size); | 3626 | return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size); |
| 3635 | } | 3627 | } |
| 3636 | 3628 | ||
| 3637 | static ssize_t srpt_tpg_attrib_store_srp_sq_size( | 3629 | static ssize_t srpt_tpg_attrib_srp_sq_size_store(struct config_item *item, |
| 3638 | struct se_portal_group *se_tpg, | 3630 | const char *page, size_t count) |
| 3639 | const char *page, | ||
| 3640 | size_t count) | ||
| 3641 | { | 3631 | { |
| 3632 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
| 3642 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3633 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3643 | unsigned long val; | 3634 | unsigned long val; |
| 3644 | int ret; | 3635 | int ret; |
| @@ -3663,29 +3654,29 @@ static ssize_t srpt_tpg_attrib_store_srp_sq_size( | |||
| 3663 | return count; | 3654 | return count; |
| 3664 | } | 3655 | } |
| 3665 | 3656 | ||
| 3666 | TF_TPG_ATTRIB_ATTR(srpt, srp_sq_size, S_IRUGO | S_IWUSR); | 3657 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rdma_size); |
| 3658 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rsp_size); | ||
| 3659 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_sq_size); | ||
| 3667 | 3660 | ||
| 3668 | static struct configfs_attribute *srpt_tpg_attrib_attrs[] = { | 3661 | static struct configfs_attribute *srpt_tpg_attrib_attrs[] = { |
| 3669 | &srpt_tpg_attrib_srp_max_rdma_size.attr, | 3662 | &srpt_tpg_attrib_attr_srp_max_rdma_size, |
| 3670 | &srpt_tpg_attrib_srp_max_rsp_size.attr, | 3663 | &srpt_tpg_attrib_attr_srp_max_rsp_size, |
| 3671 | &srpt_tpg_attrib_srp_sq_size.attr, | 3664 | &srpt_tpg_attrib_attr_srp_sq_size, |
| 3672 | NULL, | 3665 | NULL, |
| 3673 | }; | 3666 | }; |
| 3674 | 3667 | ||
| 3675 | static ssize_t srpt_tpg_show_enable( | 3668 | static ssize_t srpt_tpg_enable_show(struct config_item *item, char *page) |
| 3676 | struct se_portal_group *se_tpg, | ||
| 3677 | char *page) | ||
| 3678 | { | 3669 | { |
| 3670 | struct se_portal_group *se_tpg = to_tpg(item); | ||
| 3679 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3671 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3680 | 3672 | ||
| 3681 | return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0); | 3673 | return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0); |
| 3682 | } | 3674 | } |
| 3683 | 3675 | ||
| 3684 | static ssize_t srpt_tpg_store_enable( | 3676 | static ssize_t srpt_tpg_enable_store(struct config_item *item, |
| 3685 | struct se_portal_group *se_tpg, | 3677 | const char *page, size_t count) |
| 3686 | const char *page, | ||
| 3687 | size_t count) | ||
| 3688 | { | 3678 | { |
| 3679 | struct se_portal_group *se_tpg = to_tpg(item); | ||
| 3689 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3680 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
| 3690 | unsigned long tmp; | 3681 | unsigned long tmp; |
| 3691 | int ret; | 3682 | int ret; |
| @@ -3708,10 +3699,10 @@ static ssize_t srpt_tpg_store_enable( | |||
| 3708 | return count; | 3699 | return count; |
| 3709 | } | 3700 | } |
| 3710 | 3701 | ||
| 3711 | TF_TPG_BASE_ATTR(srpt, enable, S_IRUGO | S_IWUSR); | 3702 | CONFIGFS_ATTR(srpt_tpg_, enable); |
| 3712 | 3703 | ||
| 3713 | static struct configfs_attribute *srpt_tpg_attrs[] = { | 3704 | static struct configfs_attribute *srpt_tpg_attrs[] = { |
| 3714 | &srpt_tpg_enable.attr, | 3705 | &srpt_tpg_attr_enable, |
| 3715 | NULL, | 3706 | NULL, |
| 3716 | }; | 3707 | }; |
| 3717 | 3708 | ||
| @@ -3781,16 +3772,15 @@ static void srpt_drop_tport(struct se_wwn *wwn) | |||
| 3781 | pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item)); | 3772 | pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item)); |
| 3782 | } | 3773 | } |
| 3783 | 3774 | ||
| 3784 | static ssize_t srpt_wwn_show_attr_version(struct target_fabric_configfs *tf, | 3775 | static ssize_t srpt_wwn_version_show(struct config_item *item, char *buf) |
| 3785 | char *buf) | ||
| 3786 | { | 3776 | { |
| 3787 | return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); | 3777 | return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); |
| 3788 | } | 3778 | } |
| 3789 | 3779 | ||
| 3790 | TF_WWN_ATTR_RO(srpt, version); | 3780 | CONFIGFS_ATTR_RO(srpt_wwn_, version); |
| 3791 | 3781 | ||
| 3792 | static struct configfs_attribute *srpt_wwn_attrs[] = { | 3782 | static struct configfs_attribute *srpt_wwn_attrs[] = { |
| 3793 | &srpt_wwn_version.attr, | 3783 | &srpt_wwn_attr_version, |
| 3794 | NULL, | 3784 | NULL, |
| 3795 | }; | 3785 | }; |
| 3796 | 3786 | ||
