diff options
Diffstat (limited to 'drivers')
40 files changed, 2329 insertions, 3937 deletions
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c index 6498a9dbb7bd..11ab6d01adf6 100644 --- a/drivers/hwtracing/stm/policy.c +++ b/drivers/hwtracing/stm/policy.c | |||
@@ -76,9 +76,10 @@ to_stp_policy_node(struct config_item *item) | |||
76 | NULL; | 76 | NULL; |
77 | } | 77 | } |
78 | 78 | ||
79 | static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node, | 79 | static ssize_t |
80 | char *page) | 80 | stp_policy_node_masters_show(struct config_item *item, char *page) |
81 | { | 81 | { |
82 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
82 | ssize_t count; | 83 | ssize_t count; |
83 | 84 | ||
84 | count = sprintf(page, "%u %u\n", policy_node->first_master, | 85 | count = sprintf(page, "%u %u\n", policy_node->first_master, |
@@ -88,9 +89,10 @@ static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node, | |||
88 | } | 89 | } |
89 | 90 | ||
90 | static ssize_t | 91 | static ssize_t |
91 | stp_policy_node_masters_store(struct stp_policy_node *policy_node, | 92 | stp_policy_node_masters_store(struct config_item *item, const char *page, |
92 | const char *page, size_t count) | 93 | size_t count) |
93 | { | 94 | { |
95 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
94 | unsigned int first, last; | 96 | unsigned int first, last; |
95 | struct stm_device *stm; | 97 | struct stm_device *stm; |
96 | char *p = (char *)page; | 98 | char *p = (char *)page; |
@@ -123,8 +125,9 @@ unlock: | |||
123 | } | 125 | } |
124 | 126 | ||
125 | static ssize_t | 127 | static ssize_t |
126 | stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page) | 128 | stp_policy_node_channels_show(struct config_item *item, char *page) |
127 | { | 129 | { |
130 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
128 | ssize_t count; | 131 | ssize_t count; |
129 | 132 | ||
130 | count = sprintf(page, "%u %u\n", policy_node->first_channel, | 133 | count = sprintf(page, "%u %u\n", policy_node->first_channel, |
@@ -134,9 +137,10 @@ stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page) | |||
134 | } | 137 | } |
135 | 138 | ||
136 | static ssize_t | 139 | static ssize_t |
137 | stp_policy_node_channels_store(struct stp_policy_node *policy_node, | 140 | stp_policy_node_channels_store(struct config_item *item, const char *page, |
138 | const char *page, size_t count) | 141 | size_t count) |
139 | { | 142 | { |
143 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
140 | unsigned int first, last; | 144 | unsigned int first, last; |
141 | struct stm_device *stm; | 145 | struct stm_device *stm; |
142 | char *p = (char *)page; | 146 | char *p = (char *)page; |
@@ -171,71 +175,16 @@ static void stp_policy_node_release(struct config_item *item) | |||
171 | kfree(to_stp_policy_node(item)); | 175 | kfree(to_stp_policy_node(item)); |
172 | } | 176 | } |
173 | 177 | ||
174 | struct stp_policy_node_attribute { | ||
175 | struct configfs_attribute attr; | ||
176 | ssize_t (*show)(struct stp_policy_node *, char *); | ||
177 | ssize_t (*store)(struct stp_policy_node *, const char *, size_t); | ||
178 | }; | ||
179 | |||
180 | static ssize_t stp_policy_node_attr_show(struct config_item *item, | ||
181 | struct configfs_attribute *attr, | ||
182 | char *page) | ||
183 | { | ||
184 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
185 | struct stp_policy_node_attribute *pn_attr = | ||
186 | container_of(attr, struct stp_policy_node_attribute, attr); | ||
187 | ssize_t count = 0; | ||
188 | |||
189 | if (pn_attr->show) | ||
190 | count = pn_attr->show(policy_node, page); | ||
191 | |||
192 | return count; | ||
193 | } | ||
194 | |||
195 | static ssize_t stp_policy_node_attr_store(struct config_item *item, | ||
196 | struct configfs_attribute *attr, | ||
197 | const char *page, size_t len) | ||
198 | { | ||
199 | struct stp_policy_node *policy_node = to_stp_policy_node(item); | ||
200 | struct stp_policy_node_attribute *pn_attr = | ||
201 | container_of(attr, struct stp_policy_node_attribute, attr); | ||
202 | ssize_t count = -EINVAL; | ||
203 | |||
204 | if (pn_attr->store) | ||
205 | count = pn_attr->store(policy_node, page, len); | ||
206 | |||
207 | return count; | ||
208 | } | ||
209 | |||
210 | static struct configfs_item_operations stp_policy_node_item_ops = { | 178 | static struct configfs_item_operations stp_policy_node_item_ops = { |
211 | .release = stp_policy_node_release, | 179 | .release = stp_policy_node_release, |
212 | .show_attribute = stp_policy_node_attr_show, | ||
213 | .store_attribute = stp_policy_node_attr_store, | ||
214 | }; | 180 | }; |
215 | 181 | ||
216 | static struct stp_policy_node_attribute stp_policy_node_attr_range = { | 182 | CONFIGFS_ATTR(stp_policy_node_, masters); |
217 | .attr = { | 183 | CONFIGFS_ATTR(stp_policy_node_, channels); |
218 | .ca_owner = THIS_MODULE, | ||
219 | .ca_name = "masters", | ||
220 | .ca_mode = S_IRUGO | S_IWUSR, | ||
221 | }, | ||
222 | .show = stp_policy_node_masters_show, | ||
223 | .store = stp_policy_node_masters_store, | ||
224 | }; | ||
225 | |||
226 | static struct stp_policy_node_attribute stp_policy_node_attr_channels = { | ||
227 | .attr = { | ||
228 | .ca_owner = THIS_MODULE, | ||
229 | .ca_name = "channels", | ||
230 | .ca_mode = S_IRUGO | S_IWUSR, | ||
231 | }, | ||
232 | .show = stp_policy_node_channels_show, | ||
233 | .store = stp_policy_node_channels_store, | ||
234 | }; | ||
235 | 184 | ||
236 | static struct configfs_attribute *stp_policy_node_attrs[] = { | 185 | static struct configfs_attribute *stp_policy_node_attrs[] = { |
237 | &stp_policy_node_attr_range.attr, | 186 | &stp_policy_node_attr_masters, |
238 | &stp_policy_node_attr_channels.attr, | 187 | &stp_policy_node_attr_channels, |
239 | NULL, | 188 | NULL, |
240 | }; | 189 | }; |
241 | 190 | ||
@@ -298,20 +247,8 @@ static struct config_item_type stp_policy_node_type = { | |||
298 | /* | 247 | /* |
299 | * Root group: policies. | 248 | * Root group: policies. |
300 | */ | 249 | */ |
301 | static struct configfs_attribute stp_policy_attr_device = { | 250 | static ssize_t stp_policy_device_show(struct config_item *item, |
302 | .ca_owner = THIS_MODULE, | 251 | char *page) |
303 | .ca_name = "device", | ||
304 | .ca_mode = S_IRUGO, | ||
305 | }; | ||
306 | |||
307 | static struct configfs_attribute *stp_policy_attrs[] = { | ||
308 | &stp_policy_attr_device, | ||
309 | NULL, | ||
310 | }; | ||
311 | |||
312 | static ssize_t stp_policy_attr_show(struct config_item *item, | ||
313 | struct configfs_attribute *attr, | ||
314 | char *page) | ||
315 | { | 252 | { |
316 | struct stp_policy *policy = to_stp_policy(item); | 253 | struct stp_policy *policy = to_stp_policy(item); |
317 | ssize_t count; | 254 | ssize_t count; |
@@ -324,6 +261,13 @@ static ssize_t stp_policy_attr_show(struct config_item *item, | |||
324 | return count; | 261 | return count; |
325 | } | 262 | } |
326 | 263 | ||
264 | CONFIGFS_ATTR_RO(stp_policy_, device); | ||
265 | |||
266 | static struct configfs_attribute *stp_policy_attrs[] = { | ||
267 | &stp_policy_attr_device, | ||
268 | NULL, | ||
269 | }; | ||
270 | |||
327 | void stp_policy_unbind(struct stp_policy *policy) | 271 | void stp_policy_unbind(struct stp_policy *policy) |
328 | { | 272 | { |
329 | struct stm_device *stm = policy->stm; | 273 | struct stm_device *stm = policy->stm; |
@@ -350,7 +294,6 @@ static void stp_policy_release(struct config_item *item) | |||
350 | 294 | ||
351 | static struct configfs_item_operations stp_policy_item_ops = { | 295 | static struct configfs_item_operations stp_policy_item_ops = { |
352 | .release = stp_policy_release, | 296 | .release = stp_policy_release, |
353 | .show_attribute = stp_policy_attr_show, | ||
354 | }; | 297 | }; |
355 | 298 | ||
356 | static struct configfs_group_operations stp_policy_group_ops = { | 299 | static struct configfs_group_operations stp_policy_group_ops = { |
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 47c4022fda76..2e2fe818ca9f 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 | ||
@@ -3546,20 +3544,19 @@ static void srpt_cleanup_nodeacl(struct se_node_acl *se_nacl) | |||
3546 | spin_unlock_irq(&sport->port_acl_lock); | 3544 | spin_unlock_irq(&sport->port_acl_lock); |
3547 | } | 3545 | } |
3548 | 3546 | ||
3549 | static ssize_t srpt_tpg_attrib_show_srp_max_rdma_size( | 3547 | static ssize_t srpt_tpg_attrib_srp_max_rdma_size_show(struct config_item *item, |
3550 | struct se_portal_group *se_tpg, | 3548 | char *page) |
3551 | char *page) | ||
3552 | { | 3549 | { |
3550 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3553 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3551 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3554 | 3552 | ||
3555 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size); | 3553 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size); |
3556 | } | 3554 | } |
3557 | 3555 | ||
3558 | static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size( | 3556 | static ssize_t srpt_tpg_attrib_srp_max_rdma_size_store(struct config_item *item, |
3559 | struct se_portal_group *se_tpg, | 3557 | const char *page, size_t count) |
3560 | const char *page, | ||
3561 | size_t count) | ||
3562 | { | 3558 | { |
3559 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3563 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3560 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3564 | unsigned long val; | 3561 | unsigned long val; |
3565 | int ret; | 3562 | int ret; |
@@ -3584,22 +3581,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size( | |||
3584 | return count; | 3581 | return count; |
3585 | } | 3582 | } |
3586 | 3583 | ||
3587 | TF_TPG_ATTRIB_ATTR(srpt, srp_max_rdma_size, S_IRUGO | S_IWUSR); | 3584 | static ssize_t srpt_tpg_attrib_srp_max_rsp_size_show(struct config_item *item, |
3588 | 3585 | char *page) | |
3589 | static ssize_t srpt_tpg_attrib_show_srp_max_rsp_size( | ||
3590 | struct se_portal_group *se_tpg, | ||
3591 | char *page) | ||
3592 | { | 3586 | { |
3587 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3593 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3588 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3594 | 3589 | ||
3595 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size); | 3590 | return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size); |
3596 | } | 3591 | } |
3597 | 3592 | ||
3598 | static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size( | 3593 | static ssize_t srpt_tpg_attrib_srp_max_rsp_size_store(struct config_item *item, |
3599 | struct se_portal_group *se_tpg, | 3594 | const char *page, size_t count) |
3600 | const char *page, | ||
3601 | size_t count) | ||
3602 | { | 3595 | { |
3596 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3603 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3597 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3604 | unsigned long val; | 3598 | unsigned long val; |
3605 | int ret; | 3599 | int ret; |
@@ -3624,22 +3618,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size( | |||
3624 | return count; | 3618 | return count; |
3625 | } | 3619 | } |
3626 | 3620 | ||
3627 | TF_TPG_ATTRIB_ATTR(srpt, srp_max_rsp_size, S_IRUGO | S_IWUSR); | 3621 | static ssize_t srpt_tpg_attrib_srp_sq_size_show(struct config_item *item, |
3628 | 3622 | char *page) | |
3629 | static ssize_t srpt_tpg_attrib_show_srp_sq_size( | ||
3630 | struct se_portal_group *se_tpg, | ||
3631 | char *page) | ||
3632 | { | 3623 | { |
3624 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3633 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3625 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3634 | 3626 | ||
3635 | return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size); | 3627 | return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size); |
3636 | } | 3628 | } |
3637 | 3629 | ||
3638 | static ssize_t srpt_tpg_attrib_store_srp_sq_size( | 3630 | static ssize_t srpt_tpg_attrib_srp_sq_size_store(struct config_item *item, |
3639 | struct se_portal_group *se_tpg, | 3631 | const char *page, size_t count) |
3640 | const char *page, | ||
3641 | size_t count) | ||
3642 | { | 3632 | { |
3633 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
3643 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3634 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3644 | unsigned long val; | 3635 | unsigned long val; |
3645 | int ret; | 3636 | int ret; |
@@ -3664,29 +3655,29 @@ static ssize_t srpt_tpg_attrib_store_srp_sq_size( | |||
3664 | return count; | 3655 | return count; |
3665 | } | 3656 | } |
3666 | 3657 | ||
3667 | TF_TPG_ATTRIB_ATTR(srpt, srp_sq_size, S_IRUGO | S_IWUSR); | 3658 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rdma_size); |
3659 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rsp_size); | ||
3660 | CONFIGFS_ATTR(srpt_tpg_attrib_, srp_sq_size); | ||
3668 | 3661 | ||
3669 | static struct configfs_attribute *srpt_tpg_attrib_attrs[] = { | 3662 | static struct configfs_attribute *srpt_tpg_attrib_attrs[] = { |
3670 | &srpt_tpg_attrib_srp_max_rdma_size.attr, | 3663 | &srpt_tpg_attrib_attr_srp_max_rdma_size, |
3671 | &srpt_tpg_attrib_srp_max_rsp_size.attr, | 3664 | &srpt_tpg_attrib_attr_srp_max_rsp_size, |
3672 | &srpt_tpg_attrib_srp_sq_size.attr, | 3665 | &srpt_tpg_attrib_attr_srp_sq_size, |
3673 | NULL, | 3666 | NULL, |
3674 | }; | 3667 | }; |
3675 | 3668 | ||
3676 | static ssize_t srpt_tpg_show_enable( | 3669 | static ssize_t srpt_tpg_enable_show(struct config_item *item, char *page) |
3677 | struct se_portal_group *se_tpg, | ||
3678 | char *page) | ||
3679 | { | 3670 | { |
3671 | struct se_portal_group *se_tpg = to_tpg(item); | ||
3680 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3672 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3681 | 3673 | ||
3682 | return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0); | 3674 | return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0); |
3683 | } | 3675 | } |
3684 | 3676 | ||
3685 | static ssize_t srpt_tpg_store_enable( | 3677 | static ssize_t srpt_tpg_enable_store(struct config_item *item, |
3686 | struct se_portal_group *se_tpg, | 3678 | const char *page, size_t count) |
3687 | const char *page, | ||
3688 | size_t count) | ||
3689 | { | 3679 | { |
3680 | struct se_portal_group *se_tpg = to_tpg(item); | ||
3690 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); | 3681 | struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); |
3691 | unsigned long tmp; | 3682 | unsigned long tmp; |
3692 | int ret; | 3683 | int ret; |
@@ -3709,10 +3700,10 @@ static ssize_t srpt_tpg_store_enable( | |||
3709 | return count; | 3700 | return count; |
3710 | } | 3701 | } |
3711 | 3702 | ||
3712 | TF_TPG_BASE_ATTR(srpt, enable, S_IRUGO | S_IWUSR); | 3703 | CONFIGFS_ATTR(srpt_tpg_, enable); |
3713 | 3704 | ||
3714 | static struct configfs_attribute *srpt_tpg_attrs[] = { | 3705 | static struct configfs_attribute *srpt_tpg_attrs[] = { |
3715 | &srpt_tpg_enable.attr, | 3706 | &srpt_tpg_attr_enable, |
3716 | NULL, | 3707 | NULL, |
3717 | }; | 3708 | }; |
3718 | 3709 | ||
@@ -3782,16 +3773,15 @@ static void srpt_drop_tport(struct se_wwn *wwn) | |||
3782 | pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item)); | 3773 | pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item)); |
3783 | } | 3774 | } |
3784 | 3775 | ||
3785 | static ssize_t srpt_wwn_show_attr_version(struct target_fabric_configfs *tf, | 3776 | static ssize_t srpt_wwn_version_show(struct config_item *item, char *buf) |
3786 | char *buf) | ||
3787 | { | 3777 | { |
3788 | return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); | 3778 | return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); |
3789 | } | 3779 | } |
3790 | 3780 | ||
3791 | TF_WWN_ATTR_RO(srpt, version); | 3781 | CONFIGFS_ATTR_RO(srpt_wwn_, version); |
3792 | 3782 | ||
3793 | static struct configfs_attribute *srpt_wwn_attrs[] = { | 3783 | static struct configfs_attribute *srpt_wwn_attrs[] = { |
3794 | &srpt_wwn_version.attr, | 3784 | &srpt_wwn_attr_version, |
3795 | NULL, | 3785 | NULL, |
3796 | }; | 3786 | }; |
3797 | 3787 | ||
diff --git a/drivers/misc/spear13xx_pcie_gadget.c b/drivers/misc/spear13xx_pcie_gadget.c index b8374cdaf9c9..ee120dcbb3e6 100644 --- a/drivers/misc/spear13xx_pcie_gadget.c +++ b/drivers/misc/spear13xx_pcie_gadget.c | |||
@@ -220,11 +220,17 @@ static irqreturn_t spear_pcie_gadget_irq(int irq, void *dev_id) | |||
220 | /* | 220 | /* |
221 | * configfs interfaces show/store functions | 221 | * configfs interfaces show/store functions |
222 | */ | 222 | */ |
223 | static ssize_t pcie_gadget_show_link( | 223 | |
224 | struct spear_pcie_gadget_config *config, | 224 | static struct pcie_gadget_target *to_target(struct config_item *item) |
225 | char *buf) | ||
226 | { | 225 | { |
227 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 226 | return item ? |
227 | container_of(to_configfs_subsystem(to_config_group(item)), | ||
228 | struct pcie_gadget_target, subsys) : NULL; | ||
229 | } | ||
230 | |||
231 | static ssize_t pcie_gadget_link_show(struct config_item *item, char *buf) | ||
232 | { | ||
233 | struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; | ||
228 | 234 | ||
229 | if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID)) | 235 | if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID)) |
230 | return sprintf(buf, "UP"); | 236 | return sprintf(buf, "UP"); |
@@ -232,11 +238,10 @@ static ssize_t pcie_gadget_show_link( | |||
232 | return sprintf(buf, "DOWN"); | 238 | return sprintf(buf, "DOWN"); |
233 | } | 239 | } |
234 | 240 | ||
235 | static ssize_t pcie_gadget_store_link( | 241 | static ssize_t pcie_gadget_link_store(struct config_item *item, |
236 | struct spear_pcie_gadget_config *config, | ||
237 | const char *buf, size_t count) | 242 | const char *buf, size_t count) |
238 | { | 243 | { |
239 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 244 | struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; |
240 | 245 | ||
241 | if (sysfs_streq(buf, "UP")) | 246 | if (sysfs_streq(buf, "UP")) |
242 | writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID), | 247 | writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID), |
@@ -250,17 +255,15 @@ static ssize_t pcie_gadget_store_link( | |||
250 | return count; | 255 | return count; |
251 | } | 256 | } |
252 | 257 | ||
253 | static ssize_t pcie_gadget_show_int_type( | 258 | static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf) |
254 | struct spear_pcie_gadget_config *config, | ||
255 | char *buf) | ||
256 | { | 259 | { |
257 | return sprintf(buf, "%s", config->int_type); | 260 | return sprintf(buf, "%s", to_target(item)->int_type); |
258 | } | 261 | } |
259 | 262 | ||
260 | static ssize_t pcie_gadget_store_int_type( | 263 | static ssize_t pcie_gadget_int_type_store(struct config_item *item, |
261 | struct spear_pcie_gadget_config *config, | ||
262 | const char *buf, size_t count) | 264 | const char *buf, size_t count) |
263 | { | 265 | { |
266 | struct spear_pcie_gadget_config *config = to_target(item) | ||
264 | u32 cap, vec, flags; | 267 | u32 cap, vec, flags; |
265 | ulong vector; | 268 | ulong vector; |
266 | 269 | ||
@@ -288,11 +291,10 @@ static ssize_t pcie_gadget_store_int_type( | |||
288 | return count; | 291 | return count; |
289 | } | 292 | } |
290 | 293 | ||
291 | static ssize_t pcie_gadget_show_no_of_msi( | 294 | static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf) |
292 | struct spear_pcie_gadget_config *config, | ||
293 | char *buf) | ||
294 | { | 295 | { |
295 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 296 | struct spear_pcie_gadget_config *config = to_target(item) |
297 | struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; | ||
296 | u32 cap, vec, flags; | 298 | u32 cap, vec, flags; |
297 | ulong vector; | 299 | ulong vector; |
298 | 300 | ||
@@ -313,13 +315,12 @@ static ssize_t pcie_gadget_show_no_of_msi( | |||
313 | return sprintf(buf, "%lu", vector); | 315 | return sprintf(buf, "%lu", vector); |
314 | } | 316 | } |
315 | 317 | ||
316 | static ssize_t pcie_gadget_store_no_of_msi( | 318 | static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item, |
317 | struct spear_pcie_gadget_config *config, | ||
318 | const char *buf, size_t count) | 319 | const char *buf, size_t count) |
319 | { | 320 | { |
320 | int ret; | 321 | int ret; |
321 | 322 | ||
322 | ret = kstrtoul(buf, 0, &config->requested_msi); | 323 | ret = kstrtoul(buf, 0, &to_target(item)->requested_msi); |
323 | if (ret) | 324 | if (ret) |
324 | return ret; | 325 | return ret; |
325 | 326 | ||
@@ -329,11 +330,10 @@ static ssize_t pcie_gadget_store_no_of_msi( | |||
329 | return count; | 330 | return count; |
330 | } | 331 | } |
331 | 332 | ||
332 | static ssize_t pcie_gadget_store_inta( | 333 | static ssize_t pcie_gadget_inta_store(struct config_item *item, |
333 | struct spear_pcie_gadget_config *config, | ||
334 | const char *buf, size_t count) | 334 | const char *buf, size_t count) |
335 | { | 335 | { |
336 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 336 | struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; |
337 | ulong en; | 337 | ulong en; |
338 | int ret; | 338 | int ret; |
339 | 339 | ||
@@ -351,10 +351,10 @@ static ssize_t pcie_gadget_store_inta( | |||
351 | return count; | 351 | return count; |
352 | } | 352 | } |
353 | 353 | ||
354 | static ssize_t pcie_gadget_store_send_msi( | 354 | static ssize_t pcie_gadget_send_msi_store(struct config_item *item, |
355 | struct spear_pcie_gadget_config *config, | ||
356 | const char *buf, size_t count) | 355 | const char *buf, size_t count) |
357 | { | 356 | { |
357 | struct spear_pcie_gadget_config *config = to_target(item) | ||
358 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 358 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; |
359 | ulong vector; | 359 | ulong vector; |
360 | u32 ven_msi; | 360 | u32 ven_msi; |
@@ -388,19 +388,16 @@ static ssize_t pcie_gadget_store_send_msi( | |||
388 | return count; | 388 | return count; |
389 | } | 389 | } |
390 | 390 | ||
391 | static ssize_t pcie_gadget_show_vendor_id( | 391 | static ssize_t pcie_gadget_vendor_id_show(struct config_item *item, char *buf) |
392 | struct spear_pcie_gadget_config *config, | ||
393 | char *buf) | ||
394 | { | 392 | { |
395 | u32 id; | 393 | u32 id; |
396 | 394 | ||
397 | spear_dbi_read_reg(config, PCI_VENDOR_ID, 2, &id); | 395 | spear_dbi_read_reg(to_target(item), PCI_VENDOR_ID, 2, &id); |
398 | 396 | ||
399 | return sprintf(buf, "%x", id); | 397 | return sprintf(buf, "%x", id); |
400 | } | 398 | } |
401 | 399 | ||
402 | static ssize_t pcie_gadget_store_vendor_id( | 400 | static ssize_t pcie_gadget_vendor_id_store(struct config_item *item, |
403 | struct spear_pcie_gadget_config *config, | ||
404 | const char *buf, size_t count) | 401 | const char *buf, size_t count) |
405 | { | 402 | { |
406 | ulong id; | 403 | ulong id; |
@@ -410,24 +407,21 @@ static ssize_t pcie_gadget_store_vendor_id( | |||
410 | if (ret) | 407 | if (ret) |
411 | return ret; | 408 | return ret; |
412 | 409 | ||
413 | spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id); | 410 | spear_dbi_write_reg(to_target(item), PCI_VENDOR_ID, 2, id); |
414 | 411 | ||
415 | return count; | 412 | return count; |
416 | } | 413 | } |
417 | 414 | ||
418 | static ssize_t pcie_gadget_show_device_id( | 415 | static ssize_t pcie_gadget_device_id_show(struct config_item *item, char *buf) |
419 | struct spear_pcie_gadget_config *config, | ||
420 | char *buf) | ||
421 | { | 416 | { |
422 | u32 id; | 417 | u32 id; |
423 | 418 | ||
424 | spear_dbi_read_reg(config, PCI_DEVICE_ID, 2, &id); | 419 | spear_dbi_read_reg(to_target(item), PCI_DEVICE_ID, 2, &id); |
425 | 420 | ||
426 | return sprintf(buf, "%x", id); | 421 | return sprintf(buf, "%x", id); |
427 | } | 422 | } |
428 | 423 | ||
429 | static ssize_t pcie_gadget_store_device_id( | 424 | static ssize_t pcie_gadget_device_id_store(struct config_item *item, |
430 | struct spear_pcie_gadget_config *config, | ||
431 | const char *buf, size_t count) | 425 | const char *buf, size_t count) |
432 | { | 426 | { |
433 | ulong id; | 427 | ulong id; |
@@ -437,22 +431,20 @@ static ssize_t pcie_gadget_store_device_id( | |||
437 | if (ret) | 431 | if (ret) |
438 | return ret; | 432 | return ret; |
439 | 433 | ||
440 | spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id); | 434 | spear_dbi_write_reg(to_target(item), PCI_DEVICE_ID, 2, id); |
441 | 435 | ||
442 | return count; | 436 | return count; |
443 | } | 437 | } |
444 | 438 | ||
445 | static ssize_t pcie_gadget_show_bar0_size( | 439 | static ssize_t pcie_gadget_bar0_size_show(struct config_item *item, char *buf) |
446 | struct spear_pcie_gadget_config *config, | ||
447 | char *buf) | ||
448 | { | 440 | { |
449 | return sprintf(buf, "%lx", config->bar0_size); | 441 | return sprintf(buf, "%lx", to_target(item)->bar0_size); |
450 | } | 442 | } |
451 | 443 | ||
452 | static ssize_t pcie_gadget_store_bar0_size( | 444 | static ssize_t pcie_gadget_bar0_size_store(struct config_item *item, |
453 | struct spear_pcie_gadget_config *config, | ||
454 | const char *buf, size_t count) | 445 | const char *buf, size_t count) |
455 | { | 446 | { |
447 | struct spear_pcie_gadget_config *config = to_target(item) | ||
456 | ulong size; | 448 | ulong size; |
457 | u32 pos, pos1; | 449 | u32 pos, pos1; |
458 | u32 no_of_bit = 0; | 450 | u32 no_of_bit = 0; |
@@ -489,21 +481,20 @@ static ssize_t pcie_gadget_store_bar0_size( | |||
489 | return count; | 481 | return count; |
490 | } | 482 | } |
491 | 483 | ||
492 | static ssize_t pcie_gadget_show_bar0_address( | 484 | static ssize_t pcie_gadget_bar0_address_show(struct config_item *item, |
493 | struct spear_pcie_gadget_config *config, | ||
494 | char *buf) | 485 | char *buf) |
495 | { | 486 | { |
496 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 487 | struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; |
497 | 488 | ||
498 | u32 address = readl(&app_reg->pim0_mem_addr_start); | 489 | u32 address = readl(&app_reg->pim0_mem_addr_start); |
499 | 490 | ||
500 | return sprintf(buf, "%x", address); | 491 | return sprintf(buf, "%x", address); |
501 | } | 492 | } |
502 | 493 | ||
503 | static ssize_t pcie_gadget_store_bar0_address( | 494 | static ssize_t pcie_gadget_bar0_address_store(struct config_item *item, |
504 | struct spear_pcie_gadget_config *config, | ||
505 | const char *buf, size_t count) | 495 | const char *buf, size_t count) |
506 | { | 496 | { |
497 | struct spear_pcie_gadget_config *config = to_target(item) | ||
507 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; | 498 | struct pcie_app_reg __iomem *app_reg = config->va_app_base; |
508 | ulong address; | 499 | ulong address; |
509 | int ret; | 500 | int ret; |
@@ -524,15 +515,13 @@ static ssize_t pcie_gadget_store_bar0_address( | |||
524 | return count; | 515 | return count; |
525 | } | 516 | } |
526 | 517 | ||
527 | static ssize_t pcie_gadget_show_bar0_rw_offset( | 518 | static ssize_t pcie_gadget_bar0_rw_offset_show(struct config_item *item, |
528 | struct spear_pcie_gadget_config *config, | ||
529 | char *buf) | 519 | char *buf) |
530 | { | 520 | { |
531 | return sprintf(buf, "%lx", config->bar0_rw_offset); | 521 | return sprintf(buf, "%lx", to_target(item)->bar0_rw_offset); |
532 | } | 522 | } |
533 | 523 | ||
534 | static ssize_t pcie_gadget_store_bar0_rw_offset( | 524 | static ssize_t pcie_gadget_bar0_rw_offset_store(struct config_item *item, |
535 | struct spear_pcie_gadget_config *config, | ||
536 | const char *buf, size_t count) | 525 | const char *buf, size_t count) |
537 | { | 526 | { |
538 | ulong offset; | 527 | ulong offset; |
@@ -545,15 +534,14 @@ static ssize_t pcie_gadget_store_bar0_rw_offset( | |||
545 | if (offset % 4) | 534 | if (offset % 4) |
546 | return -EINVAL; | 535 | return -EINVAL; |
547 | 536 | ||
548 | config->bar0_rw_offset = offset; | 537 | to_target(item)->bar0_rw_offset = offset; |
549 | 538 | ||
550 | return count; | 539 | return count; |
551 | } | 540 | } |
552 | 541 | ||
553 | static ssize_t pcie_gadget_show_bar0_data( | 542 | static ssize_t pcie_gadget_bar0_data_show(struct config_item *item, char *buf) |
554 | struct spear_pcie_gadget_config *config, | ||
555 | char *buf) | ||
556 | { | 543 | { |
544 | struct spear_pcie_gadget_config *config = to_target(item) | ||
557 | ulong data; | 545 | ulong data; |
558 | 546 | ||
559 | if (!config->va_bar0_address) | 547 | if (!config->va_bar0_address) |
@@ -564,10 +552,10 @@ static ssize_t pcie_gadget_show_bar0_data( | |||
564 | return sprintf(buf, "%lx", data); | 552 | return sprintf(buf, "%lx", data); |
565 | } | 553 | } |
566 | 554 | ||
567 | static ssize_t pcie_gadget_store_bar0_data( | 555 | static ssize_t pcie_gadget_bar0_data_store(struct config_item *item, |
568 | struct spear_pcie_gadget_config *config, | ||
569 | const char *buf, size_t count) | 556 | const char *buf, size_t count) |
570 | { | 557 | { |
558 | struct spear_pcie_gadget_config *config = to_target(item) | ||
571 | ulong data; | 559 | ulong data; |
572 | int ret; | 560 | int ret; |
573 | 561 | ||
@@ -583,97 +571,35 @@ static ssize_t pcie_gadget_store_bar0_data( | |||
583 | return count; | 571 | return count; |
584 | } | 572 | } |
585 | 573 | ||
586 | /* | 574 | CONFIGFS_ATTR(pcie_gadget_, link); |
587 | * Attribute definitions. | 575 | CONFIGFS_ATTR(pcie_gadget_, int_type); |
588 | */ | 576 | CONFIGFS_ATTR(pcie_gadget_, no_of_msi); |
589 | 577 | CONFIGFS_ATTR_WO(pcie_gadget_, inta); | |
590 | #define PCIE_GADGET_TARGET_ATTR_RO(_name) \ | 578 | CONFIGFS_ATTR_WO(pcie_gadget_, send_msi); |
591 | static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ | 579 | CONFIGFS_ATTR(pcie_gadget_, vendor_id); |
592 | __CONFIGFS_ATTR(_name, S_IRUGO, pcie_gadget_show_##_name, NULL) | 580 | CONFIGFS_ATTR(pcie_gadget_, device_id); |
593 | 581 | CONFIGFS_ATTR(pcie_gadget_, bar0_size); | |
594 | #define PCIE_GADGET_TARGET_ATTR_WO(_name) \ | 582 | CONFIGFS_ATTR(pcie_gadget_, bar0_address); |
595 | static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ | 583 | CONFIGFS_ATTR(pcie_gadget_, bar0_rw_offset); |
596 | __CONFIGFS_ATTR(_name, S_IWUSR, NULL, pcie_gadget_store_##_name) | 584 | CONFIGFS_ATTR(pcie_gadget_, bar0_data); |
597 | |||
598 | #define PCIE_GADGET_TARGET_ATTR_RW(_name) \ | ||
599 | static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ | ||
600 | __CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, pcie_gadget_show_##_name, \ | ||
601 | pcie_gadget_store_##_name) | ||
602 | PCIE_GADGET_TARGET_ATTR_RW(link); | ||
603 | PCIE_GADGET_TARGET_ATTR_RW(int_type); | ||
604 | PCIE_GADGET_TARGET_ATTR_RW(no_of_msi); | ||
605 | PCIE_GADGET_TARGET_ATTR_WO(inta); | ||
606 | PCIE_GADGET_TARGET_ATTR_WO(send_msi); | ||
607 | PCIE_GADGET_TARGET_ATTR_RW(vendor_id); | ||
608 | PCIE_GADGET_TARGET_ATTR_RW(device_id); | ||
609 | PCIE_GADGET_TARGET_ATTR_RW(bar0_size); | ||
610 | PCIE_GADGET_TARGET_ATTR_RW(bar0_address); | ||
611 | PCIE_GADGET_TARGET_ATTR_RW(bar0_rw_offset); | ||
612 | PCIE_GADGET_TARGET_ATTR_RW(bar0_data); | ||
613 | 585 | ||
614 | static struct configfs_attribute *pcie_gadget_target_attrs[] = { | 586 | static struct configfs_attribute *pcie_gadget_target_attrs[] = { |
615 | &pcie_gadget_target_link.attr, | 587 | &pcie_gadget_attr_link, |
616 | &pcie_gadget_target_int_type.attr, | 588 | &pcie_gadget_attr_int_type, |
617 | &pcie_gadget_target_no_of_msi.attr, | 589 | &pcie_gadget_attr_no_of_msi, |
618 | &pcie_gadget_target_inta.attr, | 590 | &pcie_gadget_attr_inta, |
619 | &pcie_gadget_target_send_msi.attr, | 591 | &pcie_gadget_attr_send_msi, |
620 | &pcie_gadget_target_vendor_id.attr, | 592 | &pcie_gadget_attr_vendor_id, |
621 | &pcie_gadget_target_device_id.attr, | 593 | &pcie_gadget_attr_device_id, |
622 | &pcie_gadget_target_bar0_size.attr, | 594 | &pcie_gadget_attr_bar0_size, |
623 | &pcie_gadget_target_bar0_address.attr, | 595 | &pcie_gadget_attr_bar0_address, |
624 | &pcie_gadget_target_bar0_rw_offset.attr, | 596 | &pcie_gadget_attr_bar0_rw_offset, |
625 | &pcie_gadget_target_bar0_data.attr, | 597 | &pcie_gadget_attr_bar0_data, |
626 | NULL, | 598 | NULL, |
627 | }; | 599 | }; |
628 | 600 | ||
629 | static struct pcie_gadget_target *to_target(struct config_item *item) | ||
630 | { | ||
631 | return item ? | ||
632 | container_of(to_configfs_subsystem(to_config_group(item)), | ||
633 | struct pcie_gadget_target, subsys) : NULL; | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Item operations and type for pcie_gadget_target. | ||
638 | */ | ||
639 | |||
640 | static ssize_t pcie_gadget_target_attr_show(struct config_item *item, | ||
641 | struct configfs_attribute *attr, | ||
642 | char *buf) | ||
643 | { | ||
644 | ssize_t ret = -EINVAL; | ||
645 | struct pcie_gadget_target *target = to_target(item); | ||
646 | struct pcie_gadget_target_attr *t_attr = | ||
647 | container_of(attr, struct pcie_gadget_target_attr, attr); | ||
648 | |||
649 | if (t_attr->show) | ||
650 | ret = t_attr->show(&target->config, buf); | ||
651 | return ret; | ||
652 | } | ||
653 | |||
654 | static ssize_t pcie_gadget_target_attr_store(struct config_item *item, | ||
655 | struct configfs_attribute *attr, | ||
656 | const char *buf, | ||
657 | size_t count) | ||
658 | { | ||
659 | ssize_t ret = -EINVAL; | ||
660 | struct pcie_gadget_target *target = to_target(item); | ||
661 | struct pcie_gadget_target_attr *t_attr = | ||
662 | container_of(attr, struct pcie_gadget_target_attr, attr); | ||
663 | |||
664 | if (t_attr->store) | ||
665 | ret = t_attr->store(&target->config, buf, count); | ||
666 | return ret; | ||
667 | } | ||
668 | |||
669 | static struct configfs_item_operations pcie_gadget_target_item_ops = { | ||
670 | .show_attribute = pcie_gadget_target_attr_show, | ||
671 | .store_attribute = pcie_gadget_target_attr_store, | ||
672 | }; | ||
673 | |||
674 | static struct config_item_type pcie_gadget_target_type = { | 601 | static struct config_item_type pcie_gadget_target_type = { |
675 | .ct_attrs = pcie_gadget_target_attrs, | 602 | .ct_attrs = pcie_gadget_target_attrs, |
676 | .ct_item_ops = &pcie_gadget_target_item_ops, | ||
677 | .ct_owner = THIS_MODULE, | 603 | .ct_owner = THIS_MODULE, |
678 | }; | 604 | }; |
679 | 605 | ||
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 97f3acd44798..06ee6395117f 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
@@ -244,15 +244,6 @@ static void free_param_target(struct netconsole_target *nt) | |||
244 | * <target>/... | 244 | * <target>/... |
245 | */ | 245 | */ |
246 | 246 | ||
247 | struct netconsole_target_attr { | ||
248 | struct configfs_attribute attr; | ||
249 | ssize_t (*show)(struct netconsole_target *nt, | ||
250 | char *buf); | ||
251 | ssize_t (*store)(struct netconsole_target *nt, | ||
252 | const char *buf, | ||
253 | size_t count); | ||
254 | }; | ||
255 | |||
256 | static struct netconsole_target *to_target(struct config_item *item) | 247 | static struct netconsole_target *to_target(struct config_item *item) |
257 | { | 248 | { |
258 | return item ? | 249 | return item ? |
@@ -264,58 +255,62 @@ static struct netconsole_target *to_target(struct config_item *item) | |||
264 | * Attribute operations for netconsole_target. | 255 | * Attribute operations for netconsole_target. |
265 | */ | 256 | */ |
266 | 257 | ||
267 | static ssize_t show_enabled(struct netconsole_target *nt, char *buf) | 258 | static ssize_t enabled_show(struct config_item *item, char *buf) |
268 | { | 259 | { |
269 | return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled); | 260 | return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled); |
270 | } | 261 | } |
271 | 262 | ||
272 | static ssize_t show_extended(struct netconsole_target *nt, char *buf) | 263 | static ssize_t extended_show(struct config_item *item, char *buf) |
273 | { | 264 | { |
274 | return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended); | 265 | return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended); |
275 | } | 266 | } |
276 | 267 | ||
277 | static ssize_t show_dev_name(struct netconsole_target *nt, char *buf) | 268 | static ssize_t dev_name_show(struct config_item *item, char *buf) |
278 | { | 269 | { |
279 | return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name); | 270 | return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name); |
280 | } | 271 | } |
281 | 272 | ||
282 | static ssize_t show_local_port(struct netconsole_target *nt, char *buf) | 273 | static ssize_t local_port_show(struct config_item *item, char *buf) |
283 | { | 274 | { |
284 | return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port); | 275 | return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port); |
285 | } | 276 | } |
286 | 277 | ||
287 | static ssize_t show_remote_port(struct netconsole_target *nt, char *buf) | 278 | static ssize_t remote_port_show(struct config_item *item, char *buf) |
288 | { | 279 | { |
289 | return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port); | 280 | return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.remote_port); |
290 | } | 281 | } |
291 | 282 | ||
292 | static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) | 283 | static ssize_t local_ip_show(struct config_item *item, char *buf) |
293 | { | 284 | { |
285 | struct netconsole_target *nt = to_target(item); | ||
286 | |||
294 | if (nt->np.ipv6) | 287 | if (nt->np.ipv6) |
295 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); | 288 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); |
296 | else | 289 | else |
297 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); | 290 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); |
298 | } | 291 | } |
299 | 292 | ||
300 | static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) | 293 | static ssize_t remote_ip_show(struct config_item *item, char *buf) |
301 | { | 294 | { |
295 | struct netconsole_target *nt = to_target(item); | ||
296 | |||
302 | if (nt->np.ipv6) | 297 | if (nt->np.ipv6) |
303 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); | 298 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); |
304 | else | 299 | else |
305 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); | 300 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); |
306 | } | 301 | } |
307 | 302 | ||
308 | static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) | 303 | static ssize_t local_mac_show(struct config_item *item, char *buf) |
309 | { | 304 | { |
310 | struct net_device *dev = nt->np.dev; | 305 | struct net_device *dev = to_target(item)->np.dev; |
311 | static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 306 | static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
312 | 307 | ||
313 | return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast); | 308 | return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast); |
314 | } | 309 | } |
315 | 310 | ||
316 | static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) | 311 | static ssize_t remote_mac_show(struct config_item *item, char *buf) |
317 | { | 312 | { |
318 | return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac); | 313 | return snprintf(buf, PAGE_SIZE, "%pM\n", to_target(item)->np.remote_mac); |
319 | } | 314 | } |
320 | 315 | ||
321 | /* | 316 | /* |
@@ -325,23 +320,26 @@ static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) | |||
325 | * would enable him to dynamically add new netpoll targets for new | 320 | * would enable him to dynamically add new netpoll targets for new |
326 | * network interfaces as and when they come up). | 321 | * network interfaces as and when they come up). |
327 | */ | 322 | */ |
328 | static ssize_t store_enabled(struct netconsole_target *nt, | 323 | static ssize_t enabled_store(struct config_item *item, |
329 | const char *buf, | 324 | const char *buf, size_t count) |
330 | size_t count) | ||
331 | { | 325 | { |
326 | struct netconsole_target *nt = to_target(item); | ||
332 | unsigned long flags; | 327 | unsigned long flags; |
333 | int enabled; | 328 | int enabled; |
334 | int err; | 329 | int err; |
335 | 330 | ||
331 | mutex_lock(&dynamic_netconsole_mutex); | ||
336 | err = kstrtoint(buf, 10, &enabled); | 332 | err = kstrtoint(buf, 10, &enabled); |
337 | if (err < 0) | 333 | if (err < 0) |
338 | return err; | 334 | goto out_unlock; |
335 | |||
336 | err = -EINVAL; | ||
339 | if (enabled < 0 || enabled > 1) | 337 | if (enabled < 0 || enabled > 1) |
340 | return -EINVAL; | 338 | goto out_unlock; |
341 | if ((bool)enabled == nt->enabled) { | 339 | if ((bool)enabled == nt->enabled) { |
342 | pr_info("network logging has already %s\n", | 340 | pr_info("network logging has already %s\n", |
343 | nt->enabled ? "started" : "stopped"); | 341 | nt->enabled ? "started" : "stopped"); |
344 | return -EINVAL; | 342 | goto out_unlock; |
345 | } | 343 | } |
346 | 344 | ||
347 | if (enabled) { /* true */ | 345 | if (enabled) { /* true */ |
@@ -358,7 +356,7 @@ static ssize_t store_enabled(struct netconsole_target *nt, | |||
358 | 356 | ||
359 | err = netpoll_setup(&nt->np); | 357 | err = netpoll_setup(&nt->np); |
360 | if (err) | 358 | if (err) |
361 | return err; | 359 | goto out_unlock; |
362 | 360 | ||
363 | pr_info("netconsole: network logging started\n"); | 361 | pr_info("netconsole: network logging started\n"); |
364 | } else { /* false */ | 362 | } else { /* false */ |
@@ -374,42 +372,56 @@ static ssize_t store_enabled(struct netconsole_target *nt, | |||
374 | 372 | ||
375 | nt->enabled = enabled; | 373 | nt->enabled = enabled; |
376 | 374 | ||
375 | mutex_unlock(&dynamic_netconsole_mutex); | ||
377 | return strnlen(buf, count); | 376 | return strnlen(buf, count); |
377 | out_unlock: | ||
378 | mutex_unlock(&dynamic_netconsole_mutex); | ||
379 | return err; | ||
378 | } | 380 | } |
379 | 381 | ||
380 | static ssize_t store_extended(struct netconsole_target *nt, | 382 | static ssize_t extended_store(struct config_item *item, const char *buf, |
381 | const char *buf, | 383 | size_t count) |
382 | size_t count) | ||
383 | { | 384 | { |
385 | struct netconsole_target *nt = to_target(item); | ||
384 | int extended; | 386 | int extended; |
385 | int err; | 387 | int err; |
386 | 388 | ||
389 | mutex_lock(&dynamic_netconsole_mutex); | ||
387 | if (nt->enabled) { | 390 | if (nt->enabled) { |
388 | pr_err("target (%s) is enabled, disable to update parameters\n", | 391 | pr_err("target (%s) is enabled, disable to update parameters\n", |
389 | config_item_name(&nt->item)); | 392 | config_item_name(&nt->item)); |
390 | return -EINVAL; | 393 | err = -EINVAL; |
394 | goto out_unlock; | ||
391 | } | 395 | } |
392 | 396 | ||
393 | err = kstrtoint(buf, 10, &extended); | 397 | err = kstrtoint(buf, 10, &extended); |
394 | if (err < 0) | 398 | if (err < 0) |
395 | return err; | 399 | goto out_unlock; |
396 | if (extended < 0 || extended > 1) | 400 | if (extended < 0 || extended > 1) { |
397 | return -EINVAL; | 401 | err = -EINVAL; |
402 | goto out_unlock; | ||
403 | } | ||
398 | 404 | ||
399 | nt->extended = extended; | 405 | nt->extended = extended; |
400 | 406 | ||
407 | mutex_unlock(&dynamic_netconsole_mutex); | ||
401 | return strnlen(buf, count); | 408 | return strnlen(buf, count); |
409 | out_unlock: | ||
410 | mutex_unlock(&dynamic_netconsole_mutex); | ||
411 | return err; | ||
402 | } | 412 | } |
403 | 413 | ||
404 | static ssize_t store_dev_name(struct netconsole_target *nt, | 414 | static ssize_t dev_name_store(struct config_item *item, const char *buf, |
405 | const char *buf, | 415 | size_t count) |
406 | size_t count) | ||
407 | { | 416 | { |
417 | struct netconsole_target *nt = to_target(item); | ||
408 | size_t len; | 418 | size_t len; |
409 | 419 | ||
420 | mutex_lock(&dynamic_netconsole_mutex); | ||
410 | if (nt->enabled) { | 421 | if (nt->enabled) { |
411 | pr_err("target (%s) is enabled, disable to update parameters\n", | 422 | pr_err("target (%s) is enabled, disable to update parameters\n", |
412 | config_item_name(&nt->item)); | 423 | config_item_name(&nt->item)); |
424 | mutex_unlock(&dynamic_netconsole_mutex); | ||
413 | return -EINVAL; | 425 | return -EINVAL; |
414 | } | 426 | } |
415 | 427 | ||
@@ -420,53 +432,66 @@ static ssize_t store_dev_name(struct netconsole_target *nt, | |||
420 | if (nt->np.dev_name[len - 1] == '\n') | 432 | if (nt->np.dev_name[len - 1] == '\n') |
421 | nt->np.dev_name[len - 1] = '\0'; | 433 | nt->np.dev_name[len - 1] = '\0'; |
422 | 434 | ||
435 | mutex_unlock(&dynamic_netconsole_mutex); | ||
423 | return strnlen(buf, count); | 436 | return strnlen(buf, count); |
424 | } | 437 | } |
425 | 438 | ||
426 | static ssize_t store_local_port(struct netconsole_target *nt, | 439 | static ssize_t local_port_store(struct config_item *item, const char *buf, |
427 | const char *buf, | 440 | size_t count) |
428 | size_t count) | ||
429 | { | 441 | { |
430 | int rv; | 442 | struct netconsole_target *nt = to_target(item); |
443 | int rv = -EINVAL; | ||
431 | 444 | ||
445 | mutex_lock(&dynamic_netconsole_mutex); | ||
432 | if (nt->enabled) { | 446 | if (nt->enabled) { |
433 | pr_err("target (%s) is enabled, disable to update parameters\n", | 447 | pr_err("target (%s) is enabled, disable to update parameters\n", |
434 | config_item_name(&nt->item)); | 448 | config_item_name(&nt->item)); |
435 | return -EINVAL; | 449 | goto out_unlock; |
436 | } | 450 | } |
437 | 451 | ||
438 | rv = kstrtou16(buf, 10, &nt->np.local_port); | 452 | rv = kstrtou16(buf, 10, &nt->np.local_port); |
439 | if (rv < 0) | 453 | if (rv < 0) |
440 | return rv; | 454 | goto out_unlock; |
455 | mutex_unlock(&dynamic_netconsole_mutex); | ||
441 | return strnlen(buf, count); | 456 | return strnlen(buf, count); |
457 | out_unlock: | ||
458 | mutex_unlock(&dynamic_netconsole_mutex); | ||
459 | return rv; | ||
442 | } | 460 | } |
443 | 461 | ||
444 | static ssize_t store_remote_port(struct netconsole_target *nt, | 462 | static ssize_t remote_port_store(struct config_item *item, |
445 | const char *buf, | 463 | const char *buf, size_t count) |
446 | size_t count) | ||
447 | { | 464 | { |
448 | int rv; | 465 | struct netconsole_target *nt = to_target(item); |
466 | int rv = -EINVAL; | ||
449 | 467 | ||
468 | mutex_lock(&dynamic_netconsole_mutex); | ||
450 | if (nt->enabled) { | 469 | if (nt->enabled) { |
451 | pr_err("target (%s) is enabled, disable to update parameters\n", | 470 | pr_err("target (%s) is enabled, disable to update parameters\n", |
452 | config_item_name(&nt->item)); | 471 | config_item_name(&nt->item)); |
453 | return -EINVAL; | 472 | goto out_unlock; |
454 | } | 473 | } |
455 | 474 | ||
456 | rv = kstrtou16(buf, 10, &nt->np.remote_port); | 475 | rv = kstrtou16(buf, 10, &nt->np.remote_port); |
457 | if (rv < 0) | 476 | if (rv < 0) |
458 | return rv; | 477 | goto out_unlock; |
478 | mutex_unlock(&dynamic_netconsole_mutex); | ||
459 | return strnlen(buf, count); | 479 | return strnlen(buf, count); |
480 | out_unlock: | ||
481 | mutex_unlock(&dynamic_netconsole_mutex); | ||
482 | return rv; | ||
460 | } | 483 | } |
461 | 484 | ||
462 | static ssize_t store_local_ip(struct netconsole_target *nt, | 485 | static ssize_t local_ip_store(struct config_item *item, const char *buf, |
463 | const char *buf, | 486 | size_t count) |
464 | size_t count) | ||
465 | { | 487 | { |
488 | struct netconsole_target *nt = to_target(item); | ||
489 | |||
490 | mutex_lock(&dynamic_netconsole_mutex); | ||
466 | if (nt->enabled) { | 491 | if (nt->enabled) { |
467 | pr_err("target (%s) is enabled, disable to update parameters\n", | 492 | pr_err("target (%s) is enabled, disable to update parameters\n", |
468 | config_item_name(&nt->item)); | 493 | config_item_name(&nt->item)); |
469 | return -EINVAL; | 494 | goto out_unlock; |
470 | } | 495 | } |
471 | 496 | ||
472 | if (strnchr(buf, count, ':')) { | 497 | if (strnchr(buf, count, ':')) { |
@@ -474,29 +499,35 @@ static ssize_t store_local_ip(struct netconsole_target *nt, | |||
474 | if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { | 499 | if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { |
475 | if (*end && *end != '\n') { | 500 | if (*end && *end != '\n') { |
476 | pr_err("invalid IPv6 address at: <%c>\n", *end); | 501 | pr_err("invalid IPv6 address at: <%c>\n", *end); |
477 | return -EINVAL; | 502 | goto out_unlock; |
478 | } | 503 | } |
479 | nt->np.ipv6 = true; | 504 | nt->np.ipv6 = true; |
480 | } else | 505 | } else |
481 | return -EINVAL; | 506 | goto out_unlock; |
482 | } else { | 507 | } else { |
483 | if (!nt->np.ipv6) { | 508 | if (!nt->np.ipv6) { |
484 | nt->np.local_ip.ip = in_aton(buf); | 509 | nt->np.local_ip.ip = in_aton(buf); |
485 | } else | 510 | } else |
486 | return -EINVAL; | 511 | goto out_unlock; |
487 | } | 512 | } |
488 | 513 | ||
514 | mutex_unlock(&dynamic_netconsole_mutex); | ||
489 | return strnlen(buf, count); | 515 | return strnlen(buf, count); |
516 | out_unlock: | ||
517 | mutex_unlock(&dynamic_netconsole_mutex); | ||
518 | return -EINVAL; | ||
490 | } | 519 | } |
491 | 520 | ||
492 | static ssize_t store_remote_ip(struct netconsole_target *nt, | 521 | static ssize_t remote_ip_store(struct config_item *item, const char *buf, |
493 | const char *buf, | 522 | size_t count) |
494 | size_t count) | ||
495 | { | 523 | { |
524 | struct netconsole_target *nt = to_target(item); | ||
525 | |||
526 | mutex_lock(&dynamic_netconsole_mutex); | ||
496 | if (nt->enabled) { | 527 | if (nt->enabled) { |
497 | pr_err("target (%s) is enabled, disable to update parameters\n", | 528 | pr_err("target (%s) is enabled, disable to update parameters\n", |
498 | config_item_name(&nt->item)); | 529 | config_item_name(&nt->item)); |
499 | return -EINVAL; | 530 | goto out_unlock; |
500 | } | 531 | } |
501 | 532 | ||
502 | if (strnchr(buf, count, ':')) { | 533 | if (strnchr(buf, count, ':')) { |
@@ -504,74 +535,71 @@ static ssize_t store_remote_ip(struct netconsole_target *nt, | |||
504 | if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { | 535 | if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { |
505 | if (*end && *end != '\n') { | 536 | if (*end && *end != '\n') { |
506 | pr_err("invalid IPv6 address at: <%c>\n", *end); | 537 | pr_err("invalid IPv6 address at: <%c>\n", *end); |
507 | return -EINVAL; | 538 | goto out_unlock; |
508 | } | 539 | } |
509 | nt->np.ipv6 = true; | 540 | nt->np.ipv6 = true; |
510 | } else | 541 | } else |
511 | return -EINVAL; | 542 | goto out_unlock; |
512 | } else { | 543 | } else { |
513 | if (!nt->np.ipv6) { | 544 | if (!nt->np.ipv6) { |
514 | nt->np.remote_ip.ip = in_aton(buf); | 545 | nt->np.remote_ip.ip = in_aton(buf); |
515 | } else | 546 | } else |
516 | return -EINVAL; | 547 | goto out_unlock; |
517 | } | 548 | } |
518 | 549 | ||
550 | mutex_unlock(&dynamic_netconsole_mutex); | ||
519 | return strnlen(buf, count); | 551 | return strnlen(buf, count); |
552 | out_unlock: | ||
553 | mutex_unlock(&dynamic_netconsole_mutex); | ||
554 | return -EINVAL; | ||
520 | } | 555 | } |
521 | 556 | ||
522 | static ssize_t store_remote_mac(struct netconsole_target *nt, | 557 | static ssize_t remote_mac_store(struct config_item *item, const char *buf, |
523 | const char *buf, | 558 | size_t count) |
524 | size_t count) | ||
525 | { | 559 | { |
560 | struct netconsole_target *nt = to_target(item); | ||
526 | u8 remote_mac[ETH_ALEN]; | 561 | u8 remote_mac[ETH_ALEN]; |
527 | 562 | ||
563 | mutex_lock(&dynamic_netconsole_mutex); | ||
528 | if (nt->enabled) { | 564 | if (nt->enabled) { |
529 | pr_err("target (%s) is enabled, disable to update parameters\n", | 565 | pr_err("target (%s) is enabled, disable to update parameters\n", |
530 | config_item_name(&nt->item)); | 566 | config_item_name(&nt->item)); |
531 | return -EINVAL; | 567 | goto out_unlock; |
532 | } | 568 | } |
533 | 569 | ||
534 | if (!mac_pton(buf, remote_mac)) | 570 | if (!mac_pton(buf, remote_mac)) |
535 | return -EINVAL; | 571 | goto out_unlock; |
536 | if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') | 572 | if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') |
537 | return -EINVAL; | 573 | goto out_unlock; |
538 | memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); | 574 | memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); |
539 | 575 | ||
576 | mutex_unlock(&dynamic_netconsole_mutex); | ||
540 | return strnlen(buf, count); | 577 | return strnlen(buf, count); |
578 | out_unlock: | ||
579 | mutex_unlock(&dynamic_netconsole_mutex); | ||
580 | return -EINVAL; | ||
541 | } | 581 | } |
542 | 582 | ||
543 | /* | 583 | CONFIGFS_ATTR(, enabled); |
544 | * Attribute definitions for netconsole_target. | 584 | CONFIGFS_ATTR(, extended); |
545 | */ | 585 | CONFIGFS_ATTR(, dev_name); |
546 | 586 | CONFIGFS_ATTR(, local_port); | |
547 | #define NETCONSOLE_TARGET_ATTR_RO(_name) \ | 587 | CONFIGFS_ATTR(, remote_port); |
548 | static struct netconsole_target_attr netconsole_target_##_name = \ | 588 | CONFIGFS_ATTR(, local_ip); |
549 | __CONFIGFS_ATTR(_name, S_IRUGO, show_##_name, NULL) | 589 | CONFIGFS_ATTR(, remote_ip); |
550 | 590 | CONFIGFS_ATTR_RO(, local_mac); | |
551 | #define NETCONSOLE_TARGET_ATTR_RW(_name) \ | 591 | CONFIGFS_ATTR(, remote_mac); |
552 | static struct netconsole_target_attr netconsole_target_##_name = \ | ||
553 | __CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, show_##_name, store_##_name) | ||
554 | |||
555 | NETCONSOLE_TARGET_ATTR_RW(enabled); | ||
556 | NETCONSOLE_TARGET_ATTR_RW(extended); | ||
557 | NETCONSOLE_TARGET_ATTR_RW(dev_name); | ||
558 | NETCONSOLE_TARGET_ATTR_RW(local_port); | ||
559 | NETCONSOLE_TARGET_ATTR_RW(remote_port); | ||
560 | NETCONSOLE_TARGET_ATTR_RW(local_ip); | ||
561 | NETCONSOLE_TARGET_ATTR_RW(remote_ip); | ||
562 | NETCONSOLE_TARGET_ATTR_RO(local_mac); | ||
563 | NETCONSOLE_TARGET_ATTR_RW(remote_mac); | ||
564 | 592 | ||
565 | static struct configfs_attribute *netconsole_target_attrs[] = { | 593 | static struct configfs_attribute *netconsole_target_attrs[] = { |
566 | &netconsole_target_enabled.attr, | 594 | &attr_enabled, |
567 | &netconsole_target_extended.attr, | 595 | &attr_extended, |
568 | &netconsole_target_dev_name.attr, | 596 | &attr_dev_name, |
569 | &netconsole_target_local_port.attr, | 597 | &attr_local_port, |
570 | &netconsole_target_remote_port.attr, | 598 | &attr_remote_port, |
571 | &netconsole_target_local_ip.attr, | 599 | &attr_local_ip, |
572 | &netconsole_target_remote_ip.attr, | 600 | &attr_remote_ip, |
573 | &netconsole_target_local_mac.attr, | 601 | &attr_local_mac, |
574 | &netconsole_target_remote_mac.attr, | 602 | &attr_remote_mac, |
575 | NULL, | 603 | NULL, |
576 | }; | 604 | }; |
577 | 605 | ||
@@ -584,43 +612,8 @@ static void netconsole_target_release(struct config_item *item) | |||
584 | kfree(to_target(item)); | 612 | kfree(to_target(item)); |
585 | } | 613 | } |
586 | 614 | ||
587 | static ssize_t netconsole_target_attr_show(struct config_item *item, | ||
588 | struct configfs_attribute *attr, | ||
589 | char *buf) | ||
590 | { | ||
591 | ssize_t ret = -EINVAL; | ||
592 | struct netconsole_target *nt = to_target(item); | ||
593 | struct netconsole_target_attr *na = | ||
594 | container_of(attr, struct netconsole_target_attr, attr); | ||
595 | |||
596 | if (na->show) | ||
597 | ret = na->show(nt, buf); | ||
598 | |||
599 | return ret; | ||
600 | } | ||
601 | |||
602 | static ssize_t netconsole_target_attr_store(struct config_item *item, | ||
603 | struct configfs_attribute *attr, | ||
604 | const char *buf, | ||
605 | size_t count) | ||
606 | { | ||
607 | ssize_t ret = -EINVAL; | ||
608 | struct netconsole_target *nt = to_target(item); | ||
609 | struct netconsole_target_attr *na = | ||
610 | container_of(attr, struct netconsole_target_attr, attr); | ||
611 | |||
612 | mutex_lock(&dynamic_netconsole_mutex); | ||
613 | if (na->store) | ||
614 | ret = na->store(nt, buf, count); | ||
615 | mutex_unlock(&dynamic_netconsole_mutex); | ||
616 | |||
617 | return ret; | ||
618 | } | ||
619 | |||
620 | static struct configfs_item_operations netconsole_target_item_ops = { | 615 | static struct configfs_item_operations netconsole_target_item_ops = { |
621 | .release = netconsole_target_release, | 616 | .release = netconsole_target_release, |
622 | .show_attribute = netconsole_target_attr_show, | ||
623 | .store_attribute = netconsole_target_attr_store, | ||
624 | }; | 617 | }; |
625 | 618 | ||
626 | static struct config_item_type netconsole_target_type = { | 619 | static struct config_item_type netconsole_target_type = { |
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index ac65cb7b4886..3ba2e9564b9a 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
@@ -43,8 +43,6 @@ | |||
43 | #include <scsi/scsi_cmnd.h> | 43 | #include <scsi/scsi_cmnd.h> |
44 | #include <target/target_core_base.h> | 44 | #include <target/target_core_base.h> |
45 | #include <target/target_core_fabric.h> | 45 | #include <target/target_core_fabric.h> |
46 | #include <target/target_core_fabric_configfs.h> | ||
47 | #include <target/configfs_macros.h> | ||
48 | 46 | ||
49 | #include "qla_def.h" | 47 | #include "qla_def.h" |
50 | #include "qla_target.h" | 48 | #include "qla_target.h" |
@@ -729,23 +727,23 @@ static int tcm_qla2xxx_init_nodeacl(struct se_node_acl *se_nacl, | |||
729 | 727 | ||
730 | #define DEF_QLA_TPG_ATTRIB(name) \ | 728 | #define DEF_QLA_TPG_ATTRIB(name) \ |
731 | \ | 729 | \ |
732 | static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \ | 730 | static ssize_t tcm_qla2xxx_tpg_attrib_##name##_show( \ |
733 | struct se_portal_group *se_tpg, \ | 731 | struct config_item *item, char *page) \ |
734 | char *page) \ | ||
735 | { \ | 732 | { \ |
733 | struct se_portal_group *se_tpg = attrib_to_tpg(item); \ | ||
736 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ | 734 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ |
737 | struct tcm_qla2xxx_tpg, se_tpg); \ | 735 | struct tcm_qla2xxx_tpg, se_tpg); \ |
738 | \ | 736 | \ |
739 | return sprintf(page, "%u\n", tpg->tpg_attrib.name); \ | 737 | return sprintf(page, "%u\n", tpg->tpg_attrib.name); \ |
740 | } \ | 738 | } \ |
741 | \ | 739 | \ |
742 | static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \ | 740 | static ssize_t tcm_qla2xxx_tpg_attrib_##name##_store( \ |
743 | struct se_portal_group *se_tpg, \ | 741 | struct config_item *item, const char *page, size_t count) \ |
744 | const char *page, \ | ||
745 | size_t count) \ | ||
746 | { \ | 742 | { \ |
743 | struct se_portal_group *se_tpg = attrib_to_tpg(item); \ | ||
747 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ | 744 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ |
748 | struct tcm_qla2xxx_tpg, se_tpg); \ | 745 | struct tcm_qla2xxx_tpg, se_tpg); \ |
746 | struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \ | ||
749 | unsigned long val; \ | 747 | unsigned long val; \ |
750 | int ret; \ | 748 | int ret; \ |
751 | \ | 749 | \ |
@@ -755,81 +753,39 @@ static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \ | |||
755 | " ret: %d\n", ret); \ | 753 | " ret: %d\n", ret); \ |
756 | return -EINVAL; \ | 754 | return -EINVAL; \ |
757 | } \ | 755 | } \ |
758 | ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \ | ||
759 | \ | ||
760 | return (!ret) ? count : -EINVAL; \ | ||
761 | } | ||
762 | |||
763 | #define DEF_QLA_TPG_ATTR_BOOL(_name) \ | ||
764 | \ | ||
765 | static int tcm_qla2xxx_set_attrib_##_name( \ | ||
766 | struct tcm_qla2xxx_tpg *tpg, \ | ||
767 | unsigned long val) \ | ||
768 | { \ | ||
769 | struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \ | ||
770 | \ | 756 | \ |
771 | if ((val != 0) && (val != 1)) { \ | 757 | if ((val != 0) && (val != 1)) { \ |
772 | pr_err("Illegal boolean value %lu\n", val); \ | 758 | pr_err("Illegal boolean value %lu\n", val); \ |
773 | return -EINVAL; \ | 759 | return -EINVAL; \ |
774 | } \ | 760 | } \ |
775 | \ | 761 | \ |
776 | a->_name = val; \ | 762 | a->name = val; \ |
777 | return 0; \ | 763 | \ |
778 | } | 764 | return count; \ |
779 | 765 | } \ | |
780 | #define QLA_TPG_ATTR(_name, _mode) \ | 766 | CONFIGFS_ATTR(tcm_qla2xxx_tpg_attrib_, name) |
781 | TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode); | ||
782 | 767 | ||
783 | /* | ||
784 | * Define tcm_qla2xxx_tpg_attrib_s_generate_node_acls | ||
785 | */ | ||
786 | DEF_QLA_TPG_ATTR_BOOL(generate_node_acls); | ||
787 | DEF_QLA_TPG_ATTRIB(generate_node_acls); | 768 | DEF_QLA_TPG_ATTRIB(generate_node_acls); |
788 | QLA_TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR); | ||
789 | |||
790 | /* | ||
791 | Define tcm_qla2xxx_attrib_s_cache_dynamic_acls | ||
792 | */ | ||
793 | DEF_QLA_TPG_ATTR_BOOL(cache_dynamic_acls); | ||
794 | DEF_QLA_TPG_ATTRIB(cache_dynamic_acls); | 769 | DEF_QLA_TPG_ATTRIB(cache_dynamic_acls); |
795 | QLA_TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR); | ||
796 | |||
797 | /* | ||
798 | * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_write_protect | ||
799 | */ | ||
800 | DEF_QLA_TPG_ATTR_BOOL(demo_mode_write_protect); | ||
801 | DEF_QLA_TPG_ATTRIB(demo_mode_write_protect); | 770 | DEF_QLA_TPG_ATTRIB(demo_mode_write_protect); |
802 | QLA_TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); | ||
803 | |||
804 | /* | ||
805 | * Define tcm_qla2xxx_tpg_attrib_s_prod_mode_write_protect | ||
806 | */ | ||
807 | DEF_QLA_TPG_ATTR_BOOL(prod_mode_write_protect); | ||
808 | DEF_QLA_TPG_ATTRIB(prod_mode_write_protect); | 771 | DEF_QLA_TPG_ATTRIB(prod_mode_write_protect); |
809 | QLA_TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); | ||
810 | |||
811 | /* | ||
812 | * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_login_only | ||
813 | */ | ||
814 | DEF_QLA_TPG_ATTR_BOOL(demo_mode_login_only); | ||
815 | DEF_QLA_TPG_ATTRIB(demo_mode_login_only); | 772 | DEF_QLA_TPG_ATTRIB(demo_mode_login_only); |
816 | QLA_TPG_ATTR(demo_mode_login_only, S_IRUGO | S_IWUSR); | ||
817 | 773 | ||
818 | static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = { | 774 | static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = { |
819 | &tcm_qla2xxx_tpg_attrib_generate_node_acls.attr, | 775 | &tcm_qla2xxx_tpg_attrib_attr_generate_node_acls, |
820 | &tcm_qla2xxx_tpg_attrib_cache_dynamic_acls.attr, | 776 | &tcm_qla2xxx_tpg_attrib_attr_cache_dynamic_acls, |
821 | &tcm_qla2xxx_tpg_attrib_demo_mode_write_protect.attr, | 777 | &tcm_qla2xxx_tpg_attrib_attr_demo_mode_write_protect, |
822 | &tcm_qla2xxx_tpg_attrib_prod_mode_write_protect.attr, | 778 | &tcm_qla2xxx_tpg_attrib_attr_prod_mode_write_protect, |
823 | &tcm_qla2xxx_tpg_attrib_demo_mode_login_only.attr, | 779 | &tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only, |
824 | NULL, | 780 | NULL, |
825 | }; | 781 | }; |
826 | 782 | ||
827 | /* End items for tcm_qla2xxx_tpg_attrib_cit */ | 783 | /* End items for tcm_qla2xxx_tpg_attrib_cit */ |
828 | 784 | ||
829 | static ssize_t tcm_qla2xxx_tpg_show_enable( | 785 | static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item, |
830 | struct se_portal_group *se_tpg, | 786 | char *page) |
831 | char *page) | ||
832 | { | 787 | { |
788 | struct se_portal_group *se_tpg = to_tpg(item); | ||
833 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | 789 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, |
834 | struct tcm_qla2xxx_tpg, se_tpg); | 790 | struct tcm_qla2xxx_tpg, se_tpg); |
835 | 791 | ||
@@ -865,11 +821,10 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work) | |||
865 | complete(&base_tpg->tpg_base_comp); | 821 | complete(&base_tpg->tpg_base_comp); |
866 | } | 822 | } |
867 | 823 | ||
868 | static ssize_t tcm_qla2xxx_tpg_store_enable( | 824 | static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item, |
869 | struct se_portal_group *se_tpg, | 825 | const char *page, size_t count) |
870 | const char *page, | ||
871 | size_t count) | ||
872 | { | 826 | { |
827 | struct se_portal_group *se_tpg = to_tpg(item); | ||
873 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | 828 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, |
874 | struct tcm_qla2xxx_tpg, se_tpg); | 829 | struct tcm_qla2xxx_tpg, se_tpg); |
875 | unsigned long op; | 830 | unsigned long op; |
@@ -909,22 +864,16 @@ static ssize_t tcm_qla2xxx_tpg_store_enable( | |||
909 | return count; | 864 | return count; |
910 | } | 865 | } |
911 | 866 | ||
912 | TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR); | 867 | static ssize_t tcm_qla2xxx_tpg_dynamic_sessions_show(struct config_item *item, |
913 | 868 | char *page) | |
914 | static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions( | ||
915 | struct se_portal_group *se_tpg, | ||
916 | char *page) | ||
917 | { | 869 | { |
918 | return target_show_dynamic_sessions(se_tpg, page); | 870 | return target_show_dynamic_sessions(to_tpg(item), page); |
919 | } | 871 | } |
920 | 872 | ||
921 | TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions); | 873 | static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_store(struct config_item *item, |
922 | 874 | const char *page, size_t count) | |
923 | static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type( | ||
924 | struct se_portal_group *se_tpg, | ||
925 | const char *page, | ||
926 | size_t count) | ||
927 | { | 875 | { |
876 | struct se_portal_group *se_tpg = to_tpg(item); | ||
928 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | 877 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, |
929 | struct tcm_qla2xxx_tpg, se_tpg); | 878 | struct tcm_qla2xxx_tpg, se_tpg); |
930 | unsigned long val; | 879 | unsigned long val; |
@@ -943,21 +892,24 @@ static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type( | |||
943 | return count; | 892 | return count; |
944 | } | 893 | } |
945 | 894 | ||
946 | static ssize_t tcm_qla2xxx_tpg_show_fabric_prot_type( | 895 | static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_show(struct config_item *item, |
947 | struct se_portal_group *se_tpg, | 896 | char *page) |
948 | char *page) | ||
949 | { | 897 | { |
898 | struct se_portal_group *se_tpg = to_tpg(item); | ||
950 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | 899 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, |
951 | struct tcm_qla2xxx_tpg, se_tpg); | 900 | struct tcm_qla2xxx_tpg, se_tpg); |
952 | 901 | ||
953 | return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type); | 902 | return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type); |
954 | } | 903 | } |
955 | TF_TPG_BASE_ATTR(tcm_qla2xxx, fabric_prot_type, S_IRUGO | S_IWUSR); | 904 | |
905 | CONFIGFS_ATTR_WO(tcm_qla2xxx_tpg_, enable); | ||
906 | CONFIGFS_ATTR_RO(tcm_qla2xxx_tpg_, dynamic_sessions); | ||
907 | CONFIGFS_ATTR(tcm_qla2xxx_tpg_, fabric_prot_type); | ||
956 | 908 | ||
957 | static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = { | 909 | static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = { |
958 | &tcm_qla2xxx_tpg_enable.attr, | 910 | &tcm_qla2xxx_tpg_attr_enable, |
959 | &tcm_qla2xxx_tpg_dynamic_sessions.attr, | 911 | &tcm_qla2xxx_tpg_attr_dynamic_sessions, |
960 | &tcm_qla2xxx_tpg_fabric_prot_type.attr, | 912 | &tcm_qla2xxx_tpg_attr_fabric_prot_type, |
961 | NULL, | 913 | NULL, |
962 | }; | 914 | }; |
963 | 915 | ||
@@ -1030,18 +982,16 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg) | |||
1030 | kfree(tpg); | 982 | kfree(tpg); |
1031 | } | 983 | } |
1032 | 984 | ||
1033 | static ssize_t tcm_qla2xxx_npiv_tpg_show_enable( | 985 | static ssize_t tcm_qla2xxx_npiv_tpg_enable_show(struct config_item *item, |
1034 | struct se_portal_group *se_tpg, | 986 | char *page) |
1035 | char *page) | ||
1036 | { | 987 | { |
1037 | return tcm_qla2xxx_tpg_show_enable(se_tpg, page); | 988 | return tcm_qla2xxx_tpg_enable_show(item, page); |
1038 | } | 989 | } |
1039 | 990 | ||
1040 | static ssize_t tcm_qla2xxx_npiv_tpg_store_enable( | 991 | static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item, |
1041 | struct se_portal_group *se_tpg, | 992 | const char *page, size_t count) |
1042 | const char *page, | ||
1043 | size_t count) | ||
1044 | { | 993 | { |
994 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1045 | struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; | 995 | struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; |
1046 | struct tcm_qla2xxx_lport *lport = container_of(se_wwn, | 996 | struct tcm_qla2xxx_lport *lport = container_of(se_wwn, |
1047 | struct tcm_qla2xxx_lport, lport_wwn); | 997 | struct tcm_qla2xxx_lport, lport_wwn); |
@@ -1077,10 +1027,10 @@ static ssize_t tcm_qla2xxx_npiv_tpg_store_enable( | |||
1077 | return count; | 1027 | return count; |
1078 | } | 1028 | } |
1079 | 1029 | ||
1080 | TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR); | 1030 | CONFIGFS_ATTR(tcm_qla2xxx_npiv_tpg_, enable); |
1081 | 1031 | ||
1082 | static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { | 1032 | static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { |
1083 | &tcm_qla2xxx_npiv_tpg_enable.attr, | 1033 | &tcm_qla2xxx_npiv_tpg_attr_enable, |
1084 | NULL, | 1034 | NULL, |
1085 | }; | 1035 | }; |
1086 | 1036 | ||
@@ -1783,9 +1733,8 @@ static void tcm_qla2xxx_npiv_drop_lport(struct se_wwn *wwn) | |||
1783 | } | 1733 | } |
1784 | 1734 | ||
1785 | 1735 | ||
1786 | static ssize_t tcm_qla2xxx_wwn_show_attr_version( | 1736 | static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item, |
1787 | struct target_fabric_configfs *tf, | 1737 | char *page) |
1788 | char *page) | ||
1789 | { | 1738 | { |
1790 | return sprintf(page, | 1739 | return sprintf(page, |
1791 | "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " | 1740 | "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " |
@@ -1793,10 +1742,10 @@ static ssize_t tcm_qla2xxx_wwn_show_attr_version( | |||
1793 | utsname()->machine); | 1742 | utsname()->machine); |
1794 | } | 1743 | } |
1795 | 1744 | ||
1796 | TF_WWN_ATTR_RO(tcm_qla2xxx, version); | 1745 | CONFIGFS_ATTR_RO(tcm_qla2xxx_wwn_, version); |
1797 | 1746 | ||
1798 | static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = { | 1747 | static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = { |
1799 | &tcm_qla2xxx_wwn_version.attr, | 1748 | &tcm_qla2xxx_wwn_attr_version, |
1800 | NULL, | 1749 | NULL, |
1801 | }; | 1750 | }; |
1802 | 1751 | ||
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c index c7461d770d3a..255204cc43e6 100644 --- a/drivers/target/iscsi/iscsi_target_configfs.c +++ b/drivers/target/iscsi/iscsi_target_configfs.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include <linux/inet.h> | 23 | #include <linux/inet.h> |
24 | #include <target/target_core_base.h> | 24 | #include <target/target_core_base.h> |
25 | #include <target/target_core_fabric.h> | 25 | #include <target/target_core_fabric.h> |
26 | #include <target/target_core_fabric_configfs.h> | ||
27 | #include <target/configfs_macros.h> | ||
28 | #include <target/iscsi/iscsi_transport.h> | 26 | #include <target/iscsi/iscsi_transport.h> |
29 | 27 | ||
30 | #include <target/iscsi/iscsi_target_core.h> | 28 | #include <target/iscsi/iscsi_target_core.h> |
@@ -37,20 +35,17 @@ | |||
37 | #include "iscsi_target.h" | 35 | #include "iscsi_target.h" |
38 | #include <target/iscsi/iscsi_target_stat.h> | 36 | #include <target/iscsi/iscsi_target_stat.h> |
39 | 37 | ||
40 | struct lio_target_configfs_attribute { | ||
41 | struct configfs_attribute attr; | ||
42 | ssize_t (*show)(void *, char *); | ||
43 | ssize_t (*store)(void *, const char *, size_t); | ||
44 | }; | ||
45 | 38 | ||
46 | /* Start items for lio_target_portal_cit */ | 39 | /* Start items for lio_target_portal_cit */ |
47 | 40 | ||
48 | static ssize_t lio_target_np_show_sctp( | 41 | static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item) |
49 | struct se_tpg_np *se_tpg_np, | 42 | { |
50 | char *page) | 43 | return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np); |
44 | } | ||
45 | |||
46 | static ssize_t lio_target_np_sctp_show(struct config_item *item, char *page) | ||
51 | { | 47 | { |
52 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | 48 | struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); |
53 | struct iscsi_tpg_np, se_tpg_np); | ||
54 | struct iscsi_tpg_np *tpg_np_sctp; | 49 | struct iscsi_tpg_np *tpg_np_sctp; |
55 | ssize_t rb; | 50 | ssize_t rb; |
56 | 51 | ||
@@ -63,15 +58,12 @@ static ssize_t lio_target_np_show_sctp( | |||
63 | return rb; | 58 | return rb; |
64 | } | 59 | } |
65 | 60 | ||
66 | static ssize_t lio_target_np_store_sctp( | 61 | static ssize_t lio_target_np_sctp_store(struct config_item *item, |
67 | struct se_tpg_np *se_tpg_np, | 62 | const char *page, size_t count) |
68 | const char *page, | ||
69 | size_t count) | ||
70 | { | 63 | { |
64 | struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); | ||
71 | struct iscsi_np *np; | 65 | struct iscsi_np *np; |
72 | struct iscsi_portal_group *tpg; | 66 | struct iscsi_portal_group *tpg; |
73 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | ||
74 | struct iscsi_tpg_np, se_tpg_np); | ||
75 | struct iscsi_tpg_np *tpg_np_sctp = NULL; | 67 | struct iscsi_tpg_np *tpg_np_sctp = NULL; |
76 | u32 op; | 68 | u32 op; |
77 | int ret; | 69 | int ret; |
@@ -119,14 +111,9 @@ out: | |||
119 | return -EINVAL; | 111 | return -EINVAL; |
120 | } | 112 | } |
121 | 113 | ||
122 | TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR); | 114 | static ssize_t lio_target_np_iser_show(struct config_item *item, char *page) |
123 | |||
124 | static ssize_t lio_target_np_show_iser( | ||
125 | struct se_tpg_np *se_tpg_np, | ||
126 | char *page) | ||
127 | { | 115 | { |
128 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | 116 | struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); |
129 | struct iscsi_tpg_np, se_tpg_np); | ||
130 | struct iscsi_tpg_np *tpg_np_iser; | 117 | struct iscsi_tpg_np *tpg_np_iser; |
131 | ssize_t rb; | 118 | ssize_t rb; |
132 | 119 | ||
@@ -139,15 +126,12 @@ static ssize_t lio_target_np_show_iser( | |||
139 | return rb; | 126 | return rb; |
140 | } | 127 | } |
141 | 128 | ||
142 | static ssize_t lio_target_np_store_iser( | 129 | static ssize_t lio_target_np_iser_store(struct config_item *item, |
143 | struct se_tpg_np *se_tpg_np, | 130 | const char *page, size_t count) |
144 | const char *page, | ||
145 | size_t count) | ||
146 | { | 131 | { |
132 | struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); | ||
147 | struct iscsi_np *np; | 133 | struct iscsi_np *np; |
148 | struct iscsi_portal_group *tpg; | 134 | struct iscsi_portal_group *tpg; |
149 | struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, | ||
150 | struct iscsi_tpg_np, se_tpg_np); | ||
151 | struct iscsi_tpg_np *tpg_np_iser = NULL; | 135 | struct iscsi_tpg_np *tpg_np_iser = NULL; |
152 | char *endptr; | 136 | char *endptr; |
153 | u32 op; | 137 | u32 op; |
@@ -198,11 +182,12 @@ out: | |||
198 | return rc; | 182 | return rc; |
199 | } | 183 | } |
200 | 184 | ||
201 | TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR); | 185 | CONFIGFS_ATTR(lio_target_np_, sctp); |
186 | CONFIGFS_ATTR(lio_target_np_, iser); | ||
202 | 187 | ||
203 | static struct configfs_attribute *lio_target_portal_attrs[] = { | 188 | static struct configfs_attribute *lio_target_portal_attrs[] = { |
204 | &lio_target_np_sctp.attr, | 189 | &lio_target_np_attr_sctp, |
205 | &lio_target_np_iser.attr, | 190 | &lio_target_np_attr_iser, |
206 | NULL, | 191 | NULL, |
207 | }; | 192 | }; |
208 | 193 | ||
@@ -360,22 +345,21 @@ out: | |||
360 | 345 | ||
361 | /* Start items for lio_target_nacl_attrib_cit */ | 346 | /* Start items for lio_target_nacl_attrib_cit */ |
362 | 347 | ||
363 | #define DEF_NACL_ATTRIB(name) \ | 348 | #define ISCSI_NACL_ATTR(name) \ |
364 | static ssize_t iscsi_nacl_attrib_show_##name( \ | 349 | static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\ |
365 | struct se_node_acl *se_nacl, \ | 350 | char *page) \ |
366 | char *page) \ | ||
367 | { \ | 351 | { \ |
352 | struct se_node_acl *se_nacl = attrib_to_nacl(item); \ | ||
368 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ | 353 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ |
369 | se_node_acl); \ | 354 | se_node_acl); \ |
370 | \ | 355 | \ |
371 | return sprintf(page, "%u\n", nacl->node_attrib.name); \ | 356 | return sprintf(page, "%u\n", nacl->node_attrib.name); \ |
372 | } \ | 357 | } \ |
373 | \ | 358 | \ |
374 | static ssize_t iscsi_nacl_attrib_store_##name( \ | 359 | static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\ |
375 | struct se_node_acl *se_nacl, \ | 360 | const char *page, size_t count) \ |
376 | const char *page, \ | ||
377 | size_t count) \ | ||
378 | { \ | 361 | { \ |
362 | struct se_node_acl *se_nacl = attrib_to_nacl(item); \ | ||
379 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ | 363 | struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ |
380 | se_node_acl); \ | 364 | se_node_acl); \ |
381 | u32 val; \ | 365 | u32 val; \ |
@@ -389,59 +373,28 @@ static ssize_t iscsi_nacl_attrib_store_##name( \ | |||
389 | return ret; \ | 373 | return ret; \ |
390 | \ | 374 | \ |
391 | return count; \ | 375 | return count; \ |
392 | } | 376 | } \ |
377 | \ | ||
378 | CONFIGFS_ATTR(iscsi_nacl_attrib_, name) | ||
393 | 379 | ||
394 | #define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode); | 380 | ISCSI_NACL_ATTR(dataout_timeout); |
395 | /* | 381 | ISCSI_NACL_ATTR(dataout_timeout_retries); |
396 | * Define iscsi_node_attrib_s_dataout_timeout | 382 | ISCSI_NACL_ATTR(default_erl); |
397 | */ | 383 | ISCSI_NACL_ATTR(nopin_timeout); |
398 | DEF_NACL_ATTRIB(dataout_timeout); | 384 | ISCSI_NACL_ATTR(nopin_response_timeout); |
399 | NACL_ATTR(dataout_timeout, S_IRUGO | S_IWUSR); | 385 | ISCSI_NACL_ATTR(random_datain_pdu_offsets); |
400 | /* | 386 | ISCSI_NACL_ATTR(random_datain_seq_offsets); |
401 | * Define iscsi_node_attrib_s_dataout_timeout_retries | 387 | ISCSI_NACL_ATTR(random_r2t_offsets); |
402 | */ | ||
403 | DEF_NACL_ATTRIB(dataout_timeout_retries); | ||
404 | NACL_ATTR(dataout_timeout_retries, S_IRUGO | S_IWUSR); | ||
405 | /* | ||
406 | * Define iscsi_node_attrib_s_default_erl | ||
407 | */ | ||
408 | DEF_NACL_ATTRIB(default_erl); | ||
409 | NACL_ATTR(default_erl, S_IRUGO | S_IWUSR); | ||
410 | /* | ||
411 | * Define iscsi_node_attrib_s_nopin_timeout | ||
412 | */ | ||
413 | DEF_NACL_ATTRIB(nopin_timeout); | ||
414 | NACL_ATTR(nopin_timeout, S_IRUGO | S_IWUSR); | ||
415 | /* | ||
416 | * Define iscsi_node_attrib_s_nopin_response_timeout | ||
417 | */ | ||
418 | DEF_NACL_ATTRIB(nopin_response_timeout); | ||
419 | NACL_ATTR(nopin_response_timeout, S_IRUGO | S_IWUSR); | ||
420 | /* | ||
421 | * Define iscsi_node_attrib_s_random_datain_pdu_offsets | ||
422 | */ | ||
423 | DEF_NACL_ATTRIB(random_datain_pdu_offsets); | ||
424 | NACL_ATTR(random_datain_pdu_offsets, S_IRUGO | S_IWUSR); | ||
425 | /* | ||
426 | * Define iscsi_node_attrib_s_random_datain_seq_offsets | ||
427 | */ | ||
428 | DEF_NACL_ATTRIB(random_datain_seq_offsets); | ||
429 | NACL_ATTR(random_datain_seq_offsets, S_IRUGO | S_IWUSR); | ||
430 | /* | ||
431 | * Define iscsi_node_attrib_s_random_r2t_offsets | ||
432 | */ | ||
433 | DEF_NACL_ATTRIB(random_r2t_offsets); | ||
434 | NACL_ATTR(random_r2t_offsets, S_IRUGO | S_IWUSR); | ||
435 | 388 | ||
436 | static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = { | 389 | static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = { |
437 | &iscsi_nacl_attrib_dataout_timeout.attr, | 390 | &iscsi_nacl_attrib_attr_dataout_timeout, |
438 | &iscsi_nacl_attrib_dataout_timeout_retries.attr, | 391 | &iscsi_nacl_attrib_attr_dataout_timeout_retries, |
439 | &iscsi_nacl_attrib_default_erl.attr, | 392 | &iscsi_nacl_attrib_attr_default_erl, |
440 | &iscsi_nacl_attrib_nopin_timeout.attr, | 393 | &iscsi_nacl_attrib_attr_nopin_timeout, |
441 | &iscsi_nacl_attrib_nopin_response_timeout.attr, | 394 | &iscsi_nacl_attrib_attr_nopin_response_timeout, |
442 | &iscsi_nacl_attrib_random_datain_pdu_offsets.attr, | 395 | &iscsi_nacl_attrib_attr_random_datain_pdu_offsets, |
443 | &iscsi_nacl_attrib_random_datain_seq_offsets.attr, | 396 | &iscsi_nacl_attrib_attr_random_datain_seq_offsets, |
444 | &iscsi_nacl_attrib_random_r2t_offsets.attr, | 397 | &iscsi_nacl_attrib_attr_random_r2t_offsets, |
445 | NULL, | 398 | NULL, |
446 | }; | 399 | }; |
447 | 400 | ||
@@ -450,7 +403,7 @@ static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = { | |||
450 | /* Start items for lio_target_nacl_auth_cit */ | 403 | /* Start items for lio_target_nacl_auth_cit */ |
451 | 404 | ||
452 | #define __DEF_NACL_AUTH_STR(prefix, name, flags) \ | 405 | #define __DEF_NACL_AUTH_STR(prefix, name, flags) \ |
453 | static ssize_t __iscsi_##prefix##_show_##name( \ | 406 | static ssize_t __iscsi_##prefix##_##name##_show( \ |
454 | struct iscsi_node_acl *nacl, \ | 407 | struct iscsi_node_acl *nacl, \ |
455 | char *page) \ | 408 | char *page) \ |
456 | { \ | 409 | { \ |
@@ -461,7 +414,7 @@ static ssize_t __iscsi_##prefix##_show_##name( \ | |||
461 | return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ | 414 | return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ |
462 | } \ | 415 | } \ |
463 | \ | 416 | \ |
464 | static ssize_t __iscsi_##prefix##_store_##name( \ | 417 | static ssize_t __iscsi_##prefix##_##name##_store( \ |
465 | struct iscsi_node_acl *nacl, \ | 418 | struct iscsi_node_acl *nacl, \ |
466 | const char *page, \ | 419 | const char *page, \ |
467 | size_t count) \ | 420 | size_t count) \ |
@@ -487,8 +440,35 @@ static ssize_t __iscsi_##prefix##_store_##name( \ | |||
487 | return count; \ | 440 | return count; \ |
488 | } | 441 | } |
489 | 442 | ||
443 | #define DEF_NACL_AUTH_STR(name, flags) \ | ||
444 | __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \ | ||
445 | static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \ | ||
446 | char *page) \ | ||
447 | { \ | ||
448 | struct se_node_acl *nacl = auth_to_nacl(item); \ | ||
449 | return __iscsi_nacl_auth_##name##_show(container_of(nacl, \ | ||
450 | struct iscsi_node_acl, se_node_acl), page); \ | ||
451 | } \ | ||
452 | static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \ | ||
453 | const char *page, size_t count) \ | ||
454 | { \ | ||
455 | struct se_node_acl *nacl = auth_to_nacl(item); \ | ||
456 | return __iscsi_nacl_auth_##name##_store(container_of(nacl, \ | ||
457 | struct iscsi_node_acl, se_node_acl), page, count); \ | ||
458 | } \ | ||
459 | \ | ||
460 | CONFIGFS_ATTR(iscsi_nacl_auth_, name) | ||
461 | |||
462 | /* | ||
463 | * One-way authentication userid | ||
464 | */ | ||
465 | DEF_NACL_AUTH_STR(userid, NAF_USERID_SET); | ||
466 | DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET); | ||
467 | DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
468 | DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
469 | |||
490 | #define __DEF_NACL_AUTH_INT(prefix, name) \ | 470 | #define __DEF_NACL_AUTH_INT(prefix, name) \ |
491 | static ssize_t __iscsi_##prefix##_show_##name( \ | 471 | static ssize_t __iscsi_##prefix##_##name##_show( \ |
492 | struct iscsi_node_acl *nacl, \ | 472 | struct iscsi_node_acl *nacl, \ |
493 | char *page) \ | 473 | char *page) \ |
494 | { \ | 474 | { \ |
@@ -500,69 +480,26 @@ static ssize_t __iscsi_##prefix##_show_##name( \ | |||
500 | return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ | 480 | return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ |
501 | } | 481 | } |
502 | 482 | ||
503 | #define DEF_NACL_AUTH_STR(name, flags) \ | ||
504 | __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \ | ||
505 | static ssize_t iscsi_nacl_auth_show_##name( \ | ||
506 | struct se_node_acl *nacl, \ | ||
507 | char *page) \ | ||
508 | { \ | ||
509 | return __iscsi_nacl_auth_show_##name(container_of(nacl, \ | ||
510 | struct iscsi_node_acl, se_node_acl), page); \ | ||
511 | } \ | ||
512 | static ssize_t iscsi_nacl_auth_store_##name( \ | ||
513 | struct se_node_acl *nacl, \ | ||
514 | const char *page, \ | ||
515 | size_t count) \ | ||
516 | { \ | ||
517 | return __iscsi_nacl_auth_store_##name(container_of(nacl, \ | ||
518 | struct iscsi_node_acl, se_node_acl), page, count); \ | ||
519 | } | ||
520 | |||
521 | #define DEF_NACL_AUTH_INT(name) \ | 483 | #define DEF_NACL_AUTH_INT(name) \ |
522 | __DEF_NACL_AUTH_INT(nacl_auth, name) \ | 484 | __DEF_NACL_AUTH_INT(nacl_auth, name) \ |
523 | static ssize_t iscsi_nacl_auth_show_##name( \ | 485 | static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \ |
524 | struct se_node_acl *nacl, \ | 486 | char *page) \ |
525 | char *page) \ | ||
526 | { \ | 487 | { \ |
527 | return __iscsi_nacl_auth_show_##name(container_of(nacl, \ | 488 | struct se_node_acl *nacl = auth_to_nacl(item); \ |
528 | struct iscsi_node_acl, se_node_acl), page); \ | 489 | return __iscsi_nacl_auth_##name##_show(container_of(nacl, \ |
529 | } | 490 | struct iscsi_node_acl, se_node_acl), page); \ |
530 | 491 | } \ | |
531 | #define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode); | 492 | \ |
532 | #define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name); | 493 | CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name) |
533 | 494 | ||
534 | /* | ||
535 | * One-way authentication userid | ||
536 | */ | ||
537 | DEF_NACL_AUTH_STR(userid, NAF_USERID_SET); | ||
538 | AUTH_ATTR(userid, S_IRUGO | S_IWUSR); | ||
539 | /* | ||
540 | * One-way authentication password | ||
541 | */ | ||
542 | DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET); | ||
543 | AUTH_ATTR(password, S_IRUGO | S_IWUSR); | ||
544 | /* | ||
545 | * Enforce mutual authentication | ||
546 | */ | ||
547 | DEF_NACL_AUTH_INT(authenticate_target); | 495 | DEF_NACL_AUTH_INT(authenticate_target); |
548 | AUTH_ATTR_RO(authenticate_target); | ||
549 | /* | ||
550 | * Mutual authentication userid | ||
551 | */ | ||
552 | DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
553 | AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); | ||
554 | /* | ||
555 | * Mutual authentication password | ||
556 | */ | ||
557 | DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
558 | AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); | ||
559 | 496 | ||
560 | static struct configfs_attribute *lio_target_nacl_auth_attrs[] = { | 497 | static struct configfs_attribute *lio_target_nacl_auth_attrs[] = { |
561 | &iscsi_nacl_auth_userid.attr, | 498 | &iscsi_nacl_auth_attr_userid, |
562 | &iscsi_nacl_auth_password.attr, | 499 | &iscsi_nacl_auth_attr_password, |
563 | &iscsi_nacl_auth_authenticate_target.attr, | 500 | &iscsi_nacl_auth_attr_authenticate_target, |
564 | &iscsi_nacl_auth_userid_mutual.attr, | 501 | &iscsi_nacl_auth_attr_userid_mutual, |
565 | &iscsi_nacl_auth_password_mutual.attr, | 502 | &iscsi_nacl_auth_attr_password_mutual, |
566 | NULL, | 503 | NULL, |
567 | }; | 504 | }; |
568 | 505 | ||
@@ -570,11 +507,11 @@ static struct configfs_attribute *lio_target_nacl_auth_attrs[] = { | |||
570 | 507 | ||
571 | /* Start items for lio_target_nacl_param_cit */ | 508 | /* Start items for lio_target_nacl_param_cit */ |
572 | 509 | ||
573 | #define DEF_NACL_PARAM(name) \ | 510 | #define ISCSI_NACL_PARAM(name) \ |
574 | static ssize_t iscsi_nacl_param_show_##name( \ | 511 | static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \ |
575 | struct se_node_acl *se_nacl, \ | 512 | char *page) \ |
576 | char *page) \ | ||
577 | { \ | 513 | { \ |
514 | struct se_node_acl *se_nacl = param_to_nacl(item); \ | ||
578 | struct iscsi_session *sess; \ | 515 | struct iscsi_session *sess; \ |
579 | struct se_session *se_sess; \ | 516 | struct se_session *se_sess; \ |
580 | ssize_t rb; \ | 517 | ssize_t rb; \ |
@@ -592,55 +529,34 @@ static ssize_t iscsi_nacl_param_show_##name( \ | |||
592 | spin_unlock_bh(&se_nacl->nacl_sess_lock); \ | 529 | spin_unlock_bh(&se_nacl->nacl_sess_lock); \ |
593 | \ | 530 | \ |
594 | return rb; \ | 531 | return rb; \ |
595 | } | 532 | } \ |
596 | 533 | \ | |
597 | #define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name); | 534 | CONFIGFS_ATTR_RO(iscsi_nacl_param_, name) |
598 | 535 | ||
599 | DEF_NACL_PARAM(MaxConnections); | 536 | ISCSI_NACL_PARAM(MaxConnections); |
600 | NACL_PARAM_ATTR(MaxConnections); | 537 | ISCSI_NACL_PARAM(InitialR2T); |
601 | 538 | ISCSI_NACL_PARAM(ImmediateData); | |
602 | DEF_NACL_PARAM(InitialR2T); | 539 | ISCSI_NACL_PARAM(MaxBurstLength); |
603 | NACL_PARAM_ATTR(InitialR2T); | 540 | ISCSI_NACL_PARAM(FirstBurstLength); |
604 | 541 | ISCSI_NACL_PARAM(DefaultTime2Wait); | |
605 | DEF_NACL_PARAM(ImmediateData); | 542 | ISCSI_NACL_PARAM(DefaultTime2Retain); |
606 | NACL_PARAM_ATTR(ImmediateData); | 543 | ISCSI_NACL_PARAM(MaxOutstandingR2T); |
607 | 544 | ISCSI_NACL_PARAM(DataPDUInOrder); | |
608 | DEF_NACL_PARAM(MaxBurstLength); | 545 | ISCSI_NACL_PARAM(DataSequenceInOrder); |
609 | NACL_PARAM_ATTR(MaxBurstLength); | 546 | ISCSI_NACL_PARAM(ErrorRecoveryLevel); |
610 | |||
611 | DEF_NACL_PARAM(FirstBurstLength); | ||
612 | NACL_PARAM_ATTR(FirstBurstLength); | ||
613 | |||
614 | DEF_NACL_PARAM(DefaultTime2Wait); | ||
615 | NACL_PARAM_ATTR(DefaultTime2Wait); | ||
616 | |||
617 | DEF_NACL_PARAM(DefaultTime2Retain); | ||
618 | NACL_PARAM_ATTR(DefaultTime2Retain); | ||
619 | |||
620 | DEF_NACL_PARAM(MaxOutstandingR2T); | ||
621 | NACL_PARAM_ATTR(MaxOutstandingR2T); | ||
622 | |||
623 | DEF_NACL_PARAM(DataPDUInOrder); | ||
624 | NACL_PARAM_ATTR(DataPDUInOrder); | ||
625 | |||
626 | DEF_NACL_PARAM(DataSequenceInOrder); | ||
627 | NACL_PARAM_ATTR(DataSequenceInOrder); | ||
628 | |||
629 | DEF_NACL_PARAM(ErrorRecoveryLevel); | ||
630 | NACL_PARAM_ATTR(ErrorRecoveryLevel); | ||
631 | 547 | ||
632 | static struct configfs_attribute *lio_target_nacl_param_attrs[] = { | 548 | static struct configfs_attribute *lio_target_nacl_param_attrs[] = { |
633 | &iscsi_nacl_param_MaxConnections.attr, | 549 | &iscsi_nacl_param_attr_MaxConnections, |
634 | &iscsi_nacl_param_InitialR2T.attr, | 550 | &iscsi_nacl_param_attr_InitialR2T, |
635 | &iscsi_nacl_param_ImmediateData.attr, | 551 | &iscsi_nacl_param_attr_ImmediateData, |
636 | &iscsi_nacl_param_MaxBurstLength.attr, | 552 | &iscsi_nacl_param_attr_MaxBurstLength, |
637 | &iscsi_nacl_param_FirstBurstLength.attr, | 553 | &iscsi_nacl_param_attr_FirstBurstLength, |
638 | &iscsi_nacl_param_DefaultTime2Wait.attr, | 554 | &iscsi_nacl_param_attr_DefaultTime2Wait, |
639 | &iscsi_nacl_param_DefaultTime2Retain.attr, | 555 | &iscsi_nacl_param_attr_DefaultTime2Retain, |
640 | &iscsi_nacl_param_MaxOutstandingR2T.attr, | 556 | &iscsi_nacl_param_attr_MaxOutstandingR2T, |
641 | &iscsi_nacl_param_DataPDUInOrder.attr, | 557 | &iscsi_nacl_param_attr_DataPDUInOrder, |
642 | &iscsi_nacl_param_DataSequenceInOrder.attr, | 558 | &iscsi_nacl_param_attr_DataSequenceInOrder, |
643 | &iscsi_nacl_param_ErrorRecoveryLevel.attr, | 559 | &iscsi_nacl_param_attr_ErrorRecoveryLevel, |
644 | NULL, | 560 | NULL, |
645 | }; | 561 | }; |
646 | 562 | ||
@@ -648,10 +564,9 @@ static struct configfs_attribute *lio_target_nacl_param_attrs[] = { | |||
648 | 564 | ||
649 | /* Start items for lio_target_acl_cit */ | 565 | /* Start items for lio_target_acl_cit */ |
650 | 566 | ||
651 | static ssize_t lio_target_nacl_show_info( | 567 | static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) |
652 | struct se_node_acl *se_nacl, | ||
653 | char *page) | ||
654 | { | 568 | { |
569 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
655 | struct iscsi_session *sess; | 570 | struct iscsi_session *sess; |
656 | struct iscsi_conn *conn; | 571 | struct iscsi_conn *conn; |
657 | struct se_session *se_sess; | 572 | struct se_session *se_sess; |
@@ -766,20 +681,16 @@ static ssize_t lio_target_nacl_show_info( | |||
766 | return rb; | 681 | return rb; |
767 | } | 682 | } |
768 | 683 | ||
769 | TF_NACL_BASE_ATTR_RO(lio_target, info); | 684 | static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item, |
770 | 685 | char *page) | |
771 | static ssize_t lio_target_nacl_show_cmdsn_depth( | ||
772 | struct se_node_acl *se_nacl, | ||
773 | char *page) | ||
774 | { | 686 | { |
775 | return sprintf(page, "%u\n", se_nacl->queue_depth); | 687 | return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth); |
776 | } | 688 | } |
777 | 689 | ||
778 | static ssize_t lio_target_nacl_store_cmdsn_depth( | 690 | static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item, |
779 | struct se_node_acl *se_nacl, | 691 | const char *page, size_t count) |
780 | const char *page, | ||
781 | size_t count) | ||
782 | { | 692 | { |
693 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
783 | struct se_portal_group *se_tpg = se_nacl->se_tpg; | 694 | struct se_portal_group *se_tpg = se_nacl->se_tpg; |
784 | struct iscsi_portal_group *tpg = container_of(se_tpg, | 695 | struct iscsi_portal_group *tpg = container_of(se_tpg, |
785 | struct iscsi_portal_group, tpg_se_tpg); | 696 | struct iscsi_portal_group, tpg_se_tpg); |
@@ -829,20 +740,15 @@ static ssize_t lio_target_nacl_store_cmdsn_depth( | |||
829 | return (!ret) ? count : (ssize_t)ret; | 740 | return (!ret) ? count : (ssize_t)ret; |
830 | } | 741 | } |
831 | 742 | ||
832 | TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); | 743 | static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page) |
833 | |||
834 | static ssize_t lio_target_nacl_show_tag( | ||
835 | struct se_node_acl *se_nacl, | ||
836 | char *page) | ||
837 | { | 744 | { |
838 | return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag); | 745 | return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag); |
839 | } | 746 | } |
840 | 747 | ||
841 | static ssize_t lio_target_nacl_store_tag( | 748 | static ssize_t lio_target_nacl_tag_store(struct config_item *item, |
842 | struct se_node_acl *se_nacl, | 749 | const char *page, size_t count) |
843 | const char *page, | ||
844 | size_t count) | ||
845 | { | 750 | { |
751 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
846 | int ret; | 752 | int ret; |
847 | 753 | ||
848 | ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page); | 754 | ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page); |
@@ -852,12 +758,14 @@ static ssize_t lio_target_nacl_store_tag( | |||
852 | return count; | 758 | return count; |
853 | } | 759 | } |
854 | 760 | ||
855 | TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR); | 761 | CONFIGFS_ATTR_RO(lio_target_nacl_, info); |
762 | CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth); | ||
763 | CONFIGFS_ATTR(lio_target_nacl_, tag); | ||
856 | 764 | ||
857 | static struct configfs_attribute *lio_target_initiator_attrs[] = { | 765 | static struct configfs_attribute *lio_target_initiator_attrs[] = { |
858 | &lio_target_nacl_info.attr, | 766 | &lio_target_nacl_attr_info, |
859 | &lio_target_nacl_cmdsn_depth.attr, | 767 | &lio_target_nacl_attr_cmdsn_depth, |
860 | &lio_target_nacl_tag.attr, | 768 | &lio_target_nacl_attr_tag, |
861 | NULL, | 769 | NULL, |
862 | }; | 770 | }; |
863 | 771 | ||
@@ -907,10 +815,10 @@ static void lio_target_cleanup_nodeacl( struct se_node_acl *se_nacl) | |||
907 | 815 | ||
908 | #define DEF_TPG_ATTRIB(name) \ | 816 | #define DEF_TPG_ATTRIB(name) \ |
909 | \ | 817 | \ |
910 | static ssize_t iscsi_tpg_attrib_show_##name( \ | 818 | static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \ |
911 | struct se_portal_group *se_tpg, \ | 819 | char *page) \ |
912 | char *page) \ | ||
913 | { \ | 820 | { \ |
821 | struct se_portal_group *se_tpg = attrib_to_tpg(item); \ | ||
914 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 822 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
915 | struct iscsi_portal_group, tpg_se_tpg); \ | 823 | struct iscsi_portal_group, tpg_se_tpg); \ |
916 | ssize_t rb; \ | 824 | ssize_t rb; \ |
@@ -923,11 +831,10 @@ static ssize_t iscsi_tpg_attrib_show_##name( \ | |||
923 | return rb; \ | 831 | return rb; \ |
924 | } \ | 832 | } \ |
925 | \ | 833 | \ |
926 | static ssize_t iscsi_tpg_attrib_store_##name( \ | 834 | static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\ |
927 | struct se_portal_group *se_tpg, \ | 835 | const char *page, size_t count) \ |
928 | const char *page, \ | ||
929 | size_t count) \ | ||
930 | { \ | 836 | { \ |
837 | struct se_portal_group *se_tpg = attrib_to_tpg(item); \ | ||
931 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 838 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
932 | struct iscsi_portal_group, tpg_se_tpg); \ | 839 | struct iscsi_portal_group, tpg_se_tpg); \ |
933 | u32 val; \ | 840 | u32 val; \ |
@@ -948,90 +855,37 @@ static ssize_t iscsi_tpg_attrib_store_##name( \ | |||
948 | out: \ | 855 | out: \ |
949 | iscsit_put_tpg(tpg); \ | 856 | iscsit_put_tpg(tpg); \ |
950 | return ret; \ | 857 | return ret; \ |
951 | } | 858 | } \ |
952 | 859 | CONFIGFS_ATTR(iscsi_tpg_attrib_, name) | |
953 | #define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode); | ||
954 | 860 | ||
955 | /* | ||
956 | * Define iscsi_tpg_attrib_s_authentication | ||
957 | */ | ||
958 | DEF_TPG_ATTRIB(authentication); | 861 | DEF_TPG_ATTRIB(authentication); |
959 | TPG_ATTR(authentication, S_IRUGO | S_IWUSR); | ||
960 | /* | ||
961 | * Define iscsi_tpg_attrib_s_login_timeout | ||
962 | */ | ||
963 | DEF_TPG_ATTRIB(login_timeout); | 862 | DEF_TPG_ATTRIB(login_timeout); |
964 | TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR); | ||
965 | /* | ||
966 | * Define iscsi_tpg_attrib_s_netif_timeout | ||
967 | */ | ||
968 | DEF_TPG_ATTRIB(netif_timeout); | 863 | DEF_TPG_ATTRIB(netif_timeout); |
969 | TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR); | ||
970 | /* | ||
971 | * Define iscsi_tpg_attrib_s_generate_node_acls | ||
972 | */ | ||
973 | DEF_TPG_ATTRIB(generate_node_acls); | 864 | DEF_TPG_ATTRIB(generate_node_acls); |
974 | TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR); | ||
975 | /* | ||
976 | * Define iscsi_tpg_attrib_s_default_cmdsn_depth | ||
977 | */ | ||
978 | DEF_TPG_ATTRIB(default_cmdsn_depth); | 865 | DEF_TPG_ATTRIB(default_cmdsn_depth); |
979 | TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR); | ||
980 | /* | ||
981 | Define iscsi_tpg_attrib_s_cache_dynamic_acls | ||
982 | */ | ||
983 | DEF_TPG_ATTRIB(cache_dynamic_acls); | 866 | DEF_TPG_ATTRIB(cache_dynamic_acls); |
984 | TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR); | ||
985 | /* | ||
986 | * Define iscsi_tpg_attrib_s_demo_mode_write_protect | ||
987 | */ | ||
988 | DEF_TPG_ATTRIB(demo_mode_write_protect); | 867 | DEF_TPG_ATTRIB(demo_mode_write_protect); |
989 | TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); | ||
990 | /* | ||
991 | * Define iscsi_tpg_attrib_s_prod_mode_write_protect | ||
992 | */ | ||
993 | DEF_TPG_ATTRIB(prod_mode_write_protect); | 868 | DEF_TPG_ATTRIB(prod_mode_write_protect); |
994 | TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); | ||
995 | /* | ||
996 | * Define iscsi_tpg_attrib_s_demo_mode_discovery, | ||
997 | */ | ||
998 | DEF_TPG_ATTRIB(demo_mode_discovery); | 869 | DEF_TPG_ATTRIB(demo_mode_discovery); |
999 | TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR); | ||
1000 | /* | ||
1001 | * Define iscsi_tpg_attrib_s_default_erl | ||
1002 | */ | ||
1003 | DEF_TPG_ATTRIB(default_erl); | 870 | DEF_TPG_ATTRIB(default_erl); |
1004 | TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); | ||
1005 | /* | ||
1006 | * Define iscsi_tpg_attrib_s_t10_pi | ||
1007 | */ | ||
1008 | DEF_TPG_ATTRIB(t10_pi); | 871 | DEF_TPG_ATTRIB(t10_pi); |
1009 | TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR); | ||
1010 | /* | ||
1011 | * Define iscsi_tpg_attrib_s_fabric_prot_type | ||
1012 | */ | ||
1013 | DEF_TPG_ATTRIB(fabric_prot_type); | 872 | DEF_TPG_ATTRIB(fabric_prot_type); |
1014 | TPG_ATTR(fabric_prot_type, S_IRUGO | S_IWUSR); | ||
1015 | /* | ||
1016 | * Define iscsi_tpg_attrib_s_tpg_enabled_sendtargets | ||
1017 | */ | ||
1018 | DEF_TPG_ATTRIB(tpg_enabled_sendtargets); | 873 | DEF_TPG_ATTRIB(tpg_enabled_sendtargets); |
1019 | TPG_ATTR(tpg_enabled_sendtargets, S_IRUGO | S_IWUSR); | ||
1020 | 874 | ||
1021 | static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { | 875 | static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { |
1022 | &iscsi_tpg_attrib_authentication.attr, | 876 | &iscsi_tpg_attrib_attr_authentication, |
1023 | &iscsi_tpg_attrib_login_timeout.attr, | 877 | &iscsi_tpg_attrib_attr_login_timeout, |
1024 | &iscsi_tpg_attrib_netif_timeout.attr, | 878 | &iscsi_tpg_attrib_attr_netif_timeout, |
1025 | &iscsi_tpg_attrib_generate_node_acls.attr, | 879 | &iscsi_tpg_attrib_attr_generate_node_acls, |
1026 | &iscsi_tpg_attrib_default_cmdsn_depth.attr, | 880 | &iscsi_tpg_attrib_attr_default_cmdsn_depth, |
1027 | &iscsi_tpg_attrib_cache_dynamic_acls.attr, | 881 | &iscsi_tpg_attrib_attr_cache_dynamic_acls, |
1028 | &iscsi_tpg_attrib_demo_mode_write_protect.attr, | 882 | &iscsi_tpg_attrib_attr_demo_mode_write_protect, |
1029 | &iscsi_tpg_attrib_prod_mode_write_protect.attr, | 883 | &iscsi_tpg_attrib_attr_prod_mode_write_protect, |
1030 | &iscsi_tpg_attrib_demo_mode_discovery.attr, | 884 | &iscsi_tpg_attrib_attr_demo_mode_discovery, |
1031 | &iscsi_tpg_attrib_default_erl.attr, | 885 | &iscsi_tpg_attrib_attr_default_erl, |
1032 | &iscsi_tpg_attrib_t10_pi.attr, | 886 | &iscsi_tpg_attrib_attr_t10_pi, |
1033 | &iscsi_tpg_attrib_fabric_prot_type.attr, | 887 | &iscsi_tpg_attrib_attr_fabric_prot_type, |
1034 | &iscsi_tpg_attrib_tpg_enabled_sendtargets.attr, | 888 | &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets, |
1035 | NULL, | 889 | NULL, |
1036 | }; | 890 | }; |
1037 | 891 | ||
@@ -1040,9 +894,8 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { | |||
1040 | /* Start items for lio_target_tpg_auth_cit */ | 894 | /* Start items for lio_target_tpg_auth_cit */ |
1041 | 895 | ||
1042 | #define __DEF_TPG_AUTH_STR(prefix, name, flags) \ | 896 | #define __DEF_TPG_AUTH_STR(prefix, name, flags) \ |
1043 | static ssize_t __iscsi_##prefix##_show_##name( \ | 897 | static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \ |
1044 | struct se_portal_group *se_tpg, \ | 898 | char *page) \ |
1045 | char *page) \ | ||
1046 | { \ | 899 | { \ |
1047 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 900 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
1048 | struct iscsi_portal_group, tpg_se_tpg); \ | 901 | struct iscsi_portal_group, tpg_se_tpg); \ |
@@ -1054,10 +907,8 @@ static ssize_t __iscsi_##prefix##_show_##name( \ | |||
1054 | return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ | 907 | return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ |
1055 | } \ | 908 | } \ |
1056 | \ | 909 | \ |
1057 | static ssize_t __iscsi_##prefix##_store_##name( \ | 910 | static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\ |
1058 | struct se_portal_group *se_tpg, \ | 911 | const char *page, size_t count) \ |
1059 | const char *page, \ | ||
1060 | size_t count) \ | ||
1061 | { \ | 912 | { \ |
1062 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 913 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
1063 | struct iscsi_portal_group, tpg_se_tpg); \ | 914 | struct iscsi_portal_group, tpg_se_tpg); \ |
@@ -1081,10 +932,31 @@ static ssize_t __iscsi_##prefix##_store_##name( \ | |||
1081 | return count; \ | 932 | return count; \ |
1082 | } | 933 | } |
1083 | 934 | ||
935 | #define DEF_TPG_AUTH_STR(name, flags) \ | ||
936 | __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \ | ||
937 | static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \ | ||
938 | char *page) \ | ||
939 | { \ | ||
940 | return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \ | ||
941 | } \ | ||
942 | \ | ||
943 | static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \ | ||
944 | const char *page, size_t count) \ | ||
945 | { \ | ||
946 | return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \ | ||
947 | } \ | ||
948 | \ | ||
949 | CONFIGFS_ATTR(iscsi_tpg_auth_, name); | ||
950 | |||
951 | |||
952 | DEF_TPG_AUTH_STR(userid, NAF_USERID_SET); | ||
953 | DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET); | ||
954 | DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
955 | DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
956 | |||
1084 | #define __DEF_TPG_AUTH_INT(prefix, name) \ | 957 | #define __DEF_TPG_AUTH_INT(prefix, name) \ |
1085 | static ssize_t __iscsi_##prefix##_show_##name( \ | 958 | static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \ |
1086 | struct se_portal_group *se_tpg, \ | 959 | char *page) \ |
1087 | char *page) \ | ||
1088 | { \ | 960 | { \ |
1089 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 961 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
1090 | struct iscsi_portal_group, tpg_se_tpg); \ | 962 | struct iscsi_portal_group, tpg_se_tpg); \ |
@@ -1096,67 +968,23 @@ static ssize_t __iscsi_##prefix##_show_##name( \ | |||
1096 | return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ | 968 | return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ |
1097 | } | 969 | } |
1098 | 970 | ||
1099 | #define DEF_TPG_AUTH_STR(name, flags) \ | ||
1100 | __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \ | ||
1101 | static ssize_t iscsi_tpg_auth_show_##name( \ | ||
1102 | struct se_portal_group *se_tpg, \ | ||
1103 | char *page) \ | ||
1104 | { \ | ||
1105 | return __iscsi_tpg_auth_show_##name(se_tpg, page); \ | ||
1106 | } \ | ||
1107 | \ | ||
1108 | static ssize_t iscsi_tpg_auth_store_##name( \ | ||
1109 | struct se_portal_group *se_tpg, \ | ||
1110 | const char *page, \ | ||
1111 | size_t count) \ | ||
1112 | { \ | ||
1113 | return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \ | ||
1114 | } | ||
1115 | |||
1116 | #define DEF_TPG_AUTH_INT(name) \ | 971 | #define DEF_TPG_AUTH_INT(name) \ |
1117 | __DEF_TPG_AUTH_INT(tpg_auth, name) \ | 972 | __DEF_TPG_AUTH_INT(tpg_auth, name) \ |
1118 | static ssize_t iscsi_tpg_auth_show_##name( \ | 973 | static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \ |
1119 | struct se_portal_group *se_tpg, \ | 974 | char *page) \ |
1120 | char *page) \ | ||
1121 | { \ | 975 | { \ |
1122 | return __iscsi_tpg_auth_show_##name(se_tpg, page); \ | 976 | return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \ |
1123 | } | 977 | } \ |
1124 | 978 | CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name); | |
1125 | #define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode); | ||
1126 | #define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name); | ||
1127 | 979 | ||
1128 | /* | ||
1129 | * * One-way authentication userid | ||
1130 | * */ | ||
1131 | DEF_TPG_AUTH_STR(userid, NAF_USERID_SET); | ||
1132 | TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); | ||
1133 | /* | ||
1134 | * * One-way authentication password | ||
1135 | * */ | ||
1136 | DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET); | ||
1137 | TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR); | ||
1138 | /* | ||
1139 | * * Enforce mutual authentication | ||
1140 | * */ | ||
1141 | DEF_TPG_AUTH_INT(authenticate_target); | 980 | DEF_TPG_AUTH_INT(authenticate_target); |
1142 | TPG_AUTH_ATTR_RO(authenticate_target); | ||
1143 | /* | ||
1144 | * * Mutual authentication userid | ||
1145 | * */ | ||
1146 | DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
1147 | TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); | ||
1148 | /* | ||
1149 | * * Mutual authentication password | ||
1150 | * */ | ||
1151 | DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
1152 | TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); | ||
1153 | 981 | ||
1154 | static struct configfs_attribute *lio_target_tpg_auth_attrs[] = { | 982 | static struct configfs_attribute *lio_target_tpg_auth_attrs[] = { |
1155 | &iscsi_tpg_auth_userid.attr, | 983 | &iscsi_tpg_auth_attr_userid, |
1156 | &iscsi_tpg_auth_password.attr, | 984 | &iscsi_tpg_auth_attr_password, |
1157 | &iscsi_tpg_auth_authenticate_target.attr, | 985 | &iscsi_tpg_auth_attr_authenticate_target, |
1158 | &iscsi_tpg_auth_userid_mutual.attr, | 986 | &iscsi_tpg_auth_attr_userid_mutual, |
1159 | &iscsi_tpg_auth_password_mutual.attr, | 987 | &iscsi_tpg_auth_attr_password_mutual, |
1160 | NULL, | 988 | NULL, |
1161 | }; | 989 | }; |
1162 | 990 | ||
@@ -1165,10 +993,10 @@ static struct configfs_attribute *lio_target_tpg_auth_attrs[] = { | |||
1165 | /* Start items for lio_target_tpg_param_cit */ | 993 | /* Start items for lio_target_tpg_param_cit */ |
1166 | 994 | ||
1167 | #define DEF_TPG_PARAM(name) \ | 995 | #define DEF_TPG_PARAM(name) \ |
1168 | static ssize_t iscsi_tpg_param_show_##name( \ | 996 | static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \ |
1169 | struct se_portal_group *se_tpg, \ | 997 | char *page) \ |
1170 | char *page) \ | ||
1171 | { \ | 998 | { \ |
999 | struct se_portal_group *se_tpg = param_to_tpg(item); \ | ||
1172 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 1000 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
1173 | struct iscsi_portal_group, tpg_se_tpg); \ | 1001 | struct iscsi_portal_group, tpg_se_tpg); \ |
1174 | struct iscsi_param *param; \ | 1002 | struct iscsi_param *param; \ |
@@ -1188,11 +1016,10 @@ static ssize_t iscsi_tpg_param_show_##name( \ | |||
1188 | iscsit_put_tpg(tpg); \ | 1016 | iscsit_put_tpg(tpg); \ |
1189 | return rb; \ | 1017 | return rb; \ |
1190 | } \ | 1018 | } \ |
1191 | static ssize_t iscsi_tpg_param_store_##name( \ | 1019 | static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \ |
1192 | struct se_portal_group *se_tpg, \ | 1020 | const char *page, size_t count) \ |
1193 | const char *page, \ | ||
1194 | size_t count) \ | ||
1195 | { \ | 1021 | { \ |
1022 | struct se_portal_group *se_tpg = param_to_tpg(item); \ | ||
1196 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ | 1023 | struct iscsi_portal_group *tpg = container_of(se_tpg, \ |
1197 | struct iscsi_portal_group, tpg_se_tpg); \ | 1024 | struct iscsi_portal_group, tpg_se_tpg); \ |
1198 | char *buf; \ | 1025 | char *buf; \ |
@@ -1220,96 +1047,54 @@ static ssize_t iscsi_tpg_param_store_##name( \ | |||
1220 | out: \ | 1047 | out: \ |
1221 | kfree(buf); \ | 1048 | kfree(buf); \ |
1222 | iscsit_put_tpg(tpg); \ | 1049 | iscsit_put_tpg(tpg); \ |
1223 | return -EINVAL; \ | 1050 | return -EINVAL; \ |
1224 | } | 1051 | } \ |
1225 | 1052 | CONFIGFS_ATTR(iscsi_tpg_param_, name) | |
1226 | #define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode); | ||
1227 | 1053 | ||
1228 | DEF_TPG_PARAM(AuthMethod); | 1054 | DEF_TPG_PARAM(AuthMethod); |
1229 | TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR); | ||
1230 | |||
1231 | DEF_TPG_PARAM(HeaderDigest); | 1055 | DEF_TPG_PARAM(HeaderDigest); |
1232 | TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR); | ||
1233 | |||
1234 | DEF_TPG_PARAM(DataDigest); | 1056 | DEF_TPG_PARAM(DataDigest); |
1235 | TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR); | ||
1236 | |||
1237 | DEF_TPG_PARAM(MaxConnections); | 1057 | DEF_TPG_PARAM(MaxConnections); |
1238 | TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR); | ||
1239 | |||
1240 | DEF_TPG_PARAM(TargetAlias); | 1058 | DEF_TPG_PARAM(TargetAlias); |
1241 | TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR); | ||
1242 | |||
1243 | DEF_TPG_PARAM(InitialR2T); | 1059 | DEF_TPG_PARAM(InitialR2T); |
1244 | TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR); | ||
1245 | |||
1246 | DEF_TPG_PARAM(ImmediateData); | 1060 | DEF_TPG_PARAM(ImmediateData); |
1247 | TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR); | ||
1248 | |||
1249 | DEF_TPG_PARAM(MaxRecvDataSegmentLength); | 1061 | DEF_TPG_PARAM(MaxRecvDataSegmentLength); |
1250 | TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR); | ||
1251 | |||
1252 | DEF_TPG_PARAM(MaxXmitDataSegmentLength); | 1062 | DEF_TPG_PARAM(MaxXmitDataSegmentLength); |
1253 | TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR); | ||
1254 | |||
1255 | DEF_TPG_PARAM(MaxBurstLength); | 1063 | DEF_TPG_PARAM(MaxBurstLength); |
1256 | TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR); | ||
1257 | |||
1258 | DEF_TPG_PARAM(FirstBurstLength); | 1064 | DEF_TPG_PARAM(FirstBurstLength); |
1259 | TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR); | ||
1260 | |||
1261 | DEF_TPG_PARAM(DefaultTime2Wait); | 1065 | DEF_TPG_PARAM(DefaultTime2Wait); |
1262 | TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR); | ||
1263 | |||
1264 | DEF_TPG_PARAM(DefaultTime2Retain); | 1066 | DEF_TPG_PARAM(DefaultTime2Retain); |
1265 | TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR); | ||
1266 | |||
1267 | DEF_TPG_PARAM(MaxOutstandingR2T); | 1067 | DEF_TPG_PARAM(MaxOutstandingR2T); |
1268 | TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR); | ||
1269 | |||
1270 | DEF_TPG_PARAM(DataPDUInOrder); | 1068 | DEF_TPG_PARAM(DataPDUInOrder); |
1271 | TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR); | ||
1272 | |||
1273 | DEF_TPG_PARAM(DataSequenceInOrder); | 1069 | DEF_TPG_PARAM(DataSequenceInOrder); |
1274 | TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR); | ||
1275 | |||
1276 | DEF_TPG_PARAM(ErrorRecoveryLevel); | 1070 | DEF_TPG_PARAM(ErrorRecoveryLevel); |
1277 | TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR); | ||
1278 | |||
1279 | DEF_TPG_PARAM(IFMarker); | 1071 | DEF_TPG_PARAM(IFMarker); |
1280 | TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR); | ||
1281 | |||
1282 | DEF_TPG_PARAM(OFMarker); | 1072 | DEF_TPG_PARAM(OFMarker); |
1283 | TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR); | ||
1284 | |||
1285 | DEF_TPG_PARAM(IFMarkInt); | 1073 | DEF_TPG_PARAM(IFMarkInt); |
1286 | TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR); | ||
1287 | |||
1288 | DEF_TPG_PARAM(OFMarkInt); | 1074 | DEF_TPG_PARAM(OFMarkInt); |
1289 | TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR); | ||
1290 | 1075 | ||
1291 | static struct configfs_attribute *lio_target_tpg_param_attrs[] = { | 1076 | static struct configfs_attribute *lio_target_tpg_param_attrs[] = { |
1292 | &iscsi_tpg_param_AuthMethod.attr, | 1077 | &iscsi_tpg_param_attr_AuthMethod, |
1293 | &iscsi_tpg_param_HeaderDigest.attr, | 1078 | &iscsi_tpg_param_attr_HeaderDigest, |
1294 | &iscsi_tpg_param_DataDigest.attr, | 1079 | &iscsi_tpg_param_attr_DataDigest, |
1295 | &iscsi_tpg_param_MaxConnections.attr, | 1080 | &iscsi_tpg_param_attr_MaxConnections, |
1296 | &iscsi_tpg_param_TargetAlias.attr, | 1081 | &iscsi_tpg_param_attr_TargetAlias, |
1297 | &iscsi_tpg_param_InitialR2T.attr, | 1082 | &iscsi_tpg_param_attr_InitialR2T, |
1298 | &iscsi_tpg_param_ImmediateData.attr, | 1083 | &iscsi_tpg_param_attr_ImmediateData, |
1299 | &iscsi_tpg_param_MaxRecvDataSegmentLength.attr, | 1084 | &iscsi_tpg_param_attr_MaxRecvDataSegmentLength, |
1300 | &iscsi_tpg_param_MaxXmitDataSegmentLength.attr, | 1085 | &iscsi_tpg_param_attr_MaxXmitDataSegmentLength, |
1301 | &iscsi_tpg_param_MaxBurstLength.attr, | 1086 | &iscsi_tpg_param_attr_MaxBurstLength, |
1302 | &iscsi_tpg_param_FirstBurstLength.attr, | 1087 | &iscsi_tpg_param_attr_FirstBurstLength, |
1303 | &iscsi_tpg_param_DefaultTime2Wait.attr, | 1088 | &iscsi_tpg_param_attr_DefaultTime2Wait, |
1304 | &iscsi_tpg_param_DefaultTime2Retain.attr, | 1089 | &iscsi_tpg_param_attr_DefaultTime2Retain, |
1305 | &iscsi_tpg_param_MaxOutstandingR2T.attr, | 1090 | &iscsi_tpg_param_attr_MaxOutstandingR2T, |
1306 | &iscsi_tpg_param_DataPDUInOrder.attr, | 1091 | &iscsi_tpg_param_attr_DataPDUInOrder, |
1307 | &iscsi_tpg_param_DataSequenceInOrder.attr, | 1092 | &iscsi_tpg_param_attr_DataSequenceInOrder, |
1308 | &iscsi_tpg_param_ErrorRecoveryLevel.attr, | 1093 | &iscsi_tpg_param_attr_ErrorRecoveryLevel, |
1309 | &iscsi_tpg_param_IFMarker.attr, | 1094 | &iscsi_tpg_param_attr_IFMarker, |
1310 | &iscsi_tpg_param_OFMarker.attr, | 1095 | &iscsi_tpg_param_attr_OFMarker, |
1311 | &iscsi_tpg_param_IFMarkInt.attr, | 1096 | &iscsi_tpg_param_attr_IFMarkInt, |
1312 | &iscsi_tpg_param_OFMarkInt.attr, | 1097 | &iscsi_tpg_param_attr_OFMarkInt, |
1313 | NULL, | 1098 | NULL, |
1314 | }; | 1099 | }; |
1315 | 1100 | ||
@@ -1317,10 +1102,9 @@ static struct configfs_attribute *lio_target_tpg_param_attrs[] = { | |||
1317 | 1102 | ||
1318 | /* Start items for lio_target_tpg_cit */ | 1103 | /* Start items for lio_target_tpg_cit */ |
1319 | 1104 | ||
1320 | static ssize_t lio_target_tpg_show_enable( | 1105 | static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page) |
1321 | struct se_portal_group *se_tpg, | ||
1322 | char *page) | ||
1323 | { | 1106 | { |
1107 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1324 | struct iscsi_portal_group *tpg = container_of(se_tpg, | 1108 | struct iscsi_portal_group *tpg = container_of(se_tpg, |
1325 | struct iscsi_portal_group, tpg_se_tpg); | 1109 | struct iscsi_portal_group, tpg_se_tpg); |
1326 | ssize_t len; | 1110 | ssize_t len; |
@@ -1333,11 +1117,10 @@ static ssize_t lio_target_tpg_show_enable( | |||
1333 | return len; | 1117 | return len; |
1334 | } | 1118 | } |
1335 | 1119 | ||
1336 | static ssize_t lio_target_tpg_store_enable( | 1120 | static ssize_t lio_target_tpg_enable_store(struct config_item *item, |
1337 | struct se_portal_group *se_tpg, | 1121 | const char *page, size_t count) |
1338 | const char *page, | ||
1339 | size_t count) | ||
1340 | { | 1122 | { |
1123 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1341 | struct iscsi_portal_group *tpg = container_of(se_tpg, | 1124 | struct iscsi_portal_group *tpg = container_of(se_tpg, |
1342 | struct iscsi_portal_group, tpg_se_tpg); | 1125 | struct iscsi_portal_group, tpg_se_tpg); |
1343 | u32 op; | 1126 | u32 op; |
@@ -1375,20 +1158,19 @@ out: | |||
1375 | return -EINVAL; | 1158 | return -EINVAL; |
1376 | } | 1159 | } |
1377 | 1160 | ||
1378 | TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR); | ||
1379 | 1161 | ||
1380 | static ssize_t lio_target_tpg_show_dynamic_sessions( | 1162 | static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item, |
1381 | struct se_portal_group *se_tpg, | 1163 | char *page) |
1382 | char *page) | ||
1383 | { | 1164 | { |
1384 | return target_show_dynamic_sessions(se_tpg, page); | 1165 | return target_show_dynamic_sessions(to_tpg(item), page); |
1385 | } | 1166 | } |
1386 | 1167 | ||
1387 | TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions); | 1168 | CONFIGFS_ATTR(lio_target_tpg_, enable); |
1169 | CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions); | ||
1388 | 1170 | ||
1389 | static struct configfs_attribute *lio_target_tpg_attrs[] = { | 1171 | static struct configfs_attribute *lio_target_tpg_attrs[] = { |
1390 | &lio_target_tpg_enable.attr, | 1172 | &lio_target_tpg_attr_enable, |
1391 | &lio_target_tpg_dynamic_sessions.attr, | 1173 | &lio_target_tpg_attr_dynamic_sessions, |
1392 | NULL, | 1174 | NULL, |
1393 | }; | 1175 | }; |
1394 | 1176 | ||
@@ -1463,17 +1245,16 @@ static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg) | |||
1463 | 1245 | ||
1464 | /* Start LIO-Target TIQN struct contig_item lio_target_cit */ | 1246 | /* Start LIO-Target TIQN struct contig_item lio_target_cit */ |
1465 | 1247 | ||
1466 | static ssize_t lio_target_wwn_show_attr_lio_version( | 1248 | static ssize_t lio_target_wwn_lio_version_show(struct config_item *item, |
1467 | struct target_fabric_configfs *tf, | 1249 | char *page) |
1468 | char *page) | ||
1469 | { | 1250 | { |
1470 | return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n"); | 1251 | return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n"); |
1471 | } | 1252 | } |
1472 | 1253 | ||
1473 | TF_WWN_ATTR_RO(lio_target, lio_version); | 1254 | CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version); |
1474 | 1255 | ||
1475 | static struct configfs_attribute *lio_target_wwn_attrs[] = { | 1256 | static struct configfs_attribute *lio_target_wwn_attrs[] = { |
1476 | &lio_target_wwn_lio_version.attr, | 1257 | &lio_target_wwn_attr_lio_version, |
1477 | NULL, | 1258 | NULL, |
1478 | }; | 1259 | }; |
1479 | 1260 | ||
@@ -1552,77 +1333,47 @@ static void lio_target_call_coredeltiqn( | |||
1552 | 1333 | ||
1553 | #define DEF_DISC_AUTH_STR(name, flags) \ | 1334 | #define DEF_DISC_AUTH_STR(name, flags) \ |
1554 | __DEF_NACL_AUTH_STR(disc, name, flags) \ | 1335 | __DEF_NACL_AUTH_STR(disc, name, flags) \ |
1555 | static ssize_t iscsi_disc_show_##name( \ | 1336 | static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \ |
1556 | struct target_fabric_configfs *tf, \ | ||
1557 | char *page) \ | ||
1558 | { \ | 1337 | { \ |
1559 | return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ | 1338 | return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\ |
1560 | page); \ | 1339 | page); \ |
1561 | } \ | 1340 | } \ |
1562 | static ssize_t iscsi_disc_store_##name( \ | 1341 | static ssize_t iscsi_disc_##name##_store(struct config_item *item, \ |
1563 | struct target_fabric_configfs *tf, \ | 1342 | const char *page, size_t count) \ |
1564 | const char *page, \ | ||
1565 | size_t count) \ | ||
1566 | { \ | 1343 | { \ |
1567 | return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \ | 1344 | return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \ |
1568 | page, count); \ | 1345 | page, count); \ |
1569 | } | 1346 | \ |
1347 | } \ | ||
1348 | CONFIGFS_ATTR(iscsi_disc_, name) | ||
1349 | |||
1350 | DEF_DISC_AUTH_STR(userid, NAF_USERID_SET); | ||
1351 | DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET); | ||
1352 | DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
1353 | DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
1570 | 1354 | ||
1571 | #define DEF_DISC_AUTH_INT(name) \ | 1355 | #define DEF_DISC_AUTH_INT(name) \ |
1572 | __DEF_NACL_AUTH_INT(disc, name) \ | 1356 | __DEF_NACL_AUTH_INT(disc, name) \ |
1573 | static ssize_t iscsi_disc_show_##name( \ | 1357 | static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \ |
1574 | struct target_fabric_configfs *tf, \ | ||
1575 | char *page) \ | ||
1576 | { \ | 1358 | { \ |
1577 | return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ | 1359 | return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \ |
1578 | page); \ | 1360 | page); \ |
1579 | } | 1361 | } \ |
1580 | 1362 | CONFIGFS_ATTR_RO(iscsi_disc_, name) | |
1581 | #define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode) | ||
1582 | #define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name) | ||
1583 | 1363 | ||
1584 | /* | ||
1585 | * One-way authentication userid | ||
1586 | */ | ||
1587 | DEF_DISC_AUTH_STR(userid, NAF_USERID_SET); | ||
1588 | DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); | ||
1589 | /* | ||
1590 | * One-way authentication password | ||
1591 | */ | ||
1592 | DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET); | ||
1593 | DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR); | ||
1594 | /* | ||
1595 | * Enforce mutual authentication | ||
1596 | */ | ||
1597 | DEF_DISC_AUTH_INT(authenticate_target); | 1364 | DEF_DISC_AUTH_INT(authenticate_target); |
1598 | DISC_AUTH_ATTR_RO(authenticate_target); | ||
1599 | /* | ||
1600 | * Mutual authentication userid | ||
1601 | */ | ||
1602 | DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); | ||
1603 | DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); | ||
1604 | /* | ||
1605 | * Mutual authentication password | ||
1606 | */ | ||
1607 | DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); | ||
1608 | DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); | ||
1609 | 1365 | ||
1610 | /* | 1366 | |
1611 | * enforce_discovery_auth | 1367 | static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item, |
1612 | */ | 1368 | char *page) |
1613 | static ssize_t iscsi_disc_show_enforce_discovery_auth( | ||
1614 | struct target_fabric_configfs *tf, | ||
1615 | char *page) | ||
1616 | { | 1369 | { |
1617 | struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth; | 1370 | struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth; |
1618 | 1371 | ||
1619 | return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth); | 1372 | return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth); |
1620 | } | 1373 | } |
1621 | 1374 | ||
1622 | static ssize_t iscsi_disc_store_enforce_discovery_auth( | 1375 | static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item, |
1623 | struct target_fabric_configfs *tf, | 1376 | const char *page, size_t count) |
1624 | const char *page, | ||
1625 | size_t count) | ||
1626 | { | 1377 | { |
1627 | struct iscsi_param *param; | 1378 | struct iscsi_param *param; |
1628 | struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; | 1379 | struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; |
@@ -1677,15 +1428,15 @@ static ssize_t iscsi_disc_store_enforce_discovery_auth( | |||
1677 | return count; | 1428 | return count; |
1678 | } | 1429 | } |
1679 | 1430 | ||
1680 | DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR); | 1431 | CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth); |
1681 | 1432 | ||
1682 | static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { | 1433 | static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { |
1683 | &iscsi_disc_userid.attr, | 1434 | &iscsi_disc_attr_userid, |
1684 | &iscsi_disc_password.attr, | 1435 | &iscsi_disc_attr_password, |
1685 | &iscsi_disc_authenticate_target.attr, | 1436 | &iscsi_disc_attr_authenticate_target, |
1686 | &iscsi_disc_userid_mutual.attr, | 1437 | &iscsi_disc_attr_userid_mutual, |
1687 | &iscsi_disc_password_mutual.attr, | 1438 | &iscsi_disc_attr_password_mutual, |
1688 | &iscsi_disc_enforce_discovery_auth.attr, | 1439 | &iscsi_disc_attr_enforce_discovery_auth, |
1689 | NULL, | 1440 | NULL, |
1690 | }; | 1441 | }; |
1691 | 1442 | ||
diff --git a/drivers/target/iscsi/iscsi_target_stat.c b/drivers/target/iscsi/iscsi_target_stat.c index 9dd94ff0b62c..411cb266a47d 100644 --- a/drivers/target/iscsi/iscsi_target_stat.c +++ b/drivers/target/iscsi/iscsi_target_stat.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/export.h> | 21 | #include <linux/export.h> |
22 | #include <scsi/iscsi_proto.h> | 22 | #include <scsi/iscsi_proto.h> |
23 | #include <target/target_core_base.h> | 23 | #include <target/target_core_base.h> |
24 | #include <target/configfs_macros.h> | ||
25 | 24 | ||
26 | #include <target/iscsi/iscsi_target_core.h> | 25 | #include <target/iscsi/iscsi_target_core.h> |
27 | #include "iscsi_target_parameters.h" | 26 | #include "iscsi_target_parameters.h" |
@@ -50,76 +49,56 @@ | |||
50 | /* | 49 | /* |
51 | * Instance Attributes Table | 50 | * Instance Attributes Table |
52 | */ | 51 | */ |
53 | CONFIGFS_EATTR_STRUCT(iscsi_stat_instance, iscsi_wwn_stat_grps); | 52 | static struct iscsi_tiqn *iscsi_instance_tiqn(struct config_item *item) |
54 | #define ISCSI_STAT_INSTANCE_ATTR(_name, _mode) \ | 53 | { |
55 | static struct iscsi_stat_instance_attribute \ | 54 | struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), |
56 | iscsi_stat_instance_##_name = \ | 55 | struct iscsi_wwn_stat_grps, iscsi_instance_group); |
57 | __CONFIGFS_EATTR(_name, _mode, \ | 56 | return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); |
58 | iscsi_stat_instance_show_attr_##_name, \ | 57 | } |
59 | iscsi_stat_instance_store_attr_##_name); | ||
60 | |||
61 | #define ISCSI_STAT_INSTANCE_ATTR_RO(_name) \ | ||
62 | static struct iscsi_stat_instance_attribute \ | ||
63 | iscsi_stat_instance_##_name = \ | ||
64 | __CONFIGFS_EATTR_RO(_name, \ | ||
65 | iscsi_stat_instance_show_attr_##_name); | ||
66 | |||
67 | static ssize_t iscsi_stat_instance_show_attr_inst( | ||
68 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
69 | { | ||
70 | struct iscsi_tiqn *tiqn = container_of(igrps, | ||
71 | struct iscsi_tiqn, tiqn_stat_grps); | ||
72 | 58 | ||
73 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 59 | static ssize_t iscsi_stat_instance_inst_show(struct config_item *item, |
60 | char *page) | ||
61 | { | ||
62 | return snprintf(page, PAGE_SIZE, "%u\n", | ||
63 | iscsi_instance_tiqn(item)->tiqn_index); | ||
74 | } | 64 | } |
75 | ISCSI_STAT_INSTANCE_ATTR_RO(inst); | ||
76 | 65 | ||
77 | static ssize_t iscsi_stat_instance_show_attr_min_ver( | 66 | static ssize_t iscsi_stat_instance_min_ver_show(struct config_item *item, |
78 | struct iscsi_wwn_stat_grps *igrps, char *page) | 67 | char *page) |
79 | { | 68 | { |
80 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); | 69 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); |
81 | } | 70 | } |
82 | ISCSI_STAT_INSTANCE_ATTR_RO(min_ver); | ||
83 | 71 | ||
84 | static ssize_t iscsi_stat_instance_show_attr_max_ver( | 72 | static ssize_t iscsi_stat_instance_max_ver_show(struct config_item *item, |
85 | struct iscsi_wwn_stat_grps *igrps, char *page) | 73 | char *page) |
86 | { | 74 | { |
87 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); | 75 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); |
88 | } | 76 | } |
89 | ISCSI_STAT_INSTANCE_ATTR_RO(max_ver); | ||
90 | 77 | ||
91 | static ssize_t iscsi_stat_instance_show_attr_portals( | 78 | static ssize_t iscsi_stat_instance_portals_show(struct config_item *item, |
92 | struct iscsi_wwn_stat_grps *igrps, char *page) | 79 | char *page) |
93 | { | 80 | { |
94 | struct iscsi_tiqn *tiqn = container_of(igrps, | 81 | return snprintf(page, PAGE_SIZE, "%u\n", |
95 | struct iscsi_tiqn, tiqn_stat_grps); | 82 | iscsi_instance_tiqn(item)->tiqn_num_tpg_nps); |
96 | |||
97 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_num_tpg_nps); | ||
98 | } | 83 | } |
99 | ISCSI_STAT_INSTANCE_ATTR_RO(portals); | ||
100 | 84 | ||
101 | static ssize_t iscsi_stat_instance_show_attr_nodes( | 85 | static ssize_t iscsi_stat_instance_nodes_show(struct config_item *item, |
102 | struct iscsi_wwn_stat_grps *igrps, char *page) | 86 | char *page) |
103 | { | 87 | { |
104 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_INST_NUM_NODES); | 88 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_INST_NUM_NODES); |
105 | } | 89 | } |
106 | ISCSI_STAT_INSTANCE_ATTR_RO(nodes); | ||
107 | 90 | ||
108 | static ssize_t iscsi_stat_instance_show_attr_sessions( | 91 | static ssize_t iscsi_stat_instance_sessions_show(struct config_item *item, |
109 | struct iscsi_wwn_stat_grps *igrps, char *page) | 92 | char *page) |
110 | { | 93 | { |
111 | struct iscsi_tiqn *tiqn = container_of(igrps, | 94 | return snprintf(page, PAGE_SIZE, "%u\n", |
112 | struct iscsi_tiqn, tiqn_stat_grps); | 95 | iscsi_instance_tiqn(item)->tiqn_nsessions); |
113 | |||
114 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_nsessions); | ||
115 | } | 96 | } |
116 | ISCSI_STAT_INSTANCE_ATTR_RO(sessions); | ||
117 | 97 | ||
118 | static ssize_t iscsi_stat_instance_show_attr_fail_sess( | 98 | static ssize_t iscsi_stat_instance_fail_sess_show(struct config_item *item, |
119 | struct iscsi_wwn_stat_grps *igrps, char *page) | 99 | char *page) |
120 | { | 100 | { |
121 | struct iscsi_tiqn *tiqn = container_of(igrps, | 101 | struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); |
122 | struct iscsi_tiqn, tiqn_stat_grps); | ||
123 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 102 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
124 | u32 sess_err_count; | 103 | u32 sess_err_count; |
125 | 104 | ||
@@ -131,88 +110,84 @@ static ssize_t iscsi_stat_instance_show_attr_fail_sess( | |||
131 | 110 | ||
132 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err_count); | 111 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err_count); |
133 | } | 112 | } |
134 | ISCSI_STAT_INSTANCE_ATTR_RO(fail_sess); | ||
135 | 113 | ||
136 | static ssize_t iscsi_stat_instance_show_attr_fail_type( | 114 | static ssize_t iscsi_stat_instance_fail_type_show(struct config_item *item, |
137 | struct iscsi_wwn_stat_grps *igrps, char *page) | 115 | char *page) |
138 | { | 116 | { |
139 | struct iscsi_tiqn *tiqn = container_of(igrps, | 117 | struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); |
140 | struct iscsi_tiqn, tiqn_stat_grps); | ||
141 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 118 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
142 | 119 | ||
143 | return snprintf(page, PAGE_SIZE, "%u\n", | 120 | return snprintf(page, PAGE_SIZE, "%u\n", |
144 | sess_err->last_sess_failure_type); | 121 | sess_err->last_sess_failure_type); |
145 | } | 122 | } |
146 | ISCSI_STAT_INSTANCE_ATTR_RO(fail_type); | ||
147 | 123 | ||
148 | static ssize_t iscsi_stat_instance_show_attr_fail_rem_name( | 124 | static ssize_t iscsi_stat_instance_fail_rem_name_show(struct config_item *item, |
149 | struct iscsi_wwn_stat_grps *igrps, char *page) | 125 | char *page) |
150 | { | 126 | { |
151 | struct iscsi_tiqn *tiqn = container_of(igrps, | 127 | struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); |
152 | struct iscsi_tiqn, tiqn_stat_grps); | ||
153 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 128 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
154 | 129 | ||
155 | return snprintf(page, PAGE_SIZE, "%s\n", | 130 | return snprintf(page, PAGE_SIZE, "%s\n", |
156 | sess_err->last_sess_fail_rem_name[0] ? | 131 | sess_err->last_sess_fail_rem_name[0] ? |
157 | sess_err->last_sess_fail_rem_name : NONE); | 132 | sess_err->last_sess_fail_rem_name : NONE); |
158 | } | 133 | } |
159 | ISCSI_STAT_INSTANCE_ATTR_RO(fail_rem_name); | ||
160 | 134 | ||
161 | static ssize_t iscsi_stat_instance_show_attr_disc_time( | 135 | static ssize_t iscsi_stat_instance_disc_time_show(struct config_item *item, |
162 | struct iscsi_wwn_stat_grps *igrps, char *page) | 136 | char *page) |
163 | { | 137 | { |
164 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DISCONTINUITY_TIME); | 138 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DISCONTINUITY_TIME); |
165 | } | 139 | } |
166 | ISCSI_STAT_INSTANCE_ATTR_RO(disc_time); | ||
167 | 140 | ||
168 | static ssize_t iscsi_stat_instance_show_attr_description( | 141 | static ssize_t iscsi_stat_instance_description_show(struct config_item *item, |
169 | struct iscsi_wwn_stat_grps *igrps, char *page) | 142 | char *page) |
170 | { | 143 | { |
171 | return snprintf(page, PAGE_SIZE, "%s\n", ISCSI_INST_DESCR); | 144 | return snprintf(page, PAGE_SIZE, "%s\n", ISCSI_INST_DESCR); |
172 | } | 145 | } |
173 | ISCSI_STAT_INSTANCE_ATTR_RO(description); | ||
174 | 146 | ||
175 | static ssize_t iscsi_stat_instance_show_attr_vendor( | 147 | static ssize_t iscsi_stat_instance_vendor_show(struct config_item *item, |
176 | struct iscsi_wwn_stat_grps *igrps, char *page) | 148 | char *page) |
177 | { | 149 | { |
178 | return snprintf(page, PAGE_SIZE, "Datera, Inc. iSCSI-Target\n"); | 150 | return snprintf(page, PAGE_SIZE, "Datera, Inc. iSCSI-Target\n"); |
179 | } | 151 | } |
180 | ISCSI_STAT_INSTANCE_ATTR_RO(vendor); | ||
181 | 152 | ||
182 | static ssize_t iscsi_stat_instance_show_attr_version( | 153 | static ssize_t iscsi_stat_instance_version_show(struct config_item *item, |
183 | struct iscsi_wwn_stat_grps *igrps, char *page) | 154 | char *page) |
184 | { | 155 | { |
185 | return snprintf(page, PAGE_SIZE, "%s\n", ISCSIT_VERSION); | 156 | return snprintf(page, PAGE_SIZE, "%s\n", ISCSIT_VERSION); |
186 | } | 157 | } |
187 | ISCSI_STAT_INSTANCE_ATTR_RO(version); | ||
188 | 158 | ||
189 | CONFIGFS_EATTR_OPS(iscsi_stat_instance, iscsi_wwn_stat_grps, | 159 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, inst); |
190 | iscsi_instance_group); | 160 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, min_ver); |
161 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, max_ver); | ||
162 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, portals); | ||
163 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, nodes); | ||
164 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, sessions); | ||
165 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_sess); | ||
166 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_type); | ||
167 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_rem_name); | ||
168 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, disc_time); | ||
169 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, description); | ||
170 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, vendor); | ||
171 | CONFIGFS_ATTR_RO(iscsi_stat_instance_, version); | ||
191 | 172 | ||
192 | static struct configfs_attribute *iscsi_stat_instance_attrs[] = { | 173 | static struct configfs_attribute *iscsi_stat_instance_attrs[] = { |
193 | &iscsi_stat_instance_inst.attr, | 174 | &iscsi_stat_instance_attr_inst, |
194 | &iscsi_stat_instance_min_ver.attr, | 175 | &iscsi_stat_instance_attr_min_ver, |
195 | &iscsi_stat_instance_max_ver.attr, | 176 | &iscsi_stat_instance_attr_max_ver, |
196 | &iscsi_stat_instance_portals.attr, | 177 | &iscsi_stat_instance_attr_portals, |
197 | &iscsi_stat_instance_nodes.attr, | 178 | &iscsi_stat_instance_attr_nodes, |
198 | &iscsi_stat_instance_sessions.attr, | 179 | &iscsi_stat_instance_attr_sessions, |
199 | &iscsi_stat_instance_fail_sess.attr, | 180 | &iscsi_stat_instance_attr_fail_sess, |
200 | &iscsi_stat_instance_fail_type.attr, | 181 | &iscsi_stat_instance_attr_fail_type, |
201 | &iscsi_stat_instance_fail_rem_name.attr, | 182 | &iscsi_stat_instance_attr_fail_rem_name, |
202 | &iscsi_stat_instance_disc_time.attr, | 183 | &iscsi_stat_instance_attr_disc_time, |
203 | &iscsi_stat_instance_description.attr, | 184 | &iscsi_stat_instance_attr_description, |
204 | &iscsi_stat_instance_vendor.attr, | 185 | &iscsi_stat_instance_attr_vendor, |
205 | &iscsi_stat_instance_version.attr, | 186 | &iscsi_stat_instance_attr_version, |
206 | NULL, | 187 | NULL, |
207 | }; | 188 | }; |
208 | 189 | ||
209 | static struct configfs_item_operations iscsi_stat_instance_item_ops = { | ||
210 | .show_attribute = iscsi_stat_instance_attr_show, | ||
211 | .store_attribute = iscsi_stat_instance_attr_store, | ||
212 | }; | ||
213 | |||
214 | struct config_item_type iscsi_stat_instance_cit = { | 190 | struct config_item_type iscsi_stat_instance_cit = { |
215 | .ct_item_ops = &iscsi_stat_instance_item_ops, | ||
216 | .ct_attrs = iscsi_stat_instance_attrs, | 191 | .ct_attrs = iscsi_stat_instance_attrs, |
217 | .ct_owner = THIS_MODULE, | 192 | .ct_owner = THIS_MODULE, |
218 | }; | 193 | }; |
@@ -220,81 +195,61 @@ struct config_item_type iscsi_stat_instance_cit = { | |||
220 | /* | 195 | /* |
221 | * Instance Session Failure Stats Table | 196 | * Instance Session Failure Stats Table |
222 | */ | 197 | */ |
223 | CONFIGFS_EATTR_STRUCT(iscsi_stat_sess_err, iscsi_wwn_stat_grps); | 198 | static struct iscsi_tiqn *iscsi_sess_err_tiqn(struct config_item *item) |
224 | #define ISCSI_STAT_SESS_ERR_ATTR(_name, _mode) \ | 199 | { |
225 | static struct iscsi_stat_sess_err_attribute \ | 200 | struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), |
226 | iscsi_stat_sess_err_##_name = \ | 201 | struct iscsi_wwn_stat_grps, iscsi_sess_err_group); |
227 | __CONFIGFS_EATTR(_name, _mode, \ | 202 | return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); |
228 | iscsi_stat_sess_err_show_attr_##_name, \ | 203 | } |
229 | iscsi_stat_sess_err_store_attr_##_name); | ||
230 | |||
231 | #define ISCSI_STAT_SESS_ERR_ATTR_RO(_name) \ | ||
232 | static struct iscsi_stat_sess_err_attribute \ | ||
233 | iscsi_stat_sess_err_##_name = \ | ||
234 | __CONFIGFS_EATTR_RO(_name, \ | ||
235 | iscsi_stat_sess_err_show_attr_##_name); | ||
236 | |||
237 | static ssize_t iscsi_stat_sess_err_show_attr_inst( | ||
238 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
239 | { | ||
240 | struct iscsi_tiqn *tiqn = container_of(igrps, | ||
241 | struct iscsi_tiqn, tiqn_stat_grps); | ||
242 | 204 | ||
243 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 205 | static ssize_t iscsi_stat_sess_err_inst_show(struct config_item *item, |
206 | char *page) | ||
207 | { | ||
208 | return snprintf(page, PAGE_SIZE, "%u\n", | ||
209 | iscsi_sess_err_tiqn(item)->tiqn_index); | ||
244 | } | 210 | } |
245 | ISCSI_STAT_SESS_ERR_ATTR_RO(inst); | ||
246 | 211 | ||
247 | static ssize_t iscsi_stat_sess_err_show_attr_digest_errors( | 212 | static ssize_t iscsi_stat_sess_err_digest_errors_show(struct config_item *item, |
248 | struct iscsi_wwn_stat_grps *igrps, char *page) | 213 | char *page) |
249 | { | 214 | { |
250 | struct iscsi_tiqn *tiqn = container_of(igrps, | 215 | struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); |
251 | struct iscsi_tiqn, tiqn_stat_grps); | ||
252 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 216 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
253 | 217 | ||
254 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->digest_errors); | 218 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->digest_errors); |
255 | } | 219 | } |
256 | ISCSI_STAT_SESS_ERR_ATTR_RO(digest_errors); | ||
257 | 220 | ||
258 | static ssize_t iscsi_stat_sess_err_show_attr_cxn_errors( | 221 | static ssize_t iscsi_stat_sess_err_cxn_errors_show(struct config_item *item, |
259 | struct iscsi_wwn_stat_grps *igrps, char *page) | 222 | char *page) |
260 | { | 223 | { |
261 | struct iscsi_tiqn *tiqn = container_of(igrps, | 224 | struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); |
262 | struct iscsi_tiqn, tiqn_stat_grps); | ||
263 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 225 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
264 | 226 | ||
265 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->cxn_timeout_errors); | 227 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->cxn_timeout_errors); |
266 | } | 228 | } |
267 | ISCSI_STAT_SESS_ERR_ATTR_RO(cxn_errors); | ||
268 | 229 | ||
269 | static ssize_t iscsi_stat_sess_err_show_attr_format_errors( | 230 | static ssize_t iscsi_stat_sess_err_format_errors_show(struct config_item *item, |
270 | struct iscsi_wwn_stat_grps *igrps, char *page) | 231 | char *page) |
271 | { | 232 | { |
272 | struct iscsi_tiqn *tiqn = container_of(igrps, | 233 | struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); |
273 | struct iscsi_tiqn, tiqn_stat_grps); | ||
274 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; | 234 | struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; |
275 | 235 | ||
276 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->pdu_format_errors); | 236 | return snprintf(page, PAGE_SIZE, "%u\n", sess_err->pdu_format_errors); |
277 | } | 237 | } |
278 | ISCSI_STAT_SESS_ERR_ATTR_RO(format_errors); | ||
279 | 238 | ||
280 | CONFIGFS_EATTR_OPS(iscsi_stat_sess_err, iscsi_wwn_stat_grps, | 239 | CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, inst); |
281 | iscsi_sess_err_group); | 240 | CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, digest_errors); |
241 | CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, cxn_errors); | ||
242 | CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, format_errors); | ||
282 | 243 | ||
283 | static struct configfs_attribute *iscsi_stat_sess_err_attrs[] = { | 244 | static struct configfs_attribute *iscsi_stat_sess_err_attrs[] = { |
284 | &iscsi_stat_sess_err_inst.attr, | 245 | &iscsi_stat_sess_err_attr_inst, |
285 | &iscsi_stat_sess_err_digest_errors.attr, | 246 | &iscsi_stat_sess_err_attr_digest_errors, |
286 | &iscsi_stat_sess_err_cxn_errors.attr, | 247 | &iscsi_stat_sess_err_attr_cxn_errors, |
287 | &iscsi_stat_sess_err_format_errors.attr, | 248 | &iscsi_stat_sess_err_attr_format_errors, |
288 | NULL, | 249 | NULL, |
289 | }; | 250 | }; |
290 | 251 | ||
291 | static struct configfs_item_operations iscsi_stat_sess_err_item_ops = { | ||
292 | .show_attribute = iscsi_stat_sess_err_attr_show, | ||
293 | .store_attribute = iscsi_stat_sess_err_attr_store, | ||
294 | }; | ||
295 | |||
296 | struct config_item_type iscsi_stat_sess_err_cit = { | 252 | struct config_item_type iscsi_stat_sess_err_cit = { |
297 | .ct_item_ops = &iscsi_stat_sess_err_item_ops, | ||
298 | .ct_attrs = iscsi_stat_sess_err_attrs, | 253 | .ct_attrs = iscsi_stat_sess_err_attrs, |
299 | .ct_owner = THIS_MODULE, | 254 | .ct_owner = THIS_MODULE, |
300 | }; | 255 | }; |
@@ -302,42 +257,30 @@ struct config_item_type iscsi_stat_sess_err_cit = { | |||
302 | /* | 257 | /* |
303 | * Target Attributes Table | 258 | * Target Attributes Table |
304 | */ | 259 | */ |
305 | CONFIGFS_EATTR_STRUCT(iscsi_stat_tgt_attr, iscsi_wwn_stat_grps); | 260 | static struct iscsi_tiqn *iscsi_tgt_attr_tiqn(struct config_item *item) |
306 | #define ISCSI_STAT_TGT_ATTR(_name, _mode) \ | 261 | { |
307 | static struct iscsi_stat_tgt_attr_attribute \ | 262 | struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), |
308 | iscsi_stat_tgt_attr_##_name = \ | 263 | struct iscsi_wwn_stat_grps, iscsi_tgt_attr_group); |
309 | __CONFIGFS_EATTR(_name, _mode, \ | 264 | return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); |
310 | iscsi_stat_tgt-attr_show_attr_##_name, \ | 265 | } |
311 | iscsi_stat_tgt_attr_store_attr_##_name); | ||
312 | |||
313 | #define ISCSI_STAT_TGT_ATTR_RO(_name) \ | ||
314 | static struct iscsi_stat_tgt_attr_attribute \ | ||
315 | iscsi_stat_tgt_attr_##_name = \ | ||
316 | __CONFIGFS_EATTR_RO(_name, \ | ||
317 | iscsi_stat_tgt_attr_show_attr_##_name); | ||
318 | |||
319 | static ssize_t iscsi_stat_tgt_attr_show_attr_inst( | ||
320 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
321 | { | ||
322 | struct iscsi_tiqn *tiqn = container_of(igrps, | ||
323 | struct iscsi_tiqn, tiqn_stat_grps); | ||
324 | 266 | ||
325 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 267 | static ssize_t iscsi_stat_tgt_attr_inst_show(struct config_item *item, |
268 | char *page) | ||
269 | { | ||
270 | return snprintf(page, PAGE_SIZE, "%u\n", | ||
271 | iscsi_tgt_attr_tiqn(item)->tiqn_index); | ||
326 | } | 272 | } |
327 | ISCSI_STAT_TGT_ATTR_RO(inst); | ||
328 | 273 | ||
329 | static ssize_t iscsi_stat_tgt_attr_show_attr_indx( | 274 | static ssize_t iscsi_stat_tgt_attr_indx_show(struct config_item *item, |
330 | struct iscsi_wwn_stat_grps *igrps, char *page) | 275 | char *page) |
331 | { | 276 | { |
332 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); | 277 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); |
333 | } | 278 | } |
334 | ISCSI_STAT_TGT_ATTR_RO(indx); | ||
335 | 279 | ||
336 | static ssize_t iscsi_stat_tgt_attr_show_attr_login_fails( | 280 | static ssize_t iscsi_stat_tgt_attr_login_fails_show(struct config_item *item, |
337 | struct iscsi_wwn_stat_grps *igrps, char *page) | 281 | char *page) |
338 | { | 282 | { |
339 | struct iscsi_tiqn *tiqn = container_of(igrps, | 283 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
340 | struct iscsi_tiqn, tiqn_stat_grps); | ||
341 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 284 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
342 | u32 fail_count; | 285 | u32 fail_count; |
343 | 286 | ||
@@ -349,13 +292,11 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_login_fails( | |||
349 | 292 | ||
350 | return snprintf(page, PAGE_SIZE, "%u\n", fail_count); | 293 | return snprintf(page, PAGE_SIZE, "%u\n", fail_count); |
351 | } | 294 | } |
352 | ISCSI_STAT_TGT_ATTR_RO(login_fails); | ||
353 | 295 | ||
354 | static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_time( | 296 | static ssize_t iscsi_stat_tgt_attr_last_fail_time_show(struct config_item *item, |
355 | struct iscsi_wwn_stat_grps *igrps, char *page) | 297 | char *page) |
356 | { | 298 | { |
357 | struct iscsi_tiqn *tiqn = container_of(igrps, | 299 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
358 | struct iscsi_tiqn, tiqn_stat_grps); | ||
359 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 300 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
360 | u32 last_fail_time; | 301 | u32 last_fail_time; |
361 | 302 | ||
@@ -367,13 +308,11 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_time( | |||
367 | 308 | ||
368 | return snprintf(page, PAGE_SIZE, "%u\n", last_fail_time); | 309 | return snprintf(page, PAGE_SIZE, "%u\n", last_fail_time); |
369 | } | 310 | } |
370 | ISCSI_STAT_TGT_ATTR_RO(last_fail_time); | ||
371 | 311 | ||
372 | static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_type( | 312 | static ssize_t iscsi_stat_tgt_attr_last_fail_type_show(struct config_item *item, |
373 | struct iscsi_wwn_stat_grps *igrps, char *page) | 313 | char *page) |
374 | { | 314 | { |
375 | struct iscsi_tiqn *tiqn = container_of(igrps, | 315 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
376 | struct iscsi_tiqn, tiqn_stat_grps); | ||
377 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 316 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
378 | u32 last_fail_type; | 317 | u32 last_fail_type; |
379 | 318 | ||
@@ -383,13 +322,11 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_type( | |||
383 | 322 | ||
384 | return snprintf(page, PAGE_SIZE, "%u\n", last_fail_type); | 323 | return snprintf(page, PAGE_SIZE, "%u\n", last_fail_type); |
385 | } | 324 | } |
386 | ISCSI_STAT_TGT_ATTR_RO(last_fail_type); | ||
387 | 325 | ||
388 | static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_name( | 326 | static ssize_t iscsi_stat_tgt_attr_fail_intr_name_show(struct config_item *item, |
389 | struct iscsi_wwn_stat_grps *igrps, char *page) | 327 | char *page) |
390 | { | 328 | { |
391 | struct iscsi_tiqn *tiqn = container_of(igrps, | 329 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
392 | struct iscsi_tiqn, tiqn_stat_grps); | ||
393 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 330 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
394 | unsigned char buf[224]; | 331 | unsigned char buf[224]; |
395 | 332 | ||
@@ -400,13 +337,11 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_name( | |||
400 | 337 | ||
401 | return snprintf(page, PAGE_SIZE, "%s\n", buf); | 338 | return snprintf(page, PAGE_SIZE, "%s\n", buf); |
402 | } | 339 | } |
403 | ISCSI_STAT_TGT_ATTR_RO(fail_intr_name); | ||
404 | 340 | ||
405 | static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr_type( | 341 | static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_type_show(struct config_item *item, |
406 | struct iscsi_wwn_stat_grps *igrps, char *page) | 342 | char *page) |
407 | { | 343 | { |
408 | struct iscsi_tiqn *tiqn = container_of(igrps, | 344 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
409 | struct iscsi_tiqn, tiqn_stat_grps); | ||
410 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 345 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
411 | int ret; | 346 | int ret; |
412 | 347 | ||
@@ -419,13 +354,11 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr_type( | |||
419 | 354 | ||
420 | return ret; | 355 | return ret; |
421 | } | 356 | } |
422 | ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr_type); | ||
423 | 357 | ||
424 | static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr( | 358 | static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_show(struct config_item *item, |
425 | struct iscsi_wwn_stat_grps *igrps, char *page) | 359 | char *page) |
426 | { | 360 | { |
427 | struct iscsi_tiqn *tiqn = container_of(igrps, | 361 | struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); |
428 | struct iscsi_tiqn, tiqn_stat_grps); | ||
429 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 362 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
430 | int ret; | 363 | int ret; |
431 | 364 | ||
@@ -435,30 +368,29 @@ static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr( | |||
435 | 368 | ||
436 | return ret; | 369 | return ret; |
437 | } | 370 | } |
438 | ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr); | ||
439 | 371 | ||
440 | CONFIGFS_EATTR_OPS(iscsi_stat_tgt_attr, iscsi_wwn_stat_grps, | 372 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, inst); |
441 | iscsi_tgt_attr_group); | 373 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, indx); |
374 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, login_fails); | ||
375 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, last_fail_time); | ||
376 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, last_fail_type); | ||
377 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_name); | ||
378 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_addr_type); | ||
379 | CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_addr); | ||
442 | 380 | ||
443 | static struct configfs_attribute *iscsi_stat_tgt_attr_attrs[] = { | 381 | static struct configfs_attribute *iscsi_stat_tgt_attr_attrs[] = { |
444 | &iscsi_stat_tgt_attr_inst.attr, | 382 | &iscsi_stat_tgt_attr_attr_inst, |
445 | &iscsi_stat_tgt_attr_indx.attr, | 383 | &iscsi_stat_tgt_attr_attr_indx, |
446 | &iscsi_stat_tgt_attr_login_fails.attr, | 384 | &iscsi_stat_tgt_attr_attr_login_fails, |
447 | &iscsi_stat_tgt_attr_last_fail_time.attr, | 385 | &iscsi_stat_tgt_attr_attr_last_fail_time, |
448 | &iscsi_stat_tgt_attr_last_fail_type.attr, | 386 | &iscsi_stat_tgt_attr_attr_last_fail_type, |
449 | &iscsi_stat_tgt_attr_fail_intr_name.attr, | 387 | &iscsi_stat_tgt_attr_attr_fail_intr_name, |
450 | &iscsi_stat_tgt_attr_fail_intr_addr_type.attr, | 388 | &iscsi_stat_tgt_attr_attr_fail_intr_addr_type, |
451 | &iscsi_stat_tgt_attr_fail_intr_addr.attr, | 389 | &iscsi_stat_tgt_attr_attr_fail_intr_addr, |
452 | NULL, | 390 | NULL, |
453 | }; | 391 | }; |
454 | 392 | ||
455 | static struct configfs_item_operations iscsi_stat_tgt_attr_item_ops = { | ||
456 | .show_attribute = iscsi_stat_tgt_attr_attr_show, | ||
457 | .store_attribute = iscsi_stat_tgt_attr_attr_store, | ||
458 | }; | ||
459 | |||
460 | struct config_item_type iscsi_stat_tgt_attr_cit = { | 393 | struct config_item_type iscsi_stat_tgt_attr_cit = { |
461 | .ct_item_ops = &iscsi_stat_tgt_attr_item_ops, | ||
462 | .ct_attrs = iscsi_stat_tgt_attr_attrs, | 394 | .ct_attrs = iscsi_stat_tgt_attr_attrs, |
463 | .ct_owner = THIS_MODULE, | 395 | .ct_owner = THIS_MODULE, |
464 | }; | 396 | }; |
@@ -466,42 +398,29 @@ struct config_item_type iscsi_stat_tgt_attr_cit = { | |||
466 | /* | 398 | /* |
467 | * Target Login Stats Table | 399 | * Target Login Stats Table |
468 | */ | 400 | */ |
469 | CONFIGFS_EATTR_STRUCT(iscsi_stat_login, iscsi_wwn_stat_grps); | 401 | static struct iscsi_tiqn *iscsi_login_stat_tiqn(struct config_item *item) |
470 | #define ISCSI_STAT_LOGIN(_name, _mode) \ | 402 | { |
471 | static struct iscsi_stat_login_attribute \ | 403 | struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), |
472 | iscsi_stat_login_##_name = \ | 404 | struct iscsi_wwn_stat_grps, iscsi_login_stats_group); |
473 | __CONFIGFS_EATTR(_name, _mode, \ | 405 | return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); |
474 | iscsi_stat_login_show_attr_##_name, \ | 406 | } |
475 | iscsi_stat_login_store_attr_##_name); | ||
476 | |||
477 | #define ISCSI_STAT_LOGIN_RO(_name) \ | ||
478 | static struct iscsi_stat_login_attribute \ | ||
479 | iscsi_stat_login_##_name = \ | ||
480 | __CONFIGFS_EATTR_RO(_name, \ | ||
481 | iscsi_stat_login_show_attr_##_name); | ||
482 | |||
483 | static ssize_t iscsi_stat_login_show_attr_inst( | ||
484 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
485 | { | ||
486 | struct iscsi_tiqn *tiqn = container_of(igrps, | ||
487 | struct iscsi_tiqn, tiqn_stat_grps); | ||
488 | 407 | ||
489 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 408 | static ssize_t iscsi_stat_login_inst_show(struct config_item *item, char *page) |
409 | { | ||
410 | return snprintf(page, PAGE_SIZE, "%u\n", | ||
411 | iscsi_login_stat_tiqn(item)->tiqn_index); | ||
490 | } | 412 | } |
491 | ISCSI_STAT_LOGIN_RO(inst); | ||
492 | 413 | ||
493 | static ssize_t iscsi_stat_login_show_attr_indx( | 414 | static ssize_t iscsi_stat_login_indx_show(struct config_item *item, |
494 | struct iscsi_wwn_stat_grps *igrps, char *page) | 415 | char *page) |
495 | { | 416 | { |
496 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); | 417 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); |
497 | } | 418 | } |
498 | ISCSI_STAT_LOGIN_RO(indx); | ||
499 | 419 | ||
500 | static ssize_t iscsi_stat_login_show_attr_accepts( | 420 | static ssize_t iscsi_stat_login_accepts_show(struct config_item *item, |
501 | struct iscsi_wwn_stat_grps *igrps, char *page) | 421 | char *page) |
502 | { | 422 | { |
503 | struct iscsi_tiqn *tiqn = container_of(igrps, | 423 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
504 | struct iscsi_tiqn, tiqn_stat_grps); | ||
505 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 424 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
506 | ssize_t ret; | 425 | ssize_t ret; |
507 | 426 | ||
@@ -511,13 +430,11 @@ static ssize_t iscsi_stat_login_show_attr_accepts( | |||
511 | 430 | ||
512 | return ret; | 431 | return ret; |
513 | } | 432 | } |
514 | ISCSI_STAT_LOGIN_RO(accepts); | ||
515 | 433 | ||
516 | static ssize_t iscsi_stat_login_show_attr_other_fails( | 434 | static ssize_t iscsi_stat_login_other_fails_show(struct config_item *item, |
517 | struct iscsi_wwn_stat_grps *igrps, char *page) | 435 | char *page) |
518 | { | 436 | { |
519 | struct iscsi_tiqn *tiqn = container_of(igrps, | 437 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
520 | struct iscsi_tiqn, tiqn_stat_grps); | ||
521 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 438 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
522 | ssize_t ret; | 439 | ssize_t ret; |
523 | 440 | ||
@@ -527,13 +444,11 @@ static ssize_t iscsi_stat_login_show_attr_other_fails( | |||
527 | 444 | ||
528 | return ret; | 445 | return ret; |
529 | } | 446 | } |
530 | ISCSI_STAT_LOGIN_RO(other_fails); | ||
531 | 447 | ||
532 | static ssize_t iscsi_stat_login_show_attr_redirects( | 448 | static ssize_t iscsi_stat_login_redirects_show(struct config_item *item, |
533 | struct iscsi_wwn_stat_grps *igrps, char *page) | 449 | char *page) |
534 | { | 450 | { |
535 | struct iscsi_tiqn *tiqn = container_of(igrps, | 451 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
536 | struct iscsi_tiqn, tiqn_stat_grps); | ||
537 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 452 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
538 | ssize_t ret; | 453 | ssize_t ret; |
539 | 454 | ||
@@ -543,13 +458,11 @@ static ssize_t iscsi_stat_login_show_attr_redirects( | |||
543 | 458 | ||
544 | return ret; | 459 | return ret; |
545 | } | 460 | } |
546 | ISCSI_STAT_LOGIN_RO(redirects); | ||
547 | 461 | ||
548 | static ssize_t iscsi_stat_login_show_attr_authorize_fails( | 462 | static ssize_t iscsi_stat_login_authorize_fails_show(struct config_item *item, |
549 | struct iscsi_wwn_stat_grps *igrps, char *page) | 463 | char *page) |
550 | { | 464 | { |
551 | struct iscsi_tiqn *tiqn = container_of(igrps, | 465 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
552 | struct iscsi_tiqn, tiqn_stat_grps); | ||
553 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 466 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
554 | ssize_t ret; | 467 | ssize_t ret; |
555 | 468 | ||
@@ -559,13 +472,11 @@ static ssize_t iscsi_stat_login_show_attr_authorize_fails( | |||
559 | 472 | ||
560 | return ret; | 473 | return ret; |
561 | } | 474 | } |
562 | ISCSI_STAT_LOGIN_RO(authorize_fails); | ||
563 | 475 | ||
564 | static ssize_t iscsi_stat_login_show_attr_authenticate_fails( | 476 | static ssize_t iscsi_stat_login_authenticate_fails_show( |
565 | struct iscsi_wwn_stat_grps *igrps, char *page) | 477 | struct config_item *item, char *page) |
566 | { | 478 | { |
567 | struct iscsi_tiqn *tiqn = container_of(igrps, | 479 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
568 | struct iscsi_tiqn, tiqn_stat_grps); | ||
569 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 480 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
570 | ssize_t ret; | 481 | ssize_t ret; |
571 | 482 | ||
@@ -575,13 +486,11 @@ static ssize_t iscsi_stat_login_show_attr_authenticate_fails( | |||
575 | 486 | ||
576 | return ret; | 487 | return ret; |
577 | } | 488 | } |
578 | ISCSI_STAT_LOGIN_RO(authenticate_fails); | ||
579 | 489 | ||
580 | static ssize_t iscsi_stat_login_show_attr_negotiate_fails( | 490 | static ssize_t iscsi_stat_login_negotiate_fails_show(struct config_item *item, |
581 | struct iscsi_wwn_stat_grps *igrps, char *page) | 491 | char *page) |
582 | { | 492 | { |
583 | struct iscsi_tiqn *tiqn = container_of(igrps, | 493 | struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); |
584 | struct iscsi_tiqn, tiqn_stat_grps); | ||
585 | struct iscsi_login_stats *lstat = &tiqn->login_stats; | 494 | struct iscsi_login_stats *lstat = &tiqn->login_stats; |
586 | ssize_t ret; | 495 | ssize_t ret; |
587 | 496 | ||
@@ -591,30 +500,29 @@ static ssize_t iscsi_stat_login_show_attr_negotiate_fails( | |||
591 | 500 | ||
592 | return ret; | 501 | return ret; |
593 | } | 502 | } |
594 | ISCSI_STAT_LOGIN_RO(negotiate_fails); | ||
595 | 503 | ||
596 | CONFIGFS_EATTR_OPS(iscsi_stat_login, iscsi_wwn_stat_grps, | 504 | CONFIGFS_ATTR_RO(iscsi_stat_login_, inst); |
597 | iscsi_login_stats_group); | 505 | CONFIGFS_ATTR_RO(iscsi_stat_login_, indx); |
506 | CONFIGFS_ATTR_RO(iscsi_stat_login_, accepts); | ||
507 | CONFIGFS_ATTR_RO(iscsi_stat_login_, other_fails); | ||
508 | CONFIGFS_ATTR_RO(iscsi_stat_login_, redirects); | ||
509 | CONFIGFS_ATTR_RO(iscsi_stat_login_, authorize_fails); | ||
510 | CONFIGFS_ATTR_RO(iscsi_stat_login_, authenticate_fails); | ||
511 | CONFIGFS_ATTR_RO(iscsi_stat_login_, negotiate_fails); | ||
598 | 512 | ||
599 | static struct configfs_attribute *iscsi_stat_login_stats_attrs[] = { | 513 | static struct configfs_attribute *iscsi_stat_login_stats_attrs[] = { |
600 | &iscsi_stat_login_inst.attr, | 514 | &iscsi_stat_login_attr_inst, |
601 | &iscsi_stat_login_indx.attr, | 515 | &iscsi_stat_login_attr_indx, |
602 | &iscsi_stat_login_accepts.attr, | 516 | &iscsi_stat_login_attr_accepts, |
603 | &iscsi_stat_login_other_fails.attr, | 517 | &iscsi_stat_login_attr_other_fails, |
604 | &iscsi_stat_login_redirects.attr, | 518 | &iscsi_stat_login_attr_redirects, |
605 | &iscsi_stat_login_authorize_fails.attr, | 519 | &iscsi_stat_login_attr_authorize_fails, |
606 | &iscsi_stat_login_authenticate_fails.attr, | 520 | &iscsi_stat_login_attr_authenticate_fails, |
607 | &iscsi_stat_login_negotiate_fails.attr, | 521 | &iscsi_stat_login_attr_negotiate_fails, |
608 | NULL, | 522 | NULL, |
609 | }; | 523 | }; |
610 | 524 | ||
611 | static struct configfs_item_operations iscsi_stat_login_stats_item_ops = { | ||
612 | .show_attribute = iscsi_stat_login_attr_show, | ||
613 | .store_attribute = iscsi_stat_login_attr_store, | ||
614 | }; | ||
615 | |||
616 | struct config_item_type iscsi_stat_login_cit = { | 525 | struct config_item_type iscsi_stat_login_cit = { |
617 | .ct_item_ops = &iscsi_stat_login_stats_item_ops, | ||
618 | .ct_attrs = iscsi_stat_login_stats_attrs, | 526 | .ct_attrs = iscsi_stat_login_stats_attrs, |
619 | .ct_owner = THIS_MODULE, | 527 | .ct_owner = THIS_MODULE, |
620 | }; | 528 | }; |
@@ -622,78 +530,56 @@ struct config_item_type iscsi_stat_login_cit = { | |||
622 | /* | 530 | /* |
623 | * Target Logout Stats Table | 531 | * Target Logout Stats Table |
624 | */ | 532 | */ |
625 | 533 | static struct iscsi_tiqn *iscsi_logout_stat_tiqn(struct config_item *item) | |
626 | CONFIGFS_EATTR_STRUCT(iscsi_stat_logout, iscsi_wwn_stat_grps); | ||
627 | #define ISCSI_STAT_LOGOUT(_name, _mode) \ | ||
628 | static struct iscsi_stat_logout_attribute \ | ||
629 | iscsi_stat_logout_##_name = \ | ||
630 | __CONFIGFS_EATTR(_name, _mode, \ | ||
631 | iscsi_stat_logout_show_attr_##_name, \ | ||
632 | iscsi_stat_logout_store_attr_##_name); | ||
633 | |||
634 | #define ISCSI_STAT_LOGOUT_RO(_name) \ | ||
635 | static struct iscsi_stat_logout_attribute \ | ||
636 | iscsi_stat_logout_##_name = \ | ||
637 | __CONFIGFS_EATTR_RO(_name, \ | ||
638 | iscsi_stat_logout_show_attr_##_name); | ||
639 | |||
640 | static ssize_t iscsi_stat_logout_show_attr_inst( | ||
641 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
642 | { | 534 | { |
643 | struct iscsi_tiqn *tiqn = container_of(igrps, | 535 | struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), |
644 | struct iscsi_tiqn, tiqn_stat_grps); | 536 | struct iscsi_wwn_stat_grps, iscsi_logout_stats_group); |
537 | return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); | ||
538 | } | ||
645 | 539 | ||
646 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 540 | static ssize_t iscsi_stat_logout_inst_show(struct config_item *item, char *page) |
541 | { | ||
542 | return snprintf(page, PAGE_SIZE, "%u\n", | ||
543 | iscsi_logout_stat_tiqn(item)->tiqn_index); | ||
647 | } | 544 | } |
648 | ISCSI_STAT_LOGOUT_RO(inst); | ||
649 | 545 | ||
650 | static ssize_t iscsi_stat_logout_show_attr_indx( | 546 | static ssize_t iscsi_stat_logout_indx_show(struct config_item *item, char *page) |
651 | struct iscsi_wwn_stat_grps *igrps, char *page) | ||
652 | { | 547 | { |
653 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); | 548 | return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); |
654 | } | 549 | } |
655 | ISCSI_STAT_LOGOUT_RO(indx); | ||
656 | 550 | ||
657 | static ssize_t iscsi_stat_logout_show_attr_normal_logouts( | 551 | static ssize_t iscsi_stat_logout_normal_logouts_show(struct config_item *item, |
658 | struct iscsi_wwn_stat_grps *igrps, char *page) | 552 | char *page) |
659 | { | 553 | { |
660 | struct iscsi_tiqn *tiqn = container_of(igrps, | 554 | struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item); |
661 | struct iscsi_tiqn, tiqn_stat_grps); | ||
662 | struct iscsi_logout_stats *lstats = &tiqn->logout_stats; | 555 | struct iscsi_logout_stats *lstats = &tiqn->logout_stats; |
663 | 556 | ||
664 | return snprintf(page, PAGE_SIZE, "%u\n", lstats->normal_logouts); | 557 | return snprintf(page, PAGE_SIZE, "%u\n", lstats->normal_logouts); |
665 | } | 558 | } |
666 | ISCSI_STAT_LOGOUT_RO(normal_logouts); | ||
667 | 559 | ||
668 | static ssize_t iscsi_stat_logout_show_attr_abnormal_logouts( | 560 | static ssize_t iscsi_stat_logout_abnormal_logouts_show(struct config_item *item, |
669 | struct iscsi_wwn_stat_grps *igrps, char *page) | 561 | char *page) |
670 | { | 562 | { |
671 | struct iscsi_tiqn *tiqn = container_of(igrps, | 563 | struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item); |
672 | struct iscsi_tiqn, tiqn_stat_grps); | ||
673 | struct iscsi_logout_stats *lstats = &tiqn->logout_stats; | 564 | struct iscsi_logout_stats *lstats = &tiqn->logout_stats; |
674 | 565 | ||
675 | return snprintf(page, PAGE_SIZE, "%u\n", lstats->abnormal_logouts); | 566 | return snprintf(page, PAGE_SIZE, "%u\n", lstats->abnormal_logouts); |
676 | } | 567 | } |
677 | ISCSI_STAT_LOGOUT_RO(abnormal_logouts); | ||
678 | 568 | ||
679 | CONFIGFS_EATTR_OPS(iscsi_stat_logout, iscsi_wwn_stat_grps, | 569 | CONFIGFS_ATTR_RO(iscsi_stat_logout_, inst); |
680 | iscsi_logout_stats_group); | 570 | CONFIGFS_ATTR_RO(iscsi_stat_logout_, indx); |
571 | CONFIGFS_ATTR_RO(iscsi_stat_logout_, normal_logouts); | ||
572 | CONFIGFS_ATTR_RO(iscsi_stat_logout_, abnormal_logouts); | ||
681 | 573 | ||
682 | static struct configfs_attribute *iscsi_stat_logout_stats_attrs[] = { | 574 | static struct configfs_attribute *iscsi_stat_logout_stats_attrs[] = { |
683 | &iscsi_stat_logout_inst.attr, | 575 | &iscsi_stat_logout_attr_inst, |
684 | &iscsi_stat_logout_indx.attr, | 576 | &iscsi_stat_logout_attr_indx, |
685 | &iscsi_stat_logout_normal_logouts.attr, | 577 | &iscsi_stat_logout_attr_normal_logouts, |
686 | &iscsi_stat_logout_abnormal_logouts.attr, | 578 | &iscsi_stat_logout_attr_abnormal_logouts, |
687 | NULL, | 579 | NULL, |
688 | }; | 580 | }; |
689 | 581 | ||
690 | static struct configfs_item_operations iscsi_stat_logout_stats_item_ops = { | ||
691 | .show_attribute = iscsi_stat_logout_attr_show, | ||
692 | .store_attribute = iscsi_stat_logout_attr_store, | ||
693 | }; | ||
694 | |||
695 | struct config_item_type iscsi_stat_logout_cit = { | 582 | struct config_item_type iscsi_stat_logout_cit = { |
696 | .ct_item_ops = &iscsi_stat_logout_stats_item_ops, | ||
697 | .ct_attrs = iscsi_stat_logout_stats_attrs, | 583 | .ct_attrs = iscsi_stat_logout_stats_attrs, |
698 | .ct_owner = THIS_MODULE, | 584 | .ct_owner = THIS_MODULE, |
699 | }; | 585 | }; |
@@ -701,39 +587,26 @@ struct config_item_type iscsi_stat_logout_cit = { | |||
701 | /* | 587 | /* |
702 | * Session Stats Table | 588 | * Session Stats Table |
703 | */ | 589 | */ |
590 | static struct iscsi_node_acl *iscsi_stat_nacl(struct config_item *item) | ||
591 | { | ||
592 | struct iscsi_node_stat_grps *igrps = container_of(to_config_group(item), | ||
593 | struct iscsi_node_stat_grps, iscsi_sess_stats_group); | ||
594 | return container_of(igrps, struct iscsi_node_acl, node_stat_grps); | ||
595 | } | ||
704 | 596 | ||
705 | CONFIGFS_EATTR_STRUCT(iscsi_stat_sess, iscsi_node_stat_grps); | 597 | static ssize_t iscsi_stat_sess_inst_show(struct config_item *item, char *page) |
706 | #define ISCSI_STAT_SESS(_name, _mode) \ | 598 | { |
707 | static struct iscsi_stat_sess_attribute \ | 599 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
708 | iscsi_stat_sess_##_name = \ | ||
709 | __CONFIGFS_EATTR(_name, _mode, \ | ||
710 | iscsi_stat_sess_show_attr_##_name, \ | ||
711 | iscsi_stat_sess_store_attr_##_name); | ||
712 | |||
713 | #define ISCSI_STAT_SESS_RO(_name) \ | ||
714 | static struct iscsi_stat_sess_attribute \ | ||
715 | iscsi_stat_sess_##_name = \ | ||
716 | __CONFIGFS_EATTR_RO(_name, \ | ||
717 | iscsi_stat_sess_show_attr_##_name); | ||
718 | |||
719 | static ssize_t iscsi_stat_sess_show_attr_inst( | ||
720 | struct iscsi_node_stat_grps *igrps, char *page) | ||
721 | { | ||
722 | struct iscsi_node_acl *acl = container_of(igrps, | ||
723 | struct iscsi_node_acl, node_stat_grps); | ||
724 | struct se_wwn *wwn = acl->se_node_acl.se_tpg->se_tpg_wwn; | 600 | struct se_wwn *wwn = acl->se_node_acl.se_tpg->se_tpg_wwn; |
725 | struct iscsi_tiqn *tiqn = container_of(wwn, | 601 | struct iscsi_tiqn *tiqn = container_of(wwn, |
726 | struct iscsi_tiqn, tiqn_wwn); | 602 | struct iscsi_tiqn, tiqn_wwn); |
727 | 603 | ||
728 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); | 604 | return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); |
729 | } | 605 | } |
730 | ISCSI_STAT_SESS_RO(inst); | ||
731 | 606 | ||
732 | static ssize_t iscsi_stat_sess_show_attr_node( | 607 | static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page) |
733 | struct iscsi_node_stat_grps *igrps, char *page) | ||
734 | { | 608 | { |
735 | struct iscsi_node_acl *acl = container_of(igrps, | 609 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
736 | struct iscsi_node_acl, node_stat_grps); | ||
737 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 610 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
738 | struct iscsi_session *sess; | 611 | struct iscsi_session *sess; |
739 | struct se_session *se_sess; | 612 | struct se_session *se_sess; |
@@ -751,13 +624,10 @@ static ssize_t iscsi_stat_sess_show_attr_node( | |||
751 | 624 | ||
752 | return ret; | 625 | return ret; |
753 | } | 626 | } |
754 | ISCSI_STAT_SESS_RO(node); | ||
755 | 627 | ||
756 | static ssize_t iscsi_stat_sess_show_attr_indx( | 628 | static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) |
757 | struct iscsi_node_stat_grps *igrps, char *page) | ||
758 | { | 629 | { |
759 | struct iscsi_node_acl *acl = container_of(igrps, | 630 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
760 | struct iscsi_node_acl, node_stat_grps); | ||
761 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 631 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
762 | struct iscsi_session *sess; | 632 | struct iscsi_session *sess; |
763 | struct se_session *se_sess; | 633 | struct se_session *se_sess; |
@@ -775,13 +645,11 @@ static ssize_t iscsi_stat_sess_show_attr_indx( | |||
775 | 645 | ||
776 | return ret; | 646 | return ret; |
777 | } | 647 | } |
778 | ISCSI_STAT_SESS_RO(indx); | ||
779 | 648 | ||
780 | static ssize_t iscsi_stat_sess_show_attr_cmd_pdus( | 649 | static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item, |
781 | struct iscsi_node_stat_grps *igrps, char *page) | 650 | char *page) |
782 | { | 651 | { |
783 | struct iscsi_node_acl *acl = container_of(igrps, | 652 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
784 | struct iscsi_node_acl, node_stat_grps); | ||
785 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 653 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
786 | struct iscsi_session *sess; | 654 | struct iscsi_session *sess; |
787 | struct se_session *se_sess; | 655 | struct se_session *se_sess; |
@@ -799,13 +667,11 @@ static ssize_t iscsi_stat_sess_show_attr_cmd_pdus( | |||
799 | 667 | ||
800 | return ret; | 668 | return ret; |
801 | } | 669 | } |
802 | ISCSI_STAT_SESS_RO(cmd_pdus); | ||
803 | 670 | ||
804 | static ssize_t iscsi_stat_sess_show_attr_rsp_pdus( | 671 | static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item, |
805 | struct iscsi_node_stat_grps *igrps, char *page) | 672 | char *page) |
806 | { | 673 | { |
807 | struct iscsi_node_acl *acl = container_of(igrps, | 674 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
808 | struct iscsi_node_acl, node_stat_grps); | ||
809 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 675 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
810 | struct iscsi_session *sess; | 676 | struct iscsi_session *sess; |
811 | struct se_session *se_sess; | 677 | struct se_session *se_sess; |
@@ -823,13 +689,11 @@ static ssize_t iscsi_stat_sess_show_attr_rsp_pdus( | |||
823 | 689 | ||
824 | return ret; | 690 | return ret; |
825 | } | 691 | } |
826 | ISCSI_STAT_SESS_RO(rsp_pdus); | ||
827 | 692 | ||
828 | static ssize_t iscsi_stat_sess_show_attr_txdata_octs( | 693 | static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item, |
829 | struct iscsi_node_stat_grps *igrps, char *page) | 694 | char *page) |
830 | { | 695 | { |
831 | struct iscsi_node_acl *acl = container_of(igrps, | 696 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
832 | struct iscsi_node_acl, node_stat_grps); | ||
833 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 697 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
834 | struct iscsi_session *sess; | 698 | struct iscsi_session *sess; |
835 | struct se_session *se_sess; | 699 | struct se_session *se_sess; |
@@ -847,13 +711,11 @@ static ssize_t iscsi_stat_sess_show_attr_txdata_octs( | |||
847 | 711 | ||
848 | return ret; | 712 | return ret; |
849 | } | 713 | } |
850 | ISCSI_STAT_SESS_RO(txdata_octs); | ||
851 | 714 | ||
852 | static ssize_t iscsi_stat_sess_show_attr_rxdata_octs( | 715 | static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item, |
853 | struct iscsi_node_stat_grps *igrps, char *page) | 716 | char *page) |
854 | { | 717 | { |
855 | struct iscsi_node_acl *acl = container_of(igrps, | 718 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
856 | struct iscsi_node_acl, node_stat_grps); | ||
857 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 719 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
858 | struct iscsi_session *sess; | 720 | struct iscsi_session *sess; |
859 | struct se_session *se_sess; | 721 | struct se_session *se_sess; |
@@ -871,13 +733,11 @@ static ssize_t iscsi_stat_sess_show_attr_rxdata_octs( | |||
871 | 733 | ||
872 | return ret; | 734 | return ret; |
873 | } | 735 | } |
874 | ISCSI_STAT_SESS_RO(rxdata_octs); | ||
875 | 736 | ||
876 | static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors( | 737 | static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item, |
877 | struct iscsi_node_stat_grps *igrps, char *page) | 738 | char *page) |
878 | { | 739 | { |
879 | struct iscsi_node_acl *acl = container_of(igrps, | 740 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
880 | struct iscsi_node_acl, node_stat_grps); | ||
881 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 741 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
882 | struct iscsi_session *sess; | 742 | struct iscsi_session *sess; |
883 | struct se_session *se_sess; | 743 | struct se_session *se_sess; |
@@ -895,13 +755,11 @@ static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors( | |||
895 | 755 | ||
896 | return ret; | 756 | return ret; |
897 | } | 757 | } |
898 | ISCSI_STAT_SESS_RO(conn_digest_errors); | ||
899 | 758 | ||
900 | static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors( | 759 | static ssize_t iscsi_stat_sess_conn_timeout_errors_show( |
901 | struct iscsi_node_stat_grps *igrps, char *page) | 760 | struct config_item *item, char *page) |
902 | { | 761 | { |
903 | struct iscsi_node_acl *acl = container_of(igrps, | 762 | struct iscsi_node_acl *acl = iscsi_stat_nacl(item); |
904 | struct iscsi_node_acl, node_stat_grps); | ||
905 | struct se_node_acl *se_nacl = &acl->se_node_acl; | 763 | struct se_node_acl *se_nacl = &acl->se_node_acl; |
906 | struct iscsi_session *sess; | 764 | struct iscsi_session *sess; |
907 | struct se_session *se_sess; | 765 | struct se_session *se_sess; |
@@ -919,31 +777,31 @@ static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors( | |||
919 | 777 | ||
920 | return ret; | 778 | return ret; |
921 | } | 779 | } |
922 | ISCSI_STAT_SESS_RO(conn_timeout_errors); | ||
923 | 780 | ||
924 | CONFIGFS_EATTR_OPS(iscsi_stat_sess, iscsi_node_stat_grps, | 781 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, inst); |
925 | iscsi_sess_stats_group); | 782 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, node); |
783 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, indx); | ||
784 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, cmd_pdus); | ||
785 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, rsp_pdus); | ||
786 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, txdata_octs); | ||
787 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, rxdata_octs); | ||
788 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, conn_digest_errors); | ||
789 | CONFIGFS_ATTR_RO(iscsi_stat_sess_, conn_timeout_errors); | ||
926 | 790 | ||
927 | static struct configfs_attribute *iscsi_stat_sess_stats_attrs[] = { | 791 | static struct configfs_attribute *iscsi_stat_sess_stats_attrs[] = { |
928 | &iscsi_stat_sess_inst.attr, | 792 | &iscsi_stat_sess_attr_inst, |
929 | &iscsi_stat_sess_node.attr, | 793 | &iscsi_stat_sess_attr_node, |
930 | &iscsi_stat_sess_indx.attr, | 794 | &iscsi_stat_sess_attr_indx, |
931 | &iscsi_stat_sess_cmd_pdus.attr, | 795 | &iscsi_stat_sess_attr_cmd_pdus, |
932 | &iscsi_stat_sess_rsp_pdus.attr, | 796 | &iscsi_stat_sess_attr_rsp_pdus, |
933 | &iscsi_stat_sess_txdata_octs.attr, | 797 | &iscsi_stat_sess_attr_txdata_octs, |
934 | &iscsi_stat_sess_rxdata_octs.attr, | 798 | &iscsi_stat_sess_attr_rxdata_octs, |
935 | &iscsi_stat_sess_conn_digest_errors.attr, | 799 | &iscsi_stat_sess_attr_conn_digest_errors, |
936 | &iscsi_stat_sess_conn_timeout_errors.attr, | 800 | &iscsi_stat_sess_attr_conn_timeout_errors, |
937 | NULL, | 801 | NULL, |
938 | }; | 802 | }; |
939 | 803 | ||
940 | static struct configfs_item_operations iscsi_stat_sess_stats_item_ops = { | ||
941 | .show_attribute = iscsi_stat_sess_attr_show, | ||
942 | .store_attribute = iscsi_stat_sess_attr_store, | ||
943 | }; | ||
944 | |||
945 | struct config_item_type iscsi_stat_sess_cit = { | 804 | struct config_item_type iscsi_stat_sess_cit = { |
946 | .ct_item_ops = &iscsi_stat_sess_stats_item_ops, | ||
947 | .ct_attrs = iscsi_stat_sess_stats_attrs, | 805 | .ct_attrs = iscsi_stat_sess_stats_attrs, |
948 | .ct_owner = THIS_MODULE, | 806 | .ct_owner = THIS_MODULE, |
949 | }; | 807 | }; |
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 5bc85ffed720..999b6eba52e8 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -34,7 +34,6 @@ | |||
34 | 34 | ||
35 | #include <target/target_core_base.h> | 35 | #include <target/target_core_base.h> |
36 | #include <target/target_core_fabric.h> | 36 | #include <target/target_core_fabric.h> |
37 | #include <target/target_core_fabric_configfs.h> | ||
38 | 37 | ||
39 | #include "tcm_loop.h" | 38 | #include "tcm_loop.h" |
40 | 39 | ||
@@ -763,21 +762,20 @@ static void tcm_loop_port_unlink( | |||
763 | 762 | ||
764 | /* End items for tcm_loop_port_cit */ | 763 | /* End items for tcm_loop_port_cit */ |
765 | 764 | ||
766 | static ssize_t tcm_loop_tpg_attrib_show_fabric_prot_type( | 765 | static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_show( |
767 | struct se_portal_group *se_tpg, | 766 | struct config_item *item, char *page) |
768 | char *page) | ||
769 | { | 767 | { |
768 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
770 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, | 769 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, |
771 | tl_se_tpg); | 770 | tl_se_tpg); |
772 | 771 | ||
773 | return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type); | 772 | return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type); |
774 | } | 773 | } |
775 | 774 | ||
776 | static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type( | 775 | static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_store( |
777 | struct se_portal_group *se_tpg, | 776 | struct config_item *item, const char *page, size_t count) |
778 | const char *page, | ||
779 | size_t count) | ||
780 | { | 777 | { |
778 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
781 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, | 779 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, |
782 | tl_se_tpg); | 780 | tl_se_tpg); |
783 | unsigned long val; | 781 | unsigned long val; |
@@ -796,10 +794,10 @@ static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type( | |||
796 | return count; | 794 | return count; |
797 | } | 795 | } |
798 | 796 | ||
799 | TF_TPG_ATTRIB_ATTR(tcm_loop, fabric_prot_type, S_IRUGO | S_IWUSR); | 797 | CONFIGFS_ATTR(tcm_loop_tpg_attrib_, fabric_prot_type); |
800 | 798 | ||
801 | static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = { | 799 | static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = { |
802 | &tcm_loop_tpg_attrib_fabric_prot_type.attr, | 800 | &tcm_loop_tpg_attrib_attr_fabric_prot_type, |
803 | NULL, | 801 | NULL, |
804 | }; | 802 | }; |
805 | 803 | ||
@@ -894,10 +892,9 @@ static int tcm_loop_drop_nexus( | |||
894 | 892 | ||
895 | /* End items for tcm_loop_nexus_cit */ | 893 | /* End items for tcm_loop_nexus_cit */ |
896 | 894 | ||
897 | static ssize_t tcm_loop_tpg_show_nexus( | 895 | static ssize_t tcm_loop_tpg_nexus_show(struct config_item *item, char *page) |
898 | struct se_portal_group *se_tpg, | ||
899 | char *page) | ||
900 | { | 896 | { |
897 | struct se_portal_group *se_tpg = to_tpg(item); | ||
901 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | 898 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
902 | struct tcm_loop_tpg, tl_se_tpg); | 899 | struct tcm_loop_tpg, tl_se_tpg); |
903 | struct tcm_loop_nexus *tl_nexus; | 900 | struct tcm_loop_nexus *tl_nexus; |
@@ -913,11 +910,10 @@ static ssize_t tcm_loop_tpg_show_nexus( | |||
913 | return ret; | 910 | return ret; |
914 | } | 911 | } |
915 | 912 | ||
916 | static ssize_t tcm_loop_tpg_store_nexus( | 913 | static ssize_t tcm_loop_tpg_nexus_store(struct config_item *item, |
917 | struct se_portal_group *se_tpg, | 914 | const char *page, size_t count) |
918 | const char *page, | ||
919 | size_t count) | ||
920 | { | 915 | { |
916 | struct se_portal_group *se_tpg = to_tpg(item); | ||
921 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | 917 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
922 | struct tcm_loop_tpg, tl_se_tpg); | 918 | struct tcm_loop_tpg, tl_se_tpg); |
923 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; | 919 | struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; |
@@ -992,12 +988,10 @@ check_newline: | |||
992 | return count; | 988 | return count; |
993 | } | 989 | } |
994 | 990 | ||
995 | TF_TPG_BASE_ATTR(tcm_loop, nexus, S_IRUGO | S_IWUSR); | 991 | static ssize_t tcm_loop_tpg_transport_status_show(struct config_item *item, |
996 | 992 | char *page) | |
997 | static ssize_t tcm_loop_tpg_show_transport_status( | ||
998 | struct se_portal_group *se_tpg, | ||
999 | char *page) | ||
1000 | { | 993 | { |
994 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1001 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | 995 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
1002 | struct tcm_loop_tpg, tl_se_tpg); | 996 | struct tcm_loop_tpg, tl_se_tpg); |
1003 | const char *status = NULL; | 997 | const char *status = NULL; |
@@ -1020,11 +1014,10 @@ static ssize_t tcm_loop_tpg_show_transport_status( | |||
1020 | return ret; | 1014 | return ret; |
1021 | } | 1015 | } |
1022 | 1016 | ||
1023 | static ssize_t tcm_loop_tpg_store_transport_status( | 1017 | static ssize_t tcm_loop_tpg_transport_status_store(struct config_item *item, |
1024 | struct se_portal_group *se_tpg, | 1018 | const char *page, size_t count) |
1025 | const char *page, | ||
1026 | size_t count) | ||
1027 | { | 1019 | { |
1020 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1028 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, | 1021 | struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, |
1029 | struct tcm_loop_tpg, tl_se_tpg); | 1022 | struct tcm_loop_tpg, tl_se_tpg); |
1030 | 1023 | ||
@@ -1044,11 +1037,12 @@ static ssize_t tcm_loop_tpg_store_transport_status( | |||
1044 | return -EINVAL; | 1037 | return -EINVAL; |
1045 | } | 1038 | } |
1046 | 1039 | ||
1047 | TF_TPG_BASE_ATTR(tcm_loop, transport_status, S_IRUGO | S_IWUSR); | 1040 | CONFIGFS_ATTR(tcm_loop_tpg_, nexus); |
1041 | CONFIGFS_ATTR(tcm_loop_tpg_, transport_status); | ||
1048 | 1042 | ||
1049 | static struct configfs_attribute *tcm_loop_tpg_attrs[] = { | 1043 | static struct configfs_attribute *tcm_loop_tpg_attrs[] = { |
1050 | &tcm_loop_tpg_nexus.attr, | 1044 | &tcm_loop_tpg_attr_nexus, |
1051 | &tcm_loop_tpg_transport_status.attr, | 1045 | &tcm_loop_tpg_attr_transport_status, |
1052 | NULL, | 1046 | NULL, |
1053 | }; | 1047 | }; |
1054 | 1048 | ||
@@ -1216,17 +1210,15 @@ static void tcm_loop_drop_scsi_hba( | |||
1216 | } | 1210 | } |
1217 | 1211 | ||
1218 | /* Start items for tcm_loop_cit */ | 1212 | /* Start items for tcm_loop_cit */ |
1219 | static ssize_t tcm_loop_wwn_show_attr_version( | 1213 | static ssize_t tcm_loop_wwn_version_show(struct config_item *item, char *page) |
1220 | struct target_fabric_configfs *tf, | ||
1221 | char *page) | ||
1222 | { | 1214 | { |
1223 | return sprintf(page, "TCM Loopback Fabric module %s\n", TCM_LOOP_VERSION); | 1215 | return sprintf(page, "TCM Loopback Fabric module %s\n", TCM_LOOP_VERSION); |
1224 | } | 1216 | } |
1225 | 1217 | ||
1226 | TF_WWN_ATTR_RO(tcm_loop, version); | 1218 | CONFIGFS_ATTR_RO(tcm_loop_wwn_, version); |
1227 | 1219 | ||
1228 | static struct configfs_attribute *tcm_loop_wwn_attrs[] = { | 1220 | static struct configfs_attribute *tcm_loop_wwn_attrs[] = { |
1229 | &tcm_loop_wwn_version.attr, | 1221 | &tcm_loop_wwn_attr_version, |
1230 | NULL, | 1222 | NULL, |
1231 | }; | 1223 | }; |
1232 | 1224 | ||
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c index 0edf320fb685..35f7d31b29d2 100644 --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c | |||
@@ -35,8 +35,6 @@ | |||
35 | #include <target/target_core_base.h> | 35 | #include <target/target_core_base.h> |
36 | #include <target/target_core_backend.h> | 36 | #include <target/target_core_backend.h> |
37 | #include <target/target_core_fabric.h> | 37 | #include <target/target_core_fabric.h> |
38 | #include <target/target_core_fabric_configfs.h> | ||
39 | #include <target/configfs_macros.h> | ||
40 | #include <asm/unaligned.h> | 38 | #include <asm/unaligned.h> |
41 | 39 | ||
42 | #include "sbp_target.h" | 40 | #include "sbp_target.h" |
@@ -2111,24 +2109,21 @@ static void sbp_drop_tport(struct se_wwn *wwn) | |||
2111 | kfree(tport); | 2109 | kfree(tport); |
2112 | } | 2110 | } |
2113 | 2111 | ||
2114 | static ssize_t sbp_wwn_show_attr_version( | 2112 | static ssize_t sbp_wwn_version_show(struct config_item *item, char *page) |
2115 | struct target_fabric_configfs *tf, | ||
2116 | char *page) | ||
2117 | { | 2113 | { |
2118 | return sprintf(page, "FireWire SBP fabric module %s\n", SBP_VERSION); | 2114 | return sprintf(page, "FireWire SBP fabric module %s\n", SBP_VERSION); |
2119 | } | 2115 | } |
2120 | 2116 | ||
2121 | TF_WWN_ATTR_RO(sbp, version); | 2117 | CONFIGFS_ATTR_RO(sbp_wwn_, version); |
2122 | 2118 | ||
2123 | static struct configfs_attribute *sbp_wwn_attrs[] = { | 2119 | static struct configfs_attribute *sbp_wwn_attrs[] = { |
2124 | &sbp_wwn_version.attr, | 2120 | &sbp_wwn_attr_version, |
2125 | NULL, | 2121 | NULL, |
2126 | }; | 2122 | }; |
2127 | 2123 | ||
2128 | static ssize_t sbp_tpg_show_directory_id( | 2124 | static ssize_t sbp_tpg_directory_id_show(struct config_item *item, char *page) |
2129 | struct se_portal_group *se_tpg, | ||
2130 | char *page) | ||
2131 | { | 2125 | { |
2126 | struct se_portal_group *se_tpg = to_tpg(item); | ||
2132 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2127 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2133 | struct sbp_tport *tport = tpg->tport; | 2128 | struct sbp_tport *tport = tpg->tport; |
2134 | 2129 | ||
@@ -2138,11 +2133,10 @@ static ssize_t sbp_tpg_show_directory_id( | |||
2138 | return sprintf(page, "%06x\n", tport->directory_id); | 2133 | return sprintf(page, "%06x\n", tport->directory_id); |
2139 | } | 2134 | } |
2140 | 2135 | ||
2141 | static ssize_t sbp_tpg_store_directory_id( | 2136 | static ssize_t sbp_tpg_directory_id_store(struct config_item *item, |
2142 | struct se_portal_group *se_tpg, | 2137 | const char *page, size_t count) |
2143 | const char *page, | ||
2144 | size_t count) | ||
2145 | { | 2138 | { |
2139 | struct se_portal_group *se_tpg = to_tpg(item); | ||
2146 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2140 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2147 | struct sbp_tport *tport = tpg->tport; | 2141 | struct sbp_tport *tport = tpg->tport; |
2148 | unsigned long val; | 2142 | unsigned long val; |
@@ -2166,20 +2160,18 @@ static ssize_t sbp_tpg_store_directory_id( | |||
2166 | return count; | 2160 | return count; |
2167 | } | 2161 | } |
2168 | 2162 | ||
2169 | static ssize_t sbp_tpg_show_enable( | 2163 | static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page) |
2170 | struct se_portal_group *se_tpg, | ||
2171 | char *page) | ||
2172 | { | 2164 | { |
2165 | struct se_portal_group *se_tpg = to_tpg(item); | ||
2173 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2166 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2174 | struct sbp_tport *tport = tpg->tport; | 2167 | struct sbp_tport *tport = tpg->tport; |
2175 | return sprintf(page, "%d\n", tport->enable); | 2168 | return sprintf(page, "%d\n", tport->enable); |
2176 | } | 2169 | } |
2177 | 2170 | ||
2178 | static ssize_t sbp_tpg_store_enable( | 2171 | static ssize_t sbp_tpg_enable_store(struct config_item *item, |
2179 | struct se_portal_group *se_tpg, | 2172 | const char *page, size_t count) |
2180 | const char *page, | ||
2181 | size_t count) | ||
2182 | { | 2173 | { |
2174 | struct se_portal_group *se_tpg = to_tpg(item); | ||
2183 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2175 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2184 | struct sbp_tport *tport = tpg->tport; | 2176 | struct sbp_tport *tport = tpg->tport; |
2185 | unsigned long val; | 2177 | unsigned long val; |
@@ -2219,29 +2211,28 @@ static ssize_t sbp_tpg_store_enable( | |||
2219 | return count; | 2211 | return count; |
2220 | } | 2212 | } |
2221 | 2213 | ||
2222 | TF_TPG_BASE_ATTR(sbp, directory_id, S_IRUGO | S_IWUSR); | 2214 | CONFIGFS_ATTR(sbp_tpg_, directory_id); |
2223 | TF_TPG_BASE_ATTR(sbp, enable, S_IRUGO | S_IWUSR); | 2215 | CONFIGFS_ATTR(sbp_tpg_, enable); |
2224 | 2216 | ||
2225 | static struct configfs_attribute *sbp_tpg_base_attrs[] = { | 2217 | static struct configfs_attribute *sbp_tpg_base_attrs[] = { |
2226 | &sbp_tpg_directory_id.attr, | 2218 | &sbp_tpg_attr_directory_id, |
2227 | &sbp_tpg_enable.attr, | 2219 | &sbp_tpg_attr_enable, |
2228 | NULL, | 2220 | NULL, |
2229 | }; | 2221 | }; |
2230 | 2222 | ||
2231 | static ssize_t sbp_tpg_attrib_show_mgt_orb_timeout( | 2223 | static ssize_t sbp_tpg_attrib_mgt_orb_timeout_show(struct config_item *item, |
2232 | struct se_portal_group *se_tpg, | ||
2233 | char *page) | 2224 | char *page) |
2234 | { | 2225 | { |
2226 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2235 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2227 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2236 | struct sbp_tport *tport = tpg->tport; | 2228 | struct sbp_tport *tport = tpg->tport; |
2237 | return sprintf(page, "%d\n", tport->mgt_orb_timeout); | 2229 | return sprintf(page, "%d\n", tport->mgt_orb_timeout); |
2238 | } | 2230 | } |
2239 | 2231 | ||
2240 | static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout( | 2232 | static ssize_t sbp_tpg_attrib_mgt_orb_timeout_store(struct config_item *item, |
2241 | struct se_portal_group *se_tpg, | 2233 | const char *page, size_t count) |
2242 | const char *page, | ||
2243 | size_t count) | ||
2244 | { | 2234 | { |
2235 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2245 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2236 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2246 | struct sbp_tport *tport = tpg->tport; | 2237 | struct sbp_tport *tport = tpg->tport; |
2247 | unsigned long val; | 2238 | unsigned long val; |
@@ -2264,20 +2255,19 @@ static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout( | |||
2264 | return count; | 2255 | return count; |
2265 | } | 2256 | } |
2266 | 2257 | ||
2267 | static ssize_t sbp_tpg_attrib_show_max_reconnect_timeout( | 2258 | static ssize_t sbp_tpg_attrib_max_reconnect_timeout_show(struct config_item *item, |
2268 | struct se_portal_group *se_tpg, | ||
2269 | char *page) | 2259 | char *page) |
2270 | { | 2260 | { |
2261 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2271 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2262 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2272 | struct sbp_tport *tport = tpg->tport; | 2263 | struct sbp_tport *tport = tpg->tport; |
2273 | return sprintf(page, "%d\n", tport->max_reconnect_timeout); | 2264 | return sprintf(page, "%d\n", tport->max_reconnect_timeout); |
2274 | } | 2265 | } |
2275 | 2266 | ||
2276 | static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout( | 2267 | static ssize_t sbp_tpg_attrib_max_reconnect_timeout_store(struct config_item *item, |
2277 | struct se_portal_group *se_tpg, | 2268 | const char *page, size_t count) |
2278 | const char *page, | ||
2279 | size_t count) | ||
2280 | { | 2269 | { |
2270 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2281 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2271 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2282 | struct sbp_tport *tport = tpg->tport; | 2272 | struct sbp_tport *tport = tpg->tport; |
2283 | unsigned long val; | 2273 | unsigned long val; |
@@ -2300,20 +2290,19 @@ static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout( | |||
2300 | return count; | 2290 | return count; |
2301 | } | 2291 | } |
2302 | 2292 | ||
2303 | static ssize_t sbp_tpg_attrib_show_max_logins_per_lun( | 2293 | static ssize_t sbp_tpg_attrib_max_logins_per_lun_show(struct config_item *item, |
2304 | struct se_portal_group *se_tpg, | ||
2305 | char *page) | 2294 | char *page) |
2306 | { | 2295 | { |
2296 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2307 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2297 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2308 | struct sbp_tport *tport = tpg->tport; | 2298 | struct sbp_tport *tport = tpg->tport; |
2309 | return sprintf(page, "%d\n", tport->max_logins_per_lun); | 2299 | return sprintf(page, "%d\n", tport->max_logins_per_lun); |
2310 | } | 2300 | } |
2311 | 2301 | ||
2312 | static ssize_t sbp_tpg_attrib_store_max_logins_per_lun( | 2302 | static ssize_t sbp_tpg_attrib_max_logins_per_lun_store(struct config_item *item, |
2313 | struct se_portal_group *se_tpg, | 2303 | const char *page, size_t count) |
2314 | const char *page, | ||
2315 | size_t count) | ||
2316 | { | 2304 | { |
2305 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
2317 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); | 2306 | struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); |
2318 | struct sbp_tport *tport = tpg->tport; | 2307 | struct sbp_tport *tport = tpg->tport; |
2319 | unsigned long val; | 2308 | unsigned long val; |
@@ -2330,14 +2319,14 @@ static ssize_t sbp_tpg_attrib_store_max_logins_per_lun( | |||
2330 | return count; | 2319 | return count; |
2331 | } | 2320 | } |
2332 | 2321 | ||
2333 | TF_TPG_ATTRIB_ATTR(sbp, mgt_orb_timeout, S_IRUGO | S_IWUSR); | 2322 | CONFIGFS_ATTR(sbp_tpg_attrib_, mgt_orb_timeout); |
2334 | TF_TPG_ATTRIB_ATTR(sbp, max_reconnect_timeout, S_IRUGO | S_IWUSR); | 2323 | CONFIGFS_ATTR(sbp_tpg_attrib_, max_reconnect_timeout); |
2335 | TF_TPG_ATTRIB_ATTR(sbp, max_logins_per_lun, S_IRUGO | S_IWUSR); | 2324 | CONFIGFS_ATTR(sbp_tpg_attrib_, max_logins_per_lun); |
2336 | 2325 | ||
2337 | static struct configfs_attribute *sbp_tpg_attrib_attrs[] = { | 2326 | static struct configfs_attribute *sbp_tpg_attrib_attrs[] = { |
2338 | &sbp_tpg_attrib_mgt_orb_timeout.attr, | 2327 | &sbp_tpg_attrib_attr_mgt_orb_timeout, |
2339 | &sbp_tpg_attrib_max_reconnect_timeout.attr, | 2328 | &sbp_tpg_attrib_attr_max_reconnect_timeout, |
2340 | &sbp_tpg_attrib_max_logins_per_lun.attr, | 2329 | &sbp_tpg_attrib_attr_max_logins_per_lun, |
2341 | NULL, | 2330 | NULL, |
2342 | }; | 2331 | }; |
2343 | 2332 | ||
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 860e84046177..b9b9ffde4c7a 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c | |||
@@ -40,8 +40,6 @@ | |||
40 | #include <target/target_core_base.h> | 40 | #include <target/target_core_base.h> |
41 | #include <target/target_core_backend.h> | 41 | #include <target/target_core_backend.h> |
42 | #include <target/target_core_fabric.h> | 42 | #include <target/target_core_fabric.h> |
43 | #include <target/target_core_fabric_configfs.h> | ||
44 | #include <target/configfs_macros.h> | ||
45 | 43 | ||
46 | #include "target_core_internal.h" | 44 | #include "target_core_internal.h" |
47 | #include "target_core_alua.h" | 45 | #include "target_core_alua.h" |
@@ -78,12 +76,6 @@ extern struct t10_alua_lu_gp *default_lu_gp; | |||
78 | static LIST_HEAD(g_tf_list); | 76 | static LIST_HEAD(g_tf_list); |
79 | static DEFINE_MUTEX(g_tf_lock); | 77 | static DEFINE_MUTEX(g_tf_lock); |
80 | 78 | ||
81 | struct target_core_configfs_attribute { | ||
82 | struct configfs_attribute attr; | ||
83 | ssize_t (*show)(void *, char *); | ||
84 | ssize_t (*store)(void *, const char *, size_t); | ||
85 | }; | ||
86 | |||
87 | static struct config_group target_core_hbagroup; | 79 | static struct config_group target_core_hbagroup; |
88 | static struct config_group alua_group; | 80 | static struct config_group alua_group; |
89 | static struct config_group alua_lu_gps_group; | 81 | static struct config_group alua_lu_gps_group; |
@@ -97,24 +89,15 @@ item_to_hba(struct config_item *item) | |||
97 | /* | 89 | /* |
98 | * Attributes for /sys/kernel/config/target/ | 90 | * Attributes for /sys/kernel/config/target/ |
99 | */ | 91 | */ |
100 | static ssize_t target_core_attr_show(struct config_item *item, | 92 | static ssize_t target_core_item_version_show(struct config_item *item, |
101 | struct configfs_attribute *attr, | 93 | char *page) |
102 | char *page) | ||
103 | { | 94 | { |
104 | return sprintf(page, "Target Engine Core ConfigFS Infrastructure %s" | 95 | return sprintf(page, "Target Engine Core ConfigFS Infrastructure %s" |
105 | " on %s/%s on "UTS_RELEASE"\n", TARGET_CORE_VERSION, | 96 | " on %s/%s on "UTS_RELEASE"\n", TARGET_CORE_VERSION, |
106 | utsname()->sysname, utsname()->machine); | 97 | utsname()->sysname, utsname()->machine); |
107 | } | 98 | } |
108 | 99 | ||
109 | static struct configfs_item_operations target_core_fabric_item_ops = { | 100 | CONFIGFS_ATTR_RO(target_core_item_, version); |
110 | .show_attribute = target_core_attr_show, | ||
111 | }; | ||
112 | |||
113 | static struct configfs_attribute target_core_item_attr_version = { | ||
114 | .ca_owner = THIS_MODULE, | ||
115 | .ca_name = "version", | ||
116 | .ca_mode = S_IRUGO, | ||
117 | }; | ||
118 | 101 | ||
119 | static struct target_fabric_configfs *target_core_get_fabric( | 102 | static struct target_fabric_configfs *target_core_get_fabric( |
120 | const char *name) | 103 | const char *name) |
@@ -273,7 +256,6 @@ static struct configfs_attribute *target_core_fabric_item_attrs[] = { | |||
273 | * Provides Fabrics Groups and Item Attributes for /sys/kernel/config/target/ | 256 | * Provides Fabrics Groups and Item Attributes for /sys/kernel/config/target/ |
274 | */ | 257 | */ |
275 | static struct config_item_type target_core_fabrics_item = { | 258 | static struct config_item_type target_core_fabrics_item = { |
276 | .ct_item_ops = &target_core_fabric_item_ops, | ||
277 | .ct_group_ops = &target_core_fabric_group_ops, | 259 | .ct_group_ops = &target_core_fabric_group_ops, |
278 | .ct_attrs = target_core_fabric_item_attrs, | 260 | .ct_attrs = target_core_fabric_item_attrs, |
279 | .ct_owner = THIS_MODULE, | 261 | .ct_owner = THIS_MODULE, |
@@ -476,47 +458,54 @@ EXPORT_SYMBOL(target_unregister_template); | |||
476 | // Stop functions called by external Target Fabrics Modules | 458 | // Stop functions called by external Target Fabrics Modules |
477 | //############################################################################*/ | 459 | //############################################################################*/ |
478 | 460 | ||
461 | static inline struct se_dev_attrib *to_attrib(struct config_item *item) | ||
462 | { | ||
463 | return container_of(to_config_group(item), struct se_dev_attrib, | ||
464 | da_group); | ||
465 | } | ||
466 | |||
479 | /* Start functions for struct config_item_type tb_dev_attrib_cit */ | 467 | /* Start functions for struct config_item_type tb_dev_attrib_cit */ |
480 | #define DEF_TB_DEV_ATTRIB_SHOW(_name) \ | 468 | #define DEF_CONFIGFS_ATTRIB_SHOW(_name) \ |
481 | static ssize_t show_##_name(struct se_dev_attrib *da, char *page) \ | 469 | static ssize_t _name##_show(struct config_item *item, char *page) \ |
482 | { \ | 470 | { \ |
483 | return snprintf(page, PAGE_SIZE, "%u\n", da->_name); \ | 471 | return snprintf(page, PAGE_SIZE, "%u\n", to_attrib(item)->_name); \ |
484 | } | 472 | } |
485 | 473 | ||
486 | DEF_TB_DEV_ATTRIB_SHOW(emulate_model_alias); | 474 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_model_alias); |
487 | DEF_TB_DEV_ATTRIB_SHOW(emulate_dpo); | 475 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_dpo); |
488 | DEF_TB_DEV_ATTRIB_SHOW(emulate_fua_write); | 476 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_fua_write); |
489 | DEF_TB_DEV_ATTRIB_SHOW(emulate_fua_read); | 477 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_fua_read); |
490 | DEF_TB_DEV_ATTRIB_SHOW(emulate_write_cache); | 478 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_write_cache); |
491 | DEF_TB_DEV_ATTRIB_SHOW(emulate_ua_intlck_ctrl); | 479 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_ua_intlck_ctrl); |
492 | DEF_TB_DEV_ATTRIB_SHOW(emulate_tas); | 480 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_tas); |
493 | DEF_TB_DEV_ATTRIB_SHOW(emulate_tpu); | 481 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_tpu); |
494 | DEF_TB_DEV_ATTRIB_SHOW(emulate_tpws); | 482 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_tpws); |
495 | DEF_TB_DEV_ATTRIB_SHOW(emulate_caw); | 483 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_caw); |
496 | DEF_TB_DEV_ATTRIB_SHOW(emulate_3pc); | 484 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_3pc); |
497 | DEF_TB_DEV_ATTRIB_SHOW(pi_prot_type); | 485 | DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_type); |
498 | DEF_TB_DEV_ATTRIB_SHOW(hw_pi_prot_type); | 486 | DEF_CONFIGFS_ATTRIB_SHOW(hw_pi_prot_type); |
499 | DEF_TB_DEV_ATTRIB_SHOW(pi_prot_format); | 487 | DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_format); |
500 | DEF_TB_DEV_ATTRIB_SHOW(enforce_pr_isids); | 488 | DEF_CONFIGFS_ATTRIB_SHOW(enforce_pr_isids); |
501 | DEF_TB_DEV_ATTRIB_SHOW(is_nonrot); | 489 | DEF_CONFIGFS_ATTRIB_SHOW(is_nonrot); |
502 | DEF_TB_DEV_ATTRIB_SHOW(emulate_rest_reord); | 490 | DEF_CONFIGFS_ATTRIB_SHOW(emulate_rest_reord); |
503 | DEF_TB_DEV_ATTRIB_SHOW(force_pr_aptpl); | 491 | DEF_CONFIGFS_ATTRIB_SHOW(force_pr_aptpl); |
504 | DEF_TB_DEV_ATTRIB_SHOW(hw_block_size); | 492 | DEF_CONFIGFS_ATTRIB_SHOW(hw_block_size); |
505 | DEF_TB_DEV_ATTRIB_SHOW(block_size); | 493 | DEF_CONFIGFS_ATTRIB_SHOW(block_size); |
506 | DEF_TB_DEV_ATTRIB_SHOW(hw_max_sectors); | 494 | DEF_CONFIGFS_ATTRIB_SHOW(hw_max_sectors); |
507 | DEF_TB_DEV_ATTRIB_SHOW(optimal_sectors); | 495 | DEF_CONFIGFS_ATTRIB_SHOW(optimal_sectors); |
508 | DEF_TB_DEV_ATTRIB_SHOW(hw_queue_depth); | 496 | DEF_CONFIGFS_ATTRIB_SHOW(hw_queue_depth); |
509 | DEF_TB_DEV_ATTRIB_SHOW(queue_depth); | 497 | DEF_CONFIGFS_ATTRIB_SHOW(queue_depth); |
510 | DEF_TB_DEV_ATTRIB_SHOW(max_unmap_lba_count); | 498 | DEF_CONFIGFS_ATTRIB_SHOW(max_unmap_lba_count); |
511 | DEF_TB_DEV_ATTRIB_SHOW(max_unmap_block_desc_count); | 499 | DEF_CONFIGFS_ATTRIB_SHOW(max_unmap_block_desc_count); |
512 | DEF_TB_DEV_ATTRIB_SHOW(unmap_granularity); | 500 | DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity); |
513 | DEF_TB_DEV_ATTRIB_SHOW(unmap_granularity_alignment); | 501 | DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment); |
514 | DEF_TB_DEV_ATTRIB_SHOW(max_write_same_len); | 502 | DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len); |
515 | 503 | ||
516 | #define DEF_TB_DEV_ATTRIB_STORE_U32(_name) \ | 504 | #define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \ |
517 | static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | 505 | static ssize_t _name##_store(struct config_item *item, const char *page,\ |
518 | size_t count) \ | 506 | size_t count) \ |
519 | { \ | 507 | { \ |
508 | struct se_dev_attrib *da = to_attrib(item); \ | ||
520 | u32 val; \ | 509 | u32 val; \ |
521 | int ret; \ | 510 | int ret; \ |
522 | \ | 511 | \ |
@@ -527,16 +516,17 @@ static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | |||
527 | return count; \ | 516 | return count; \ |
528 | } | 517 | } |
529 | 518 | ||
530 | DEF_TB_DEV_ATTRIB_STORE_U32(max_unmap_lba_count); | 519 | DEF_CONFIGFS_ATTRIB_STORE_U32(max_unmap_lba_count); |
531 | DEF_TB_DEV_ATTRIB_STORE_U32(max_unmap_block_desc_count); | 520 | DEF_CONFIGFS_ATTRIB_STORE_U32(max_unmap_block_desc_count); |
532 | DEF_TB_DEV_ATTRIB_STORE_U32(unmap_granularity); | 521 | DEF_CONFIGFS_ATTRIB_STORE_U32(unmap_granularity); |
533 | DEF_TB_DEV_ATTRIB_STORE_U32(unmap_granularity_alignment); | 522 | DEF_CONFIGFS_ATTRIB_STORE_U32(unmap_granularity_alignment); |
534 | DEF_TB_DEV_ATTRIB_STORE_U32(max_write_same_len); | 523 | DEF_CONFIGFS_ATTRIB_STORE_U32(max_write_same_len); |
535 | 524 | ||
536 | #define DEF_TB_DEV_ATTRIB_STORE_BOOL(_name) \ | 525 | #define DEF_CONFIGFS_ATTRIB_STORE_BOOL(_name) \ |
537 | static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | 526 | static ssize_t _name##_store(struct config_item *item, const char *page, \ |
538 | size_t count) \ | 527 | size_t count) \ |
539 | { \ | 528 | { \ |
529 | struct se_dev_attrib *da = to_attrib(item); \ | ||
540 | bool flag; \ | 530 | bool flag; \ |
541 | int ret; \ | 531 | int ret; \ |
542 | \ | 532 | \ |
@@ -547,14 +537,14 @@ static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | |||
547 | return count; \ | 537 | return count; \ |
548 | } | 538 | } |
549 | 539 | ||
550 | DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_fua_write); | 540 | DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_fua_write); |
551 | DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_caw); | 541 | DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_caw); |
552 | DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_3pc); | 542 | DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_3pc); |
553 | DEF_TB_DEV_ATTRIB_STORE_BOOL(enforce_pr_isids); | 543 | DEF_CONFIGFS_ATTRIB_STORE_BOOL(enforce_pr_isids); |
554 | DEF_TB_DEV_ATTRIB_STORE_BOOL(is_nonrot); | 544 | DEF_CONFIGFS_ATTRIB_STORE_BOOL(is_nonrot); |
555 | 545 | ||
556 | #define DEF_TB_DEV_ATTRIB_STORE_STUB(_name) \ | 546 | #define DEF_CONFIGFS_ATTRIB_STORE_STUB(_name) \ |
557 | static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | 547 | static ssize_t _name##_store(struct config_item *item, const char *page,\ |
558 | size_t count) \ | 548 | size_t count) \ |
559 | { \ | 549 | { \ |
560 | printk_once(KERN_WARNING \ | 550 | printk_once(KERN_WARNING \ |
@@ -562,8 +552,8 @@ static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ | |||
562 | return count; \ | 552 | return count; \ |
563 | } | 553 | } |
564 | 554 | ||
565 | DEF_TB_DEV_ATTRIB_STORE_STUB(emulate_dpo); | 555 | DEF_CONFIGFS_ATTRIB_STORE_STUB(emulate_dpo); |
566 | DEF_TB_DEV_ATTRIB_STORE_STUB(emulate_fua_read); | 556 | DEF_CONFIGFS_ATTRIB_STORE_STUB(emulate_fua_read); |
567 | 557 | ||
568 | static void dev_set_t10_wwn_model_alias(struct se_device *dev) | 558 | static void dev_set_t10_wwn_model_alias(struct se_device *dev) |
569 | { | 559 | { |
@@ -578,9 +568,10 @@ static void dev_set_t10_wwn_model_alias(struct se_device *dev) | |||
578 | snprintf(&dev->t10_wwn.model[0], 16, "%s", configname); | 568 | snprintf(&dev->t10_wwn.model[0], 16, "%s", configname); |
579 | } | 569 | } |
580 | 570 | ||
581 | static ssize_t store_emulate_model_alias(struct se_dev_attrib *da, | 571 | static ssize_t emulate_model_alias_store(struct config_item *item, |
582 | const char *page, size_t count) | 572 | const char *page, size_t count) |
583 | { | 573 | { |
574 | struct se_dev_attrib *da = to_attrib(item); | ||
584 | struct se_device *dev = da->da_dev; | 575 | struct se_device *dev = da->da_dev; |
585 | bool flag; | 576 | bool flag; |
586 | int ret; | 577 | int ret; |
@@ -606,9 +597,10 @@ static ssize_t store_emulate_model_alias(struct se_dev_attrib *da, | |||
606 | return count; | 597 | return count; |
607 | } | 598 | } |
608 | 599 | ||
609 | static ssize_t store_emulate_write_cache(struct se_dev_attrib *da, | 600 | static ssize_t emulate_write_cache_store(struct config_item *item, |
610 | const char *page, size_t count) | 601 | const char *page, size_t count) |
611 | { | 602 | { |
603 | struct se_dev_attrib *da = to_attrib(item); | ||
612 | bool flag; | 604 | bool flag; |
613 | int ret; | 605 | int ret; |
614 | 606 | ||
@@ -627,9 +619,10 @@ static ssize_t store_emulate_write_cache(struct se_dev_attrib *da, | |||
627 | return count; | 619 | return count; |
628 | } | 620 | } |
629 | 621 | ||
630 | static ssize_t store_emulate_ua_intlck_ctrl(struct se_dev_attrib *da, | 622 | static ssize_t emulate_ua_intlck_ctrl_store(struct config_item *item, |
631 | const char *page, size_t count) | 623 | const char *page, size_t count) |
632 | { | 624 | { |
625 | struct se_dev_attrib *da = to_attrib(item); | ||
633 | u32 val; | 626 | u32 val; |
634 | int ret; | 627 | int ret; |
635 | 628 | ||
@@ -654,9 +647,10 @@ static ssize_t store_emulate_ua_intlck_ctrl(struct se_dev_attrib *da, | |||
654 | return count; | 647 | return count; |
655 | } | 648 | } |
656 | 649 | ||
657 | static ssize_t store_emulate_tas(struct se_dev_attrib *da, | 650 | static ssize_t emulate_tas_store(struct config_item *item, |
658 | const char *page, size_t count) | 651 | const char *page, size_t count) |
659 | { | 652 | { |
653 | struct se_dev_attrib *da = to_attrib(item); | ||
660 | bool flag; | 654 | bool flag; |
661 | int ret; | 655 | int ret; |
662 | 656 | ||
@@ -677,9 +671,10 @@ static ssize_t store_emulate_tas(struct se_dev_attrib *da, | |||
677 | return count; | 671 | return count; |
678 | } | 672 | } |
679 | 673 | ||
680 | static ssize_t store_emulate_tpu(struct se_dev_attrib *da, | 674 | static ssize_t emulate_tpu_store(struct config_item *item, |
681 | const char *page, size_t count) | 675 | const char *page, size_t count) |
682 | { | 676 | { |
677 | struct se_dev_attrib *da = to_attrib(item); | ||
683 | bool flag; | 678 | bool flag; |
684 | int ret; | 679 | int ret; |
685 | 680 | ||
@@ -702,9 +697,10 @@ static ssize_t store_emulate_tpu(struct se_dev_attrib *da, | |||
702 | return count; | 697 | return count; |
703 | } | 698 | } |
704 | 699 | ||
705 | static ssize_t store_emulate_tpws(struct se_dev_attrib *da, | 700 | static ssize_t emulate_tpws_store(struct config_item *item, |
706 | const char *page, size_t count) | 701 | const char *page, size_t count) |
707 | { | 702 | { |
703 | struct se_dev_attrib *da = to_attrib(item); | ||
708 | bool flag; | 704 | bool flag; |
709 | int ret; | 705 | int ret; |
710 | 706 | ||
@@ -727,9 +723,10 @@ static ssize_t store_emulate_tpws(struct se_dev_attrib *da, | |||
727 | return count; | 723 | return count; |
728 | } | 724 | } |
729 | 725 | ||
730 | static ssize_t store_pi_prot_type(struct se_dev_attrib *da, | 726 | static ssize_t pi_prot_type_store(struct config_item *item, |
731 | const char *page, size_t count) | 727 | const char *page, size_t count) |
732 | { | 728 | { |
729 | struct se_dev_attrib *da = to_attrib(item); | ||
733 | int old_prot = da->pi_prot_type, ret; | 730 | int old_prot = da->pi_prot_type, ret; |
734 | struct se_device *dev = da->da_dev; | 731 | struct se_device *dev = da->da_dev; |
735 | u32 flag; | 732 | u32 flag; |
@@ -787,9 +784,10 @@ static ssize_t store_pi_prot_type(struct se_dev_attrib *da, | |||
787 | return count; | 784 | return count; |
788 | } | 785 | } |
789 | 786 | ||
790 | static ssize_t store_pi_prot_format(struct se_dev_attrib *da, | 787 | static ssize_t pi_prot_format_store(struct config_item *item, |
791 | const char *page, size_t count) | 788 | const char *page, size_t count) |
792 | { | 789 | { |
790 | struct se_dev_attrib *da = to_attrib(item); | ||
793 | struct se_device *dev = da->da_dev; | 791 | struct se_device *dev = da->da_dev; |
794 | bool flag; | 792 | bool flag; |
795 | int ret; | 793 | int ret; |
@@ -824,9 +822,10 @@ static ssize_t store_pi_prot_format(struct se_dev_attrib *da, | |||
824 | return count; | 822 | return count; |
825 | } | 823 | } |
826 | 824 | ||
827 | static ssize_t store_force_pr_aptpl(struct se_dev_attrib *da, | 825 | static ssize_t force_pr_aptpl_store(struct config_item *item, |
828 | const char *page, size_t count) | 826 | const char *page, size_t count) |
829 | { | 827 | { |
828 | struct se_dev_attrib *da = to_attrib(item); | ||
830 | bool flag; | 829 | bool flag; |
831 | int ret; | 830 | int ret; |
832 | 831 | ||
@@ -845,9 +844,10 @@ static ssize_t store_force_pr_aptpl(struct se_dev_attrib *da, | |||
845 | return count; | 844 | return count; |
846 | } | 845 | } |
847 | 846 | ||
848 | static ssize_t store_emulate_rest_reord(struct se_dev_attrib *da, | 847 | static ssize_t emulate_rest_reord_store(struct config_item *item, |
849 | const char *page, size_t count) | 848 | const char *page, size_t count) |
850 | { | 849 | { |
850 | struct se_dev_attrib *da = to_attrib(item); | ||
851 | bool flag; | 851 | bool flag; |
852 | int ret; | 852 | int ret; |
853 | 853 | ||
@@ -869,9 +869,10 @@ static ssize_t store_emulate_rest_reord(struct se_dev_attrib *da, | |||
869 | /* | 869 | /* |
870 | * Note, this can only be called on unexported SE Device Object. | 870 | * Note, this can only be called on unexported SE Device Object. |
871 | */ | 871 | */ |
872 | static ssize_t store_queue_depth(struct se_dev_attrib *da, | 872 | static ssize_t queue_depth_store(struct config_item *item, |
873 | const char *page, size_t count) | 873 | const char *page, size_t count) |
874 | { | 874 | { |
875 | struct se_dev_attrib *da = to_attrib(item); | ||
875 | struct se_device *dev = da->da_dev; | 876 | struct se_device *dev = da->da_dev; |
876 | u32 val; | 877 | u32 val; |
877 | int ret; | 878 | int ret; |
@@ -905,9 +906,10 @@ static ssize_t store_queue_depth(struct se_dev_attrib *da, | |||
905 | return count; | 906 | return count; |
906 | } | 907 | } |
907 | 908 | ||
908 | static ssize_t store_optimal_sectors(struct se_dev_attrib *da, | 909 | static ssize_t optimal_sectors_store(struct config_item *item, |
909 | const char *page, size_t count) | 910 | const char *page, size_t count) |
910 | { | 911 | { |
912 | struct se_dev_attrib *da = to_attrib(item); | ||
911 | u32 val; | 913 | u32 val; |
912 | int ret; | 914 | int ret; |
913 | 915 | ||
@@ -934,9 +936,10 @@ static ssize_t store_optimal_sectors(struct se_dev_attrib *da, | |||
934 | return count; | 936 | return count; |
935 | } | 937 | } |
936 | 938 | ||
937 | static ssize_t store_block_size(struct se_dev_attrib *da, | 939 | static ssize_t block_size_store(struct config_item *item, |
938 | const char *page, size_t count) | 940 | const char *page, size_t count) |
939 | { | 941 | { |
942 | struct se_dev_attrib *da = to_attrib(item); | ||
940 | u32 val; | 943 | u32 val; |
941 | int ret; | 944 | int ret; |
942 | 945 | ||
@@ -967,50 +970,35 @@ static ssize_t store_block_size(struct se_dev_attrib *da, | |||
967 | return count; | 970 | return count; |
968 | } | 971 | } |
969 | 972 | ||
970 | CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib); | 973 | CONFIGFS_ATTR(, emulate_model_alias); |
971 | #define TB_DEV_ATTR(_backend, _name, _mode) \ | 974 | CONFIGFS_ATTR(, emulate_dpo); |
972 | static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ | 975 | CONFIGFS_ATTR(, emulate_fua_write); |
973 | __CONFIGFS_EATTR(_name, _mode, \ | 976 | CONFIGFS_ATTR(, emulate_fua_read); |
974 | show_##_name, \ | 977 | CONFIGFS_ATTR(, emulate_write_cache); |
975 | store_##_name); | 978 | CONFIGFS_ATTR(, emulate_ua_intlck_ctrl); |
976 | 979 | CONFIGFS_ATTR(, emulate_tas); | |
977 | #define TB_DEV_ATTR_RO(_backend, _name) \ | 980 | CONFIGFS_ATTR(, emulate_tpu); |
978 | static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ | 981 | CONFIGFS_ATTR(, emulate_tpws); |
979 | __CONFIGFS_EATTR_RO(_name, \ | 982 | CONFIGFS_ATTR(, emulate_caw); |
980 | show_##_name); | 983 | CONFIGFS_ATTR(, emulate_3pc); |
981 | 984 | CONFIGFS_ATTR(, pi_prot_type); | |
982 | TB_DEV_ATTR(target_core, emulate_model_alias, S_IRUGO | S_IWUSR); | 985 | CONFIGFS_ATTR_RO(, hw_pi_prot_type); |
983 | TB_DEV_ATTR(target_core, emulate_dpo, S_IRUGO | S_IWUSR); | 986 | CONFIGFS_ATTR(, pi_prot_format); |
984 | TB_DEV_ATTR(target_core, emulate_fua_write, S_IRUGO | S_IWUSR); | 987 | CONFIGFS_ATTR(, enforce_pr_isids); |
985 | TB_DEV_ATTR(target_core, emulate_fua_read, S_IRUGO | S_IWUSR); | 988 | CONFIGFS_ATTR(, is_nonrot); |
986 | TB_DEV_ATTR(target_core, emulate_write_cache, S_IRUGO | S_IWUSR); | 989 | CONFIGFS_ATTR(, emulate_rest_reord); |
987 | TB_DEV_ATTR(target_core, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); | 990 | CONFIGFS_ATTR(, force_pr_aptpl); |
988 | TB_DEV_ATTR(target_core, emulate_tas, S_IRUGO | S_IWUSR); | 991 | CONFIGFS_ATTR_RO(, hw_block_size); |
989 | TB_DEV_ATTR(target_core, emulate_tpu, S_IRUGO | S_IWUSR); | 992 | CONFIGFS_ATTR(, block_size); |
990 | TB_DEV_ATTR(target_core, emulate_tpws, S_IRUGO | S_IWUSR); | 993 | CONFIGFS_ATTR_RO(, hw_max_sectors); |
991 | TB_DEV_ATTR(target_core, emulate_caw, S_IRUGO | S_IWUSR); | 994 | CONFIGFS_ATTR(, optimal_sectors); |
992 | TB_DEV_ATTR(target_core, emulate_3pc, S_IRUGO | S_IWUSR); | 995 | CONFIGFS_ATTR_RO(, hw_queue_depth); |
993 | TB_DEV_ATTR(target_core, pi_prot_type, S_IRUGO | S_IWUSR); | 996 | CONFIGFS_ATTR(, queue_depth); |
994 | TB_DEV_ATTR_RO(target_core, hw_pi_prot_type); | 997 | CONFIGFS_ATTR(, max_unmap_lba_count); |
995 | TB_DEV_ATTR(target_core, pi_prot_format, S_IRUGO | S_IWUSR); | 998 | CONFIGFS_ATTR(, max_unmap_block_desc_count); |
996 | TB_DEV_ATTR(target_core, enforce_pr_isids, S_IRUGO | S_IWUSR); | 999 | CONFIGFS_ATTR(, unmap_granularity); |
997 | TB_DEV_ATTR(target_core, is_nonrot, S_IRUGO | S_IWUSR); | 1000 | CONFIGFS_ATTR(, unmap_granularity_alignment); |
998 | TB_DEV_ATTR(target_core, emulate_rest_reord, S_IRUGO | S_IWUSR); | 1001 | CONFIGFS_ATTR(, max_write_same_len); |
999 | TB_DEV_ATTR(target_core, force_pr_aptpl, S_IRUGO | S_IWUSR) | ||
1000 | TB_DEV_ATTR_RO(target_core, hw_block_size); | ||
1001 | TB_DEV_ATTR(target_core, block_size, S_IRUGO | S_IWUSR) | ||
1002 | TB_DEV_ATTR_RO(target_core, hw_max_sectors); | ||
1003 | TB_DEV_ATTR(target_core, optimal_sectors, S_IRUGO | S_IWUSR); | ||
1004 | TB_DEV_ATTR_RO(target_core, hw_queue_depth); | ||
1005 | TB_DEV_ATTR(target_core, queue_depth, S_IRUGO | S_IWUSR); | ||
1006 | TB_DEV_ATTR(target_core, max_unmap_lba_count, S_IRUGO | S_IWUSR); | ||
1007 | TB_DEV_ATTR(target_core, max_unmap_block_desc_count, S_IRUGO | S_IWUSR); | ||
1008 | TB_DEV_ATTR(target_core, unmap_granularity, S_IRUGO | S_IWUSR); | ||
1009 | TB_DEV_ATTR(target_core, unmap_granularity_alignment, S_IRUGO | S_IWUSR); | ||
1010 | TB_DEV_ATTR(target_core, max_write_same_len, S_IRUGO | S_IWUSR); | ||
1011 | |||
1012 | CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib); | ||
1013 | CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); | ||
1014 | 1002 | ||
1015 | /* | 1003 | /* |
1016 | * dev_attrib attributes for devices using the target core SBC/SPC | 1004 | * dev_attrib attributes for devices using the target core SBC/SPC |
@@ -1018,100 +1006,78 @@ CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); | |||
1018 | * these. | 1006 | * these. |
1019 | */ | 1007 | */ |
1020 | struct configfs_attribute *sbc_attrib_attrs[] = { | 1008 | struct configfs_attribute *sbc_attrib_attrs[] = { |
1021 | &target_core_dev_attrib_emulate_model_alias.attr, | 1009 | &attr_emulate_model_alias, |
1022 | &target_core_dev_attrib_emulate_dpo.attr, | 1010 | &attr_emulate_dpo, |
1023 | &target_core_dev_attrib_emulate_fua_write.attr, | 1011 | &attr_emulate_fua_write, |
1024 | &target_core_dev_attrib_emulate_fua_read.attr, | 1012 | &attr_emulate_fua_read, |
1025 | &target_core_dev_attrib_emulate_write_cache.attr, | 1013 | &attr_emulate_write_cache, |
1026 | &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr, | 1014 | &attr_emulate_ua_intlck_ctrl, |
1027 | &target_core_dev_attrib_emulate_tas.attr, | 1015 | &attr_emulate_tas, |
1028 | &target_core_dev_attrib_emulate_tpu.attr, | 1016 | &attr_emulate_tpu, |
1029 | &target_core_dev_attrib_emulate_tpws.attr, | 1017 | &attr_emulate_tpws, |
1030 | &target_core_dev_attrib_emulate_caw.attr, | 1018 | &attr_emulate_caw, |
1031 | &target_core_dev_attrib_emulate_3pc.attr, | 1019 | &attr_emulate_3pc, |
1032 | &target_core_dev_attrib_pi_prot_type.attr, | 1020 | &attr_pi_prot_type, |
1033 | &target_core_dev_attrib_hw_pi_prot_type.attr, | 1021 | &attr_hw_pi_prot_type, |
1034 | &target_core_dev_attrib_pi_prot_format.attr, | 1022 | &attr_pi_prot_format, |
1035 | &target_core_dev_attrib_enforce_pr_isids.attr, | 1023 | &attr_enforce_pr_isids, |
1036 | &target_core_dev_attrib_is_nonrot.attr, | 1024 | &attr_is_nonrot, |
1037 | &target_core_dev_attrib_emulate_rest_reord.attr, | 1025 | &attr_emulate_rest_reord, |
1038 | &target_core_dev_attrib_force_pr_aptpl.attr, | 1026 | &attr_force_pr_aptpl, |
1039 | &target_core_dev_attrib_hw_block_size.attr, | 1027 | &attr_hw_block_size, |
1040 | &target_core_dev_attrib_block_size.attr, | 1028 | &attr_block_size, |
1041 | &target_core_dev_attrib_hw_max_sectors.attr, | 1029 | &attr_hw_max_sectors, |
1042 | &target_core_dev_attrib_optimal_sectors.attr, | 1030 | &attr_optimal_sectors, |
1043 | &target_core_dev_attrib_hw_queue_depth.attr, | 1031 | &attr_hw_queue_depth, |
1044 | &target_core_dev_attrib_queue_depth.attr, | 1032 | &attr_queue_depth, |
1045 | &target_core_dev_attrib_max_unmap_lba_count.attr, | 1033 | &attr_max_unmap_lba_count, |
1046 | &target_core_dev_attrib_max_unmap_block_desc_count.attr, | 1034 | &attr_max_unmap_block_desc_count, |
1047 | &target_core_dev_attrib_unmap_granularity.attr, | 1035 | &attr_unmap_granularity, |
1048 | &target_core_dev_attrib_unmap_granularity_alignment.attr, | 1036 | &attr_unmap_granularity_alignment, |
1049 | &target_core_dev_attrib_max_write_same_len.attr, | 1037 | &attr_max_write_same_len, |
1050 | NULL, | 1038 | NULL, |
1051 | }; | 1039 | }; |
1052 | EXPORT_SYMBOL(sbc_attrib_attrs); | 1040 | EXPORT_SYMBOL(sbc_attrib_attrs); |
1053 | 1041 | ||
1054 | TB_DEV_ATTR_RO(target_pt, hw_pi_prot_type); | ||
1055 | TB_DEV_ATTR_RO(target_pt, hw_block_size); | ||
1056 | TB_DEV_ATTR_RO(target_pt, hw_max_sectors); | ||
1057 | TB_DEV_ATTR_RO(target_pt, hw_queue_depth); | ||
1058 | |||
1059 | /* | 1042 | /* |
1060 | * Minimal dev_attrib attributes for devices passing through CDBs. | 1043 | * Minimal dev_attrib attributes for devices passing through CDBs. |
1061 | * In this case we only provide a few read-only attributes for | 1044 | * In this case we only provide a few read-only attributes for |
1062 | * backwards compatibility. | 1045 | * backwards compatibility. |
1063 | */ | 1046 | */ |
1064 | struct configfs_attribute *passthrough_attrib_attrs[] = { | 1047 | struct configfs_attribute *passthrough_attrib_attrs[] = { |
1065 | &target_pt_dev_attrib_hw_pi_prot_type.attr, | 1048 | &attr_hw_pi_prot_type, |
1066 | &target_pt_dev_attrib_hw_block_size.attr, | 1049 | &attr_hw_block_size, |
1067 | &target_pt_dev_attrib_hw_max_sectors.attr, | 1050 | &attr_hw_max_sectors, |
1068 | &target_pt_dev_attrib_hw_queue_depth.attr, | 1051 | &attr_hw_queue_depth, |
1069 | NULL, | 1052 | NULL, |
1070 | }; | 1053 | }; |
1071 | EXPORT_SYMBOL(passthrough_attrib_attrs); | 1054 | EXPORT_SYMBOL(passthrough_attrib_attrs); |
1072 | 1055 | ||
1073 | static struct configfs_item_operations target_core_dev_attrib_ops = { | 1056 | TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL); |
1074 | .show_attribute = target_core_dev_attrib_attr_show, | ||
1075 | .store_attribute = target_core_dev_attrib_attr_store, | ||
1076 | }; | ||
1077 | |||
1078 | TB_CIT_SETUP_DRV(dev_attrib, &target_core_dev_attrib_ops, NULL); | ||
1079 | 1057 | ||
1080 | /* End functions for struct config_item_type tb_dev_attrib_cit */ | 1058 | /* End functions for struct config_item_type tb_dev_attrib_cit */ |
1081 | 1059 | ||
1082 | /* Start functions for struct config_item_type tb_dev_wwn_cit */ | 1060 | /* Start functions for struct config_item_type tb_dev_wwn_cit */ |
1083 | 1061 | ||
1084 | CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn); | 1062 | static struct t10_wwn *to_t10_wwn(struct config_item *item) |
1085 | #define SE_DEV_WWN_ATTR(_name, _mode) \ | 1063 | { |
1086 | static struct target_core_dev_wwn_attribute target_core_dev_wwn_##_name = \ | 1064 | return container_of(to_config_group(item), struct t10_wwn, t10_wwn_group); |
1087 | __CONFIGFS_EATTR(_name, _mode, \ | 1065 | } |
1088 | target_core_dev_wwn_show_attr_##_name, \ | ||
1089 | target_core_dev_wwn_store_attr_##_name); | ||
1090 | |||
1091 | #define SE_DEV_WWN_ATTR_RO(_name); \ | ||
1092 | do { \ | ||
1093 | static struct target_core_dev_wwn_attribute \ | ||
1094 | target_core_dev_wwn_##_name = \ | ||
1095 | __CONFIGFS_EATTR_RO(_name, \ | ||
1096 | target_core_dev_wwn_show_attr_##_name); \ | ||
1097 | } while (0); | ||
1098 | 1066 | ||
1099 | /* | 1067 | /* |
1100 | * VPD page 0x80 Unit serial | 1068 | * VPD page 0x80 Unit serial |
1101 | */ | 1069 | */ |
1102 | static ssize_t target_core_dev_wwn_show_attr_vpd_unit_serial( | 1070 | static ssize_t target_wwn_vpd_unit_serial_show(struct config_item *item, |
1103 | struct t10_wwn *t10_wwn, | 1071 | char *page) |
1104 | char *page) | ||
1105 | { | 1072 | { |
1106 | return sprintf(page, "T10 VPD Unit Serial Number: %s\n", | 1073 | return sprintf(page, "T10 VPD Unit Serial Number: %s\n", |
1107 | &t10_wwn->unit_serial[0]); | 1074 | &to_t10_wwn(item)->unit_serial[0]); |
1108 | } | 1075 | } |
1109 | 1076 | ||
1110 | static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial( | 1077 | static ssize_t target_wwn_vpd_unit_serial_store(struct config_item *item, |
1111 | struct t10_wwn *t10_wwn, | 1078 | const char *page, size_t count) |
1112 | const char *page, | ||
1113 | size_t count) | ||
1114 | { | 1079 | { |
1080 | struct t10_wwn *t10_wwn = to_t10_wwn(item); | ||
1115 | struct se_device *dev = t10_wwn->t10_dev; | 1081 | struct se_device *dev = t10_wwn->t10_dev; |
1116 | unsigned char buf[INQUIRY_VPD_SERIAL_LEN]; | 1082 | unsigned char buf[INQUIRY_VPD_SERIAL_LEN]; |
1117 | 1083 | ||
@@ -1167,15 +1133,13 @@ static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial( | |||
1167 | return count; | 1133 | return count; |
1168 | } | 1134 | } |
1169 | 1135 | ||
1170 | SE_DEV_WWN_ATTR(vpd_unit_serial, S_IRUGO | S_IWUSR); | ||
1171 | |||
1172 | /* | 1136 | /* |
1173 | * VPD page 0x83 Protocol Identifier | 1137 | * VPD page 0x83 Protocol Identifier |
1174 | */ | 1138 | */ |
1175 | static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier( | 1139 | static ssize_t target_wwn_vpd_protocol_identifier_show(struct config_item *item, |
1176 | struct t10_wwn *t10_wwn, | 1140 | char *page) |
1177 | char *page) | ||
1178 | { | 1141 | { |
1142 | struct t10_wwn *t10_wwn = to_t10_wwn(item); | ||
1179 | struct t10_vpd *vpd; | 1143 | struct t10_vpd *vpd; |
1180 | unsigned char buf[VPD_TMP_BUF_SIZE]; | 1144 | unsigned char buf[VPD_TMP_BUF_SIZE]; |
1181 | ssize_t len = 0; | 1145 | ssize_t len = 0; |
@@ -1199,25 +1163,15 @@ static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier( | |||
1199 | return len; | 1163 | return len; |
1200 | } | 1164 | } |
1201 | 1165 | ||
1202 | static ssize_t target_core_dev_wwn_store_attr_vpd_protocol_identifier( | ||
1203 | struct t10_wwn *t10_wwn, | ||
1204 | const char *page, | ||
1205 | size_t count) | ||
1206 | { | ||
1207 | return -ENOSYS; | ||
1208 | } | ||
1209 | |||
1210 | SE_DEV_WWN_ATTR(vpd_protocol_identifier, S_IRUGO | S_IWUSR); | ||
1211 | |||
1212 | /* | 1166 | /* |
1213 | * Generic wrapper for dumping VPD identifiers by association. | 1167 | * Generic wrapper for dumping VPD identifiers by association. |
1214 | */ | 1168 | */ |
1215 | #define DEF_DEV_WWN_ASSOC_SHOW(_name, _assoc) \ | 1169 | #define DEF_DEV_WWN_ASSOC_SHOW(_name, _assoc) \ |
1216 | static ssize_t target_core_dev_wwn_show_attr_##_name( \ | 1170 | static ssize_t target_wwn_##_name##_show(struct config_item *item, \ |
1217 | struct t10_wwn *t10_wwn, \ | 1171 | char *page) \ |
1218 | char *page) \ | ||
1219 | { \ | 1172 | { \ |
1220 | struct t10_vpd *vpd; \ | 1173 | struct t10_wwn *t10_wwn = to_t10_wwn(item); \ |
1174 | struct t10_vpd *vpd; \ | ||
1221 | unsigned char buf[VPD_TMP_BUF_SIZE]; \ | 1175 | unsigned char buf[VPD_TMP_BUF_SIZE]; \ |
1222 | ssize_t len = 0; \ | 1176 | ssize_t len = 0; \ |
1223 | \ | 1177 | \ |
@@ -1249,84 +1203,39 @@ static ssize_t target_core_dev_wwn_show_attr_##_name( \ | |||
1249 | return len; \ | 1203 | return len; \ |
1250 | } | 1204 | } |
1251 | 1205 | ||
1252 | /* | 1206 | /* VPD page 0x83 Association: Logical Unit */ |
1253 | * VPD page 0x83 Association: Logical Unit | ||
1254 | */ | ||
1255 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_logical_unit, 0x00); | 1207 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_logical_unit, 0x00); |
1256 | 1208 | /* VPD page 0x83 Association: Target Port */ | |
1257 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_logical_unit( | ||
1258 | struct t10_wwn *t10_wwn, | ||
1259 | const char *page, | ||
1260 | size_t count) | ||
1261 | { | ||
1262 | return -ENOSYS; | ||
1263 | } | ||
1264 | |||
1265 | SE_DEV_WWN_ATTR(vpd_assoc_logical_unit, S_IRUGO | S_IWUSR); | ||
1266 | |||
1267 | /* | ||
1268 | * VPD page 0x83 Association: Target Port | ||
1269 | */ | ||
1270 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10); | 1209 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10); |
1271 | 1210 | /* VPD page 0x83 Association: SCSI Target Device */ | |
1272 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_target_port( | ||
1273 | struct t10_wwn *t10_wwn, | ||
1274 | const char *page, | ||
1275 | size_t count) | ||
1276 | { | ||
1277 | return -ENOSYS; | ||
1278 | } | ||
1279 | |||
1280 | SE_DEV_WWN_ATTR(vpd_assoc_target_port, S_IRUGO | S_IWUSR); | ||
1281 | |||
1282 | /* | ||
1283 | * VPD page 0x83 Association: SCSI Target Device | ||
1284 | */ | ||
1285 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20); | 1211 | DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20); |
1286 | 1212 | ||
1287 | static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_scsi_target_device( | 1213 | CONFIGFS_ATTR(target_wwn_, vpd_unit_serial); |
1288 | struct t10_wwn *t10_wwn, | 1214 | CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier); |
1289 | const char *page, | 1215 | CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit); |
1290 | size_t count) | 1216 | CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_target_port); |
1291 | { | 1217 | CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_scsi_target_device); |
1292 | return -ENOSYS; | ||
1293 | } | ||
1294 | |||
1295 | SE_DEV_WWN_ATTR(vpd_assoc_scsi_target_device, S_IRUGO | S_IWUSR); | ||
1296 | |||
1297 | CONFIGFS_EATTR_OPS(target_core_dev_wwn, t10_wwn, t10_wwn_group); | ||
1298 | 1218 | ||
1299 | static struct configfs_attribute *target_core_dev_wwn_attrs[] = { | 1219 | static struct configfs_attribute *target_core_dev_wwn_attrs[] = { |
1300 | &target_core_dev_wwn_vpd_unit_serial.attr, | 1220 | &target_wwn_attr_vpd_unit_serial, |
1301 | &target_core_dev_wwn_vpd_protocol_identifier.attr, | 1221 | &target_wwn_attr_vpd_protocol_identifier, |
1302 | &target_core_dev_wwn_vpd_assoc_logical_unit.attr, | 1222 | &target_wwn_attr_vpd_assoc_logical_unit, |
1303 | &target_core_dev_wwn_vpd_assoc_target_port.attr, | 1223 | &target_wwn_attr_vpd_assoc_target_port, |
1304 | &target_core_dev_wwn_vpd_assoc_scsi_target_device.attr, | 1224 | &target_wwn_attr_vpd_assoc_scsi_target_device, |
1305 | NULL, | 1225 | NULL, |
1306 | }; | 1226 | }; |
1307 | 1227 | ||
1308 | static struct configfs_item_operations target_core_dev_wwn_ops = { | 1228 | TB_CIT_SETUP(dev_wwn, NULL, NULL, target_core_dev_wwn_attrs); |
1309 | .show_attribute = target_core_dev_wwn_attr_show, | ||
1310 | .store_attribute = target_core_dev_wwn_attr_store, | ||
1311 | }; | ||
1312 | |||
1313 | TB_CIT_SETUP(dev_wwn, &target_core_dev_wwn_ops, NULL, target_core_dev_wwn_attrs); | ||
1314 | 1229 | ||
1315 | /* End functions for struct config_item_type tb_dev_wwn_cit */ | 1230 | /* End functions for struct config_item_type tb_dev_wwn_cit */ |
1316 | 1231 | ||
1317 | /* Start functions for struct config_item_type tb_dev_pr_cit */ | 1232 | /* Start functions for struct config_item_type tb_dev_pr_cit */ |
1318 | 1233 | ||
1319 | CONFIGFS_EATTR_STRUCT(target_core_dev_pr, se_device); | 1234 | static struct se_device *pr_to_dev(struct config_item *item) |
1320 | #define SE_DEV_PR_ATTR(_name, _mode) \ | 1235 | { |
1321 | static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ | 1236 | return container_of(to_config_group(item), struct se_device, |
1322 | __CONFIGFS_EATTR(_name, _mode, \ | 1237 | dev_pr_group); |
1323 | target_core_dev_pr_show_attr_##_name, \ | 1238 | } |
1324 | target_core_dev_pr_store_attr_##_name); | ||
1325 | |||
1326 | #define SE_DEV_PR_ATTR_RO(_name); \ | ||
1327 | static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ | ||
1328 | __CONFIGFS_EATTR_RO(_name, \ | ||
1329 | target_core_dev_pr_show_attr_##_name); | ||
1330 | 1239 | ||
1331 | static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev, | 1240 | static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev, |
1332 | char *page) | 1241 | char *page) |
@@ -1367,9 +1276,9 @@ static ssize_t target_core_dev_pr_show_spc2_res(struct se_device *dev, | |||
1367 | return len; | 1276 | return len; |
1368 | } | 1277 | } |
1369 | 1278 | ||
1370 | static ssize_t target_core_dev_pr_show_attr_res_holder(struct se_device *dev, | 1279 | static ssize_t target_pr_res_holder_show(struct config_item *item, char *page) |
1371 | char *page) | ||
1372 | { | 1280 | { |
1281 | struct se_device *dev = pr_to_dev(item); | ||
1373 | int ret; | 1282 | int ret; |
1374 | 1283 | ||
1375 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) | 1284 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) |
@@ -1384,11 +1293,10 @@ static ssize_t target_core_dev_pr_show_attr_res_holder(struct se_device *dev, | |||
1384 | return ret; | 1293 | return ret; |
1385 | } | 1294 | } |
1386 | 1295 | ||
1387 | SE_DEV_PR_ATTR_RO(res_holder); | 1296 | static ssize_t target_pr_res_pr_all_tgt_pts_show(struct config_item *item, |
1388 | 1297 | char *page) | |
1389 | static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts( | ||
1390 | struct se_device *dev, char *page) | ||
1391 | { | 1298 | { |
1299 | struct se_device *dev = pr_to_dev(item); | ||
1392 | ssize_t len = 0; | 1300 | ssize_t len = 0; |
1393 | 1301 | ||
1394 | spin_lock(&dev->dev_reservation_lock); | 1302 | spin_lock(&dev->dev_reservation_lock); |
@@ -1406,22 +1314,17 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts( | |||
1406 | return len; | 1314 | return len; |
1407 | } | 1315 | } |
1408 | 1316 | ||
1409 | SE_DEV_PR_ATTR_RO(res_pr_all_tgt_pts); | 1317 | static ssize_t target_pr_res_pr_generation_show(struct config_item *item, |
1410 | 1318 | char *page) | |
1411 | static ssize_t target_core_dev_pr_show_attr_res_pr_generation( | ||
1412 | struct se_device *dev, char *page) | ||
1413 | { | 1319 | { |
1414 | return sprintf(page, "0x%08x\n", dev->t10_pr.pr_generation); | 1320 | return sprintf(page, "0x%08x\n", pr_to_dev(item)->t10_pr.pr_generation); |
1415 | } | 1321 | } |
1416 | 1322 | ||
1417 | SE_DEV_PR_ATTR_RO(res_pr_generation); | ||
1418 | 1323 | ||
1419 | /* | 1324 | static ssize_t target_pr_res_pr_holder_tg_port_show(struct config_item *item, |
1420 | * res_pr_holder_tg_port | 1325 | char *page) |
1421 | */ | ||
1422 | static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( | ||
1423 | struct se_device *dev, char *page) | ||
1424 | { | 1326 | { |
1327 | struct se_device *dev = pr_to_dev(item); | ||
1425 | struct se_node_acl *se_nacl; | 1328 | struct se_node_acl *se_nacl; |
1426 | struct se_portal_group *se_tpg; | 1329 | struct se_portal_group *se_tpg; |
1427 | struct t10_pr_registration *pr_reg; | 1330 | struct t10_pr_registration *pr_reg; |
@@ -1453,11 +1356,11 @@ out_unlock: | |||
1453 | return len; | 1356 | return len; |
1454 | } | 1357 | } |
1455 | 1358 | ||
1456 | SE_DEV_PR_ATTR_RO(res_pr_holder_tg_port); | ||
1457 | 1359 | ||
1458 | static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( | 1360 | static ssize_t target_pr_res_pr_registered_i_pts_show(struct config_item *item, |
1459 | struct se_device *dev, char *page) | 1361 | char *page) |
1460 | { | 1362 | { |
1363 | struct se_device *dev = pr_to_dev(item); | ||
1461 | const struct target_core_fabric_ops *tfo; | 1364 | const struct target_core_fabric_ops *tfo; |
1462 | struct t10_pr_registration *pr_reg; | 1365 | struct t10_pr_registration *pr_reg; |
1463 | unsigned char buf[384]; | 1366 | unsigned char buf[384]; |
@@ -1495,11 +1398,9 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( | |||
1495 | return len; | 1398 | return len; |
1496 | } | 1399 | } |
1497 | 1400 | ||
1498 | SE_DEV_PR_ATTR_RO(res_pr_registered_i_pts); | 1401 | static ssize_t target_pr_res_pr_type_show(struct config_item *item, char *page) |
1499 | |||
1500 | static ssize_t target_core_dev_pr_show_attr_res_pr_type( | ||
1501 | struct se_device *dev, char *page) | ||
1502 | { | 1402 | { |
1403 | struct se_device *dev = pr_to_dev(item); | ||
1503 | struct t10_pr_registration *pr_reg; | 1404 | struct t10_pr_registration *pr_reg; |
1504 | ssize_t len = 0; | 1405 | ssize_t len = 0; |
1505 | 1406 | ||
@@ -1516,11 +1417,10 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_type( | |||
1516 | return len; | 1417 | return len; |
1517 | } | 1418 | } |
1518 | 1419 | ||
1519 | SE_DEV_PR_ATTR_RO(res_pr_type); | 1420 | static ssize_t target_pr_res_type_show(struct config_item *item, char *page) |
1520 | |||
1521 | static ssize_t target_core_dev_pr_show_attr_res_type( | ||
1522 | struct se_device *dev, char *page) | ||
1523 | { | 1421 | { |
1422 | struct se_device *dev = pr_to_dev(item); | ||
1423 | |||
1524 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) | 1424 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) |
1525 | return sprintf(page, "SPC_PASSTHROUGH\n"); | 1425 | return sprintf(page, "SPC_PASSTHROUGH\n"); |
1526 | else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) | 1426 | else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) |
@@ -1529,11 +1429,11 @@ static ssize_t target_core_dev_pr_show_attr_res_type( | |||
1529 | return sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n"); | 1429 | return sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n"); |
1530 | } | 1430 | } |
1531 | 1431 | ||
1532 | SE_DEV_PR_ATTR_RO(res_type); | 1432 | static ssize_t target_pr_res_aptpl_active_show(struct config_item *item, |
1533 | 1433 | char *page) | |
1534 | static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( | ||
1535 | struct se_device *dev, char *page) | ||
1536 | { | 1434 | { |
1435 | struct se_device *dev = pr_to_dev(item); | ||
1436 | |||
1537 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) | 1437 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) |
1538 | return 0; | 1438 | return 0; |
1539 | 1439 | ||
@@ -1541,14 +1441,11 @@ static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( | |||
1541 | (dev->t10_pr.pr_aptpl_active) ? "Activated" : "Disabled"); | 1441 | (dev->t10_pr.pr_aptpl_active) ? "Activated" : "Disabled"); |
1542 | } | 1442 | } |
1543 | 1443 | ||
1544 | SE_DEV_PR_ATTR_RO(res_aptpl_active); | 1444 | static ssize_t target_pr_res_aptpl_metadata_show(struct config_item *item, |
1545 | 1445 | char *page) | |
1546 | /* | ||
1547 | * res_aptpl_metadata | ||
1548 | */ | ||
1549 | static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( | ||
1550 | struct se_device *dev, char *page) | ||
1551 | { | 1446 | { |
1447 | struct se_device *dev = pr_to_dev(item); | ||
1448 | |||
1552 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) | 1449 | if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) |
1553 | return 0; | 1450 | return 0; |
1554 | 1451 | ||
@@ -1580,11 +1477,10 @@ static match_table_t tokens = { | |||
1580 | {Opt_err, NULL} | 1477 | {Opt_err, NULL} |
1581 | }; | 1478 | }; |
1582 | 1479 | ||
1583 | static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( | 1480 | static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, |
1584 | struct se_device *dev, | 1481 | const char *page, size_t count) |
1585 | const char *page, | ||
1586 | size_t count) | ||
1587 | { | 1482 | { |
1483 | struct se_device *dev = pr_to_dev(item); | ||
1588 | unsigned char *i_fabric = NULL, *i_port = NULL, *isid = NULL; | 1484 | unsigned char *i_fabric = NULL, *i_port = NULL, *isid = NULL; |
1589 | unsigned char *t_fabric = NULL, *t_port = NULL; | 1485 | unsigned char *t_fabric = NULL, *t_port = NULL; |
1590 | char *orig, *ptr, *opts; | 1486 | char *orig, *ptr, *opts; |
@@ -1765,37 +1661,44 @@ out: | |||
1765 | return (ret == 0) ? count : ret; | 1661 | return (ret == 0) ? count : ret; |
1766 | } | 1662 | } |
1767 | 1663 | ||
1768 | SE_DEV_PR_ATTR(res_aptpl_metadata, S_IRUGO | S_IWUSR); | ||
1769 | 1664 | ||
1770 | CONFIGFS_EATTR_OPS(target_core_dev_pr, se_device, dev_pr_group); | 1665 | CONFIGFS_ATTR_RO(target_pr_, res_holder); |
1666 | CONFIGFS_ATTR_RO(target_pr_, res_pr_all_tgt_pts); | ||
1667 | CONFIGFS_ATTR_RO(target_pr_, res_pr_generation); | ||
1668 | CONFIGFS_ATTR_RO(target_pr_, res_pr_holder_tg_port); | ||
1669 | CONFIGFS_ATTR_RO(target_pr_, res_pr_registered_i_pts); | ||
1670 | CONFIGFS_ATTR_RO(target_pr_, res_pr_type); | ||
1671 | CONFIGFS_ATTR_RO(target_pr_, res_type); | ||
1672 | CONFIGFS_ATTR_RO(target_pr_, res_aptpl_active); | ||
1673 | CONFIGFS_ATTR(target_pr_, res_aptpl_metadata); | ||
1771 | 1674 | ||
1772 | static struct configfs_attribute *target_core_dev_pr_attrs[] = { | 1675 | static struct configfs_attribute *target_core_dev_pr_attrs[] = { |
1773 | &target_core_dev_pr_res_holder.attr, | 1676 | &target_pr_attr_res_holder, |
1774 | &target_core_dev_pr_res_pr_all_tgt_pts.attr, | 1677 | &target_pr_attr_res_pr_all_tgt_pts, |
1775 | &target_core_dev_pr_res_pr_generation.attr, | 1678 | &target_pr_attr_res_pr_generation, |
1776 | &target_core_dev_pr_res_pr_holder_tg_port.attr, | 1679 | &target_pr_attr_res_pr_holder_tg_port, |
1777 | &target_core_dev_pr_res_pr_registered_i_pts.attr, | 1680 | &target_pr_attr_res_pr_registered_i_pts, |
1778 | &target_core_dev_pr_res_pr_type.attr, | 1681 | &target_pr_attr_res_pr_type, |
1779 | &target_core_dev_pr_res_type.attr, | 1682 | &target_pr_attr_res_type, |
1780 | &target_core_dev_pr_res_aptpl_active.attr, | 1683 | &target_pr_attr_res_aptpl_active, |
1781 | &target_core_dev_pr_res_aptpl_metadata.attr, | 1684 | &target_pr_attr_res_aptpl_metadata, |
1782 | NULL, | 1685 | NULL, |
1783 | }; | 1686 | }; |
1784 | 1687 | ||
1785 | static struct configfs_item_operations target_core_dev_pr_ops = { | 1688 | TB_CIT_SETUP(dev_pr, NULL, NULL, target_core_dev_pr_attrs); |
1786 | .show_attribute = target_core_dev_pr_attr_show, | ||
1787 | .store_attribute = target_core_dev_pr_attr_store, | ||
1788 | }; | ||
1789 | |||
1790 | TB_CIT_SETUP(dev_pr, &target_core_dev_pr_ops, NULL, target_core_dev_pr_attrs); | ||
1791 | 1689 | ||
1792 | /* End functions for struct config_item_type tb_dev_pr_cit */ | 1690 | /* End functions for struct config_item_type tb_dev_pr_cit */ |
1793 | 1691 | ||
1794 | /* Start functions for struct config_item_type tb_dev_cit */ | 1692 | /* Start functions for struct config_item_type tb_dev_cit */ |
1795 | 1693 | ||
1796 | static ssize_t target_core_show_dev_info(void *p, char *page) | 1694 | static inline struct se_device *to_device(struct config_item *item) |
1695 | { | ||
1696 | return container_of(to_config_group(item), struct se_device, dev_group); | ||
1697 | } | ||
1698 | |||
1699 | static ssize_t target_dev_info_show(struct config_item *item, char *page) | ||
1797 | { | 1700 | { |
1798 | struct se_device *dev = p; | 1701 | struct se_device *dev = to_device(item); |
1799 | int bl = 0; | 1702 | int bl = 0; |
1800 | ssize_t read_bytes = 0; | 1703 | ssize_t read_bytes = 0; |
1801 | 1704 | ||
@@ -1806,35 +1709,17 @@ static ssize_t target_core_show_dev_info(void *p, char *page) | |||
1806 | return read_bytes; | 1709 | return read_bytes; |
1807 | } | 1710 | } |
1808 | 1711 | ||
1809 | static struct target_core_configfs_attribute target_core_attr_dev_info = { | 1712 | static ssize_t target_dev_control_store(struct config_item *item, |
1810 | .attr = { .ca_owner = THIS_MODULE, | 1713 | const char *page, size_t count) |
1811 | .ca_name = "info", | ||
1812 | .ca_mode = S_IRUGO }, | ||
1813 | .show = target_core_show_dev_info, | ||
1814 | .store = NULL, | ||
1815 | }; | ||
1816 | |||
1817 | static ssize_t target_core_store_dev_control( | ||
1818 | void *p, | ||
1819 | const char *page, | ||
1820 | size_t count) | ||
1821 | { | 1714 | { |
1822 | struct se_device *dev = p; | 1715 | struct se_device *dev = to_device(item); |
1823 | 1716 | ||
1824 | return dev->transport->set_configfs_dev_params(dev, page, count); | 1717 | return dev->transport->set_configfs_dev_params(dev, page, count); |
1825 | } | 1718 | } |
1826 | 1719 | ||
1827 | static struct target_core_configfs_attribute target_core_attr_dev_control = { | 1720 | static ssize_t target_dev_alias_show(struct config_item *item, char *page) |
1828 | .attr = { .ca_owner = THIS_MODULE, | ||
1829 | .ca_name = "control", | ||
1830 | .ca_mode = S_IWUSR }, | ||
1831 | .show = NULL, | ||
1832 | .store = target_core_store_dev_control, | ||
1833 | }; | ||
1834 | |||
1835 | static ssize_t target_core_show_dev_alias(void *p, char *page) | ||
1836 | { | 1721 | { |
1837 | struct se_device *dev = p; | 1722 | struct se_device *dev = to_device(item); |
1838 | 1723 | ||
1839 | if (!(dev->dev_flags & DF_USING_ALIAS)) | 1724 | if (!(dev->dev_flags & DF_USING_ALIAS)) |
1840 | return 0; | 1725 | return 0; |
@@ -1842,12 +1727,10 @@ static ssize_t target_core_show_dev_alias(void *p, char *page) | |||
1842 | return snprintf(page, PAGE_SIZE, "%s\n", dev->dev_alias); | 1727 | return snprintf(page, PAGE_SIZE, "%s\n", dev->dev_alias); |
1843 | } | 1728 | } |
1844 | 1729 | ||
1845 | static ssize_t target_core_store_dev_alias( | 1730 | static ssize_t target_dev_alias_store(struct config_item *item, |
1846 | void *p, | 1731 | const char *page, size_t count) |
1847 | const char *page, | ||
1848 | size_t count) | ||
1849 | { | 1732 | { |
1850 | struct se_device *dev = p; | 1733 | struct se_device *dev = to_device(item); |
1851 | struct se_hba *hba = dev->se_hba; | 1734 | struct se_hba *hba = dev->se_hba; |
1852 | ssize_t read_bytes; | 1735 | ssize_t read_bytes; |
1853 | 1736 | ||
@@ -1874,17 +1757,9 @@ static ssize_t target_core_store_dev_alias( | |||
1874 | return read_bytes; | 1757 | return read_bytes; |
1875 | } | 1758 | } |
1876 | 1759 | ||
1877 | static struct target_core_configfs_attribute target_core_attr_dev_alias = { | 1760 | static ssize_t target_dev_udev_path_show(struct config_item *item, char *page) |
1878 | .attr = { .ca_owner = THIS_MODULE, | ||
1879 | .ca_name = "alias", | ||
1880 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1881 | .show = target_core_show_dev_alias, | ||
1882 | .store = target_core_store_dev_alias, | ||
1883 | }; | ||
1884 | |||
1885 | static ssize_t target_core_show_dev_udev_path(void *p, char *page) | ||
1886 | { | 1761 | { |
1887 | struct se_device *dev = p; | 1762 | struct se_device *dev = to_device(item); |
1888 | 1763 | ||
1889 | if (!(dev->dev_flags & DF_USING_UDEV_PATH)) | 1764 | if (!(dev->dev_flags & DF_USING_UDEV_PATH)) |
1890 | return 0; | 1765 | return 0; |
@@ -1892,12 +1767,10 @@ static ssize_t target_core_show_dev_udev_path(void *p, char *page) | |||
1892 | return snprintf(page, PAGE_SIZE, "%s\n", dev->udev_path); | 1767 | return snprintf(page, PAGE_SIZE, "%s\n", dev->udev_path); |
1893 | } | 1768 | } |
1894 | 1769 | ||
1895 | static ssize_t target_core_store_dev_udev_path( | 1770 | static ssize_t target_dev_udev_path_store(struct config_item *item, |
1896 | void *p, | 1771 | const char *page, size_t count) |
1897 | const char *page, | ||
1898 | size_t count) | ||
1899 | { | 1772 | { |
1900 | struct se_device *dev = p; | 1773 | struct se_device *dev = to_device(item); |
1901 | struct se_hba *hba = dev->se_hba; | 1774 | struct se_hba *hba = dev->se_hba; |
1902 | ssize_t read_bytes; | 1775 | ssize_t read_bytes; |
1903 | 1776 | ||
@@ -1925,27 +1798,17 @@ static ssize_t target_core_store_dev_udev_path( | |||
1925 | return read_bytes; | 1798 | return read_bytes; |
1926 | } | 1799 | } |
1927 | 1800 | ||
1928 | static struct target_core_configfs_attribute target_core_attr_dev_udev_path = { | 1801 | static ssize_t target_dev_enable_show(struct config_item *item, char *page) |
1929 | .attr = { .ca_owner = THIS_MODULE, | ||
1930 | .ca_name = "udev_path", | ||
1931 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1932 | .show = target_core_show_dev_udev_path, | ||
1933 | .store = target_core_store_dev_udev_path, | ||
1934 | }; | ||
1935 | |||
1936 | static ssize_t target_core_show_dev_enable(void *p, char *page) | ||
1937 | { | 1802 | { |
1938 | struct se_device *dev = p; | 1803 | struct se_device *dev = to_device(item); |
1939 | 1804 | ||
1940 | return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED)); | 1805 | return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED)); |
1941 | } | 1806 | } |
1942 | 1807 | ||
1943 | static ssize_t target_core_store_dev_enable( | 1808 | static ssize_t target_dev_enable_store(struct config_item *item, |
1944 | void *p, | 1809 | const char *page, size_t count) |
1945 | const char *page, | ||
1946 | size_t count) | ||
1947 | { | 1810 | { |
1948 | struct se_device *dev = p; | 1811 | struct se_device *dev = to_device(item); |
1949 | char *ptr; | 1812 | char *ptr; |
1950 | int ret; | 1813 | int ret; |
1951 | 1814 | ||
@@ -1962,17 +1825,9 @@ static ssize_t target_core_store_dev_enable( | |||
1962 | return count; | 1825 | return count; |
1963 | } | 1826 | } |
1964 | 1827 | ||
1965 | static struct target_core_configfs_attribute target_core_attr_dev_enable = { | 1828 | static ssize_t target_dev_alua_lu_gp_show(struct config_item *item, char *page) |
1966 | .attr = { .ca_owner = THIS_MODULE, | ||
1967 | .ca_name = "enable", | ||
1968 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
1969 | .show = target_core_show_dev_enable, | ||
1970 | .store = target_core_store_dev_enable, | ||
1971 | }; | ||
1972 | |||
1973 | static ssize_t target_core_show_alua_lu_gp(void *p, char *page) | ||
1974 | { | 1829 | { |
1975 | struct se_device *dev = p; | 1830 | struct se_device *dev = to_device(item); |
1976 | struct config_item *lu_ci; | 1831 | struct config_item *lu_ci; |
1977 | struct t10_alua_lu_gp *lu_gp; | 1832 | struct t10_alua_lu_gp *lu_gp; |
1978 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1833 | struct t10_alua_lu_gp_member *lu_gp_mem; |
@@ -1994,12 +1849,10 @@ static ssize_t target_core_show_alua_lu_gp(void *p, char *page) | |||
1994 | return len; | 1849 | return len; |
1995 | } | 1850 | } |
1996 | 1851 | ||
1997 | static ssize_t target_core_store_alua_lu_gp( | 1852 | static ssize_t target_dev_alua_lu_gp_store(struct config_item *item, |
1998 | void *p, | 1853 | const char *page, size_t count) |
1999 | const char *page, | ||
2000 | size_t count) | ||
2001 | { | 1854 | { |
2002 | struct se_device *dev = p; | 1855 | struct se_device *dev = to_device(item); |
2003 | struct se_hba *hba = dev->se_hba; | 1856 | struct se_hba *hba = dev->se_hba; |
2004 | struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; | 1857 | struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; |
2005 | struct t10_alua_lu_gp_member *lu_gp_mem; | 1858 | struct t10_alua_lu_gp_member *lu_gp_mem; |
@@ -2076,17 +1929,9 @@ static ssize_t target_core_store_alua_lu_gp( | |||
2076 | return count; | 1929 | return count; |
2077 | } | 1930 | } |
2078 | 1931 | ||
2079 | static struct target_core_configfs_attribute target_core_attr_dev_alua_lu_gp = { | 1932 | static ssize_t target_dev_lba_map_show(struct config_item *item, char *page) |
2080 | .attr = { .ca_owner = THIS_MODULE, | ||
2081 | .ca_name = "alua_lu_gp", | ||
2082 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
2083 | .show = target_core_show_alua_lu_gp, | ||
2084 | .store = target_core_store_alua_lu_gp, | ||
2085 | }; | ||
2086 | |||
2087 | static ssize_t target_core_show_dev_lba_map(void *p, char *page) | ||
2088 | { | 1933 | { |
2089 | struct se_device *dev = p; | 1934 | struct se_device *dev = to_device(item); |
2090 | struct t10_alua_lba_map *map; | 1935 | struct t10_alua_lba_map *map; |
2091 | struct t10_alua_lba_map_member *mem; | 1936 | struct t10_alua_lba_map_member *mem; |
2092 | char *b = page; | 1937 | char *b = page; |
@@ -2129,12 +1974,10 @@ static ssize_t target_core_show_dev_lba_map(void *p, char *page) | |||
2129 | return bl; | 1974 | return bl; |
2130 | } | 1975 | } |
2131 | 1976 | ||
2132 | static ssize_t target_core_store_dev_lba_map( | 1977 | static ssize_t target_dev_lba_map_store(struct config_item *item, |
2133 | void *p, | 1978 | const char *page, size_t count) |
2134 | const char *page, | ||
2135 | size_t count) | ||
2136 | { | 1979 | { |
2137 | struct se_device *dev = p; | 1980 | struct se_device *dev = to_device(item); |
2138 | struct t10_alua_lba_map *lba_map = NULL; | 1981 | struct t10_alua_lba_map *lba_map = NULL; |
2139 | struct list_head lba_list; | 1982 | struct list_head lba_list; |
2140 | char *map_entries, *ptr; | 1983 | char *map_entries, *ptr; |
@@ -2246,22 +2089,22 @@ out: | |||
2246 | return count; | 2089 | return count; |
2247 | } | 2090 | } |
2248 | 2091 | ||
2249 | static struct target_core_configfs_attribute target_core_attr_dev_lba_map = { | 2092 | CONFIGFS_ATTR_RO(target_dev_, info); |
2250 | .attr = { .ca_owner = THIS_MODULE, | 2093 | CONFIGFS_ATTR_WO(target_dev_, control); |
2251 | .ca_name = "lba_map", | 2094 | CONFIGFS_ATTR(target_dev_, alias); |
2252 | .ca_mode = S_IRUGO | S_IWUSR }, | 2095 | CONFIGFS_ATTR(target_dev_, udev_path); |
2253 | .show = target_core_show_dev_lba_map, | 2096 | CONFIGFS_ATTR(target_dev_, enable); |
2254 | .store = target_core_store_dev_lba_map, | 2097 | CONFIGFS_ATTR(target_dev_, alua_lu_gp); |
2255 | }; | 2098 | CONFIGFS_ATTR(target_dev_, lba_map); |
2256 | 2099 | ||
2257 | static struct configfs_attribute *target_core_dev_attrs[] = { | 2100 | static struct configfs_attribute *target_core_dev_attrs[] = { |
2258 | &target_core_attr_dev_info.attr, | 2101 | &target_dev_attr_info, |
2259 | &target_core_attr_dev_control.attr, | 2102 | &target_dev_attr_control, |
2260 | &target_core_attr_dev_alias.attr, | 2103 | &target_dev_attr_alias, |
2261 | &target_core_attr_dev_udev_path.attr, | 2104 | &target_dev_attr_udev_path, |
2262 | &target_core_attr_dev_enable.attr, | 2105 | &target_dev_attr_enable, |
2263 | &target_core_attr_dev_alua_lu_gp.attr, | 2106 | &target_dev_attr_alua_lu_gp, |
2264 | &target_core_attr_dev_lba_map.attr, | 2107 | &target_dev_attr_lba_map, |
2265 | NULL, | 2108 | NULL, |
2266 | }; | 2109 | }; |
2267 | 2110 | ||
@@ -2275,42 +2118,8 @@ static void target_core_dev_release(struct config_item *item) | |||
2275 | target_free_device(dev); | 2118 | target_free_device(dev); |
2276 | } | 2119 | } |
2277 | 2120 | ||
2278 | static ssize_t target_core_dev_show(struct config_item *item, | ||
2279 | struct configfs_attribute *attr, | ||
2280 | char *page) | ||
2281 | { | ||
2282 | struct config_group *dev_cg = to_config_group(item); | ||
2283 | struct se_device *dev = | ||
2284 | container_of(dev_cg, struct se_device, dev_group); | ||
2285 | struct target_core_configfs_attribute *tc_attr = container_of( | ||
2286 | attr, struct target_core_configfs_attribute, attr); | ||
2287 | |||
2288 | if (!tc_attr->show) | ||
2289 | return -EINVAL; | ||
2290 | |||
2291 | return tc_attr->show(dev, page); | ||
2292 | } | ||
2293 | |||
2294 | static ssize_t target_core_dev_store(struct config_item *item, | ||
2295 | struct configfs_attribute *attr, | ||
2296 | const char *page, size_t count) | ||
2297 | { | ||
2298 | struct config_group *dev_cg = to_config_group(item); | ||
2299 | struct se_device *dev = | ||
2300 | container_of(dev_cg, struct se_device, dev_group); | ||
2301 | struct target_core_configfs_attribute *tc_attr = container_of( | ||
2302 | attr, struct target_core_configfs_attribute, attr); | ||
2303 | |||
2304 | if (!tc_attr->store) | ||
2305 | return -EINVAL; | ||
2306 | |||
2307 | return tc_attr->store(dev, page, count); | ||
2308 | } | ||
2309 | |||
2310 | static struct configfs_item_operations target_core_dev_item_ops = { | 2121 | static struct configfs_item_operations target_core_dev_item_ops = { |
2311 | .release = target_core_dev_release, | 2122 | .release = target_core_dev_release, |
2312 | .show_attribute = target_core_dev_show, | ||
2313 | .store_attribute = target_core_dev_store, | ||
2314 | }; | 2123 | }; |
2315 | 2124 | ||
2316 | TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs); | 2125 | TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs); |
@@ -2319,38 +2128,25 @@ TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs); | |||
2319 | 2128 | ||
2320 | /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */ | 2129 | /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */ |
2321 | 2130 | ||
2322 | CONFIGFS_EATTR_STRUCT(target_core_alua_lu_gp, t10_alua_lu_gp); | 2131 | static inline struct t10_alua_lu_gp *to_lu_gp(struct config_item *item) |
2323 | #define SE_DEV_ALUA_LU_ATTR(_name, _mode) \ | 2132 | { |
2324 | static struct target_core_alua_lu_gp_attribute \ | 2133 | return container_of(to_config_group(item), struct t10_alua_lu_gp, |
2325 | target_core_alua_lu_gp_##_name = \ | 2134 | lu_gp_group); |
2326 | __CONFIGFS_EATTR(_name, _mode, \ | 2135 | } |
2327 | target_core_alua_lu_gp_show_attr_##_name, \ | ||
2328 | target_core_alua_lu_gp_store_attr_##_name); | ||
2329 | |||
2330 | #define SE_DEV_ALUA_LU_ATTR_RO(_name) \ | ||
2331 | static struct target_core_alua_lu_gp_attribute \ | ||
2332 | target_core_alua_lu_gp_##_name = \ | ||
2333 | __CONFIGFS_EATTR_RO(_name, \ | ||
2334 | target_core_alua_lu_gp_show_attr_##_name); | ||
2335 | 2136 | ||
2336 | /* | 2137 | static ssize_t target_lu_gp_lu_gp_id_show(struct config_item *item, char *page) |
2337 | * lu_gp_id | ||
2338 | */ | ||
2339 | static ssize_t target_core_alua_lu_gp_show_attr_lu_gp_id( | ||
2340 | struct t10_alua_lu_gp *lu_gp, | ||
2341 | char *page) | ||
2342 | { | 2138 | { |
2139 | struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); | ||
2140 | |||
2343 | if (!lu_gp->lu_gp_valid_id) | 2141 | if (!lu_gp->lu_gp_valid_id) |
2344 | return 0; | 2142 | return 0; |
2345 | |||
2346 | return sprintf(page, "%hu\n", lu_gp->lu_gp_id); | 2143 | return sprintf(page, "%hu\n", lu_gp->lu_gp_id); |
2347 | } | 2144 | } |
2348 | 2145 | ||
2349 | static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id( | 2146 | static ssize_t target_lu_gp_lu_gp_id_store(struct config_item *item, |
2350 | struct t10_alua_lu_gp *lu_gp, | 2147 | const char *page, size_t count) |
2351 | const char *page, | ||
2352 | size_t count) | ||
2353 | { | 2148 | { |
2149 | struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); | ||
2354 | struct config_group *alua_lu_gp_cg = &lu_gp->lu_gp_group; | 2150 | struct config_group *alua_lu_gp_cg = &lu_gp->lu_gp_group; |
2355 | unsigned long lu_gp_id; | 2151 | unsigned long lu_gp_id; |
2356 | int ret; | 2152 | int ret; |
@@ -2379,15 +2175,9 @@ static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id( | |||
2379 | return count; | 2175 | return count; |
2380 | } | 2176 | } |
2381 | 2177 | ||
2382 | SE_DEV_ALUA_LU_ATTR(lu_gp_id, S_IRUGO | S_IWUSR); | 2178 | static ssize_t target_lu_gp_members_show(struct config_item *item, char *page) |
2383 | |||
2384 | /* | ||
2385 | * members | ||
2386 | */ | ||
2387 | static ssize_t target_core_alua_lu_gp_show_attr_members( | ||
2388 | struct t10_alua_lu_gp *lu_gp, | ||
2389 | char *page) | ||
2390 | { | 2179 | { |
2180 | struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); | ||
2391 | struct se_device *dev; | 2181 | struct se_device *dev; |
2392 | struct se_hba *hba; | 2182 | struct se_hba *hba; |
2393 | struct t10_alua_lu_gp_member *lu_gp_mem; | 2183 | struct t10_alua_lu_gp_member *lu_gp_mem; |
@@ -2419,13 +2209,12 @@ static ssize_t target_core_alua_lu_gp_show_attr_members( | |||
2419 | return len; | 2209 | return len; |
2420 | } | 2210 | } |
2421 | 2211 | ||
2422 | SE_DEV_ALUA_LU_ATTR_RO(members); | 2212 | CONFIGFS_ATTR(target_lu_gp_, lu_gp_id); |
2423 | 2213 | CONFIGFS_ATTR_RO(target_lu_gp_, members); | |
2424 | CONFIGFS_EATTR_OPS(target_core_alua_lu_gp, t10_alua_lu_gp, lu_gp_group); | ||
2425 | 2214 | ||
2426 | static struct configfs_attribute *target_core_alua_lu_gp_attrs[] = { | 2215 | static struct configfs_attribute *target_core_alua_lu_gp_attrs[] = { |
2427 | &target_core_alua_lu_gp_lu_gp_id.attr, | 2216 | &target_lu_gp_attr_lu_gp_id, |
2428 | &target_core_alua_lu_gp_members.attr, | 2217 | &target_lu_gp_attr_members, |
2429 | NULL, | 2218 | NULL, |
2430 | }; | 2219 | }; |
2431 | 2220 | ||
@@ -2439,8 +2228,6 @@ static void target_core_alua_lu_gp_release(struct config_item *item) | |||
2439 | 2228 | ||
2440 | static struct configfs_item_operations target_core_alua_lu_gp_ops = { | 2229 | static struct configfs_item_operations target_core_alua_lu_gp_ops = { |
2441 | .release = target_core_alua_lu_gp_release, | 2230 | .release = target_core_alua_lu_gp_release, |
2442 | .show_attribute = target_core_alua_lu_gp_attr_show, | ||
2443 | .store_attribute = target_core_alua_lu_gp_attr_store, | ||
2444 | }; | 2231 | }; |
2445 | 2232 | ||
2446 | static struct config_item_type target_core_alua_lu_gp_cit = { | 2233 | static struct config_item_type target_core_alua_lu_gp_cit = { |
@@ -2511,36 +2298,23 @@ static struct config_item_type target_core_alua_lu_gps_cit = { | |||
2511 | 2298 | ||
2512 | /* Start functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ | 2299 | /* Start functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ |
2513 | 2300 | ||
2514 | CONFIGFS_EATTR_STRUCT(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp); | 2301 | static inline struct t10_alua_tg_pt_gp *to_tg_pt_gp(struct config_item *item) |
2515 | #define SE_DEV_ALUA_TG_PT_ATTR(_name, _mode) \ | 2302 | { |
2516 | static struct target_core_alua_tg_pt_gp_attribute \ | 2303 | return container_of(to_config_group(item), struct t10_alua_tg_pt_gp, |
2517 | target_core_alua_tg_pt_gp_##_name = \ | 2304 | tg_pt_gp_group); |
2518 | __CONFIGFS_EATTR(_name, _mode, \ | 2305 | } |
2519 | target_core_alua_tg_pt_gp_show_attr_##_name, \ | ||
2520 | target_core_alua_tg_pt_gp_store_attr_##_name); | ||
2521 | |||
2522 | #define SE_DEV_ALUA_TG_PT_ATTR_RO(_name) \ | ||
2523 | static struct target_core_alua_tg_pt_gp_attribute \ | ||
2524 | target_core_alua_tg_pt_gp_##_name = \ | ||
2525 | __CONFIGFS_EATTR_RO(_name, \ | ||
2526 | target_core_alua_tg_pt_gp_show_attr_##_name); | ||
2527 | 2306 | ||
2528 | /* | 2307 | static ssize_t target_tg_pt_gp_alua_access_state_show(struct config_item *item, |
2529 | * alua_access_state | 2308 | char *page) |
2530 | */ | ||
2531 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_state( | ||
2532 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2533 | char *page) | ||
2534 | { | 2309 | { |
2535 | return sprintf(page, "%d\n", | 2310 | return sprintf(page, "%d\n", |
2536 | atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state)); | 2311 | atomic_read(&to_tg_pt_gp(item)->tg_pt_gp_alua_access_state)); |
2537 | } | 2312 | } |
2538 | 2313 | ||
2539 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state( | 2314 | static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item, |
2540 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2315 | const char *page, size_t count) |
2541 | const char *page, | ||
2542 | size_t count) | ||
2543 | { | 2316 | { |
2317 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2544 | struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; | 2318 | struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; |
2545 | unsigned long tmp; | 2319 | unsigned long tmp; |
2546 | int new_state, ret; | 2320 | int new_state, ret; |
@@ -2582,24 +2356,18 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state( | |||
2582 | return (!ret) ? count : -EINVAL; | 2356 | return (!ret) ? count : -EINVAL; |
2583 | } | 2357 | } |
2584 | 2358 | ||
2585 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_state, S_IRUGO | S_IWUSR); | 2359 | static ssize_t target_tg_pt_gp_alua_access_status_show(struct config_item *item, |
2586 | 2360 | char *page) | |
2587 | /* | ||
2588 | * alua_access_status | ||
2589 | */ | ||
2590 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_status( | ||
2591 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2592 | char *page) | ||
2593 | { | 2361 | { |
2362 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2594 | return sprintf(page, "%s\n", | 2363 | return sprintf(page, "%s\n", |
2595 | core_alua_dump_status(tg_pt_gp->tg_pt_gp_alua_access_status)); | 2364 | core_alua_dump_status(tg_pt_gp->tg_pt_gp_alua_access_status)); |
2596 | } | 2365 | } |
2597 | 2366 | ||
2598 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status( | 2367 | static ssize_t target_tg_pt_gp_alua_access_status_store( |
2599 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2368 | struct config_item *item, const char *page, size_t count) |
2600 | const char *page, | ||
2601 | size_t count) | ||
2602 | { | 2369 | { |
2370 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2603 | unsigned long tmp; | 2371 | unsigned long tmp; |
2604 | int new_status, ret; | 2372 | int new_status, ret; |
2605 | 2373 | ||
@@ -2630,43 +2398,31 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status( | |||
2630 | return count; | 2398 | return count; |
2631 | } | 2399 | } |
2632 | 2400 | ||
2633 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_status, S_IRUGO | S_IWUSR); | 2401 | static ssize_t target_tg_pt_gp_alua_access_type_show(struct config_item *item, |
2634 | 2402 | char *page) | |
2635 | /* | ||
2636 | * alua_access_type | ||
2637 | */ | ||
2638 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_type( | ||
2639 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2640 | char *page) | ||
2641 | { | 2403 | { |
2642 | return core_alua_show_access_type(tg_pt_gp, page); | 2404 | return core_alua_show_access_type(to_tg_pt_gp(item), page); |
2643 | } | 2405 | } |
2644 | 2406 | ||
2645 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_type( | 2407 | static ssize_t target_tg_pt_gp_alua_access_type_store(struct config_item *item, |
2646 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2408 | const char *page, size_t count) |
2647 | const char *page, | ||
2648 | size_t count) | ||
2649 | { | 2409 | { |
2650 | return core_alua_store_access_type(tg_pt_gp, page, count); | 2410 | return core_alua_store_access_type(to_tg_pt_gp(item), page, count); |
2651 | } | 2411 | } |
2652 | 2412 | ||
2653 | SE_DEV_ALUA_TG_PT_ATTR(alua_access_type, S_IRUGO | S_IWUSR); | 2413 | #define ALUA_SUPPORTED_STATE_ATTR(_name, _bit) \ |
2654 | 2414 | static ssize_t target_tg_pt_gp_alua_support_##_name##_show( \ | |
2655 | /* | 2415 | struct config_item *item, char *p) \ |
2656 | * alua_supported_states | ||
2657 | */ | ||
2658 | |||
2659 | #define SE_DEV_ALUA_SUPPORT_STATE_SHOW(_name, _var, _bit) \ | ||
2660 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_support_##_name( \ | ||
2661 | struct t10_alua_tg_pt_gp *t, char *p) \ | ||
2662 | { \ | 2416 | { \ |
2663 | return sprintf(p, "%d\n", !!(t->_var & _bit)); \ | 2417 | struct t10_alua_tg_pt_gp *t = to_tg_pt_gp(item); \ |
2664 | } | 2418 | return sprintf(p, "%d\n", \ |
2665 | 2419 | !!(t->tg_pt_gp_alua_supported_states & _bit)); \ | |
2666 | #define SE_DEV_ALUA_SUPPORT_STATE_STORE(_name, _var, _bit) \ | 2420 | } \ |
2667 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_support_##_name(\ | 2421 | \ |
2668 | struct t10_alua_tg_pt_gp *t, const char *p, size_t c) \ | 2422 | static ssize_t target_tg_pt_gp_alua_support_##_name##_store( \ |
2423 | struct config_item *item, const char *p, size_t c) \ | ||
2669 | { \ | 2424 | { \ |
2425 | struct t10_alua_tg_pt_gp *t = to_tg_pt_gp(item); \ | ||
2670 | unsigned long tmp; \ | 2426 | unsigned long tmp; \ |
2671 | int ret; \ | 2427 | int ret; \ |
2672 | \ | 2428 | \ |
@@ -2687,70 +2443,32 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_support_##_name(\ | |||
2687 | return -EINVAL; \ | 2443 | return -EINVAL; \ |
2688 | } \ | 2444 | } \ |
2689 | if (tmp) \ | 2445 | if (tmp) \ |
2690 | t->_var |= _bit; \ | 2446 | t->tg_pt_gp_alua_supported_states |= _bit; \ |
2691 | else \ | 2447 | else \ |
2692 | t->_var &= ~_bit; \ | 2448 | t->tg_pt_gp_alua_supported_states &= ~_bit; \ |
2693 | \ | 2449 | \ |
2694 | return c; \ | 2450 | return c; \ |
2695 | } | 2451 | } |
2696 | 2452 | ||
2697 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(transitioning, | 2453 | ALUA_SUPPORTED_STATE_ATTR(transitioning, ALUA_T_SUP); |
2698 | tg_pt_gp_alua_supported_states, ALUA_T_SUP); | 2454 | ALUA_SUPPORTED_STATE_ATTR(offline, ALUA_O_SUP); |
2699 | SE_DEV_ALUA_SUPPORT_STATE_STORE(transitioning, | 2455 | ALUA_SUPPORTED_STATE_ATTR(lba_dependent, ALUA_LBD_SUP); |
2700 | tg_pt_gp_alua_supported_states, ALUA_T_SUP); | 2456 | ALUA_SUPPORTED_STATE_ATTR(unavailable, ALUA_U_SUP); |
2701 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_transitioning, S_IRUGO | S_IWUSR); | 2457 | ALUA_SUPPORTED_STATE_ATTR(standby, ALUA_S_SUP); |
2702 | 2458 | ALUA_SUPPORTED_STATE_ATTR(active_optimized, ALUA_AO_SUP); | |
2703 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(offline, | 2459 | ALUA_SUPPORTED_STATE_ATTR(active_nonoptimized, ALUA_AN_SUP); |
2704 | tg_pt_gp_alua_supported_states, ALUA_O_SUP); | ||
2705 | SE_DEV_ALUA_SUPPORT_STATE_STORE(offline, | ||
2706 | tg_pt_gp_alua_supported_states, ALUA_O_SUP); | ||
2707 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_offline, S_IRUGO | S_IWUSR); | ||
2708 | |||
2709 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(lba_dependent, | ||
2710 | tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); | ||
2711 | SE_DEV_ALUA_SUPPORT_STATE_STORE(lba_dependent, | ||
2712 | tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); | ||
2713 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_lba_dependent, S_IRUGO); | ||
2714 | |||
2715 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(unavailable, | ||
2716 | tg_pt_gp_alua_supported_states, ALUA_U_SUP); | ||
2717 | SE_DEV_ALUA_SUPPORT_STATE_STORE(unavailable, | ||
2718 | tg_pt_gp_alua_supported_states, ALUA_U_SUP); | ||
2719 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_unavailable, S_IRUGO | S_IWUSR); | ||
2720 | |||
2721 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(standby, | ||
2722 | tg_pt_gp_alua_supported_states, ALUA_S_SUP); | ||
2723 | SE_DEV_ALUA_SUPPORT_STATE_STORE(standby, | ||
2724 | tg_pt_gp_alua_supported_states, ALUA_S_SUP); | ||
2725 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_standby, S_IRUGO | S_IWUSR); | ||
2726 | |||
2727 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_optimized, | ||
2728 | tg_pt_gp_alua_supported_states, ALUA_AO_SUP); | ||
2729 | SE_DEV_ALUA_SUPPORT_STATE_STORE(active_optimized, | ||
2730 | tg_pt_gp_alua_supported_states, ALUA_AO_SUP); | ||
2731 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_optimized, S_IRUGO | S_IWUSR); | ||
2732 | |||
2733 | SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_nonoptimized, | ||
2734 | tg_pt_gp_alua_supported_states, ALUA_AN_SUP); | ||
2735 | SE_DEV_ALUA_SUPPORT_STATE_STORE(active_nonoptimized, | ||
2736 | tg_pt_gp_alua_supported_states, ALUA_AN_SUP); | ||
2737 | SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_nonoptimized, S_IRUGO | S_IWUSR); | ||
2738 | 2460 | ||
2739 | /* | 2461 | static ssize_t target_tg_pt_gp_alua_write_metadata_show( |
2740 | * alua_write_metadata | 2462 | struct config_item *item, char *page) |
2741 | */ | ||
2742 | static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_write_metadata( | ||
2743 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2744 | char *page) | ||
2745 | { | 2463 | { |
2746 | return sprintf(page, "%d\n", tg_pt_gp->tg_pt_gp_write_metadata); | 2464 | return sprintf(page, "%d\n", |
2465 | to_tg_pt_gp(item)->tg_pt_gp_write_metadata); | ||
2747 | } | 2466 | } |
2748 | 2467 | ||
2749 | static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata( | 2468 | static ssize_t target_tg_pt_gp_alua_write_metadata_store( |
2750 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2469 | struct config_item *item, const char *page, size_t count) |
2751 | const char *page, | ||
2752 | size_t count) | ||
2753 | { | 2470 | { |
2471 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2754 | unsigned long tmp; | 2472 | unsigned long tmp; |
2755 | int ret; | 2473 | int ret; |
2756 | 2474 | ||
@@ -2770,110 +2488,71 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata( | |||
2770 | return count; | 2488 | return count; |
2771 | } | 2489 | } |
2772 | 2490 | ||
2773 | SE_DEV_ALUA_TG_PT_ATTR(alua_write_metadata, S_IRUGO | S_IWUSR); | 2491 | static ssize_t target_tg_pt_gp_nonop_delay_msecs_show(struct config_item *item, |
2774 | 2492 | char *page) | |
2775 | |||
2776 | |||
2777 | /* | ||
2778 | * nonop_delay_msecs | ||
2779 | */ | ||
2780 | static ssize_t target_core_alua_tg_pt_gp_show_attr_nonop_delay_msecs( | ||
2781 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2782 | char *page) | ||
2783 | { | 2493 | { |
2784 | return core_alua_show_nonop_delay_msecs(tg_pt_gp, page); | 2494 | return core_alua_show_nonop_delay_msecs(to_tg_pt_gp(item), page); |
2785 | |||
2786 | } | 2495 | } |
2787 | 2496 | ||
2788 | static ssize_t target_core_alua_tg_pt_gp_store_attr_nonop_delay_msecs( | 2497 | static ssize_t target_tg_pt_gp_nonop_delay_msecs_store(struct config_item *item, |
2789 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2498 | const char *page, size_t count) |
2790 | const char *page, | ||
2791 | size_t count) | ||
2792 | { | 2499 | { |
2793 | return core_alua_store_nonop_delay_msecs(tg_pt_gp, page, count); | 2500 | return core_alua_store_nonop_delay_msecs(to_tg_pt_gp(item), page, |
2501 | count); | ||
2794 | } | 2502 | } |
2795 | 2503 | ||
2796 | SE_DEV_ALUA_TG_PT_ATTR(nonop_delay_msecs, S_IRUGO | S_IWUSR); | 2504 | static ssize_t target_tg_pt_gp_trans_delay_msecs_show(struct config_item *item, |
2797 | 2505 | char *page) | |
2798 | /* | ||
2799 | * trans_delay_msecs | ||
2800 | */ | ||
2801 | static ssize_t target_core_alua_tg_pt_gp_show_attr_trans_delay_msecs( | ||
2802 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2803 | char *page) | ||
2804 | { | 2506 | { |
2805 | return core_alua_show_trans_delay_msecs(tg_pt_gp, page); | 2507 | return core_alua_show_trans_delay_msecs(to_tg_pt_gp(item), page); |
2806 | } | 2508 | } |
2807 | 2509 | ||
2808 | static ssize_t target_core_alua_tg_pt_gp_store_attr_trans_delay_msecs( | 2510 | static ssize_t target_tg_pt_gp_trans_delay_msecs_store(struct config_item *item, |
2809 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2511 | const char *page, size_t count) |
2810 | const char *page, | ||
2811 | size_t count) | ||
2812 | { | 2512 | { |
2813 | return core_alua_store_trans_delay_msecs(tg_pt_gp, page, count); | 2513 | return core_alua_store_trans_delay_msecs(to_tg_pt_gp(item), page, |
2514 | count); | ||
2814 | } | 2515 | } |
2815 | 2516 | ||
2816 | SE_DEV_ALUA_TG_PT_ATTR(trans_delay_msecs, S_IRUGO | S_IWUSR); | 2517 | static ssize_t target_tg_pt_gp_implicit_trans_secs_show( |
2817 | 2518 | struct config_item *item, char *page) | |
2818 | /* | ||
2819 | * implicit_trans_secs | ||
2820 | */ | ||
2821 | static ssize_t target_core_alua_tg_pt_gp_show_attr_implicit_trans_secs( | ||
2822 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2823 | char *page) | ||
2824 | { | 2519 | { |
2825 | return core_alua_show_implicit_trans_secs(tg_pt_gp, page); | 2520 | return core_alua_show_implicit_trans_secs(to_tg_pt_gp(item), page); |
2826 | } | 2521 | } |
2827 | 2522 | ||
2828 | static ssize_t target_core_alua_tg_pt_gp_store_attr_implicit_trans_secs( | 2523 | static ssize_t target_tg_pt_gp_implicit_trans_secs_store( |
2829 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2524 | struct config_item *item, const char *page, size_t count) |
2830 | const char *page, | ||
2831 | size_t count) | ||
2832 | { | 2525 | { |
2833 | return core_alua_store_implicit_trans_secs(tg_pt_gp, page, count); | 2526 | return core_alua_store_implicit_trans_secs(to_tg_pt_gp(item), page, |
2527 | count); | ||
2834 | } | 2528 | } |
2835 | 2529 | ||
2836 | SE_DEV_ALUA_TG_PT_ATTR(implicit_trans_secs, S_IRUGO | S_IWUSR); | 2530 | static ssize_t target_tg_pt_gp_preferred_show(struct config_item *item, |
2837 | 2531 | char *page) | |
2838 | /* | ||
2839 | * preferred | ||
2840 | */ | ||
2841 | |||
2842 | static ssize_t target_core_alua_tg_pt_gp_show_attr_preferred( | ||
2843 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2844 | char *page) | ||
2845 | { | 2532 | { |
2846 | return core_alua_show_preferred_bit(tg_pt_gp, page); | 2533 | return core_alua_show_preferred_bit(to_tg_pt_gp(item), page); |
2847 | } | 2534 | } |
2848 | 2535 | ||
2849 | static ssize_t target_core_alua_tg_pt_gp_store_attr_preferred( | 2536 | static ssize_t target_tg_pt_gp_preferred_store(struct config_item *item, |
2850 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2537 | const char *page, size_t count) |
2851 | const char *page, | ||
2852 | size_t count) | ||
2853 | { | 2538 | { |
2854 | return core_alua_store_preferred_bit(tg_pt_gp, page, count); | 2539 | return core_alua_store_preferred_bit(to_tg_pt_gp(item), page, count); |
2855 | } | 2540 | } |
2856 | 2541 | ||
2857 | SE_DEV_ALUA_TG_PT_ATTR(preferred, S_IRUGO | S_IWUSR); | 2542 | static ssize_t target_tg_pt_gp_tg_pt_gp_id_show(struct config_item *item, |
2858 | 2543 | char *page) | |
2859 | /* | ||
2860 | * tg_pt_gp_id | ||
2861 | */ | ||
2862 | static ssize_t target_core_alua_tg_pt_gp_show_attr_tg_pt_gp_id( | ||
2863 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2864 | char *page) | ||
2865 | { | 2544 | { |
2545 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2546 | |||
2866 | if (!tg_pt_gp->tg_pt_gp_valid_id) | 2547 | if (!tg_pt_gp->tg_pt_gp_valid_id) |
2867 | return 0; | 2548 | return 0; |
2868 | |||
2869 | return sprintf(page, "%hu\n", tg_pt_gp->tg_pt_gp_id); | 2549 | return sprintf(page, "%hu\n", tg_pt_gp->tg_pt_gp_id); |
2870 | } | 2550 | } |
2871 | 2551 | ||
2872 | static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id( | 2552 | static ssize_t target_tg_pt_gp_tg_pt_gp_id_store(struct config_item *item, |
2873 | struct t10_alua_tg_pt_gp *tg_pt_gp, | 2553 | const char *page, size_t count) |
2874 | const char *page, | ||
2875 | size_t count) | ||
2876 | { | 2554 | { |
2555 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2877 | struct config_group *alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group; | 2556 | struct config_group *alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group; |
2878 | unsigned long tg_pt_gp_id; | 2557 | unsigned long tg_pt_gp_id; |
2879 | int ret; | 2558 | int ret; |
@@ -2902,15 +2581,10 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id( | |||
2902 | return count; | 2581 | return count; |
2903 | } | 2582 | } |
2904 | 2583 | ||
2905 | SE_DEV_ALUA_TG_PT_ATTR(tg_pt_gp_id, S_IRUGO | S_IWUSR); | 2584 | static ssize_t target_tg_pt_gp_members_show(struct config_item *item, |
2906 | 2585 | char *page) | |
2907 | /* | ||
2908 | * members | ||
2909 | */ | ||
2910 | static ssize_t target_core_alua_tg_pt_gp_show_attr_members( | ||
2911 | struct t10_alua_tg_pt_gp *tg_pt_gp, | ||
2912 | char *page) | ||
2913 | { | 2586 | { |
2587 | struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); | ||
2914 | struct se_lun *lun; | 2588 | struct se_lun *lun; |
2915 | ssize_t len = 0, cur_len; | 2589 | ssize_t len = 0, cur_len; |
2916 | unsigned char buf[TG_PT_GROUP_NAME_BUF]; | 2590 | unsigned char buf[TG_PT_GROUP_NAME_BUF]; |
@@ -2942,29 +2616,42 @@ static ssize_t target_core_alua_tg_pt_gp_show_attr_members( | |||
2942 | return len; | 2616 | return len; |
2943 | } | 2617 | } |
2944 | 2618 | ||
2945 | SE_DEV_ALUA_TG_PT_ATTR_RO(members); | 2619 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_state); |
2946 | 2620 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_status); | |
2947 | CONFIGFS_EATTR_OPS(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp, | 2621 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_type); |
2948 | tg_pt_gp_group); | 2622 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_transitioning); |
2623 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_offline); | ||
2624 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_lba_dependent); | ||
2625 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_unavailable); | ||
2626 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_standby); | ||
2627 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_active_optimized); | ||
2628 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_active_nonoptimized); | ||
2629 | CONFIGFS_ATTR(target_tg_pt_gp_, alua_write_metadata); | ||
2630 | CONFIGFS_ATTR(target_tg_pt_gp_, nonop_delay_msecs); | ||
2631 | CONFIGFS_ATTR(target_tg_pt_gp_, trans_delay_msecs); | ||
2632 | CONFIGFS_ATTR(target_tg_pt_gp_, implicit_trans_secs); | ||
2633 | CONFIGFS_ATTR(target_tg_pt_gp_, preferred); | ||
2634 | CONFIGFS_ATTR(target_tg_pt_gp_, tg_pt_gp_id); | ||
2635 | CONFIGFS_ATTR_RO(target_tg_pt_gp_, members); | ||
2949 | 2636 | ||
2950 | static struct configfs_attribute *target_core_alua_tg_pt_gp_attrs[] = { | 2637 | static struct configfs_attribute *target_core_alua_tg_pt_gp_attrs[] = { |
2951 | &target_core_alua_tg_pt_gp_alua_access_state.attr, | 2638 | &target_tg_pt_gp_attr_alua_access_state, |
2952 | &target_core_alua_tg_pt_gp_alua_access_status.attr, | 2639 | &target_tg_pt_gp_attr_alua_access_status, |
2953 | &target_core_alua_tg_pt_gp_alua_access_type.attr, | 2640 | &target_tg_pt_gp_attr_alua_access_type, |
2954 | &target_core_alua_tg_pt_gp_alua_support_transitioning.attr, | 2641 | &target_tg_pt_gp_attr_alua_support_transitioning, |
2955 | &target_core_alua_tg_pt_gp_alua_support_offline.attr, | 2642 | &target_tg_pt_gp_attr_alua_support_offline, |
2956 | &target_core_alua_tg_pt_gp_alua_support_lba_dependent.attr, | 2643 | &target_tg_pt_gp_attr_alua_support_lba_dependent, |
2957 | &target_core_alua_tg_pt_gp_alua_support_unavailable.attr, | 2644 | &target_tg_pt_gp_attr_alua_support_unavailable, |
2958 | &target_core_alua_tg_pt_gp_alua_support_standby.attr, | 2645 | &target_tg_pt_gp_attr_alua_support_standby, |
2959 | &target_core_alua_tg_pt_gp_alua_support_active_nonoptimized.attr, | 2646 | &target_tg_pt_gp_attr_alua_support_active_nonoptimized, |
2960 | &target_core_alua_tg_pt_gp_alua_support_active_optimized.attr, | 2647 | &target_tg_pt_gp_attr_alua_support_active_optimized, |
2961 | &target_core_alua_tg_pt_gp_alua_write_metadata.attr, | 2648 | &target_tg_pt_gp_attr_alua_write_metadata, |
2962 | &target_core_alua_tg_pt_gp_nonop_delay_msecs.attr, | 2649 | &target_tg_pt_gp_attr_nonop_delay_msecs, |
2963 | &target_core_alua_tg_pt_gp_trans_delay_msecs.attr, | 2650 | &target_tg_pt_gp_attr_trans_delay_msecs, |
2964 | &target_core_alua_tg_pt_gp_implicit_trans_secs.attr, | 2651 | &target_tg_pt_gp_attr_implicit_trans_secs, |
2965 | &target_core_alua_tg_pt_gp_preferred.attr, | 2652 | &target_tg_pt_gp_attr_preferred, |
2966 | &target_core_alua_tg_pt_gp_tg_pt_gp_id.attr, | 2653 | &target_tg_pt_gp_attr_tg_pt_gp_id, |
2967 | &target_core_alua_tg_pt_gp_members.attr, | 2654 | &target_tg_pt_gp_attr_members, |
2968 | NULL, | 2655 | NULL, |
2969 | }; | 2656 | }; |
2970 | 2657 | ||
@@ -2978,8 +2665,6 @@ static void target_core_alua_tg_pt_gp_release(struct config_item *item) | |||
2978 | 2665 | ||
2979 | static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { | 2666 | static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { |
2980 | .release = target_core_alua_tg_pt_gp_release, | 2667 | .release = target_core_alua_tg_pt_gp_release, |
2981 | .show_attribute = target_core_alua_tg_pt_gp_attr_show, | ||
2982 | .store_attribute = target_core_alua_tg_pt_gp_attr_store, | ||
2983 | }; | 2668 | }; |
2984 | 2669 | ||
2985 | static struct config_item_type target_core_alua_tg_pt_gp_cit = { | 2670 | static struct config_item_type target_core_alua_tg_pt_gp_cit = { |
@@ -3237,34 +2922,24 @@ static struct configfs_group_operations target_core_hba_group_ops = { | |||
3237 | .drop_item = target_core_drop_subdev, | 2922 | .drop_item = target_core_drop_subdev, |
3238 | }; | 2923 | }; |
3239 | 2924 | ||
3240 | CONFIGFS_EATTR_STRUCT(target_core_hba, se_hba); | ||
3241 | #define SE_HBA_ATTR(_name, _mode) \ | ||
3242 | static struct target_core_hba_attribute \ | ||
3243 | target_core_hba_##_name = \ | ||
3244 | __CONFIGFS_EATTR(_name, _mode, \ | ||
3245 | target_core_hba_show_attr_##_name, \ | ||
3246 | target_core_hba_store_attr_##_name); | ||
3247 | 2925 | ||
3248 | #define SE_HBA_ATTR_RO(_name) \ | 2926 | static inline struct se_hba *to_hba(struct config_item *item) |
3249 | static struct target_core_hba_attribute \ | 2927 | { |
3250 | target_core_hba_##_name = \ | 2928 | return container_of(to_config_group(item), struct se_hba, hba_group); |
3251 | __CONFIGFS_EATTR_RO(_name, \ | 2929 | } |
3252 | target_core_hba_show_attr_##_name); | ||
3253 | 2930 | ||
3254 | static ssize_t target_core_hba_show_attr_hba_info( | 2931 | static ssize_t target_hba_info_show(struct config_item *item, char *page) |
3255 | struct se_hba *hba, | ||
3256 | char *page) | ||
3257 | { | 2932 | { |
2933 | struct se_hba *hba = to_hba(item); | ||
2934 | |||
3258 | return sprintf(page, "HBA Index: %d plugin: %s version: %s\n", | 2935 | return sprintf(page, "HBA Index: %d plugin: %s version: %s\n", |
3259 | hba->hba_id, hba->backend->ops->name, | 2936 | hba->hba_id, hba->backend->ops->name, |
3260 | TARGET_CORE_VERSION); | 2937 | TARGET_CORE_VERSION); |
3261 | } | 2938 | } |
3262 | 2939 | ||
3263 | SE_HBA_ATTR_RO(hba_info); | 2940 | static ssize_t target_hba_mode_show(struct config_item *item, char *page) |
3264 | |||
3265 | static ssize_t target_core_hba_show_attr_hba_mode(struct se_hba *hba, | ||
3266 | char *page) | ||
3267 | { | 2941 | { |
2942 | struct se_hba *hba = to_hba(item); | ||
3268 | int hba_mode = 0; | 2943 | int hba_mode = 0; |
3269 | 2944 | ||
3270 | if (hba->hba_flags & HBA_FLAGS_PSCSI_MODE) | 2945 | if (hba->hba_flags & HBA_FLAGS_PSCSI_MODE) |
@@ -3273,9 +2948,10 @@ static ssize_t target_core_hba_show_attr_hba_mode(struct se_hba *hba, | |||
3273 | return sprintf(page, "%d\n", hba_mode); | 2948 | return sprintf(page, "%d\n", hba_mode); |
3274 | } | 2949 | } |
3275 | 2950 | ||
3276 | static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba, | 2951 | static ssize_t target_hba_mode_store(struct config_item *item, |
3277 | const char *page, size_t count) | 2952 | const char *page, size_t count) |
3278 | { | 2953 | { |
2954 | struct se_hba *hba = to_hba(item); | ||
3279 | unsigned long mode_flag; | 2955 | unsigned long mode_flag; |
3280 | int ret; | 2956 | int ret; |
3281 | 2957 | ||
@@ -3304,9 +2980,8 @@ static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba, | |||
3304 | return count; | 2980 | return count; |
3305 | } | 2981 | } |
3306 | 2982 | ||
3307 | SE_HBA_ATTR(hba_mode, S_IRUGO | S_IWUSR); | 2983 | CONFIGFS_ATTR_RO(target_, hba_info); |
3308 | 2984 | CONFIGFS_ATTR(target_, hba_mode); | |
3309 | CONFIGFS_EATTR_OPS(target_core_hba, se_hba, hba_group); | ||
3310 | 2985 | ||
3311 | static void target_core_hba_release(struct config_item *item) | 2986 | static void target_core_hba_release(struct config_item *item) |
3312 | { | 2987 | { |
@@ -3316,15 +2991,13 @@ static void target_core_hba_release(struct config_item *item) | |||
3316 | } | 2991 | } |
3317 | 2992 | ||
3318 | static struct configfs_attribute *target_core_hba_attrs[] = { | 2993 | static struct configfs_attribute *target_core_hba_attrs[] = { |
3319 | &target_core_hba_hba_info.attr, | 2994 | &target_attr_hba_info, |
3320 | &target_core_hba_hba_mode.attr, | 2995 | &target_attr_hba_mode, |
3321 | NULL, | 2996 | NULL, |
3322 | }; | 2997 | }; |
3323 | 2998 | ||
3324 | static struct configfs_item_operations target_core_hba_item_ops = { | 2999 | static struct configfs_item_operations target_core_hba_item_ops = { |
3325 | .release = target_core_hba_release, | 3000 | .release = target_core_hba_release, |
3326 | .show_attribute = target_core_hba_attr_show, | ||
3327 | .store_attribute = target_core_hba_attr_store, | ||
3328 | }; | 3001 | }; |
3329 | 3002 | ||
3330 | static struct config_item_type target_core_hba_cit = { | 3003 | static struct config_item_type target_core_hba_cit = { |
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c index be42429468e2..f916d18ccb48 100644 --- a/drivers/target/target_core_fabric_configfs.c +++ b/drivers/target/target_core_fabric_configfs.c | |||
@@ -35,8 +35,6 @@ | |||
35 | 35 | ||
36 | #include <target/target_core_base.h> | 36 | #include <target/target_core_base.h> |
37 | #include <target/target_core_fabric.h> | 37 | #include <target/target_core_fabric.h> |
38 | #include <target/target_core_fabric_configfs.h> | ||
39 | #include <target/configfs_macros.h> | ||
40 | 38 | ||
41 | #include "target_core_internal.h" | 39 | #include "target_core_internal.h" |
42 | #include "target_core_alua.h" | 40 | #include "target_core_alua.h" |
@@ -152,17 +150,16 @@ static int target_fabric_mappedlun_unlink( | |||
152 | return core_dev_del_initiator_node_lun_acl(lun, lacl); | 150 | return core_dev_del_initiator_node_lun_acl(lun, lacl); |
153 | } | 151 | } |
154 | 152 | ||
155 | CONFIGFS_EATTR_STRUCT(target_fabric_mappedlun, se_lun_acl); | 153 | static struct se_lun_acl *item_to_lun_acl(struct config_item *item) |
156 | #define TCM_MAPPEDLUN_ATTR(_name, _mode) \ | 154 | { |
157 | static struct target_fabric_mappedlun_attribute target_fabric_mappedlun_##_name = \ | 155 | return container_of(to_config_group(item), struct se_lun_acl, |
158 | __CONFIGFS_EATTR(_name, _mode, \ | 156 | se_lun_group); |
159 | target_fabric_mappedlun_show_##_name, \ | 157 | } |
160 | target_fabric_mappedlun_store_##_name); | ||
161 | 158 | ||
162 | static ssize_t target_fabric_mappedlun_show_write_protect( | 159 | static ssize_t target_fabric_mappedlun_write_protect_show( |
163 | struct se_lun_acl *lacl, | 160 | struct config_item *item, char *page) |
164 | char *page) | ||
165 | { | 161 | { |
162 | struct se_lun_acl *lacl = item_to_lun_acl(item); | ||
166 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; | 163 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; |
167 | struct se_dev_entry *deve; | 164 | struct se_dev_entry *deve; |
168 | ssize_t len = 0; | 165 | ssize_t len = 0; |
@@ -178,11 +175,10 @@ static ssize_t target_fabric_mappedlun_show_write_protect( | |||
178 | return len; | 175 | return len; |
179 | } | 176 | } |
180 | 177 | ||
181 | static ssize_t target_fabric_mappedlun_store_write_protect( | 178 | static ssize_t target_fabric_mappedlun_write_protect_store( |
182 | struct se_lun_acl *lacl, | 179 | struct config_item *item, const char *page, size_t count) |
183 | const char *page, | ||
184 | size_t count) | ||
185 | { | 180 | { |
181 | struct se_lun_acl *lacl = item_to_lun_acl(item); | ||
186 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; | 182 | struct se_node_acl *se_nacl = lacl->se_lun_nacl; |
187 | struct se_portal_group *se_tpg = se_nacl->se_tpg; | 183 | struct se_portal_group *se_tpg = se_nacl->se_tpg; |
188 | unsigned long op; | 184 | unsigned long op; |
@@ -209,9 +205,12 @@ static ssize_t target_fabric_mappedlun_store_write_protect( | |||
209 | 205 | ||
210 | } | 206 | } |
211 | 207 | ||
212 | TCM_MAPPEDLUN_ATTR(write_protect, S_IRUGO | S_IWUSR); | 208 | CONFIGFS_ATTR(target_fabric_mappedlun_, write_protect); |
213 | 209 | ||
214 | CONFIGFS_EATTR_OPS(target_fabric_mappedlun, se_lun_acl, se_lun_group); | 210 | static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { |
211 | &target_fabric_mappedlun_attr_write_protect, | ||
212 | NULL, | ||
213 | }; | ||
215 | 214 | ||
216 | static void target_fabric_mappedlun_release(struct config_item *item) | 215 | static void target_fabric_mappedlun_release(struct config_item *item) |
217 | { | 216 | { |
@@ -222,15 +221,8 @@ static void target_fabric_mappedlun_release(struct config_item *item) | |||
222 | core_dev_free_initiator_node_lun_acl(se_tpg, lacl); | 221 | core_dev_free_initiator_node_lun_acl(se_tpg, lacl); |
223 | } | 222 | } |
224 | 223 | ||
225 | static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { | ||
226 | &target_fabric_mappedlun_write_protect.attr, | ||
227 | NULL, | ||
228 | }; | ||
229 | |||
230 | static struct configfs_item_operations target_fabric_mappedlun_item_ops = { | 224 | static struct configfs_item_operations target_fabric_mappedlun_item_ops = { |
231 | .release = target_fabric_mappedlun_release, | 225 | .release = target_fabric_mappedlun_release, |
232 | .show_attribute = target_fabric_mappedlun_attr_show, | ||
233 | .store_attribute = target_fabric_mappedlun_attr_store, | ||
234 | .allow_link = target_fabric_mappedlun_link, | 226 | .allow_link = target_fabric_mappedlun_link, |
235 | .drop_link = target_fabric_mappedlun_unlink, | 227 | .drop_link = target_fabric_mappedlun_unlink, |
236 | }; | 228 | }; |
@@ -266,49 +258,12 @@ TF_CIT_SETUP(tpg_mappedlun_stat, NULL, &target_fabric_mappedlun_stat_group_ops, | |||
266 | 258 | ||
267 | /* End of tfc_tpg_mappedlun_port_cit */ | 259 | /* End of tfc_tpg_mappedlun_port_cit */ |
268 | 260 | ||
269 | /* Start of tfc_tpg_nacl_attrib_cit */ | 261 | TF_CIT_SETUP_DRV(tpg_nacl_attrib, NULL, NULL); |
270 | 262 | TF_CIT_SETUP_DRV(tpg_nacl_auth, NULL, NULL); | |
271 | CONFIGFS_EATTR_OPS(target_fabric_nacl_attrib, se_node_acl, acl_attrib_group); | 263 | TF_CIT_SETUP_DRV(tpg_nacl_param, NULL, NULL); |
272 | |||
273 | static struct configfs_item_operations target_fabric_nacl_attrib_item_ops = { | ||
274 | .show_attribute = target_fabric_nacl_attrib_attr_show, | ||
275 | .store_attribute = target_fabric_nacl_attrib_attr_store, | ||
276 | }; | ||
277 | |||
278 | TF_CIT_SETUP_DRV(tpg_nacl_attrib, &target_fabric_nacl_attrib_item_ops, NULL); | ||
279 | |||
280 | /* End of tfc_tpg_nacl_attrib_cit */ | ||
281 | |||
282 | /* Start of tfc_tpg_nacl_auth_cit */ | ||
283 | |||
284 | CONFIGFS_EATTR_OPS(target_fabric_nacl_auth, se_node_acl, acl_auth_group); | ||
285 | |||
286 | static struct configfs_item_operations target_fabric_nacl_auth_item_ops = { | ||
287 | .show_attribute = target_fabric_nacl_auth_attr_show, | ||
288 | .store_attribute = target_fabric_nacl_auth_attr_store, | ||
289 | }; | ||
290 | |||
291 | TF_CIT_SETUP_DRV(tpg_nacl_auth, &target_fabric_nacl_auth_item_ops, NULL); | ||
292 | |||
293 | /* End of tfc_tpg_nacl_auth_cit */ | ||
294 | |||
295 | /* Start of tfc_tpg_nacl_param_cit */ | ||
296 | |||
297 | CONFIGFS_EATTR_OPS(target_fabric_nacl_param, se_node_acl, acl_param_group); | ||
298 | |||
299 | static struct configfs_item_operations target_fabric_nacl_param_item_ops = { | ||
300 | .show_attribute = target_fabric_nacl_param_attr_show, | ||
301 | .store_attribute = target_fabric_nacl_param_attr_store, | ||
302 | }; | ||
303 | |||
304 | TF_CIT_SETUP_DRV(tpg_nacl_param, &target_fabric_nacl_param_item_ops, NULL); | ||
305 | |||
306 | /* End of tfc_tpg_nacl_param_cit */ | ||
307 | 264 | ||
308 | /* Start of tfc_tpg_nacl_base_cit */ | 265 | /* Start of tfc_tpg_nacl_base_cit */ |
309 | 266 | ||
310 | CONFIGFS_EATTR_OPS(target_fabric_nacl_base, se_node_acl, acl_group); | ||
311 | |||
312 | static struct config_group *target_fabric_make_mappedlun( | 267 | static struct config_group *target_fabric_make_mappedlun( |
313 | struct config_group *group, | 268 | struct config_group *group, |
314 | const char *name) | 269 | const char *name) |
@@ -438,8 +393,6 @@ static void target_fabric_nacl_base_release(struct config_item *item) | |||
438 | 393 | ||
439 | static struct configfs_item_operations target_fabric_nacl_base_item_ops = { | 394 | static struct configfs_item_operations target_fabric_nacl_base_item_ops = { |
440 | .release = target_fabric_nacl_base_release, | 395 | .release = target_fabric_nacl_base_release, |
441 | .show_attribute = target_fabric_nacl_base_attr_show, | ||
442 | .store_attribute = target_fabric_nacl_base_attr_store, | ||
443 | }; | 396 | }; |
444 | 397 | ||
445 | static struct configfs_group_operations target_fabric_nacl_base_group_ops = { | 398 | static struct configfs_group_operations target_fabric_nacl_base_group_ops = { |
@@ -540,8 +493,6 @@ TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL); | |||
540 | 493 | ||
541 | /* Start of tfc_tpg_np_base_cit */ | 494 | /* Start of tfc_tpg_np_base_cit */ |
542 | 495 | ||
543 | CONFIGFS_EATTR_OPS(target_fabric_np_base, se_tpg_np, tpg_np_group); | ||
544 | |||
545 | static void target_fabric_np_base_release(struct config_item *item) | 496 | static void target_fabric_np_base_release(struct config_item *item) |
546 | { | 497 | { |
547 | struct se_tpg_np *se_tpg_np = container_of(to_config_group(item), | 498 | struct se_tpg_np *se_tpg_np = container_of(to_config_group(item), |
@@ -554,8 +505,6 @@ static void target_fabric_np_base_release(struct config_item *item) | |||
554 | 505 | ||
555 | static struct configfs_item_operations target_fabric_np_base_item_ops = { | 506 | static struct configfs_item_operations target_fabric_np_base_item_ops = { |
556 | .release = target_fabric_np_base_release, | 507 | .release = target_fabric_np_base_release, |
557 | .show_attribute = target_fabric_np_base_attr_show, | ||
558 | .store_attribute = target_fabric_np_base_attr_store, | ||
559 | }; | 508 | }; |
560 | 509 | ||
561 | TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL); | 510 | TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL); |
@@ -610,132 +559,113 @@ TF_CIT_SETUP(tpg_np, NULL, &target_fabric_np_group_ops, NULL); | |||
610 | 559 | ||
611 | /* Start of tfc_tpg_port_cit */ | 560 | /* Start of tfc_tpg_port_cit */ |
612 | 561 | ||
613 | CONFIGFS_EATTR_STRUCT(target_fabric_port, se_lun); | 562 | static struct se_lun *item_to_lun(struct config_item *item) |
614 | #define TCM_PORT_ATTR(_name, _mode) \ | 563 | { |
615 | static struct target_fabric_port_attribute target_fabric_port_##_name = \ | 564 | return container_of(to_config_group(item), struct se_lun, |
616 | __CONFIGFS_EATTR(_name, _mode, \ | 565 | lun_group); |
617 | target_fabric_port_show_attr_##_name, \ | 566 | } |
618 | target_fabric_port_store_attr_##_name); | ||
619 | |||
620 | #define TCM_PORT_ATTOR_RO(_name) \ | ||
621 | __CONFIGFS_EATTR_RO(_name, \ | ||
622 | target_fabric_port_show_attr_##_name); | ||
623 | 567 | ||
624 | /* | 568 | static ssize_t target_fabric_port_alua_tg_pt_gp_show(struct config_item *item, |
625 | * alua_tg_pt_gp | 569 | char *page) |
626 | */ | ||
627 | static ssize_t target_fabric_port_show_attr_alua_tg_pt_gp( | ||
628 | struct se_lun *lun, | ||
629 | char *page) | ||
630 | { | 570 | { |
571 | struct se_lun *lun = item_to_lun(item); | ||
572 | |||
631 | if (!lun || !lun->lun_se_dev) | 573 | if (!lun || !lun->lun_se_dev) |
632 | return -ENODEV; | 574 | return -ENODEV; |
633 | 575 | ||
634 | return core_alua_show_tg_pt_gp_info(lun, page); | 576 | return core_alua_show_tg_pt_gp_info(lun, page); |
635 | } | 577 | } |
636 | 578 | ||
637 | static ssize_t target_fabric_port_store_attr_alua_tg_pt_gp( | 579 | static ssize_t target_fabric_port_alua_tg_pt_gp_store(struct config_item *item, |
638 | struct se_lun *lun, | 580 | const char *page, size_t count) |
639 | const char *page, | ||
640 | size_t count) | ||
641 | { | 581 | { |
582 | struct se_lun *lun = item_to_lun(item); | ||
583 | |||
642 | if (!lun || !lun->lun_se_dev) | 584 | if (!lun || !lun->lun_se_dev) |
643 | return -ENODEV; | 585 | return -ENODEV; |
644 | 586 | ||
645 | return core_alua_store_tg_pt_gp_info(lun, page, count); | 587 | return core_alua_store_tg_pt_gp_info(lun, page, count); |
646 | } | 588 | } |
647 | 589 | ||
648 | TCM_PORT_ATTR(alua_tg_pt_gp, S_IRUGO | S_IWUSR); | 590 | static ssize_t target_fabric_port_alua_tg_pt_offline_show( |
649 | 591 | struct config_item *item, char *page) | |
650 | /* | ||
651 | * alua_tg_pt_offline | ||
652 | */ | ||
653 | static ssize_t target_fabric_port_show_attr_alua_tg_pt_offline( | ||
654 | struct se_lun *lun, | ||
655 | char *page) | ||
656 | { | 592 | { |
593 | struct se_lun *lun = item_to_lun(item); | ||
594 | |||
657 | if (!lun || !lun->lun_se_dev) | 595 | if (!lun || !lun->lun_se_dev) |
658 | return -ENODEV; | 596 | return -ENODEV; |
659 | 597 | ||
660 | return core_alua_show_offline_bit(lun, page); | 598 | return core_alua_show_offline_bit(lun, page); |
661 | } | 599 | } |
662 | 600 | ||
663 | static ssize_t target_fabric_port_store_attr_alua_tg_pt_offline( | 601 | static ssize_t target_fabric_port_alua_tg_pt_offline_store( |
664 | struct se_lun *lun, | 602 | struct config_item *item, const char *page, size_t count) |
665 | const char *page, | ||
666 | size_t count) | ||
667 | { | 603 | { |
604 | struct se_lun *lun = item_to_lun(item); | ||
605 | |||
668 | if (!lun || !lun->lun_se_dev) | 606 | if (!lun || !lun->lun_se_dev) |
669 | return -ENODEV; | 607 | return -ENODEV; |
670 | 608 | ||
671 | return core_alua_store_offline_bit(lun, page, count); | 609 | return core_alua_store_offline_bit(lun, page, count); |
672 | } | 610 | } |
673 | 611 | ||
674 | TCM_PORT_ATTR(alua_tg_pt_offline, S_IRUGO | S_IWUSR); | 612 | static ssize_t target_fabric_port_alua_tg_pt_status_show( |
675 | 613 | struct config_item *item, char *page) | |
676 | /* | ||
677 | * alua_tg_pt_status | ||
678 | */ | ||
679 | static ssize_t target_fabric_port_show_attr_alua_tg_pt_status( | ||
680 | struct se_lun *lun, | ||
681 | char *page) | ||
682 | { | 614 | { |
615 | struct se_lun *lun = item_to_lun(item); | ||
616 | |||
683 | if (!lun || !lun->lun_se_dev) | 617 | if (!lun || !lun->lun_se_dev) |
684 | return -ENODEV; | 618 | return -ENODEV; |
685 | 619 | ||
686 | return core_alua_show_secondary_status(lun, page); | 620 | return core_alua_show_secondary_status(lun, page); |
687 | } | 621 | } |
688 | 622 | ||
689 | static ssize_t target_fabric_port_store_attr_alua_tg_pt_status( | 623 | static ssize_t target_fabric_port_alua_tg_pt_status_store( |
690 | struct se_lun *lun, | 624 | struct config_item *item, const char *page, size_t count) |
691 | const char *page, | ||
692 | size_t count) | ||
693 | { | 625 | { |
626 | struct se_lun *lun = item_to_lun(item); | ||
627 | |||
694 | if (!lun || !lun->lun_se_dev) | 628 | if (!lun || !lun->lun_se_dev) |
695 | return -ENODEV; | 629 | return -ENODEV; |
696 | 630 | ||
697 | return core_alua_store_secondary_status(lun, page, count); | 631 | return core_alua_store_secondary_status(lun, page, count); |
698 | } | 632 | } |
699 | 633 | ||
700 | TCM_PORT_ATTR(alua_tg_pt_status, S_IRUGO | S_IWUSR); | 634 | static ssize_t target_fabric_port_alua_tg_pt_write_md_show( |
701 | 635 | struct config_item *item, char *page) | |
702 | /* | ||
703 | * alua_tg_pt_write_md | ||
704 | */ | ||
705 | static ssize_t target_fabric_port_show_attr_alua_tg_pt_write_md( | ||
706 | struct se_lun *lun, | ||
707 | char *page) | ||
708 | { | 636 | { |
637 | struct se_lun *lun = item_to_lun(item); | ||
638 | |||
709 | if (!lun || !lun->lun_se_dev) | 639 | if (!lun || !lun->lun_se_dev) |
710 | return -ENODEV; | 640 | return -ENODEV; |
711 | 641 | ||
712 | return core_alua_show_secondary_write_metadata(lun, page); | 642 | return core_alua_show_secondary_write_metadata(lun, page); |
713 | } | 643 | } |
714 | 644 | ||
715 | static ssize_t target_fabric_port_store_attr_alua_tg_pt_write_md( | 645 | static ssize_t target_fabric_port_alua_tg_pt_write_md_store( |
716 | struct se_lun *lun, | 646 | struct config_item *item, const char *page, size_t count) |
717 | const char *page, | ||
718 | size_t count) | ||
719 | { | 647 | { |
648 | struct se_lun *lun = item_to_lun(item); | ||
649 | |||
720 | if (!lun || !lun->lun_se_dev) | 650 | if (!lun || !lun->lun_se_dev) |
721 | return -ENODEV; | 651 | return -ENODEV; |
722 | 652 | ||
723 | return core_alua_store_secondary_write_metadata(lun, page, count); | 653 | return core_alua_store_secondary_write_metadata(lun, page, count); |
724 | } | 654 | } |
725 | 655 | ||
726 | TCM_PORT_ATTR(alua_tg_pt_write_md, S_IRUGO | S_IWUSR); | 656 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_gp); |
727 | 657 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_offline); | |
658 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_status); | ||
659 | CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_write_md); | ||
728 | 660 | ||
729 | static struct configfs_attribute *target_fabric_port_attrs[] = { | 661 | static struct configfs_attribute *target_fabric_port_attrs[] = { |
730 | &target_fabric_port_alua_tg_pt_gp.attr, | 662 | &target_fabric_port_attr_alua_tg_pt_gp, |
731 | &target_fabric_port_alua_tg_pt_offline.attr, | 663 | &target_fabric_port_attr_alua_tg_pt_offline, |
732 | &target_fabric_port_alua_tg_pt_status.attr, | 664 | &target_fabric_port_attr_alua_tg_pt_status, |
733 | &target_fabric_port_alua_tg_pt_write_md.attr, | 665 | &target_fabric_port_attr_alua_tg_pt_write_md, |
734 | NULL, | 666 | NULL, |
735 | }; | 667 | }; |
736 | 668 | ||
737 | CONFIGFS_EATTR_OPS(target_fabric_port, se_lun, lun_group); | ||
738 | |||
739 | static int target_fabric_port_link( | 669 | static int target_fabric_port_link( |
740 | struct config_item *lun_ci, | 670 | struct config_item *lun_ci, |
741 | struct config_item *se_dev_ci) | 671 | struct config_item *se_dev_ci) |
@@ -821,8 +751,6 @@ static void target_fabric_port_release(struct config_item *item) | |||
821 | } | 751 | } |
822 | 752 | ||
823 | static struct configfs_item_operations target_fabric_port_item_ops = { | 753 | static struct configfs_item_operations target_fabric_port_item_ops = { |
824 | .show_attribute = target_fabric_port_attr_show, | ||
825 | .store_attribute = target_fabric_port_attr_store, | ||
826 | .release = target_fabric_port_release, | 754 | .release = target_fabric_port_release, |
827 | .allow_link = target_fabric_port_link, | 755 | .allow_link = target_fabric_port_link, |
828 | .drop_link = target_fabric_port_unlink, | 756 | .drop_link = target_fabric_port_unlink, |
@@ -952,50 +880,11 @@ TF_CIT_SETUP(tpg_lun, NULL, &target_fabric_lun_group_ops, NULL); | |||
952 | 880 | ||
953 | /* End of tfc_tpg_lun_cit */ | 881 | /* End of tfc_tpg_lun_cit */ |
954 | 882 | ||
955 | /* Start of tfc_tpg_attrib_cit */ | 883 | TF_CIT_SETUP_DRV(tpg_attrib, NULL, NULL); |
956 | 884 | TF_CIT_SETUP_DRV(tpg_auth, NULL, NULL); | |
957 | CONFIGFS_EATTR_OPS(target_fabric_tpg_attrib, se_portal_group, tpg_attrib_group); | 885 | TF_CIT_SETUP_DRV(tpg_param, NULL, NULL); |
958 | |||
959 | static struct configfs_item_operations target_fabric_tpg_attrib_item_ops = { | ||
960 | .show_attribute = target_fabric_tpg_attrib_attr_show, | ||
961 | .store_attribute = target_fabric_tpg_attrib_attr_store, | ||
962 | }; | ||
963 | |||
964 | TF_CIT_SETUP_DRV(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL); | ||
965 | |||
966 | /* End of tfc_tpg_attrib_cit */ | ||
967 | |||
968 | /* Start of tfc_tpg_auth_cit */ | ||
969 | |||
970 | CONFIGFS_EATTR_OPS(target_fabric_tpg_auth, se_portal_group, tpg_auth_group); | ||
971 | |||
972 | static struct configfs_item_operations target_fabric_tpg_auth_item_ops = { | ||
973 | .show_attribute = target_fabric_tpg_auth_attr_show, | ||
974 | .store_attribute = target_fabric_tpg_auth_attr_store, | ||
975 | }; | ||
976 | |||
977 | TF_CIT_SETUP_DRV(tpg_auth, &target_fabric_tpg_auth_item_ops, NULL); | ||
978 | |||
979 | /* End of tfc_tpg_attrib_cit */ | ||
980 | |||
981 | /* Start of tfc_tpg_param_cit */ | ||
982 | |||
983 | CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group); | ||
984 | |||
985 | static struct configfs_item_operations target_fabric_tpg_param_item_ops = { | ||
986 | .show_attribute = target_fabric_tpg_param_attr_show, | ||
987 | .store_attribute = target_fabric_tpg_param_attr_store, | ||
988 | }; | ||
989 | |||
990 | TF_CIT_SETUP_DRV(tpg_param, &target_fabric_tpg_param_item_ops, NULL); | ||
991 | |||
992 | /* End of tfc_tpg_param_cit */ | ||
993 | 886 | ||
994 | /* Start of tfc_tpg_base_cit */ | 887 | /* Start of tfc_tpg_base_cit */ |
995 | /* | ||
996 | * For use with TF_TPG_ATTR() and TF_TPG_ATTR_RO() | ||
997 | */ | ||
998 | CONFIGFS_EATTR_OPS(target_fabric_tpg, se_portal_group, tpg_group); | ||
999 | 888 | ||
1000 | static void target_fabric_tpg_release(struct config_item *item) | 889 | static void target_fabric_tpg_release(struct config_item *item) |
1001 | { | 890 | { |
@@ -1009,8 +898,6 @@ static void target_fabric_tpg_release(struct config_item *item) | |||
1009 | 898 | ||
1010 | static struct configfs_item_operations target_fabric_tpg_base_item_ops = { | 899 | static struct configfs_item_operations target_fabric_tpg_base_item_ops = { |
1011 | .release = target_fabric_tpg_release, | 900 | .release = target_fabric_tpg_release, |
1012 | .show_attribute = target_fabric_tpg_attr_show, | ||
1013 | .store_attribute = target_fabric_tpg_attr_store, | ||
1014 | }; | 901 | }; |
1015 | 902 | ||
1016 | TF_CIT_SETUP_DRV(tpg_base, &target_fabric_tpg_base_item_ops, NULL); | 903 | TF_CIT_SETUP_DRV(tpg_base, &target_fabric_tpg_base_item_ops, NULL); |
@@ -1176,33 +1063,9 @@ static struct configfs_group_operations target_fabric_wwn_group_ops = { | |||
1176 | .make_group = target_fabric_make_wwn, | 1063 | .make_group = target_fabric_make_wwn, |
1177 | .drop_item = target_fabric_drop_wwn, | 1064 | .drop_item = target_fabric_drop_wwn, |
1178 | }; | 1065 | }; |
1179 | /* | ||
1180 | * For use with TF_WWN_ATTR() and TF_WWN_ATTR_RO() | ||
1181 | */ | ||
1182 | CONFIGFS_EATTR_OPS(target_fabric_wwn, target_fabric_configfs, tf_group); | ||
1183 | |||
1184 | static struct configfs_item_operations target_fabric_wwn_item_ops = { | ||
1185 | .show_attribute = target_fabric_wwn_attr_show, | ||
1186 | .store_attribute = target_fabric_wwn_attr_store, | ||
1187 | }; | ||
1188 | |||
1189 | TF_CIT_SETUP_DRV(wwn, &target_fabric_wwn_item_ops, &target_fabric_wwn_group_ops); | ||
1190 | |||
1191 | /* End of tfc_wwn_cit */ | ||
1192 | |||
1193 | /* Start of tfc_discovery_cit */ | ||
1194 | |||
1195 | CONFIGFS_EATTR_OPS(target_fabric_discovery, target_fabric_configfs, | ||
1196 | tf_disc_group); | ||
1197 | |||
1198 | static struct configfs_item_operations target_fabric_discovery_item_ops = { | ||
1199 | .show_attribute = target_fabric_discovery_attr_show, | ||
1200 | .store_attribute = target_fabric_discovery_attr_store, | ||
1201 | }; | ||
1202 | |||
1203 | TF_CIT_SETUP_DRV(discovery, &target_fabric_discovery_item_ops, NULL); | ||
1204 | 1066 | ||
1205 | /* End of tfc_discovery_cit */ | 1067 | TF_CIT_SETUP_DRV(wwn, NULL, &target_fabric_wwn_group_ops); |
1068 | TF_CIT_SETUP_DRV(discovery, NULL, NULL); | ||
1206 | 1069 | ||
1207 | int target_fabric_setup_cits(struct target_fabric_configfs *tf) | 1070 | int target_fabric_setup_cits(struct target_fabric_configfs *tf) |
1208 | { | 1071 | { |
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index 99c24acfe676..dae0750c2032 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h | |||
@@ -87,6 +87,9 @@ void target_free_device(struct se_device *); | |||
87 | /* target_core_configfs.c */ | 87 | /* target_core_configfs.c */ |
88 | void target_setup_backend_cits(struct target_backend *); | 88 | void target_setup_backend_cits(struct target_backend *); |
89 | 89 | ||
90 | /* target_core_fabric_configfs.c */ | ||
91 | int target_fabric_setup_cits(struct target_fabric_configfs *); | ||
92 | |||
90 | /* target_core_fabric_lib.c */ | 93 | /* target_core_fabric_lib.c */ |
91 | int target_get_pr_transport_id_len(struct se_node_acl *nacl, | 94 | int target_get_pr_transport_id_len(struct se_node_acl *nacl, |
92 | struct t10_pr_registration *pr_reg, int *format_code); | 95 | struct t10_pr_registration *pr_reg, int *format_code); |
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 20ed5d2e151a..273c72b2b83d 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <target/target_core_base.h> | 37 | #include <target/target_core_base.h> |
38 | #include <target/target_core_backend.h> | 38 | #include <target/target_core_backend.h> |
39 | #include <target/target_core_fabric.h> | 39 | #include <target/target_core_fabric.h> |
40 | #include <target/configfs_macros.h> | ||
41 | 40 | ||
42 | #include "target_core_internal.h" | 41 | #include "target_core_internal.h" |
43 | 42 | ||
@@ -55,75 +54,49 @@ | |||
55 | * SCSI Device Table | 54 | * SCSI Device Table |
56 | */ | 55 | */ |
57 | 56 | ||
58 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_dev, se_dev_stat_grps); | 57 | static struct se_device *to_stat_dev(struct config_item *item) |
59 | #define DEV_STAT_SCSI_DEV_ATTR(_name, _mode) \ | 58 | { |
60 | static struct target_stat_scsi_dev_attribute \ | 59 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), |
61 | target_stat_scsi_dev_##_name = \ | 60 | struct se_dev_stat_grps, scsi_dev_group); |
62 | __CONFIGFS_EATTR(_name, _mode, \ | 61 | return container_of(sgrps, struct se_device, dev_stat_grps); |
63 | target_stat_scsi_dev_show_attr_##_name, \ | 62 | } |
64 | target_stat_scsi_dev_store_attr_##_name); | ||
65 | |||
66 | #define DEV_STAT_SCSI_DEV_ATTR_RO(_name) \ | ||
67 | static struct target_stat_scsi_dev_attribute \ | ||
68 | target_stat_scsi_dev_##_name = \ | ||
69 | __CONFIGFS_EATTR_RO(_name, \ | ||
70 | target_stat_scsi_dev_show_attr_##_name); | ||
71 | 63 | ||
72 | static ssize_t target_stat_scsi_dev_show_attr_inst( | 64 | static ssize_t target_stat_inst_show(struct config_item *item, char *page) |
73 | struct se_dev_stat_grps *sgrps, char *page) | ||
74 | { | 65 | { |
75 | struct se_device *dev = | 66 | struct se_hba *hba = to_stat_dev(item)->se_hba; |
76 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
77 | struct se_hba *hba = dev->se_hba; | ||
78 | 67 | ||
79 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 68 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
80 | } | 69 | } |
81 | DEV_STAT_SCSI_DEV_ATTR_RO(inst); | ||
82 | 70 | ||
83 | static ssize_t target_stat_scsi_dev_show_attr_indx( | 71 | static ssize_t target_stat_indx_show(struct config_item *item, char *page) |
84 | struct se_dev_stat_grps *sgrps, char *page) | ||
85 | { | 72 | { |
86 | struct se_device *dev = | 73 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->dev_index); |
87 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
88 | |||
89 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | ||
90 | } | 74 | } |
91 | DEV_STAT_SCSI_DEV_ATTR_RO(indx); | ||
92 | 75 | ||
93 | static ssize_t target_stat_scsi_dev_show_attr_role( | 76 | static ssize_t target_stat_role_show(struct config_item *item, char *page) |
94 | struct se_dev_stat_grps *sgrps, char *page) | ||
95 | { | 77 | { |
96 | return snprintf(page, PAGE_SIZE, "Target\n"); | 78 | return snprintf(page, PAGE_SIZE, "Target\n"); |
97 | } | 79 | } |
98 | DEV_STAT_SCSI_DEV_ATTR_RO(role); | ||
99 | 80 | ||
100 | static ssize_t target_stat_scsi_dev_show_attr_ports( | 81 | static ssize_t target_stat_ports_show(struct config_item *item, char *page) |
101 | struct se_dev_stat_grps *sgrps, char *page) | ||
102 | { | 82 | { |
103 | struct se_device *dev = | 83 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->export_count); |
104 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
105 | |||
106 | return snprintf(page, PAGE_SIZE, "%u\n", dev->export_count); | ||
107 | } | 84 | } |
108 | DEV_STAT_SCSI_DEV_ATTR_RO(ports); | ||
109 | 85 | ||
110 | CONFIGFS_EATTR_OPS(target_stat_scsi_dev, se_dev_stat_grps, scsi_dev_group); | 86 | CONFIGFS_ATTR_RO(target_stat_, inst); |
87 | CONFIGFS_ATTR_RO(target_stat_, indx); | ||
88 | CONFIGFS_ATTR_RO(target_stat_, role); | ||
89 | CONFIGFS_ATTR_RO(target_stat_, ports); | ||
111 | 90 | ||
112 | static struct configfs_attribute *target_stat_scsi_dev_attrs[] = { | 91 | static struct configfs_attribute *target_stat_scsi_dev_attrs[] = { |
113 | &target_stat_scsi_dev_inst.attr, | 92 | &target_stat_attr_inst, |
114 | &target_stat_scsi_dev_indx.attr, | 93 | &target_stat_attr_indx, |
115 | &target_stat_scsi_dev_role.attr, | 94 | &target_stat_attr_role, |
116 | &target_stat_scsi_dev_ports.attr, | 95 | &target_stat_attr_ports, |
117 | NULL, | 96 | NULL, |
118 | }; | 97 | }; |
119 | 98 | ||
120 | static struct configfs_item_operations target_stat_scsi_dev_attrib_ops = { | ||
121 | .show_attribute = target_stat_scsi_dev_attr_show, | ||
122 | .store_attribute = target_stat_scsi_dev_attr_store, | ||
123 | }; | ||
124 | |||
125 | static struct config_item_type target_stat_scsi_dev_cit = { | 99 | static struct config_item_type target_stat_scsi_dev_cit = { |
126 | .ct_item_ops = &target_stat_scsi_dev_attrib_ops, | ||
127 | .ct_attrs = target_stat_scsi_dev_attrs, | 100 | .ct_attrs = target_stat_scsi_dev_attrs, |
128 | .ct_owner = THIS_MODULE, | 101 | .ct_owner = THIS_MODULE, |
129 | }; | 102 | }; |
@@ -131,109 +104,78 @@ static struct config_item_type target_stat_scsi_dev_cit = { | |||
131 | /* | 104 | /* |
132 | * SCSI Target Device Table | 105 | * SCSI Target Device Table |
133 | */ | 106 | */ |
107 | static struct se_device *to_stat_tgt_dev(struct config_item *item) | ||
108 | { | ||
109 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), | ||
110 | struct se_dev_stat_grps, scsi_tgt_dev_group); | ||
111 | return container_of(sgrps, struct se_device, dev_stat_grps); | ||
112 | } | ||
134 | 113 | ||
135 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_dev, se_dev_stat_grps); | 114 | static ssize_t target_stat_tgt_inst_show(struct config_item *item, char *page) |
136 | #define DEV_STAT_SCSI_TGT_DEV_ATTR(_name, _mode) \ | ||
137 | static struct target_stat_scsi_tgt_dev_attribute \ | ||
138 | target_stat_scsi_tgt_dev_##_name = \ | ||
139 | __CONFIGFS_EATTR(_name, _mode, \ | ||
140 | target_stat_scsi_tgt_dev_show_attr_##_name, \ | ||
141 | target_stat_scsi_tgt_dev_store_attr_##_name); | ||
142 | |||
143 | #define DEV_STAT_SCSI_TGT_DEV_ATTR_RO(_name) \ | ||
144 | static struct target_stat_scsi_tgt_dev_attribute \ | ||
145 | target_stat_scsi_tgt_dev_##_name = \ | ||
146 | __CONFIGFS_EATTR_RO(_name, \ | ||
147 | target_stat_scsi_tgt_dev_show_attr_##_name); | ||
148 | |||
149 | static ssize_t target_stat_scsi_tgt_dev_show_attr_inst( | ||
150 | struct se_dev_stat_grps *sgrps, char *page) | ||
151 | { | 115 | { |
152 | struct se_device *dev = | 116 | struct se_hba *hba = to_stat_tgt_dev(item)->se_hba; |
153 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
154 | struct se_hba *hba = dev->se_hba; | ||
155 | 117 | ||
156 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 118 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
157 | } | 119 | } |
158 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst); | ||
159 | 120 | ||
160 | static ssize_t target_stat_scsi_tgt_dev_show_attr_indx( | 121 | static ssize_t target_stat_tgt_indx_show(struct config_item *item, char *page) |
161 | struct se_dev_stat_grps *sgrps, char *page) | ||
162 | { | 122 | { |
163 | struct se_device *dev = | 123 | return snprintf(page, PAGE_SIZE, "%u\n", to_stat_tgt_dev(item)->dev_index); |
164 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
165 | |||
166 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | ||
167 | } | 124 | } |
168 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx); | ||
169 | 125 | ||
170 | static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus( | 126 | static ssize_t target_stat_tgt_num_lus_show(struct config_item *item, |
171 | struct se_dev_stat_grps *sgrps, char *page) | 127 | char *page) |
172 | { | 128 | { |
173 | return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); | 129 | return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); |
174 | } | 130 | } |
175 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus); | ||
176 | 131 | ||
177 | static ssize_t target_stat_scsi_tgt_dev_show_attr_status( | 132 | static ssize_t target_stat_tgt_status_show(struct config_item *item, |
178 | struct se_dev_stat_grps *sgrps, char *page) | 133 | char *page) |
179 | { | 134 | { |
180 | struct se_device *dev = | 135 | if (to_stat_tgt_dev(item)->export_count) |
181 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
182 | |||
183 | if (dev->export_count) | ||
184 | return snprintf(page, PAGE_SIZE, "activated"); | 136 | return snprintf(page, PAGE_SIZE, "activated"); |
185 | else | 137 | else |
186 | return snprintf(page, PAGE_SIZE, "deactivated"); | 138 | return snprintf(page, PAGE_SIZE, "deactivated"); |
187 | } | 139 | } |
188 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status); | ||
189 | 140 | ||
190 | static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus( | 141 | static ssize_t target_stat_tgt_non_access_lus_show(struct config_item *item, |
191 | struct se_dev_stat_grps *sgrps, char *page) | 142 | char *page) |
192 | { | 143 | { |
193 | struct se_device *dev = | ||
194 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
195 | int non_accessible_lus; | 144 | int non_accessible_lus; |
196 | 145 | ||
197 | if (dev->export_count) | 146 | if (to_stat_tgt_dev(item)->export_count) |
198 | non_accessible_lus = 0; | 147 | non_accessible_lus = 0; |
199 | else | 148 | else |
200 | non_accessible_lus = 1; | 149 | non_accessible_lus = 1; |
201 | 150 | ||
202 | return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); | 151 | return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); |
203 | } | 152 | } |
204 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus); | ||
205 | 153 | ||
206 | static ssize_t target_stat_scsi_tgt_dev_show_attr_resets( | 154 | static ssize_t target_stat_tgt_resets_show(struct config_item *item, |
207 | struct se_dev_stat_grps *sgrps, char *page) | 155 | char *page) |
208 | { | 156 | { |
209 | struct se_device *dev = | ||
210 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
211 | |||
212 | return snprintf(page, PAGE_SIZE, "%lu\n", | 157 | return snprintf(page, PAGE_SIZE, "%lu\n", |
213 | atomic_long_read(&dev->num_resets)); | 158 | atomic_long_read(&to_stat_tgt_dev(item)->num_resets)); |
214 | } | 159 | } |
215 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets); | ||
216 | 160 | ||
217 | 161 | CONFIGFS_ATTR_RO(target_stat_tgt_, inst); | |
218 | CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_dev, se_dev_stat_grps, scsi_tgt_dev_group); | 162 | CONFIGFS_ATTR_RO(target_stat_tgt_, indx); |
163 | CONFIGFS_ATTR_RO(target_stat_tgt_, num_lus); | ||
164 | CONFIGFS_ATTR_RO(target_stat_tgt_, status); | ||
165 | CONFIGFS_ATTR_RO(target_stat_tgt_, non_access_lus); | ||
166 | CONFIGFS_ATTR_RO(target_stat_tgt_, resets); | ||
219 | 167 | ||
220 | static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = { | 168 | static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = { |
221 | &target_stat_scsi_tgt_dev_inst.attr, | 169 | &target_stat_tgt_attr_inst, |
222 | &target_stat_scsi_tgt_dev_indx.attr, | 170 | &target_stat_tgt_attr_indx, |
223 | &target_stat_scsi_tgt_dev_num_lus.attr, | 171 | &target_stat_tgt_attr_num_lus, |
224 | &target_stat_scsi_tgt_dev_status.attr, | 172 | &target_stat_tgt_attr_status, |
225 | &target_stat_scsi_tgt_dev_non_access_lus.attr, | 173 | &target_stat_tgt_attr_non_access_lus, |
226 | &target_stat_scsi_tgt_dev_resets.attr, | 174 | &target_stat_tgt_attr_resets, |
227 | NULL, | 175 | NULL, |
228 | }; | 176 | }; |
229 | 177 | ||
230 | static struct configfs_item_operations target_stat_scsi_tgt_dev_attrib_ops = { | ||
231 | .show_attribute = target_stat_scsi_tgt_dev_attr_show, | ||
232 | .store_attribute = target_stat_scsi_tgt_dev_attr_store, | ||
233 | }; | ||
234 | |||
235 | static struct config_item_type target_stat_scsi_tgt_dev_cit = { | 178 | static struct config_item_type target_stat_scsi_tgt_dev_cit = { |
236 | .ct_item_ops = &target_stat_scsi_tgt_dev_attrib_ops, | ||
237 | .ct_attrs = target_stat_scsi_tgt_dev_attrs, | 179 | .ct_attrs = target_stat_scsi_tgt_dev_attrs, |
238 | .ct_owner = THIS_MODULE, | 180 | .ct_owner = THIS_MODULE, |
239 | }; | 181 | }; |
@@ -242,72 +184,50 @@ static struct config_item_type target_stat_scsi_tgt_dev_cit = { | |||
242 | * SCSI Logical Unit Table | 184 | * SCSI Logical Unit Table |
243 | */ | 185 | */ |
244 | 186 | ||
245 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_lu, se_dev_stat_grps); | 187 | static struct se_device *to_stat_lu_dev(struct config_item *item) |
246 | #define DEV_STAT_SCSI_LU_ATTR(_name, _mode) \ | 188 | { |
247 | static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \ | 189 | struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), |
248 | __CONFIGFS_EATTR(_name, _mode, \ | 190 | struct se_dev_stat_grps, scsi_lu_group); |
249 | target_stat_scsi_lu_show_attr_##_name, \ | 191 | return container_of(sgrps, struct se_device, dev_stat_grps); |
250 | target_stat_scsi_lu_store_attr_##_name); | 192 | } |
251 | |||
252 | #define DEV_STAT_SCSI_LU_ATTR_RO(_name) \ | ||
253 | static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \ | ||
254 | __CONFIGFS_EATTR_RO(_name, \ | ||
255 | target_stat_scsi_lu_show_attr_##_name); | ||
256 | 193 | ||
257 | static ssize_t target_stat_scsi_lu_show_attr_inst( | 194 | static ssize_t target_stat_lu_inst_show(struct config_item *item, char *page) |
258 | struct se_dev_stat_grps *sgrps, char *page) | ||
259 | { | 195 | { |
260 | struct se_device *dev = | 196 | struct se_hba *hba = to_stat_lu_dev(item)->se_hba; |
261 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
262 | struct se_hba *hba = dev->se_hba; | ||
263 | 197 | ||
264 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); | 198 | return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); |
265 | } | 199 | } |
266 | DEV_STAT_SCSI_LU_ATTR_RO(inst); | ||
267 | 200 | ||
268 | static ssize_t target_stat_scsi_lu_show_attr_dev( | 201 | static ssize_t target_stat_lu_dev_show(struct config_item *item, char *page) |
269 | struct se_dev_stat_grps *sgrps, char *page) | ||
270 | { | 202 | { |
271 | struct se_device *dev = | 203 | return snprintf(page, PAGE_SIZE, "%u\n", |
272 | container_of(sgrps, struct se_device, dev_stat_grps); | 204 | to_stat_lu_dev(item)->dev_index); |
273 | |||
274 | return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); | ||
275 | } | 205 | } |
276 | DEV_STAT_SCSI_LU_ATTR_RO(dev); | ||
277 | 206 | ||
278 | static ssize_t target_stat_scsi_lu_show_attr_indx( | 207 | static ssize_t target_stat_lu_indx_show(struct config_item *item, char *page) |
279 | struct se_dev_stat_grps *sgrps, char *page) | ||
280 | { | 208 | { |
281 | return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); | 209 | return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); |
282 | } | 210 | } |
283 | DEV_STAT_SCSI_LU_ATTR_RO(indx); | ||
284 | 211 | ||
285 | static ssize_t target_stat_scsi_lu_show_attr_lun( | 212 | static ssize_t target_stat_lu_lun_show(struct config_item *item, char *page) |
286 | struct se_dev_stat_grps *sgrps, char *page) | ||
287 | { | 213 | { |
288 | /* FIXME: scsiLuDefaultLun */ | 214 | /* FIXME: scsiLuDefaultLun */ |
289 | return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); | 215 | return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); |
290 | } | 216 | } |
291 | DEV_STAT_SCSI_LU_ATTR_RO(lun); | ||
292 | 217 | ||
293 | static ssize_t target_stat_scsi_lu_show_attr_lu_name( | 218 | static ssize_t target_stat_lu_lu_name_show(struct config_item *item, char *page) |
294 | struct se_dev_stat_grps *sgrps, char *page) | ||
295 | { | 219 | { |
296 | struct se_device *dev = | 220 | struct se_device *dev = to_stat_lu_dev(item); |
297 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
298 | 221 | ||
299 | /* scsiLuWwnName */ | 222 | /* scsiLuWwnName */ |
300 | return snprintf(page, PAGE_SIZE, "%s\n", | 223 | return snprintf(page, PAGE_SIZE, "%s\n", |
301 | (strlen(dev->t10_wwn.unit_serial)) ? | 224 | (strlen(dev->t10_wwn.unit_serial)) ? |
302 | dev->t10_wwn.unit_serial : "None"); | 225 | dev->t10_wwn.unit_serial : "None"); |
303 | } | 226 | } |
304 | DEV_STAT_SCSI_LU_ATTR_RO(lu_name); | ||
305 | 227 | ||
306 | static ssize_t target_stat_scsi_lu_show_attr_vend( | 228 | static ssize_t target_stat_lu_vend_show(struct config_item *item, char *page) |
307 | struct se_dev_stat_grps *sgrps, char *page) | ||
308 | { | 229 | { |
309 | struct se_device *dev = | 230 | struct se_device *dev = to_stat_lu_dev(item); |
310 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
311 | int i; | 231 | int i; |
312 | char str[sizeof(dev->t10_wwn.vendor)+1]; | 232 | char str[sizeof(dev->t10_wwn.vendor)+1]; |
313 | 233 | ||
@@ -318,13 +238,10 @@ static ssize_t target_stat_scsi_lu_show_attr_vend( | |||
318 | str[i] = '\0'; | 238 | str[i] = '\0'; |
319 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 239 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
320 | } | 240 | } |
321 | DEV_STAT_SCSI_LU_ATTR_RO(vend); | ||
322 | 241 | ||
323 | static ssize_t target_stat_scsi_lu_show_attr_prod( | 242 | static ssize_t target_stat_lu_prod_show(struct config_item *item, char *page) |
324 | struct se_dev_stat_grps *sgrps, char *page) | ||
325 | { | 243 | { |
326 | struct se_device *dev = | 244 | struct se_device *dev = to_stat_lu_dev(item); |
327 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
328 | int i; | 245 | int i; |
329 | char str[sizeof(dev->t10_wwn.model)+1]; | 246 | char str[sizeof(dev->t10_wwn.model)+1]; |
330 | 247 | ||
@@ -335,13 +252,10 @@ static ssize_t target_stat_scsi_lu_show_attr_prod( | |||
335 | str[i] = '\0'; | 252 | str[i] = '\0'; |
336 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 253 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
337 | } | 254 | } |
338 | DEV_STAT_SCSI_LU_ATTR_RO(prod); | ||
339 | 255 | ||
340 | static ssize_t target_stat_scsi_lu_show_attr_rev( | 256 | static ssize_t target_stat_lu_rev_show(struct config_item *item, char *page) |
341 | struct se_dev_stat_grps *sgrps, char *page) | ||
342 | { | 257 | { |
343 | struct se_device *dev = | 258 | struct se_device *dev = to_stat_lu_dev(item); |
344 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
345 | int i; | 259 | int i; |
346 | char str[sizeof(dev->t10_wwn.revision)+1]; | 260 | char str[sizeof(dev->t10_wwn.revision)+1]; |
347 | 261 | ||
@@ -352,146 +266,137 @@ static ssize_t target_stat_scsi_lu_show_attr_rev( | |||
352 | str[i] = '\0'; | 266 | str[i] = '\0'; |
353 | return snprintf(page, PAGE_SIZE, "%s\n", str); | 267 | return snprintf(page, PAGE_SIZE, "%s\n", str); |
354 | } | 268 | } |
355 | DEV_STAT_SCSI_LU_ATTR_RO(rev); | ||
356 | 269 | ||
357 | static ssize_t target_stat_scsi_lu_show_attr_dev_type( | 270 | static ssize_t target_stat_lu_dev_type_show(struct config_item *item, char *page) |
358 | struct se_dev_stat_grps *sgrps, char *page) | ||
359 | { | 271 | { |
360 | struct se_device *dev = | 272 | struct se_device *dev = to_stat_lu_dev(item); |
361 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
362 | 273 | ||
363 | /* scsiLuPeripheralType */ | 274 | /* scsiLuPeripheralType */ |
364 | return snprintf(page, PAGE_SIZE, "%u\n", | 275 | return snprintf(page, PAGE_SIZE, "%u\n", |
365 | dev->transport->get_device_type(dev)); | 276 | dev->transport->get_device_type(dev)); |
366 | } | 277 | } |
367 | DEV_STAT_SCSI_LU_ATTR_RO(dev_type); | ||
368 | 278 | ||
369 | static ssize_t target_stat_scsi_lu_show_attr_status( | 279 | static ssize_t target_stat_lu_status_show(struct config_item *item, char *page) |
370 | struct se_dev_stat_grps *sgrps, char *page) | ||
371 | { | 280 | { |
372 | struct se_device *dev = | 281 | struct se_device *dev = to_stat_lu_dev(item); |
373 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
374 | 282 | ||
375 | /* scsiLuStatus */ | 283 | /* scsiLuStatus */ |
376 | return snprintf(page, PAGE_SIZE, "%s\n", | 284 | return snprintf(page, PAGE_SIZE, "%s\n", |
377 | (dev->export_count) ? "available" : "notavailable"); | 285 | (dev->export_count) ? "available" : "notavailable"); |
378 | } | 286 | } |
379 | DEV_STAT_SCSI_LU_ATTR_RO(status); | ||
380 | 287 | ||
381 | static ssize_t target_stat_scsi_lu_show_attr_state_bit( | 288 | static ssize_t target_stat_lu_state_bit_show(struct config_item *item, |
382 | struct se_dev_stat_grps *sgrps, char *page) | 289 | char *page) |
383 | { | 290 | { |
384 | /* scsiLuState */ | 291 | /* scsiLuState */ |
385 | return snprintf(page, PAGE_SIZE, "exposed\n"); | 292 | return snprintf(page, PAGE_SIZE, "exposed\n"); |
386 | } | 293 | } |
387 | DEV_STAT_SCSI_LU_ATTR_RO(state_bit); | ||
388 | 294 | ||
389 | static ssize_t target_stat_scsi_lu_show_attr_num_cmds( | 295 | static ssize_t target_stat_lu_num_cmds_show(struct config_item *item, |
390 | struct se_dev_stat_grps *sgrps, char *page) | 296 | char *page) |
391 | { | 297 | { |
392 | struct se_device *dev = | 298 | struct se_device *dev = to_stat_lu_dev(item); |
393 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
394 | 299 | ||
395 | /* scsiLuNumCommands */ | 300 | /* scsiLuNumCommands */ |
396 | return snprintf(page, PAGE_SIZE, "%lu\n", | 301 | return snprintf(page, PAGE_SIZE, "%lu\n", |
397 | atomic_long_read(&dev->num_cmds)); | 302 | atomic_long_read(&dev->num_cmds)); |
398 | } | 303 | } |
399 | DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); | ||
400 | 304 | ||
401 | static ssize_t target_stat_scsi_lu_show_attr_read_mbytes( | 305 | static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item, |
402 | struct se_dev_stat_grps *sgrps, char *page) | 306 | char *page) |
403 | { | 307 | { |
404 | struct se_device *dev = | 308 | struct se_device *dev = to_stat_lu_dev(item); |
405 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
406 | 309 | ||
407 | /* scsiLuReadMegaBytes */ | 310 | /* scsiLuReadMegaBytes */ |
408 | return snprintf(page, PAGE_SIZE, "%lu\n", | 311 | return snprintf(page, PAGE_SIZE, "%lu\n", |
409 | atomic_long_read(&dev->read_bytes) >> 20); | 312 | atomic_long_read(&dev->read_bytes) >> 20); |
410 | } | 313 | } |
411 | DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); | ||
412 | 314 | ||
413 | static ssize_t target_stat_scsi_lu_show_attr_write_mbytes( | 315 | static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item, |
414 | struct se_dev_stat_grps *sgrps, char *page) | 316 | char *page) |
415 | { | 317 | { |
416 | struct se_device *dev = | 318 | struct se_device *dev = to_stat_lu_dev(item); |
417 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
418 | 319 | ||
419 | /* scsiLuWrittenMegaBytes */ | 320 | /* scsiLuWrittenMegaBytes */ |
420 | return snprintf(page, PAGE_SIZE, "%lu\n", | 321 | return snprintf(page, PAGE_SIZE, "%lu\n", |
421 | atomic_long_read(&dev->write_bytes) >> 20); | 322 | atomic_long_read(&dev->write_bytes) >> 20); |
422 | } | 323 | } |
423 | DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); | ||
424 | 324 | ||
425 | static ssize_t target_stat_scsi_lu_show_attr_resets( | 325 | static ssize_t target_stat_lu_resets_show(struct config_item *item, char *page) |
426 | struct se_dev_stat_grps *sgrps, char *page) | ||
427 | { | 326 | { |
428 | struct se_device *dev = | 327 | struct se_device *dev = to_stat_lu_dev(item); |
429 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
430 | 328 | ||
431 | /* scsiLuInResets */ | 329 | /* scsiLuInResets */ |
432 | return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets)); | 330 | return snprintf(page, PAGE_SIZE, "%lu\n", |
331 | atomic_long_read(&dev->num_resets)); | ||
433 | } | 332 | } |
434 | DEV_STAT_SCSI_LU_ATTR_RO(resets); | ||
435 | 333 | ||
436 | static ssize_t target_stat_scsi_lu_show_attr_full_stat( | 334 | static ssize_t target_stat_lu_full_stat_show(struct config_item *item, |
437 | struct se_dev_stat_grps *sgrps, char *page) | 335 | char *page) |
438 | { | 336 | { |
439 | /* FIXME: scsiLuOutTaskSetFullStatus */ | 337 | /* FIXME: scsiLuOutTaskSetFullStatus */ |
440 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | 338 | return snprintf(page, PAGE_SIZE, "%u\n", 0); |
441 | } | 339 | } |
442 | DEV_STAT_SCSI_LU_ATTR_RO(full_stat); | ||
443 | 340 | ||
444 | static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds( | 341 | static ssize_t target_stat_lu_hs_num_cmds_show(struct config_item *item, |
445 | struct se_dev_stat_grps *sgrps, char *page) | 342 | char *page) |
446 | { | 343 | { |
447 | /* FIXME: scsiLuHSInCommands */ | 344 | /* FIXME: scsiLuHSInCommands */ |
448 | return snprintf(page, PAGE_SIZE, "%u\n", 0); | 345 | return snprintf(page, PAGE_SIZE, "%u\n", 0); |
449 | } | 346 | } |
450 | DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds); | ||
451 | 347 | ||
452 | static ssize_t target_stat_scsi_lu_show_attr_creation_time( | 348 | static ssize_t target_stat_lu_creation_time_show(struct config_item *item, |
453 | struct se_dev_stat_grps *sgrps, char *page) | 349 | char *page) |
454 | { | 350 | { |
455 | struct se_device *dev = | 351 | struct se_device *dev = to_stat_lu_dev(item); |
456 | container_of(sgrps, struct se_device, dev_stat_grps); | ||
457 | 352 | ||
458 | /* scsiLuCreationTime */ | 353 | /* scsiLuCreationTime */ |
459 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - | 354 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - |
460 | INITIAL_JIFFIES) * 100 / HZ)); | 355 | INITIAL_JIFFIES) * 100 / HZ)); |
461 | } | 356 | } |
462 | DEV_STAT_SCSI_LU_ATTR_RO(creation_time); | ||
463 | 357 | ||
464 | CONFIGFS_EATTR_OPS(target_stat_scsi_lu, se_dev_stat_grps, scsi_lu_group); | 358 | CONFIGFS_ATTR_RO(target_stat_lu_, inst); |
359 | CONFIGFS_ATTR_RO(target_stat_lu_, dev); | ||
360 | CONFIGFS_ATTR_RO(target_stat_lu_, indx); | ||
361 | CONFIGFS_ATTR_RO(target_stat_lu_, lun); | ||
362 | CONFIGFS_ATTR_RO(target_stat_lu_, lu_name); | ||
363 | CONFIGFS_ATTR_RO(target_stat_lu_, vend); | ||
364 | CONFIGFS_ATTR_RO(target_stat_lu_, prod); | ||
365 | CONFIGFS_ATTR_RO(target_stat_lu_, rev); | ||
366 | CONFIGFS_ATTR_RO(target_stat_lu_, dev_type); | ||
367 | CONFIGFS_ATTR_RO(target_stat_lu_, status); | ||
368 | CONFIGFS_ATTR_RO(target_stat_lu_, state_bit); | ||
369 | CONFIGFS_ATTR_RO(target_stat_lu_, num_cmds); | ||
370 | CONFIGFS_ATTR_RO(target_stat_lu_, read_mbytes); | ||
371 | CONFIGFS_ATTR_RO(target_stat_lu_, write_mbytes); | ||
372 | CONFIGFS_ATTR_RO(target_stat_lu_, resets); | ||
373 | CONFIGFS_ATTR_RO(target_stat_lu_, full_stat); | ||
374 | CONFIGFS_ATTR_RO(target_stat_lu_, hs_num_cmds); | ||
375 | CONFIGFS_ATTR_RO(target_stat_lu_, creation_time); | ||
465 | 376 | ||
466 | static struct configfs_attribute *target_stat_scsi_lu_attrs[] = { | 377 | static struct configfs_attribute *target_stat_scsi_lu_attrs[] = { |
467 | &target_stat_scsi_lu_inst.attr, | 378 | &target_stat_lu_attr_inst, |
468 | &target_stat_scsi_lu_dev.attr, | 379 | &target_stat_lu_attr_dev, |
469 | &target_stat_scsi_lu_indx.attr, | 380 | &target_stat_lu_attr_indx, |
470 | &target_stat_scsi_lu_lun.attr, | 381 | &target_stat_lu_attr_lun, |
471 | &target_stat_scsi_lu_lu_name.attr, | 382 | &target_stat_lu_attr_lu_name, |
472 | &target_stat_scsi_lu_vend.attr, | 383 | &target_stat_lu_attr_vend, |
473 | &target_stat_scsi_lu_prod.attr, | 384 | &target_stat_lu_attr_prod, |
474 | &target_stat_scsi_lu_rev.attr, | 385 | &target_stat_lu_attr_rev, |
475 | &target_stat_scsi_lu_dev_type.attr, | 386 | &target_stat_lu_attr_dev_type, |
476 | &target_stat_scsi_lu_status.attr, | 387 | &target_stat_lu_attr_status, |
477 | &target_stat_scsi_lu_state_bit.attr, | 388 | &target_stat_lu_attr_state_bit, |
478 | &target_stat_scsi_lu_num_cmds.attr, | 389 | &target_stat_lu_attr_num_cmds, |
479 | &target_stat_scsi_lu_read_mbytes.attr, | 390 | &target_stat_lu_attr_read_mbytes, |
480 | &target_stat_scsi_lu_write_mbytes.attr, | 391 | &target_stat_lu_attr_write_mbytes, |
481 | &target_stat_scsi_lu_resets.attr, | 392 | &target_stat_lu_attr_resets, |
482 | &target_stat_scsi_lu_full_stat.attr, | 393 | &target_stat_lu_attr_full_stat, |
483 | &target_stat_scsi_lu_hs_num_cmds.attr, | 394 | &target_stat_lu_attr_hs_num_cmds, |
484 | &target_stat_scsi_lu_creation_time.attr, | 395 | &target_stat_lu_attr_creation_time, |
485 | NULL, | 396 | NULL, |
486 | }; | 397 | }; |
487 | 398 | ||
488 | static struct configfs_item_operations target_stat_scsi_lu_attrib_ops = { | ||
489 | .show_attribute = target_stat_scsi_lu_attr_show, | ||
490 | .store_attribute = target_stat_scsi_lu_attr_store, | ||
491 | }; | ||
492 | |||
493 | static struct config_item_type target_stat_scsi_lu_cit = { | 399 | static struct config_item_type target_stat_scsi_lu_cit = { |
494 | .ct_item_ops = &target_stat_scsi_lu_attrib_ops, | ||
495 | .ct_attrs = target_stat_scsi_lu_attrs, | 400 | .ct_attrs = target_stat_scsi_lu_attrs, |
496 | .ct_owner = THIS_MODULE, | 401 | .ct_owner = THIS_MODULE, |
497 | }; | 402 | }; |
@@ -521,24 +426,16 @@ void target_stat_setup_dev_default_groups(struct se_device *dev) | |||
521 | * SCSI Port Table | 426 | * SCSI Port Table |
522 | */ | 427 | */ |
523 | 428 | ||
524 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_port, se_port_stat_grps); | 429 | static struct se_lun *to_stat_port(struct config_item *item) |
525 | #define DEV_STAT_SCSI_PORT_ATTR(_name, _mode) \ | 430 | { |
526 | static struct target_stat_scsi_port_attribute \ | 431 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), |
527 | target_stat_scsi_port_##_name = \ | 432 | struct se_port_stat_grps, scsi_port_group); |
528 | __CONFIGFS_EATTR(_name, _mode, \ | 433 | return container_of(pgrps, struct se_lun, port_stat_grps); |
529 | target_stat_scsi_port_show_attr_##_name, \ | 434 | } |
530 | target_stat_scsi_port_store_attr_##_name); | ||
531 | |||
532 | #define DEV_STAT_SCSI_PORT_ATTR_RO(_name) \ | ||
533 | static struct target_stat_scsi_port_attribute \ | ||
534 | target_stat_scsi_port_##_name = \ | ||
535 | __CONFIGFS_EATTR_RO(_name, \ | ||
536 | target_stat_scsi_port_show_attr_##_name); | ||
537 | 435 | ||
538 | static ssize_t target_stat_scsi_port_show_attr_inst( | 436 | static ssize_t target_stat_port_inst_show(struct config_item *item, char *page) |
539 | struct se_port_stat_grps *pgrps, char *page) | ||
540 | { | 437 | { |
541 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 438 | struct se_lun *lun = to_stat_port(item); |
542 | struct se_device *dev; | 439 | struct se_device *dev; |
543 | ssize_t ret = -ENODEV; | 440 | ssize_t ret = -ENODEV; |
544 | 441 | ||
@@ -549,12 +446,10 @@ static ssize_t target_stat_scsi_port_show_attr_inst( | |||
549 | rcu_read_unlock(); | 446 | rcu_read_unlock(); |
550 | return ret; | 447 | return ret; |
551 | } | 448 | } |
552 | DEV_STAT_SCSI_PORT_ATTR_RO(inst); | ||
553 | 449 | ||
554 | static ssize_t target_stat_scsi_port_show_attr_dev( | 450 | static ssize_t target_stat_port_dev_show(struct config_item *item, char *page) |
555 | struct se_port_stat_grps *pgrps, char *page) | ||
556 | { | 451 | { |
557 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 452 | struct se_lun *lun = to_stat_port(item); |
558 | struct se_device *dev; | 453 | struct se_device *dev; |
559 | ssize_t ret = -ENODEV; | 454 | ssize_t ret = -ENODEV; |
560 | 455 | ||
@@ -565,12 +460,10 @@ static ssize_t target_stat_scsi_port_show_attr_dev( | |||
565 | rcu_read_unlock(); | 460 | rcu_read_unlock(); |
566 | return ret; | 461 | return ret; |
567 | } | 462 | } |
568 | DEV_STAT_SCSI_PORT_ATTR_RO(dev); | ||
569 | 463 | ||
570 | static ssize_t target_stat_scsi_port_show_attr_indx( | 464 | static ssize_t target_stat_port_indx_show(struct config_item *item, char *page) |
571 | struct se_port_stat_grps *pgrps, char *page) | ||
572 | { | 465 | { |
573 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 466 | struct se_lun *lun = to_stat_port(item); |
574 | struct se_device *dev; | 467 | struct se_device *dev; |
575 | ssize_t ret = -ENODEV; | 468 | ssize_t ret = -ENODEV; |
576 | 469 | ||
@@ -581,12 +474,10 @@ static ssize_t target_stat_scsi_port_show_attr_indx( | |||
581 | rcu_read_unlock(); | 474 | rcu_read_unlock(); |
582 | return ret; | 475 | return ret; |
583 | } | 476 | } |
584 | DEV_STAT_SCSI_PORT_ATTR_RO(indx); | ||
585 | 477 | ||
586 | static ssize_t target_stat_scsi_port_show_attr_role( | 478 | static ssize_t target_stat_port_role_show(struct config_item *item, char *page) |
587 | struct se_port_stat_grps *pgrps, char *page) | ||
588 | { | 479 | { |
589 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 480 | struct se_lun *lun = to_stat_port(item); |
590 | struct se_device *dev; | 481 | struct se_device *dev; |
591 | ssize_t ret = -ENODEV; | 482 | ssize_t ret = -ENODEV; |
592 | 483 | ||
@@ -597,12 +488,11 @@ static ssize_t target_stat_scsi_port_show_attr_role( | |||
597 | rcu_read_unlock(); | 488 | rcu_read_unlock(); |
598 | return ret; | 489 | return ret; |
599 | } | 490 | } |
600 | DEV_STAT_SCSI_PORT_ATTR_RO(role); | ||
601 | 491 | ||
602 | static ssize_t target_stat_scsi_port_show_attr_busy_count( | 492 | static ssize_t target_stat_port_busy_count_show(struct config_item *item, |
603 | struct se_port_stat_grps *pgrps, char *page) | 493 | char *page) |
604 | { | 494 | { |
605 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 495 | struct se_lun *lun = to_stat_port(item); |
606 | struct se_device *dev; | 496 | struct se_device *dev; |
607 | ssize_t ret = -ENODEV; | 497 | ssize_t ret = -ENODEV; |
608 | 498 | ||
@@ -615,26 +505,23 @@ static ssize_t target_stat_scsi_port_show_attr_busy_count( | |||
615 | rcu_read_unlock(); | 505 | rcu_read_unlock(); |
616 | return ret; | 506 | return ret; |
617 | } | 507 | } |
618 | DEV_STAT_SCSI_PORT_ATTR_RO(busy_count); | ||
619 | 508 | ||
620 | CONFIGFS_EATTR_OPS(target_stat_scsi_port, se_port_stat_grps, scsi_port_group); | 509 | CONFIGFS_ATTR_RO(target_stat_port_, inst); |
510 | CONFIGFS_ATTR_RO(target_stat_port_, dev); | ||
511 | CONFIGFS_ATTR_RO(target_stat_port_, indx); | ||
512 | CONFIGFS_ATTR_RO(target_stat_port_, role); | ||
513 | CONFIGFS_ATTR_RO(target_stat_port_, busy_count); | ||
621 | 514 | ||
622 | static struct configfs_attribute *target_stat_scsi_port_attrs[] = { | 515 | static struct configfs_attribute *target_stat_scsi_port_attrs[] = { |
623 | &target_stat_scsi_port_inst.attr, | 516 | &target_stat_port_attr_inst, |
624 | &target_stat_scsi_port_dev.attr, | 517 | &target_stat_port_attr_dev, |
625 | &target_stat_scsi_port_indx.attr, | 518 | &target_stat_port_attr_indx, |
626 | &target_stat_scsi_port_role.attr, | 519 | &target_stat_port_attr_role, |
627 | &target_stat_scsi_port_busy_count.attr, | 520 | &target_stat_port_attr_busy_count, |
628 | NULL, | 521 | NULL, |
629 | }; | 522 | }; |
630 | 523 | ||
631 | static struct configfs_item_operations target_stat_scsi_port_attrib_ops = { | ||
632 | .show_attribute = target_stat_scsi_port_attr_show, | ||
633 | .store_attribute = target_stat_scsi_port_attr_store, | ||
634 | }; | ||
635 | |||
636 | static struct config_item_type target_stat_scsi_port_cit = { | 524 | static struct config_item_type target_stat_scsi_port_cit = { |
637 | .ct_item_ops = &target_stat_scsi_port_attrib_ops, | ||
638 | .ct_attrs = target_stat_scsi_port_attrs, | 525 | .ct_attrs = target_stat_scsi_port_attrs, |
639 | .ct_owner = THIS_MODULE, | 526 | .ct_owner = THIS_MODULE, |
640 | }; | 527 | }; |
@@ -642,24 +529,17 @@ static struct config_item_type target_stat_scsi_port_cit = { | |||
642 | /* | 529 | /* |
643 | * SCSI Target Port Table | 530 | * SCSI Target Port Table |
644 | */ | 531 | */ |
645 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_port, se_port_stat_grps); | 532 | static struct se_lun *to_stat_tgt_port(struct config_item *item) |
646 | #define DEV_STAT_SCSI_TGT_PORT_ATTR(_name, _mode) \ | 533 | { |
647 | static struct target_stat_scsi_tgt_port_attribute \ | 534 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), |
648 | target_stat_scsi_tgt_port_##_name = \ | 535 | struct se_port_stat_grps, scsi_tgt_port_group); |
649 | __CONFIGFS_EATTR(_name, _mode, \ | 536 | return container_of(pgrps, struct se_lun, port_stat_grps); |
650 | target_stat_scsi_tgt_port_show_attr_##_name, \ | 537 | } |
651 | target_stat_scsi_tgt_port_store_attr_##_name); | 538 | |
652 | 539 | static ssize_t target_stat_tgt_port_inst_show(struct config_item *item, | |
653 | #define DEV_STAT_SCSI_TGT_PORT_ATTR_RO(_name) \ | 540 | char *page) |
654 | static struct target_stat_scsi_tgt_port_attribute \ | 541 | { |
655 | target_stat_scsi_tgt_port_##_name = \ | 542 | struct se_lun *lun = to_stat_tgt_port(item); |
656 | __CONFIGFS_EATTR_RO(_name, \ | ||
657 | target_stat_scsi_tgt_port_show_attr_##_name); | ||
658 | |||
659 | static ssize_t target_stat_scsi_tgt_port_show_attr_inst( | ||
660 | struct se_port_stat_grps *pgrps, char *page) | ||
661 | { | ||
662 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | ||
663 | struct se_device *dev; | 543 | struct se_device *dev; |
664 | ssize_t ret = -ENODEV; | 544 | ssize_t ret = -ENODEV; |
665 | 545 | ||
@@ -670,12 +550,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_inst( | |||
670 | rcu_read_unlock(); | 550 | rcu_read_unlock(); |
671 | return ret; | 551 | return ret; |
672 | } | 552 | } |
673 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst); | ||
674 | 553 | ||
675 | static ssize_t target_stat_scsi_tgt_port_show_attr_dev( | 554 | static ssize_t target_stat_tgt_port_dev_show(struct config_item *item, |
676 | struct se_port_stat_grps *pgrps, char *page) | 555 | char *page) |
677 | { | 556 | { |
678 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 557 | struct se_lun *lun = to_stat_tgt_port(item); |
679 | struct se_device *dev; | 558 | struct se_device *dev; |
680 | ssize_t ret = -ENODEV; | 559 | ssize_t ret = -ENODEV; |
681 | 560 | ||
@@ -686,12 +565,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_dev( | |||
686 | rcu_read_unlock(); | 565 | rcu_read_unlock(); |
687 | return ret; | 566 | return ret; |
688 | } | 567 | } |
689 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev); | ||
690 | 568 | ||
691 | static ssize_t target_stat_scsi_tgt_port_show_attr_indx( | 569 | static ssize_t target_stat_tgt_port_indx_show(struct config_item *item, |
692 | struct se_port_stat_grps *pgrps, char *page) | 570 | char *page) |
693 | { | 571 | { |
694 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 572 | struct se_lun *lun = to_stat_tgt_port(item); |
695 | struct se_device *dev; | 573 | struct se_device *dev; |
696 | ssize_t ret = -ENODEV; | 574 | ssize_t ret = -ENODEV; |
697 | 575 | ||
@@ -702,12 +580,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_indx( | |||
702 | rcu_read_unlock(); | 580 | rcu_read_unlock(); |
703 | return ret; | 581 | return ret; |
704 | } | 582 | } |
705 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx); | ||
706 | 583 | ||
707 | static ssize_t target_stat_scsi_tgt_port_show_attr_name( | 584 | static ssize_t target_stat_tgt_port_name_show(struct config_item *item, |
708 | struct se_port_stat_grps *pgrps, char *page) | 585 | char *page) |
709 | { | 586 | { |
710 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 587 | struct se_lun *lun = to_stat_tgt_port(item); |
711 | struct se_portal_group *tpg = lun->lun_tpg; | 588 | struct se_portal_group *tpg = lun->lun_tpg; |
712 | struct se_device *dev; | 589 | struct se_device *dev; |
713 | ssize_t ret = -ENODEV; | 590 | ssize_t ret = -ENODEV; |
@@ -721,12 +598,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_name( | |||
721 | rcu_read_unlock(); | 598 | rcu_read_unlock(); |
722 | return ret; | 599 | return ret; |
723 | } | 600 | } |
724 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name); | ||
725 | 601 | ||
726 | static ssize_t target_stat_scsi_tgt_port_show_attr_port_index( | 602 | static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item, |
727 | struct se_port_stat_grps *pgrps, char *page) | 603 | char *page) |
728 | { | 604 | { |
729 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 605 | struct se_lun *lun = to_stat_tgt_port(item); |
730 | struct se_portal_group *tpg = lun->lun_tpg; | 606 | struct se_portal_group *tpg = lun->lun_tpg; |
731 | struct se_device *dev; | 607 | struct se_device *dev; |
732 | ssize_t ret = -ENODEV; | 608 | ssize_t ret = -ENODEV; |
@@ -740,12 +616,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_port_index( | |||
740 | rcu_read_unlock(); | 616 | rcu_read_unlock(); |
741 | return ret; | 617 | return ret; |
742 | } | 618 | } |
743 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index); | ||
744 | 619 | ||
745 | static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds( | 620 | static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item, |
746 | struct se_port_stat_grps *pgrps, char *page) | 621 | char *page) |
747 | { | 622 | { |
748 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 623 | struct se_lun *lun = to_stat_tgt_port(item); |
749 | struct se_device *dev; | 624 | struct se_device *dev; |
750 | ssize_t ret = -ENODEV; | 625 | ssize_t ret = -ENODEV; |
751 | 626 | ||
@@ -757,12 +632,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds( | |||
757 | rcu_read_unlock(); | 632 | rcu_read_unlock(); |
758 | return ret; | 633 | return ret; |
759 | } | 634 | } |
760 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds); | ||
761 | 635 | ||
762 | static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes( | 636 | static ssize_t target_stat_tgt_port_write_mbytes_show(struct config_item *item, |
763 | struct se_port_stat_grps *pgrps, char *page) | 637 | char *page) |
764 | { | 638 | { |
765 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 639 | struct se_lun *lun = to_stat_tgt_port(item); |
766 | struct se_device *dev; | 640 | struct se_device *dev; |
767 | ssize_t ret = -ENODEV; | 641 | ssize_t ret = -ENODEV; |
768 | 642 | ||
@@ -774,12 +648,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes( | |||
774 | rcu_read_unlock(); | 648 | rcu_read_unlock(); |
775 | return ret; | 649 | return ret; |
776 | } | 650 | } |
777 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes); | ||
778 | 651 | ||
779 | static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes( | 652 | static ssize_t target_stat_tgt_port_read_mbytes_show(struct config_item *item, |
780 | struct se_port_stat_grps *pgrps, char *page) | 653 | char *page) |
781 | { | 654 | { |
782 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 655 | struct se_lun *lun = to_stat_tgt_port(item); |
783 | struct se_device *dev; | 656 | struct se_device *dev; |
784 | ssize_t ret = -ENODEV; | 657 | ssize_t ret = -ENODEV; |
785 | 658 | ||
@@ -791,12 +664,11 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes( | |||
791 | rcu_read_unlock(); | 664 | rcu_read_unlock(); |
792 | return ret; | 665 | return ret; |
793 | } | 666 | } |
794 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes); | ||
795 | 667 | ||
796 | static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds( | 668 | static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, |
797 | struct se_port_stat_grps *pgrps, char *page) | 669 | char *page) |
798 | { | 670 | { |
799 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 671 | struct se_lun *lun = to_stat_tgt_port(item); |
800 | struct se_device *dev; | 672 | struct se_device *dev; |
801 | ssize_t ret = -ENODEV; | 673 | ssize_t ret = -ENODEV; |
802 | 674 | ||
@@ -809,57 +681,49 @@ static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds( | |||
809 | rcu_read_unlock(); | 681 | rcu_read_unlock(); |
810 | return ret; | 682 | return ret; |
811 | } | 683 | } |
812 | DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds); | ||
813 | 684 | ||
814 | CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port, se_port_stat_grps, | 685 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, inst); |
815 | scsi_tgt_port_group); | 686 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, dev); |
687 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx); | ||
688 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, name); | ||
689 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index); | ||
690 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds); | ||
691 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes); | ||
692 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes); | ||
693 | CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds); | ||
816 | 694 | ||
817 | static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = { | 695 | static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = { |
818 | &target_stat_scsi_tgt_port_inst.attr, | 696 | &target_stat_tgt_port_attr_inst, |
819 | &target_stat_scsi_tgt_port_dev.attr, | 697 | &target_stat_tgt_port_attr_dev, |
820 | &target_stat_scsi_tgt_port_indx.attr, | 698 | &target_stat_tgt_port_attr_indx, |
821 | &target_stat_scsi_tgt_port_name.attr, | 699 | &target_stat_tgt_port_attr_name, |
822 | &target_stat_scsi_tgt_port_port_index.attr, | 700 | &target_stat_tgt_port_attr_port_index, |
823 | &target_stat_scsi_tgt_port_in_cmds.attr, | 701 | &target_stat_tgt_port_attr_in_cmds, |
824 | &target_stat_scsi_tgt_port_write_mbytes.attr, | 702 | &target_stat_tgt_port_attr_write_mbytes, |
825 | &target_stat_scsi_tgt_port_read_mbytes.attr, | 703 | &target_stat_tgt_port_attr_read_mbytes, |
826 | &target_stat_scsi_tgt_port_hs_in_cmds.attr, | 704 | &target_stat_tgt_port_attr_hs_in_cmds, |
827 | NULL, | 705 | NULL, |
828 | }; | 706 | }; |
829 | 707 | ||
830 | static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops = { | ||
831 | .show_attribute = target_stat_scsi_tgt_port_attr_show, | ||
832 | .store_attribute = target_stat_scsi_tgt_port_attr_store, | ||
833 | }; | ||
834 | |||
835 | static struct config_item_type target_stat_scsi_tgt_port_cit = { | 708 | static struct config_item_type target_stat_scsi_tgt_port_cit = { |
836 | .ct_item_ops = &target_stat_scsi_tgt_port_attrib_ops, | ||
837 | .ct_attrs = target_stat_scsi_tgt_port_attrs, | 709 | .ct_attrs = target_stat_scsi_tgt_port_attrs, |
838 | .ct_owner = THIS_MODULE, | 710 | .ct_owner = THIS_MODULE, |
839 | }; | 711 | }; |
840 | 712 | ||
841 | /* | 713 | /* |
842 | * SCSI Transport Table | 714 | * SCSI Transport Table |
843 | o */ | 715 | */ |
844 | 716 | static struct se_lun *to_transport_stat(struct config_item *item) | |
845 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport, se_port_stat_grps); | 717 | { |
846 | #define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \ | 718 | struct se_port_stat_grps *pgrps = container_of(to_config_group(item), |
847 | static struct target_stat_scsi_transport_attribute \ | 719 | struct se_port_stat_grps, scsi_transport_group); |
848 | target_stat_scsi_transport_##_name = \ | 720 | return container_of(pgrps, struct se_lun, port_stat_grps); |
849 | __CONFIGFS_EATTR(_name, _mode, \ | 721 | } |
850 | target_stat_scsi_transport_show_attr_##_name, \ | 722 | |
851 | target_stat_scsi_transport_store_attr_##_name); | 723 | static ssize_t target_stat_transport_inst_show(struct config_item *item, |
852 | 724 | char *page) | |
853 | #define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \ | 725 | { |
854 | static struct target_stat_scsi_transport_attribute \ | 726 | struct se_lun *lun = to_transport_stat(item); |
855 | target_stat_scsi_transport_##_name = \ | ||
856 | __CONFIGFS_EATTR_RO(_name, \ | ||
857 | target_stat_scsi_transport_show_attr_##_name); | ||
858 | |||
859 | static ssize_t target_stat_scsi_transport_show_attr_inst( | ||
860 | struct se_port_stat_grps *pgrps, char *page) | ||
861 | { | ||
862 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | ||
863 | struct se_device *dev; | 727 | struct se_device *dev; |
864 | ssize_t ret = -ENODEV; | 728 | ssize_t ret = -ENODEV; |
865 | 729 | ||
@@ -870,12 +734,11 @@ static ssize_t target_stat_scsi_transport_show_attr_inst( | |||
870 | rcu_read_unlock(); | 734 | rcu_read_unlock(); |
871 | return ret; | 735 | return ret; |
872 | } | 736 | } |
873 | DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst); | ||
874 | 737 | ||
875 | static ssize_t target_stat_scsi_transport_show_attr_device( | 738 | static ssize_t target_stat_transport_device_show(struct config_item *item, |
876 | struct se_port_stat_grps *pgrps, char *page) | 739 | char *page) |
877 | { | 740 | { |
878 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 741 | struct se_lun *lun = to_transport_stat(item); |
879 | struct se_device *dev; | 742 | struct se_device *dev; |
880 | struct se_portal_group *tpg = lun->lun_tpg; | 743 | struct se_portal_group *tpg = lun->lun_tpg; |
881 | ssize_t ret = -ENODEV; | 744 | ssize_t ret = -ENODEV; |
@@ -890,12 +753,11 @@ static ssize_t target_stat_scsi_transport_show_attr_device( | |||
890 | rcu_read_unlock(); | 753 | rcu_read_unlock(); |
891 | return ret; | 754 | return ret; |
892 | } | 755 | } |
893 | DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device); | ||
894 | 756 | ||
895 | static ssize_t target_stat_scsi_transport_show_attr_indx( | 757 | static ssize_t target_stat_transport_indx_show(struct config_item *item, |
896 | struct se_port_stat_grps *pgrps, char *page) | 758 | char *page) |
897 | { | 759 | { |
898 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 760 | struct se_lun *lun = to_transport_stat(item); |
899 | struct se_device *dev; | 761 | struct se_device *dev; |
900 | struct se_portal_group *tpg = lun->lun_tpg; | 762 | struct se_portal_group *tpg = lun->lun_tpg; |
901 | ssize_t ret = -ENODEV; | 763 | ssize_t ret = -ENODEV; |
@@ -908,12 +770,11 @@ static ssize_t target_stat_scsi_transport_show_attr_indx( | |||
908 | rcu_read_unlock(); | 770 | rcu_read_unlock(); |
909 | return ret; | 771 | return ret; |
910 | } | 772 | } |
911 | DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx); | ||
912 | 773 | ||
913 | static ssize_t target_stat_scsi_transport_show_attr_dev_name( | 774 | static ssize_t target_stat_transport_dev_name_show(struct config_item *item, |
914 | struct se_port_stat_grps *pgrps, char *page) | 775 | char *page) |
915 | { | 776 | { |
916 | struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); | 777 | struct se_lun *lun = to_transport_stat(item); |
917 | struct se_device *dev; | 778 | struct se_device *dev; |
918 | struct se_portal_group *tpg = lun->lun_tpg; | 779 | struct se_portal_group *tpg = lun->lun_tpg; |
919 | struct t10_wwn *wwn; | 780 | struct t10_wwn *wwn; |
@@ -932,26 +793,21 @@ static ssize_t target_stat_scsi_transport_show_attr_dev_name( | |||
932 | rcu_read_unlock(); | 793 | rcu_read_unlock(); |
933 | return ret; | 794 | return ret; |
934 | } | 795 | } |
935 | DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name); | ||
936 | 796 | ||
937 | CONFIGFS_EATTR_OPS(target_stat_scsi_transport, se_port_stat_grps, | 797 | CONFIGFS_ATTR_RO(target_stat_transport_, inst); |
938 | scsi_transport_group); | 798 | CONFIGFS_ATTR_RO(target_stat_transport_, device); |
799 | CONFIGFS_ATTR_RO(target_stat_transport_, indx); | ||
800 | CONFIGFS_ATTR_RO(target_stat_transport_, dev_name); | ||
939 | 801 | ||
940 | static struct configfs_attribute *target_stat_scsi_transport_attrs[] = { | 802 | static struct configfs_attribute *target_stat_scsi_transport_attrs[] = { |
941 | &target_stat_scsi_transport_inst.attr, | 803 | &target_stat_transport_attr_inst, |
942 | &target_stat_scsi_transport_device.attr, | 804 | &target_stat_transport_attr_device, |
943 | &target_stat_scsi_transport_indx.attr, | 805 | &target_stat_transport_attr_indx, |
944 | &target_stat_scsi_transport_dev_name.attr, | 806 | &target_stat_transport_attr_dev_name, |
945 | NULL, | 807 | NULL, |
946 | }; | 808 | }; |
947 | 809 | ||
948 | static struct configfs_item_operations target_stat_scsi_transport_attrib_ops = { | ||
949 | .show_attribute = target_stat_scsi_transport_attr_show, | ||
950 | .store_attribute = target_stat_scsi_transport_attr_store, | ||
951 | }; | ||
952 | |||
953 | static struct config_item_type target_stat_scsi_transport_cit = { | 810 | static struct config_item_type target_stat_scsi_transport_cit = { |
954 | .ct_item_ops = &target_stat_scsi_transport_attrib_ops, | ||
955 | .ct_attrs = target_stat_scsi_transport_attrs, | 811 | .ct_attrs = target_stat_scsi_transport_attrs, |
956 | .ct_owner = THIS_MODULE, | 812 | .ct_owner = THIS_MODULE, |
957 | }; | 813 | }; |
@@ -981,25 +837,17 @@ void target_stat_setup_port_default_groups(struct se_lun *lun) | |||
981 | * SCSI Authorized Initiator Table | 837 | * SCSI Authorized Initiator Table |
982 | */ | 838 | */ |
983 | 839 | ||
984 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr, se_ml_stat_grps); | 840 | static struct se_lun_acl *auth_to_lacl(struct config_item *item) |
985 | #define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \ | 841 | { |
986 | static struct target_stat_scsi_auth_intr_attribute \ | 842 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), |
987 | target_stat_scsi_auth_intr_##_name = \ | 843 | struct se_ml_stat_grps, scsi_auth_intr_group); |
988 | __CONFIGFS_EATTR(_name, _mode, \ | 844 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); |
989 | target_stat_scsi_auth_intr_show_attr_##_name, \ | 845 | } |
990 | target_stat_scsi_auth_intr_store_attr_##_name); | 846 | |
991 | 847 | static ssize_t target_stat_auth_inst_show(struct config_item *item, | |
992 | #define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \ | 848 | char *page) |
993 | static struct target_stat_scsi_auth_intr_attribute \ | 849 | { |
994 | target_stat_scsi_auth_intr_##_name = \ | 850 | struct se_lun_acl *lacl = auth_to_lacl(item); |
995 | __CONFIGFS_EATTR_RO(_name, \ | ||
996 | target_stat_scsi_auth_intr_show_attr_##_name); | ||
997 | |||
998 | static ssize_t target_stat_scsi_auth_intr_show_attr_inst( | ||
999 | struct se_ml_stat_grps *lgrps, char *page) | ||
1000 | { | ||
1001 | struct se_lun_acl *lacl = container_of(lgrps, | ||
1002 | struct se_lun_acl, ml_stat_grps); | ||
1003 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 851 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1004 | struct se_dev_entry *deve; | 852 | struct se_dev_entry *deve; |
1005 | struct se_portal_group *tpg; | 853 | struct se_portal_group *tpg; |
@@ -1018,13 +866,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_inst( | |||
1018 | rcu_read_unlock(); | 866 | rcu_read_unlock(); |
1019 | return ret; | 867 | return ret; |
1020 | } | 868 | } |
1021 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst); | ||
1022 | 869 | ||
1023 | static ssize_t target_stat_scsi_auth_intr_show_attr_dev( | 870 | static ssize_t target_stat_auth_dev_show(struct config_item *item, |
1024 | struct se_ml_stat_grps *lgrps, char *page) | 871 | char *page) |
1025 | { | 872 | { |
1026 | struct se_lun_acl *lacl = container_of(lgrps, | 873 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1027 | struct se_lun_acl, ml_stat_grps); | ||
1028 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 874 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1029 | struct se_dev_entry *deve; | 875 | struct se_dev_entry *deve; |
1030 | struct se_lun *lun; | 876 | struct se_lun *lun; |
@@ -1042,13 +888,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev( | |||
1042 | rcu_read_unlock(); | 888 | rcu_read_unlock(); |
1043 | return ret; | 889 | return ret; |
1044 | } | 890 | } |
1045 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev); | ||
1046 | 891 | ||
1047 | static ssize_t target_stat_scsi_auth_intr_show_attr_port( | 892 | static ssize_t target_stat_auth_port_show(struct config_item *item, |
1048 | struct se_ml_stat_grps *lgrps, char *page) | 893 | char *page) |
1049 | { | 894 | { |
1050 | struct se_lun_acl *lacl = container_of(lgrps, | 895 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1051 | struct se_lun_acl, ml_stat_grps); | ||
1052 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 896 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1053 | struct se_dev_entry *deve; | 897 | struct se_dev_entry *deve; |
1054 | struct se_portal_group *tpg; | 898 | struct se_portal_group *tpg; |
@@ -1066,13 +910,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_port( | |||
1066 | rcu_read_unlock(); | 910 | rcu_read_unlock(); |
1067 | return ret; | 911 | return ret; |
1068 | } | 912 | } |
1069 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port); | ||
1070 | 913 | ||
1071 | static ssize_t target_stat_scsi_auth_intr_show_attr_indx( | 914 | static ssize_t target_stat_auth_indx_show(struct config_item *item, |
1072 | struct se_ml_stat_grps *lgrps, char *page) | 915 | char *page) |
1073 | { | 916 | { |
1074 | struct se_lun_acl *lacl = container_of(lgrps, | 917 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1075 | struct se_lun_acl, ml_stat_grps); | ||
1076 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 918 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1077 | struct se_dev_entry *deve; | 919 | struct se_dev_entry *deve; |
1078 | ssize_t ret; | 920 | ssize_t ret; |
@@ -1088,13 +930,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_indx( | |||
1088 | rcu_read_unlock(); | 930 | rcu_read_unlock(); |
1089 | return ret; | 931 | return ret; |
1090 | } | 932 | } |
1091 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx); | ||
1092 | 933 | ||
1093 | static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port( | 934 | static ssize_t target_stat_auth_dev_or_port_show(struct config_item *item, |
1094 | struct se_ml_stat_grps *lgrps, char *page) | 935 | char *page) |
1095 | { | 936 | { |
1096 | struct se_lun_acl *lacl = container_of(lgrps, | 937 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1097 | struct se_lun_acl, ml_stat_grps); | ||
1098 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 938 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1099 | struct se_dev_entry *deve; | 939 | struct se_dev_entry *deve; |
1100 | ssize_t ret; | 940 | ssize_t ret; |
@@ -1110,13 +950,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port( | |||
1110 | rcu_read_unlock(); | 950 | rcu_read_unlock(); |
1111 | return ret; | 951 | return ret; |
1112 | } | 952 | } |
1113 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port); | ||
1114 | 953 | ||
1115 | static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name( | 954 | static ssize_t target_stat_auth_intr_name_show(struct config_item *item, |
1116 | struct se_ml_stat_grps *lgrps, char *page) | 955 | char *page) |
1117 | { | 956 | { |
1118 | struct se_lun_acl *lacl = container_of(lgrps, | 957 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1119 | struct se_lun_acl, ml_stat_grps); | ||
1120 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 958 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1121 | struct se_dev_entry *deve; | 959 | struct se_dev_entry *deve; |
1122 | ssize_t ret; | 960 | ssize_t ret; |
@@ -1132,13 +970,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name( | |||
1132 | rcu_read_unlock(); | 970 | rcu_read_unlock(); |
1133 | return ret; | 971 | return ret; |
1134 | } | 972 | } |
1135 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name); | ||
1136 | 973 | ||
1137 | static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx( | 974 | static ssize_t target_stat_auth_map_indx_show(struct config_item *item, |
1138 | struct se_ml_stat_grps *lgrps, char *page) | 975 | char *page) |
1139 | { | 976 | { |
1140 | struct se_lun_acl *lacl = container_of(lgrps, | 977 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1141 | struct se_lun_acl, ml_stat_grps); | ||
1142 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 978 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1143 | struct se_dev_entry *deve; | 979 | struct se_dev_entry *deve; |
1144 | ssize_t ret; | 980 | ssize_t ret; |
@@ -1154,13 +990,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx( | |||
1154 | rcu_read_unlock(); | 990 | rcu_read_unlock(); |
1155 | return ret; | 991 | return ret; |
1156 | } | 992 | } |
1157 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx); | ||
1158 | 993 | ||
1159 | static ssize_t target_stat_scsi_auth_intr_show_attr_att_count( | 994 | static ssize_t target_stat_auth_att_count_show(struct config_item *item, |
1160 | struct se_ml_stat_grps *lgrps, char *page) | 995 | char *page) |
1161 | { | 996 | { |
1162 | struct se_lun_acl *lacl = container_of(lgrps, | 997 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1163 | struct se_lun_acl, ml_stat_grps); | ||
1164 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 998 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1165 | struct se_dev_entry *deve; | 999 | struct se_dev_entry *deve; |
1166 | ssize_t ret; | 1000 | ssize_t ret; |
@@ -1176,13 +1010,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_att_count( | |||
1176 | rcu_read_unlock(); | 1010 | rcu_read_unlock(); |
1177 | return ret; | 1011 | return ret; |
1178 | } | 1012 | } |
1179 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count); | ||
1180 | 1013 | ||
1181 | static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds( | 1014 | static ssize_t target_stat_auth_num_cmds_show(struct config_item *item, |
1182 | struct se_ml_stat_grps *lgrps, char *page) | 1015 | char *page) |
1183 | { | 1016 | { |
1184 | struct se_lun_acl *lacl = container_of(lgrps, | 1017 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1185 | struct se_lun_acl, ml_stat_grps); | ||
1186 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1018 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1187 | struct se_dev_entry *deve; | 1019 | struct se_dev_entry *deve; |
1188 | ssize_t ret; | 1020 | ssize_t ret; |
@@ -1199,13 +1031,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds( | |||
1199 | rcu_read_unlock(); | 1031 | rcu_read_unlock(); |
1200 | return ret; | 1032 | return ret; |
1201 | } | 1033 | } |
1202 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds); | ||
1203 | 1034 | ||
1204 | static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes( | 1035 | static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item, |
1205 | struct se_ml_stat_grps *lgrps, char *page) | 1036 | char *page) |
1206 | { | 1037 | { |
1207 | struct se_lun_acl *lacl = container_of(lgrps, | 1038 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1208 | struct se_lun_acl, ml_stat_grps); | ||
1209 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1039 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1210 | struct se_dev_entry *deve; | 1040 | struct se_dev_entry *deve; |
1211 | ssize_t ret; | 1041 | ssize_t ret; |
@@ -1222,13 +1052,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes( | |||
1222 | rcu_read_unlock(); | 1052 | rcu_read_unlock(); |
1223 | return ret; | 1053 | return ret; |
1224 | } | 1054 | } |
1225 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes); | ||
1226 | 1055 | ||
1227 | static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes( | 1056 | static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item, |
1228 | struct se_ml_stat_grps *lgrps, char *page) | 1057 | char *page) |
1229 | { | 1058 | { |
1230 | struct se_lun_acl *lacl = container_of(lgrps, | 1059 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1231 | struct se_lun_acl, ml_stat_grps); | ||
1232 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1060 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1233 | struct se_dev_entry *deve; | 1061 | struct se_dev_entry *deve; |
1234 | ssize_t ret; | 1062 | ssize_t ret; |
@@ -1245,13 +1073,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes( | |||
1245 | rcu_read_unlock(); | 1073 | rcu_read_unlock(); |
1246 | return ret; | 1074 | return ret; |
1247 | } | 1075 | } |
1248 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes); | ||
1249 | 1076 | ||
1250 | static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds( | 1077 | static ssize_t target_stat_auth_hs_num_cmds_show(struct config_item *item, |
1251 | struct se_ml_stat_grps *lgrps, char *page) | 1078 | char *page) |
1252 | { | 1079 | { |
1253 | struct se_lun_acl *lacl = container_of(lgrps, | 1080 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1254 | struct se_lun_acl, ml_stat_grps); | ||
1255 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1081 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1256 | struct se_dev_entry *deve; | 1082 | struct se_dev_entry *deve; |
1257 | ssize_t ret; | 1083 | ssize_t ret; |
@@ -1267,13 +1093,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds( | |||
1267 | rcu_read_unlock(); | 1093 | rcu_read_unlock(); |
1268 | return ret; | 1094 | return ret; |
1269 | } | 1095 | } |
1270 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds); | ||
1271 | 1096 | ||
1272 | static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time( | 1097 | static ssize_t target_stat_auth_creation_time_show(struct config_item *item, |
1273 | struct se_ml_stat_grps *lgrps, char *page) | 1098 | char *page) |
1274 | { | 1099 | { |
1275 | struct se_lun_acl *lacl = container_of(lgrps, | 1100 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1276 | struct se_lun_acl, ml_stat_grps); | ||
1277 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1101 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1278 | struct se_dev_entry *deve; | 1102 | struct se_dev_entry *deve; |
1279 | ssize_t ret; | 1103 | ssize_t ret; |
@@ -1290,13 +1114,11 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time( | |||
1290 | rcu_read_unlock(); | 1114 | rcu_read_unlock(); |
1291 | return ret; | 1115 | return ret; |
1292 | } | 1116 | } |
1293 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time); | ||
1294 | 1117 | ||
1295 | static ssize_t target_stat_scsi_auth_intr_show_attr_row_status( | 1118 | static ssize_t target_stat_auth_row_status_show(struct config_item *item, |
1296 | struct se_ml_stat_grps *lgrps, char *page) | 1119 | char *page) |
1297 | { | 1120 | { |
1298 | struct se_lun_acl *lacl = container_of(lgrps, | 1121 | struct se_lun_acl *lacl = auth_to_lacl(item); |
1299 | struct se_lun_acl, ml_stat_grps); | ||
1300 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1122 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1301 | struct se_dev_entry *deve; | 1123 | struct se_dev_entry *deve; |
1302 | ssize_t ret; | 1124 | ssize_t ret; |
@@ -1312,36 +1134,41 @@ static ssize_t target_stat_scsi_auth_intr_show_attr_row_status( | |||
1312 | rcu_read_unlock(); | 1134 | rcu_read_unlock(); |
1313 | return ret; | 1135 | return ret; |
1314 | } | 1136 | } |
1315 | DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status); | ||
1316 | 1137 | ||
1317 | CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr, se_ml_stat_grps, | 1138 | CONFIGFS_ATTR_RO(target_stat_auth_, inst); |
1318 | scsi_auth_intr_group); | 1139 | CONFIGFS_ATTR_RO(target_stat_auth_, dev); |
1140 | CONFIGFS_ATTR_RO(target_stat_auth_, port); | ||
1141 | CONFIGFS_ATTR_RO(target_stat_auth_, indx); | ||
1142 | CONFIGFS_ATTR_RO(target_stat_auth_, dev_or_port); | ||
1143 | CONFIGFS_ATTR_RO(target_stat_auth_, intr_name); | ||
1144 | CONFIGFS_ATTR_RO(target_stat_auth_, map_indx); | ||
1145 | CONFIGFS_ATTR_RO(target_stat_auth_, att_count); | ||
1146 | CONFIGFS_ATTR_RO(target_stat_auth_, num_cmds); | ||
1147 | CONFIGFS_ATTR_RO(target_stat_auth_, read_mbytes); | ||
1148 | CONFIGFS_ATTR_RO(target_stat_auth_, write_mbytes); | ||
1149 | CONFIGFS_ATTR_RO(target_stat_auth_, hs_num_cmds); | ||
1150 | CONFIGFS_ATTR_RO(target_stat_auth_, creation_time); | ||
1151 | CONFIGFS_ATTR_RO(target_stat_auth_, row_status); | ||
1319 | 1152 | ||
1320 | static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = { | 1153 | static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = { |
1321 | &target_stat_scsi_auth_intr_inst.attr, | 1154 | &target_stat_auth_attr_inst, |
1322 | &target_stat_scsi_auth_intr_dev.attr, | 1155 | &target_stat_auth_attr_dev, |
1323 | &target_stat_scsi_auth_intr_port.attr, | 1156 | &target_stat_auth_attr_port, |
1324 | &target_stat_scsi_auth_intr_indx.attr, | 1157 | &target_stat_auth_attr_indx, |
1325 | &target_stat_scsi_auth_intr_dev_or_port.attr, | 1158 | &target_stat_auth_attr_dev_or_port, |
1326 | &target_stat_scsi_auth_intr_intr_name.attr, | 1159 | &target_stat_auth_attr_intr_name, |
1327 | &target_stat_scsi_auth_intr_map_indx.attr, | 1160 | &target_stat_auth_attr_map_indx, |
1328 | &target_stat_scsi_auth_intr_att_count.attr, | 1161 | &target_stat_auth_attr_att_count, |
1329 | &target_stat_scsi_auth_intr_num_cmds.attr, | 1162 | &target_stat_auth_attr_num_cmds, |
1330 | &target_stat_scsi_auth_intr_read_mbytes.attr, | 1163 | &target_stat_auth_attr_read_mbytes, |
1331 | &target_stat_scsi_auth_intr_write_mbytes.attr, | 1164 | &target_stat_auth_attr_write_mbytes, |
1332 | &target_stat_scsi_auth_intr_hs_num_cmds.attr, | 1165 | &target_stat_auth_attr_hs_num_cmds, |
1333 | &target_stat_scsi_auth_intr_creation_time.attr, | 1166 | &target_stat_auth_attr_creation_time, |
1334 | &target_stat_scsi_auth_intr_row_status.attr, | 1167 | &target_stat_auth_attr_row_status, |
1335 | NULL, | 1168 | NULL, |
1336 | }; | 1169 | }; |
1337 | 1170 | ||
1338 | static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops = { | ||
1339 | .show_attribute = target_stat_scsi_auth_intr_attr_show, | ||
1340 | .store_attribute = target_stat_scsi_auth_intr_attr_store, | ||
1341 | }; | ||
1342 | |||
1343 | static struct config_item_type target_stat_scsi_auth_intr_cit = { | 1171 | static struct config_item_type target_stat_scsi_auth_intr_cit = { |
1344 | .ct_item_ops = &target_stat_scsi_auth_intr_attrib_ops, | ||
1345 | .ct_attrs = target_stat_scsi_auth_intr_attrs, | 1172 | .ct_attrs = target_stat_scsi_auth_intr_attrs, |
1346 | .ct_owner = THIS_MODULE, | 1173 | .ct_owner = THIS_MODULE, |
1347 | }; | 1174 | }; |
@@ -1350,25 +1177,17 @@ static struct config_item_type target_stat_scsi_auth_intr_cit = { | |||
1350 | * SCSI Attached Initiator Port Table | 1177 | * SCSI Attached Initiator Port Table |
1351 | */ | 1178 | */ |
1352 | 1179 | ||
1353 | CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port, se_ml_stat_grps); | 1180 | static struct se_lun_acl *iport_to_lacl(struct config_item *item) |
1354 | #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \ | 1181 | { |
1355 | static struct target_stat_scsi_att_intr_port_attribute \ | 1182 | struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), |
1356 | target_stat_scsi_att_intr_port_##_name = \ | 1183 | struct se_ml_stat_grps, scsi_att_intr_port_group); |
1357 | __CONFIGFS_EATTR(_name, _mode, \ | 1184 | return container_of(lgrps, struct se_lun_acl, ml_stat_grps); |
1358 | target_stat_scsi_att_intr_port_show_attr_##_name, \ | 1185 | } |
1359 | target_stat_scsi_att_intr_port_store_attr_##_name); | 1186 | |
1360 | 1187 | static ssize_t target_stat_iport_inst_show(struct config_item *item, | |
1361 | #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \ | 1188 | char *page) |
1362 | static struct target_stat_scsi_att_intr_port_attribute \ | 1189 | { |
1363 | target_stat_scsi_att_intr_port_##_name = \ | 1190 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1364 | __CONFIGFS_EATTR_RO(_name, \ | ||
1365 | target_stat_scsi_att_intr_port_show_attr_##_name); | ||
1366 | |||
1367 | static ssize_t target_stat_scsi_att_intr_port_show_attr_inst( | ||
1368 | struct se_ml_stat_grps *lgrps, char *page) | ||
1369 | { | ||
1370 | struct se_lun_acl *lacl = container_of(lgrps, | ||
1371 | struct se_lun_acl, ml_stat_grps); | ||
1372 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1191 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1373 | struct se_dev_entry *deve; | 1192 | struct se_dev_entry *deve; |
1374 | struct se_portal_group *tpg; | 1193 | struct se_portal_group *tpg; |
@@ -1387,13 +1206,11 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_inst( | |||
1387 | rcu_read_unlock(); | 1206 | rcu_read_unlock(); |
1388 | return ret; | 1207 | return ret; |
1389 | } | 1208 | } |
1390 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst); | ||
1391 | 1209 | ||
1392 | static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( | 1210 | static ssize_t target_stat_iport_dev_show(struct config_item *item, |
1393 | struct se_ml_stat_grps *lgrps, char *page) | 1211 | char *page) |
1394 | { | 1212 | { |
1395 | struct se_lun_acl *lacl = container_of(lgrps, | 1213 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1396 | struct se_lun_acl, ml_stat_grps); | ||
1397 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1214 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1398 | struct se_dev_entry *deve; | 1215 | struct se_dev_entry *deve; |
1399 | struct se_lun *lun; | 1216 | struct se_lun *lun; |
@@ -1411,13 +1228,11 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( | |||
1411 | rcu_read_unlock(); | 1228 | rcu_read_unlock(); |
1412 | return ret; | 1229 | return ret; |
1413 | } | 1230 | } |
1414 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev); | ||
1415 | 1231 | ||
1416 | static ssize_t target_stat_scsi_att_intr_port_show_attr_port( | 1232 | static ssize_t target_stat_iport_port_show(struct config_item *item, |
1417 | struct se_ml_stat_grps *lgrps, char *page) | 1233 | char *page) |
1418 | { | 1234 | { |
1419 | struct se_lun_acl *lacl = container_of(lgrps, | 1235 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1420 | struct se_lun_acl, ml_stat_grps); | ||
1421 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1236 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1422 | struct se_dev_entry *deve; | 1237 | struct se_dev_entry *deve; |
1423 | struct se_portal_group *tpg; | 1238 | struct se_portal_group *tpg; |
@@ -1435,13 +1250,11 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port( | |||
1435 | rcu_read_unlock(); | 1250 | rcu_read_unlock(); |
1436 | return ret; | 1251 | return ret; |
1437 | } | 1252 | } |
1438 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port); | ||
1439 | 1253 | ||
1440 | static ssize_t target_stat_scsi_att_intr_port_show_attr_indx( | 1254 | static ssize_t target_stat_iport_indx_show(struct config_item *item, |
1441 | struct se_ml_stat_grps *lgrps, char *page) | 1255 | char *page) |
1442 | { | 1256 | { |
1443 | struct se_lun_acl *lacl = container_of(lgrps, | 1257 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1444 | struct se_lun_acl, ml_stat_grps); | ||
1445 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1258 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1446 | struct se_session *se_sess; | 1259 | struct se_session *se_sess; |
1447 | struct se_portal_group *tpg; | 1260 | struct se_portal_group *tpg; |
@@ -1461,13 +1274,11 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_indx( | |||
1461 | spin_unlock_irq(&nacl->nacl_sess_lock); | 1274 | spin_unlock_irq(&nacl->nacl_sess_lock); |
1462 | return ret; | 1275 | return ret; |
1463 | } | 1276 | } |
1464 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx); | ||
1465 | 1277 | ||
1466 | static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx( | 1278 | static ssize_t target_stat_iport_port_auth_indx_show(struct config_item *item, |
1467 | struct se_ml_stat_grps *lgrps, char *page) | 1279 | char *page) |
1468 | { | 1280 | { |
1469 | struct se_lun_acl *lacl = container_of(lgrps, | 1281 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1470 | struct se_lun_acl, ml_stat_grps); | ||
1471 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1282 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1472 | struct se_dev_entry *deve; | 1283 | struct se_dev_entry *deve; |
1473 | ssize_t ret; | 1284 | ssize_t ret; |
@@ -1483,13 +1294,11 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx( | |||
1483 | rcu_read_unlock(); | 1294 | rcu_read_unlock(); |
1484 | return ret; | 1295 | return ret; |
1485 | } | 1296 | } |
1486 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx); | ||
1487 | 1297 | ||
1488 | static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident( | 1298 | static ssize_t target_stat_iport_port_ident_show(struct config_item *item, |
1489 | struct se_ml_stat_grps *lgrps, char *page) | 1299 | char *page) |
1490 | { | 1300 | { |
1491 | struct se_lun_acl *lacl = container_of(lgrps, | 1301 | struct se_lun_acl *lacl = iport_to_lacl(item); |
1492 | struct se_lun_acl, ml_stat_grps); | ||
1493 | struct se_node_acl *nacl = lacl->se_lun_nacl; | 1302 | struct se_node_acl *nacl = lacl->se_lun_nacl; |
1494 | struct se_session *se_sess; | 1303 | struct se_session *se_sess; |
1495 | struct se_portal_group *tpg; | 1304 | struct se_portal_group *tpg; |
@@ -1513,28 +1322,25 @@ static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident( | |||
1513 | spin_unlock_irq(&nacl->nacl_sess_lock); | 1322 | spin_unlock_irq(&nacl->nacl_sess_lock); |
1514 | return ret; | 1323 | return ret; |
1515 | } | 1324 | } |
1516 | DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident); | ||
1517 | 1325 | ||
1518 | CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port, se_ml_stat_grps, | 1326 | CONFIGFS_ATTR_RO(target_stat_iport_, inst); |
1519 | scsi_att_intr_port_group); | 1327 | CONFIGFS_ATTR_RO(target_stat_iport_, dev); |
1328 | CONFIGFS_ATTR_RO(target_stat_iport_, port); | ||
1329 | CONFIGFS_ATTR_RO(target_stat_iport_, indx); | ||
1330 | CONFIGFS_ATTR_RO(target_stat_iport_, port_auth_indx); | ||
1331 | CONFIGFS_ATTR_RO(target_stat_iport_, port_ident); | ||
1520 | 1332 | ||
1521 | static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = { | 1333 | static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = { |
1522 | &target_stat_scsi_att_intr_port_inst.attr, | 1334 | &target_stat_iport_attr_inst, |
1523 | &target_stat_scsi_att_intr_port_dev.attr, | 1335 | &target_stat_iport_attr_dev, |
1524 | &target_stat_scsi_att_intr_port_port.attr, | 1336 | &target_stat_iport_attr_port, |
1525 | &target_stat_scsi_att_intr_port_indx.attr, | 1337 | &target_stat_iport_attr_indx, |
1526 | &target_stat_scsi_att_intr_port_port_auth_indx.attr, | 1338 | &target_stat_iport_attr_port_auth_indx, |
1527 | &target_stat_scsi_att_intr_port_port_ident.attr, | 1339 | &target_stat_iport_attr_port_ident, |
1528 | NULL, | 1340 | NULL, |
1529 | }; | 1341 | }; |
1530 | 1342 | ||
1531 | static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops = { | ||
1532 | .show_attribute = target_stat_scsi_att_intr_port_attr_show, | ||
1533 | .store_attribute = target_stat_scsi_att_intr_port_attr_store, | ||
1534 | }; | ||
1535 | |||
1536 | static struct config_item_type target_stat_scsi_att_intr_port_cit = { | 1343 | static struct config_item_type target_stat_scsi_att_intr_port_cit = { |
1537 | .ct_item_ops = &target_stat_scsi_att_intr_port_attrib_ops, | ||
1538 | .ct_attrs = target_stat_scsi_ath_intr_port_attrs, | 1344 | .ct_attrs = target_stat_scsi_ath_intr_port_attrs, |
1539 | .ct_owner = THIS_MODULE, | 1345 | .ct_owner = THIS_MODULE, |
1540 | }; | 1346 | }; |
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c index aa3caca8bace..064d6dfb5b6d 100644 --- a/drivers/target/tcm_fc/tfc_cmd.c +++ b/drivers/target/tcm_fc/tfc_cmd.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <target/target_core_base.h> | 37 | #include <target/target_core_base.h> |
38 | #include <target/target_core_fabric.h> | 38 | #include <target/target_core_fabric.h> |
39 | #include <target/configfs_macros.h> | ||
40 | 39 | ||
41 | #include "tcm_fc.h" | 40 | #include "tcm_fc.h" |
42 | 41 | ||
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 16670933013b..85aeaa0ad303 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #include <target/target_core_base.h> | 39 | #include <target/target_core_base.h> |
40 | #include <target/target_core_fabric.h> | 40 | #include <target/target_core_fabric.h> |
41 | #include <target/target_core_fabric_configfs.h> | ||
42 | #include <target/configfs_macros.h> | ||
43 | 41 | ||
44 | #include "tcm_fc.h" | 42 | #include "tcm_fc.h" |
45 | 43 | ||
@@ -131,55 +129,51 @@ static ssize_t ft_wwn_store(void *arg, const char *buf, size_t len) | |||
131 | * ACL auth ops. | 129 | * ACL auth ops. |
132 | */ | 130 | */ |
133 | 131 | ||
134 | static ssize_t ft_nacl_show_port_name( | 132 | static ssize_t ft_nacl_port_name_show(struct config_item *item, char *page) |
135 | struct se_node_acl *se_nacl, | ||
136 | char *page) | ||
137 | { | 133 | { |
134 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
138 | struct ft_node_acl *acl = container_of(se_nacl, | 135 | struct ft_node_acl *acl = container_of(se_nacl, |
139 | struct ft_node_acl, se_node_acl); | 136 | struct ft_node_acl, se_node_acl); |
140 | 137 | ||
141 | return ft_wwn_show(&acl->node_auth.port_name, page); | 138 | return ft_wwn_show(&acl->node_auth.port_name, page); |
142 | } | 139 | } |
143 | 140 | ||
144 | static ssize_t ft_nacl_store_port_name( | 141 | static ssize_t ft_nacl_port_name_store(struct config_item *item, |
145 | struct se_node_acl *se_nacl, | 142 | const char *page, size_t count) |
146 | const char *page, | ||
147 | size_t count) | ||
148 | { | 143 | { |
144 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
149 | struct ft_node_acl *acl = container_of(se_nacl, | 145 | struct ft_node_acl *acl = container_of(se_nacl, |
150 | struct ft_node_acl, se_node_acl); | 146 | struct ft_node_acl, se_node_acl); |
151 | 147 | ||
152 | return ft_wwn_store(&acl->node_auth.port_name, page, count); | 148 | return ft_wwn_store(&acl->node_auth.port_name, page, count); |
153 | } | 149 | } |
154 | 150 | ||
155 | TF_NACL_BASE_ATTR(ft, port_name, S_IRUGO | S_IWUSR); | 151 | static ssize_t ft_nacl_node_name_show(struct config_item *item, |
156 | 152 | char *page) | |
157 | static ssize_t ft_nacl_show_node_name( | ||
158 | struct se_node_acl *se_nacl, | ||
159 | char *page) | ||
160 | { | 153 | { |
154 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
161 | struct ft_node_acl *acl = container_of(se_nacl, | 155 | struct ft_node_acl *acl = container_of(se_nacl, |
162 | struct ft_node_acl, se_node_acl); | 156 | struct ft_node_acl, se_node_acl); |
163 | 157 | ||
164 | return ft_wwn_show(&acl->node_auth.node_name, page); | 158 | return ft_wwn_show(&acl->node_auth.node_name, page); |
165 | } | 159 | } |
166 | 160 | ||
167 | static ssize_t ft_nacl_store_node_name( | 161 | static ssize_t ft_nacl_node_name_store(struct config_item *item, |
168 | struct se_node_acl *se_nacl, | 162 | const char *page, size_t count) |
169 | const char *page, | ||
170 | size_t count) | ||
171 | { | 163 | { |
164 | struct se_node_acl *se_nacl = acl_to_nacl(item); | ||
172 | struct ft_node_acl *acl = container_of(se_nacl, | 165 | struct ft_node_acl *acl = container_of(se_nacl, |
173 | struct ft_node_acl, se_node_acl); | 166 | struct ft_node_acl, se_node_acl); |
174 | 167 | ||
175 | return ft_wwn_store(&acl->node_auth.node_name, page, count); | 168 | return ft_wwn_store(&acl->node_auth.node_name, page, count); |
176 | } | 169 | } |
177 | 170 | ||
178 | TF_NACL_BASE_ATTR(ft, node_name, S_IRUGO | S_IWUSR); | 171 | CONFIGFS_ATTR(ft_nacl_, node_name); |
172 | CONFIGFS_ATTR(ft_nacl_, port_name); | ||
179 | 173 | ||
180 | static struct configfs_attribute *ft_nacl_base_attrs[] = { | 174 | static struct configfs_attribute *ft_nacl_base_attrs[] = { |
181 | &ft_nacl_port_name.attr, | 175 | &ft_nacl_attr_port_name, |
182 | &ft_nacl_node_name.attr, | 176 | &ft_nacl_attr_node_name, |
183 | NULL, | 177 | NULL, |
184 | }; | 178 | }; |
185 | 179 | ||
@@ -386,18 +380,16 @@ static void ft_del_wwn(struct se_wwn *wwn) | |||
386 | kfree(ft_wwn); | 380 | kfree(ft_wwn); |
387 | } | 381 | } |
388 | 382 | ||
389 | static ssize_t ft_wwn_show_attr_version( | 383 | static ssize_t ft_wwn_version_show(struct config_item *item, char *page) |
390 | struct target_fabric_configfs *tf, | ||
391 | char *page) | ||
392 | { | 384 | { |
393 | return sprintf(page, "TCM FC " FT_VERSION " on %s/%s on " | 385 | return sprintf(page, "TCM FC " FT_VERSION " on %s/%s on " |
394 | ""UTS_RELEASE"\n", utsname()->sysname, utsname()->machine); | 386 | ""UTS_RELEASE"\n", utsname()->sysname, utsname()->machine); |
395 | } | 387 | } |
396 | 388 | ||
397 | TF_WWN_ATTR_RO(ft, version); | 389 | CONFIGFS_ATTR_RO(ft_wwn_, version); |
398 | 390 | ||
399 | static struct configfs_attribute *ft_wwn_attrs[] = { | 391 | static struct configfs_attribute *ft_wwn_attrs[] = { |
400 | &ft_wwn_version.attr, | 392 | &ft_wwn_attr_version, |
401 | NULL, | 393 | NULL, |
402 | }; | 394 | }; |
403 | 395 | ||
diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c index 4b0fedd6bd4b..847c1aa6fbf4 100644 --- a/drivers/target/tcm_fc/tfc_io.c +++ b/drivers/target/tcm_fc/tfc_io.c | |||
@@ -44,7 +44,6 @@ | |||
44 | 44 | ||
45 | #include <target/target_core_base.h> | 45 | #include <target/target_core_base.h> |
46 | #include <target/target_core_fabric.h> | 46 | #include <target/target_core_fabric.h> |
47 | #include <target/configfs_macros.h> | ||
48 | 47 | ||
49 | #include "tcm_fc.h" | 48 | #include "tcm_fc.h" |
50 | 49 | ||
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 31a9e3fb98c5..7b934eac995d 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c | |||
@@ -36,7 +36,6 @@ | |||
36 | 36 | ||
37 | #include <target/target_core_base.h> | 37 | #include <target/target_core_base.h> |
38 | #include <target/target_core_fabric.h> | 38 | #include <target/target_core_fabric.h> |
39 | #include <target/configfs_macros.h> | ||
40 | 39 | ||
41 | #include "tcm_fc.h" | 40 | #include "tcm_fc.h" |
42 | 41 | ||
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 294eb74fb078..163d305e1200 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c | |||
@@ -64,6 +64,11 @@ struct gadget_info { | |||
64 | char qw_sign[OS_STRING_QW_SIGN_LEN]; | 64 | char qw_sign[OS_STRING_QW_SIGN_LEN]; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static inline struct gadget_info *to_gadget_info(struct config_item *item) | ||
68 | { | ||
69 | return container_of(to_config_group(item), struct gadget_info, group); | ||
70 | } | ||
71 | |||
67 | struct config_usb_cfg { | 72 | struct config_usb_cfg { |
68 | struct config_group group; | 73 | struct config_group group; |
69 | struct config_group strings_group; | 74 | struct config_group strings_group; |
@@ -74,6 +79,12 @@ struct config_usb_cfg { | |||
74 | struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1]; | 79 | struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1]; |
75 | }; | 80 | }; |
76 | 81 | ||
82 | static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item) | ||
83 | { | ||
84 | return container_of(to_config_group(item), struct config_usb_cfg, | ||
85 | group); | ||
86 | } | ||
87 | |||
77 | struct gadget_strings { | 88 | struct gadget_strings { |
78 | struct usb_gadget_strings stringtab_dev; | 89 | struct usb_gadget_strings stringtab_dev; |
79 | struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX]; | 90 | struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX]; |
@@ -117,32 +128,25 @@ static int usb_string_copy(const char *s, char **s_copy) | |||
117 | return 0; | 128 | return 0; |
118 | } | 129 | } |
119 | 130 | ||
120 | CONFIGFS_ATTR_STRUCT(gadget_info); | ||
121 | CONFIGFS_ATTR_STRUCT(config_usb_cfg); | ||
122 | |||
123 | #define GI_DEVICE_DESC_ITEM_ATTR(name) \ | ||
124 | static struct gadget_info_attribute gadget_cdev_desc_##name = \ | ||
125 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
126 | gadget_dev_desc_##name##_show, \ | ||
127 | gadget_dev_desc_##name##_store) | ||
128 | |||
129 | #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \ | 131 | #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \ |
130 | static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \ | 132 | static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \ |
131 | char *page) \ | 133 | char *page) \ |
132 | { \ | 134 | { \ |
133 | return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \ | 135 | return sprintf(page, "0x%02x\n", \ |
136 | to_gadget_info(item)->cdev.desc.__name); \ | ||
134 | } | 137 | } |
135 | 138 | ||
136 | #define GI_DEVICE_DESC_SIMPLE_R_u16(__name) \ | 139 | #define GI_DEVICE_DESC_SIMPLE_R_u16(__name) \ |
137 | static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \ | 140 | static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \ |
138 | char *page) \ | 141 | char *page) \ |
139 | { \ | 142 | { \ |
140 | return sprintf(page, "0x%04x\n", le16_to_cpup(&gi->cdev.desc.__name)); \ | 143 | return sprintf(page, "0x%04x\n", \ |
144 | le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \ | ||
141 | } | 145 | } |
142 | 146 | ||
143 | 147 | ||
144 | #define GI_DEVICE_DESC_SIMPLE_W_u8(_name) \ | 148 | #define GI_DEVICE_DESC_SIMPLE_W_u8(_name) \ |
145 | static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \ | 149 | static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \ |
146 | const char *page, size_t len) \ | 150 | const char *page, size_t len) \ |
147 | { \ | 151 | { \ |
148 | u8 val; \ | 152 | u8 val; \ |
@@ -150,12 +154,12 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg); | |||
150 | ret = kstrtou8(page, 0, &val); \ | 154 | ret = kstrtou8(page, 0, &val); \ |
151 | if (ret) \ | 155 | if (ret) \ |
152 | return ret; \ | 156 | return ret; \ |
153 | gi->cdev.desc._name = val; \ | 157 | to_gadget_info(item)->cdev.desc._name = val; \ |
154 | return len; \ | 158 | return len; \ |
155 | } | 159 | } |
156 | 160 | ||
157 | #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \ | 161 | #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \ |
158 | static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \ | 162 | static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \ |
159 | const char *page, size_t len) \ | 163 | const char *page, size_t len) \ |
160 | { \ | 164 | { \ |
161 | u16 val; \ | 165 | u16 val; \ |
@@ -163,7 +167,7 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg); | |||
163 | ret = kstrtou16(page, 0, &val); \ | 167 | ret = kstrtou16(page, 0, &val); \ |
164 | if (ret) \ | 168 | if (ret) \ |
165 | return ret; \ | 169 | return ret; \ |
166 | gi->cdev.desc._name = cpu_to_le16p(&val); \ | 170 | to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \ |
167 | return len; \ | 171 | return len; \ |
168 | } | 172 | } |
169 | 173 | ||
@@ -193,7 +197,7 @@ static ssize_t is_valid_bcd(u16 bcd_val) | |||
193 | return 0; | 197 | return 0; |
194 | } | 198 | } |
195 | 199 | ||
196 | static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi, | 200 | static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item, |
197 | const char *page, size_t len) | 201 | const char *page, size_t len) |
198 | { | 202 | { |
199 | u16 bcdDevice; | 203 | u16 bcdDevice; |
@@ -206,11 +210,11 @@ static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi, | |||
206 | if (ret) | 210 | if (ret) |
207 | return ret; | 211 | return ret; |
208 | 212 | ||
209 | gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice); | 213 | to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice); |
210 | return len; | 214 | return len; |
211 | } | 215 | } |
212 | 216 | ||
213 | static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi, | 217 | static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item, |
214 | const char *page, size_t len) | 218 | const char *page, size_t len) |
215 | { | 219 | { |
216 | u16 bcdUSB; | 220 | u16 bcdUSB; |
@@ -223,13 +227,13 @@ static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi, | |||
223 | if (ret) | 227 | if (ret) |
224 | return ret; | 228 | return ret; |
225 | 229 | ||
226 | gi->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB); | 230 | to_gadget_info(item)->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB); |
227 | return len; | 231 | return len; |
228 | } | 232 | } |
229 | 233 | ||
230 | static ssize_t gadget_dev_desc_UDC_show(struct gadget_info *gi, char *page) | 234 | static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page) |
231 | { | 235 | { |
232 | return sprintf(page, "%s\n", gi->udc_name ?: ""); | 236 | return sprintf(page, "%s\n", to_gadget_info(item)->udc_name ?: ""); |
233 | } | 237 | } |
234 | 238 | ||
235 | static int unregister_gadget(struct gadget_info *gi) | 239 | static int unregister_gadget(struct gadget_info *gi) |
@@ -247,9 +251,10 @@ static int unregister_gadget(struct gadget_info *gi) | |||
247 | return 0; | 251 | return 0; |
248 | } | 252 | } |
249 | 253 | ||
250 | static ssize_t gadget_dev_desc_UDC_store(struct gadget_info *gi, | 254 | static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, |
251 | const char *page, size_t len) | 255 | const char *page, size_t len) |
252 | { | 256 | { |
257 | struct gadget_info *gi = to_gadget_info(item); | ||
253 | char *name; | 258 | char *name; |
254 | int ret; | 259 | int ret; |
255 | 260 | ||
@@ -283,34 +288,29 @@ err: | |||
283 | return ret; | 288 | return ret; |
284 | } | 289 | } |
285 | 290 | ||
286 | GI_DEVICE_DESC_ITEM_ATTR(bDeviceClass); | 291 | CONFIGFS_ATTR(gadget_dev_desc_, bDeviceClass); |
287 | GI_DEVICE_DESC_ITEM_ATTR(bDeviceSubClass); | 292 | CONFIGFS_ATTR(gadget_dev_desc_, bDeviceSubClass); |
288 | GI_DEVICE_DESC_ITEM_ATTR(bDeviceProtocol); | 293 | CONFIGFS_ATTR(gadget_dev_desc_, bDeviceProtocol); |
289 | GI_DEVICE_DESC_ITEM_ATTR(bMaxPacketSize0); | 294 | CONFIGFS_ATTR(gadget_dev_desc_, bMaxPacketSize0); |
290 | GI_DEVICE_DESC_ITEM_ATTR(idVendor); | 295 | CONFIGFS_ATTR(gadget_dev_desc_, idVendor); |
291 | GI_DEVICE_DESC_ITEM_ATTR(idProduct); | 296 | CONFIGFS_ATTR(gadget_dev_desc_, idProduct); |
292 | GI_DEVICE_DESC_ITEM_ATTR(bcdDevice); | 297 | CONFIGFS_ATTR(gadget_dev_desc_, bcdDevice); |
293 | GI_DEVICE_DESC_ITEM_ATTR(bcdUSB); | 298 | CONFIGFS_ATTR(gadget_dev_desc_, bcdUSB); |
294 | GI_DEVICE_DESC_ITEM_ATTR(UDC); | 299 | CONFIGFS_ATTR(gadget_dev_desc_, UDC); |
295 | 300 | ||
296 | static struct configfs_attribute *gadget_root_attrs[] = { | 301 | static struct configfs_attribute *gadget_root_attrs[] = { |
297 | &gadget_cdev_desc_bDeviceClass.attr, | 302 | &gadget_dev_desc_attr_bDeviceClass, |
298 | &gadget_cdev_desc_bDeviceSubClass.attr, | 303 | &gadget_dev_desc_attr_bDeviceSubClass, |
299 | &gadget_cdev_desc_bDeviceProtocol.attr, | 304 | &gadget_dev_desc_attr_bDeviceProtocol, |
300 | &gadget_cdev_desc_bMaxPacketSize0.attr, | 305 | &gadget_dev_desc_attr_bMaxPacketSize0, |
301 | &gadget_cdev_desc_idVendor.attr, | 306 | &gadget_dev_desc_attr_idVendor, |
302 | &gadget_cdev_desc_idProduct.attr, | 307 | &gadget_dev_desc_attr_idProduct, |
303 | &gadget_cdev_desc_bcdDevice.attr, | 308 | &gadget_dev_desc_attr_bcdDevice, |
304 | &gadget_cdev_desc_bcdUSB.attr, | 309 | &gadget_dev_desc_attr_bcdUSB, |
305 | &gadget_cdev_desc_UDC.attr, | 310 | &gadget_dev_desc_attr_UDC, |
306 | NULL, | 311 | NULL, |
307 | }; | 312 | }; |
308 | 313 | ||
309 | static inline struct gadget_info *to_gadget_info(struct config_item *item) | ||
310 | { | ||
311 | return container_of(to_config_group(item), struct gadget_info, group); | ||
312 | } | ||
313 | |||
314 | static inline struct gadget_strings *to_gadget_strings(struct config_item *item) | 314 | static inline struct gadget_strings *to_gadget_strings(struct config_item *item) |
315 | { | 315 | { |
316 | return container_of(to_config_group(item), struct gadget_strings, | 316 | return container_of(to_config_group(item), struct gadget_strings, |
@@ -324,12 +324,6 @@ static inline struct gadget_config_name *to_gadget_config_name( | |||
324 | group); | 324 | group); |
325 | } | 325 | } |
326 | 326 | ||
327 | static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item) | ||
328 | { | ||
329 | return container_of(to_config_group(item), struct config_usb_cfg, | ||
330 | group); | ||
331 | } | ||
332 | |||
333 | static inline struct usb_function_instance *to_usb_function_instance( | 327 | static inline struct usb_function_instance *to_usb_function_instance( |
334 | struct config_item *item) | 328 | struct config_item *item) |
335 | { | 329 | { |
@@ -348,12 +342,8 @@ static void gadget_info_attr_release(struct config_item *item) | |||
348 | kfree(gi); | 342 | kfree(gi); |
349 | } | 343 | } |
350 | 344 | ||
351 | CONFIGFS_ATTR_OPS(gadget_info); | ||
352 | |||
353 | static struct configfs_item_operations gadget_root_item_ops = { | 345 | static struct configfs_item_operations gadget_root_item_ops = { |
354 | .release = gadget_info_attr_release, | 346 | .release = gadget_info_attr_release, |
355 | .show_attribute = gadget_info_attr_show, | ||
356 | .store_attribute = gadget_info_attr_store, | ||
357 | }; | 347 | }; |
358 | 348 | ||
359 | static void gadget_config_attr_release(struct config_item *item) | 349 | static void gadget_config_attr_release(struct config_item *item) |
@@ -454,24 +444,20 @@ static int config_usb_cfg_unlink( | |||
454 | return 0; | 444 | return 0; |
455 | } | 445 | } |
456 | 446 | ||
457 | CONFIGFS_ATTR_OPS(config_usb_cfg); | ||
458 | |||
459 | static struct configfs_item_operations gadget_config_item_ops = { | 447 | static struct configfs_item_operations gadget_config_item_ops = { |
460 | .release = gadget_config_attr_release, | 448 | .release = gadget_config_attr_release, |
461 | .show_attribute = config_usb_cfg_attr_show, | ||
462 | .store_attribute = config_usb_cfg_attr_store, | ||
463 | .allow_link = config_usb_cfg_link, | 449 | .allow_link = config_usb_cfg_link, |
464 | .drop_link = config_usb_cfg_unlink, | 450 | .drop_link = config_usb_cfg_unlink, |
465 | }; | 451 | }; |
466 | 452 | ||
467 | 453 | ||
468 | static ssize_t gadget_config_desc_MaxPower_show(struct config_usb_cfg *cfg, | 454 | static ssize_t gadget_config_desc_MaxPower_show(struct config_item *item, |
469 | char *page) | 455 | char *page) |
470 | { | 456 | { |
471 | return sprintf(page, "%u\n", cfg->c.MaxPower); | 457 | return sprintf(page, "%u\n", to_config_usb_cfg(item)->c.MaxPower); |
472 | } | 458 | } |
473 | 459 | ||
474 | static ssize_t gadget_config_desc_MaxPower_store(struct config_usb_cfg *cfg, | 460 | static ssize_t gadget_config_desc_MaxPower_store(struct config_item *item, |
475 | const char *page, size_t len) | 461 | const char *page, size_t len) |
476 | { | 462 | { |
477 | u16 val; | 463 | u16 val; |
@@ -481,17 +467,18 @@ static ssize_t gadget_config_desc_MaxPower_store(struct config_usb_cfg *cfg, | |||
481 | return ret; | 467 | return ret; |
482 | if (DIV_ROUND_UP(val, 8) > 0xff) | 468 | if (DIV_ROUND_UP(val, 8) > 0xff) |
483 | return -ERANGE; | 469 | return -ERANGE; |
484 | cfg->c.MaxPower = val; | 470 | to_config_usb_cfg(item)->c.MaxPower = val; |
485 | return len; | 471 | return len; |
486 | } | 472 | } |
487 | 473 | ||
488 | static ssize_t gadget_config_desc_bmAttributes_show(struct config_usb_cfg *cfg, | 474 | static ssize_t gadget_config_desc_bmAttributes_show(struct config_item *item, |
489 | char *page) | 475 | char *page) |
490 | { | 476 | { |
491 | return sprintf(page, "0x%02x\n", cfg->c.bmAttributes); | 477 | return sprintf(page, "0x%02x\n", |
478 | to_config_usb_cfg(item)->c.bmAttributes); | ||
492 | } | 479 | } |
493 | 480 | ||
494 | static ssize_t gadget_config_desc_bmAttributes_store(struct config_usb_cfg *cfg, | 481 | static ssize_t gadget_config_desc_bmAttributes_store(struct config_item *item, |
495 | const char *page, size_t len) | 482 | const char *page, size_t len) |
496 | { | 483 | { |
497 | u8 val; | 484 | u8 val; |
@@ -504,22 +491,16 @@ static ssize_t gadget_config_desc_bmAttributes_store(struct config_usb_cfg *cfg, | |||
504 | if (val & ~(USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER | | 491 | if (val & ~(USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER | |
505 | USB_CONFIG_ATT_WAKEUP)) | 492 | USB_CONFIG_ATT_WAKEUP)) |
506 | return -EINVAL; | 493 | return -EINVAL; |
507 | cfg->c.bmAttributes = val; | 494 | to_config_usb_cfg(item)->c.bmAttributes = val; |
508 | return len; | 495 | return len; |
509 | } | 496 | } |
510 | 497 | ||
511 | #define CFG_CONFIG_DESC_ITEM_ATTR(name) \ | 498 | CONFIGFS_ATTR(gadget_config_desc_, MaxPower); |
512 | static struct config_usb_cfg_attribute gadget_usb_cfg_##name = \ | 499 | CONFIGFS_ATTR(gadget_config_desc_, bmAttributes); |
513 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
514 | gadget_config_desc_##name##_show, \ | ||
515 | gadget_config_desc_##name##_store) | ||
516 | |||
517 | CFG_CONFIG_DESC_ITEM_ATTR(MaxPower); | ||
518 | CFG_CONFIG_DESC_ITEM_ATTR(bmAttributes); | ||
519 | 500 | ||
520 | static struct configfs_attribute *gadget_config_attrs[] = { | 501 | static struct configfs_attribute *gadget_config_attrs[] = { |
521 | &gadget_usb_cfg_MaxPower.attr, | 502 | &gadget_config_desc_attr_MaxPower, |
522 | &gadget_usb_cfg_bmAttributes.attr, | 503 | &gadget_config_desc_attr_bmAttributes, |
523 | NULL, | 504 | NULL, |
524 | }; | 505 | }; |
525 | 506 | ||
@@ -616,11 +597,10 @@ static struct config_item_type functions_type = { | |||
616 | .ct_owner = THIS_MODULE, | 597 | .ct_owner = THIS_MODULE, |
617 | }; | 598 | }; |
618 | 599 | ||
619 | CONFIGFS_ATTR_STRUCT(gadget_config_name); | ||
620 | GS_STRINGS_RW(gadget_config_name, configuration); | 600 | GS_STRINGS_RW(gadget_config_name, configuration); |
621 | 601 | ||
622 | static struct configfs_attribute *gadget_config_name_langid_attrs[] = { | 602 | static struct configfs_attribute *gadget_config_name_langid_attrs[] = { |
623 | &gadget_config_name_configuration.attr, | 603 | &gadget_config_name_attr_configuration, |
624 | NULL, | 604 | NULL, |
625 | }; | 605 | }; |
626 | 606 | ||
@@ -719,15 +699,14 @@ static struct config_item_type config_desc_type = { | |||
719 | .ct_owner = THIS_MODULE, | 699 | .ct_owner = THIS_MODULE, |
720 | }; | 700 | }; |
721 | 701 | ||
722 | CONFIGFS_ATTR_STRUCT(gadget_strings); | ||
723 | GS_STRINGS_RW(gadget_strings, manufacturer); | 702 | GS_STRINGS_RW(gadget_strings, manufacturer); |
724 | GS_STRINGS_RW(gadget_strings, product); | 703 | GS_STRINGS_RW(gadget_strings, product); |
725 | GS_STRINGS_RW(gadget_strings, serialnumber); | 704 | GS_STRINGS_RW(gadget_strings, serialnumber); |
726 | 705 | ||
727 | static struct configfs_attribute *gadget_strings_langid_attrs[] = { | 706 | static struct configfs_attribute *gadget_strings_langid_attrs[] = { |
728 | &gadget_strings_manufacturer.attr, | 707 | &gadget_strings_attr_manufacturer, |
729 | &gadget_strings_product.attr, | 708 | &gadget_strings_attr_product, |
730 | &gadget_strings_serialnumber.attr, | 709 | &gadget_strings_attr_serialnumber, |
731 | NULL, | 710 | NULL, |
732 | }; | 711 | }; |
733 | 712 | ||
@@ -751,27 +730,25 @@ static inline struct os_desc *to_os_desc(struct config_item *item) | |||
751 | return container_of(to_config_group(item), struct os_desc, group); | 730 | return container_of(to_config_group(item), struct os_desc, group); |
752 | } | 731 | } |
753 | 732 | ||
754 | CONFIGFS_ATTR_STRUCT(os_desc); | 733 | static inline struct gadget_info *os_desc_item_to_gadget_info( |
755 | CONFIGFS_ATTR_OPS(os_desc); | 734 | struct config_item *item) |
756 | |||
757 | static ssize_t os_desc_use_show(struct os_desc *os_desc, char *page) | ||
758 | { | 735 | { |
759 | struct gadget_info *gi; | 736 | return to_gadget_info(to_os_desc(item)->group.cg_item.ci_parent); |
760 | 737 | } | |
761 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
762 | 738 | ||
763 | return sprintf(page, "%d", gi->use_os_desc); | 739 | static ssize_t os_desc_use_show(struct config_item *item, char *page) |
740 | { | ||
741 | return sprintf(page, "%d", | ||
742 | os_desc_item_to_gadget_info(item)->use_os_desc); | ||
764 | } | 743 | } |
765 | 744 | ||
766 | static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page, | 745 | static ssize_t os_desc_use_store(struct config_item *item, const char *page, |
767 | size_t len) | 746 | size_t len) |
768 | { | 747 | { |
769 | struct gadget_info *gi; | 748 | struct gadget_info *gi = os_desc_item_to_gadget_info(item); |
770 | int ret; | 749 | int ret; |
771 | bool use; | 750 | bool use; |
772 | 751 | ||
773 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
774 | |||
775 | mutex_lock(&gi->lock); | 752 | mutex_lock(&gi->lock); |
776 | ret = strtobool(page, &use); | 753 | ret = strtobool(page, &use); |
777 | if (!ret) { | 754 | if (!ret) { |
@@ -783,29 +760,19 @@ static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page, | |||
783 | return ret; | 760 | return ret; |
784 | } | 761 | } |
785 | 762 | ||
786 | static struct os_desc_attribute os_desc_use = | 763 | static ssize_t os_desc_b_vendor_code_show(struct config_item *item, char *page) |
787 | __CONFIGFS_ATTR(use, S_IRUGO | S_IWUSR, | ||
788 | os_desc_use_show, | ||
789 | os_desc_use_store); | ||
790 | |||
791 | static ssize_t os_desc_b_vendor_code_show(struct os_desc *os_desc, char *page) | ||
792 | { | 764 | { |
793 | struct gadget_info *gi; | 765 | return sprintf(page, "%d", |
794 | 766 | os_desc_item_to_gadget_info(item)->b_vendor_code); | |
795 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
796 | |||
797 | return sprintf(page, "%d", gi->b_vendor_code); | ||
798 | } | 767 | } |
799 | 768 | ||
800 | static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc, | 769 | static ssize_t os_desc_b_vendor_code_store(struct config_item *item, |
801 | const char *page, size_t len) | 770 | const char *page, size_t len) |
802 | { | 771 | { |
803 | struct gadget_info *gi; | 772 | struct gadget_info *gi = os_desc_item_to_gadget_info(item); |
804 | int ret; | 773 | int ret; |
805 | u8 b_vendor_code; | 774 | u8 b_vendor_code; |
806 | 775 | ||
807 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
808 | |||
809 | mutex_lock(&gi->lock); | 776 | mutex_lock(&gi->lock); |
810 | ret = kstrtou8(page, 0, &b_vendor_code); | 777 | ret = kstrtou8(page, 0, &b_vendor_code); |
811 | if (!ret) { | 778 | if (!ret) { |
@@ -817,29 +784,20 @@ static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc, | |||
817 | return ret; | 784 | return ret; |
818 | } | 785 | } |
819 | 786 | ||
820 | static struct os_desc_attribute os_desc_b_vendor_code = | 787 | static ssize_t os_desc_qw_sign_show(struct config_item *item, char *page) |
821 | __CONFIGFS_ATTR(b_vendor_code, S_IRUGO | S_IWUSR, | ||
822 | os_desc_b_vendor_code_show, | ||
823 | os_desc_b_vendor_code_store); | ||
824 | |||
825 | static ssize_t os_desc_qw_sign_show(struct os_desc *os_desc, char *page) | ||
826 | { | 788 | { |
827 | struct gadget_info *gi; | 789 | struct gadget_info *gi = os_desc_item_to_gadget_info(item); |
828 | |||
829 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
830 | 790 | ||
831 | memcpy(page, gi->qw_sign, OS_STRING_QW_SIGN_LEN); | 791 | memcpy(page, gi->qw_sign, OS_STRING_QW_SIGN_LEN); |
832 | |||
833 | return OS_STRING_QW_SIGN_LEN; | 792 | return OS_STRING_QW_SIGN_LEN; |
834 | } | 793 | } |
835 | 794 | ||
836 | static ssize_t os_desc_qw_sign_store(struct os_desc *os_desc, const char *page, | 795 | static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page, |
837 | size_t len) | 796 | size_t len) |
838 | { | 797 | { |
839 | struct gadget_info *gi; | 798 | struct gadget_info *gi = os_desc_item_to_gadget_info(item); |
840 | int res, l; | 799 | int res, l; |
841 | 800 | ||
842 | gi = to_gadget_info(os_desc->group.cg_item.ci_parent); | ||
843 | l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1); | 801 | l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1); |
844 | if (page[l - 1] == '\n') | 802 | if (page[l - 1] == '\n') |
845 | --l; | 803 | --l; |
@@ -855,15 +813,14 @@ static ssize_t os_desc_qw_sign_store(struct os_desc *os_desc, const char *page, | |||
855 | return res; | 813 | return res; |
856 | } | 814 | } |
857 | 815 | ||
858 | static struct os_desc_attribute os_desc_qw_sign = | 816 | CONFIGFS_ATTR(os_desc_, use); |
859 | __CONFIGFS_ATTR(qw_sign, S_IRUGO | S_IWUSR, | 817 | CONFIGFS_ATTR(os_desc_, b_vendor_code); |
860 | os_desc_qw_sign_show, | 818 | CONFIGFS_ATTR(os_desc_, qw_sign); |
861 | os_desc_qw_sign_store); | ||
862 | 819 | ||
863 | static struct configfs_attribute *os_desc_attrs[] = { | 820 | static struct configfs_attribute *os_desc_attrs[] = { |
864 | &os_desc_use.attr, | 821 | &os_desc_attr_use, |
865 | &os_desc_b_vendor_code.attr, | 822 | &os_desc_attr_b_vendor_code, |
866 | &os_desc_qw_sign.attr, | 823 | &os_desc_attr_qw_sign, |
867 | NULL, | 824 | NULL, |
868 | }; | 825 | }; |
869 | 826 | ||
@@ -926,8 +883,6 @@ static int os_desc_unlink(struct config_item *os_desc_ci, | |||
926 | 883 | ||
927 | static struct configfs_item_operations os_desc_ops = { | 884 | static struct configfs_item_operations os_desc_ops = { |
928 | .release = os_desc_attr_release, | 885 | .release = os_desc_attr_release, |
929 | .show_attribute = os_desc_attr_show, | ||
930 | .store_attribute = os_desc_attr_store, | ||
931 | .allow_link = os_desc_link, | 886 | .allow_link = os_desc_link, |
932 | .drop_link = os_desc_unlink, | 887 | .drop_link = os_desc_unlink, |
933 | }; | 888 | }; |
@@ -938,28 +893,21 @@ static struct config_item_type os_desc_type = { | |||
938 | .ct_owner = THIS_MODULE, | 893 | .ct_owner = THIS_MODULE, |
939 | }; | 894 | }; |
940 | 895 | ||
941 | CONFIGFS_ATTR_STRUCT(usb_os_desc); | ||
942 | CONFIGFS_ATTR_OPS(usb_os_desc); | ||
943 | |||
944 | |||
945 | static inline struct usb_os_desc_ext_prop | 896 | static inline struct usb_os_desc_ext_prop |
946 | *to_usb_os_desc_ext_prop(struct config_item *item) | 897 | *to_usb_os_desc_ext_prop(struct config_item *item) |
947 | { | 898 | { |
948 | return container_of(item, struct usb_os_desc_ext_prop, item); | 899 | return container_of(item, struct usb_os_desc_ext_prop, item); |
949 | } | 900 | } |
950 | 901 | ||
951 | CONFIGFS_ATTR_STRUCT(usb_os_desc_ext_prop); | 902 | static ssize_t ext_prop_type_show(struct config_item *item, char *page) |
952 | CONFIGFS_ATTR_OPS(usb_os_desc_ext_prop); | ||
953 | |||
954 | static ssize_t ext_prop_type_show(struct usb_os_desc_ext_prop *ext_prop, | ||
955 | char *page) | ||
956 | { | 903 | { |
957 | return sprintf(page, "%d", ext_prop->type); | 904 | return sprintf(page, "%d", to_usb_os_desc_ext_prop(item)->type); |
958 | } | 905 | } |
959 | 906 | ||
960 | static ssize_t ext_prop_type_store(struct usb_os_desc_ext_prop *ext_prop, | 907 | static ssize_t ext_prop_type_store(struct config_item *item, |
961 | const char *page, size_t len) | 908 | const char *page, size_t len) |
962 | { | 909 | { |
910 | struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); | ||
963 | struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); | 911 | struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); |
964 | u8 type; | 912 | u8 type; |
965 | int ret; | 913 | int ret; |
@@ -997,9 +945,9 @@ end: | |||
997 | return ret; | 945 | return ret; |
998 | } | 946 | } |
999 | 947 | ||
1000 | static ssize_t ext_prop_data_show(struct usb_os_desc_ext_prop *ext_prop, | 948 | static ssize_t ext_prop_data_show(struct config_item *item, char *page) |
1001 | char *page) | ||
1002 | { | 949 | { |
950 | struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); | ||
1003 | int len = ext_prop->data_len; | 951 | int len = ext_prop->data_len; |
1004 | 952 | ||
1005 | if (ext_prop->type == USB_EXT_PROP_UNICODE || | 953 | if (ext_prop->type == USB_EXT_PROP_UNICODE || |
@@ -1011,9 +959,10 @@ static ssize_t ext_prop_data_show(struct usb_os_desc_ext_prop *ext_prop, | |||
1011 | return len; | 959 | return len; |
1012 | } | 960 | } |
1013 | 961 | ||
1014 | static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, | 962 | static ssize_t ext_prop_data_store(struct config_item *item, |
1015 | const char *page, size_t len) | 963 | const char *page, size_t len) |
1016 | { | 964 | { |
965 | struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); | ||
1017 | struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); | 966 | struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); |
1018 | char *new_data; | 967 | char *new_data; |
1019 | size_t ret_len = len; | 968 | size_t ret_len = len; |
@@ -1044,17 +993,12 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, | |||
1044 | return ret_len; | 993 | return ret_len; |
1045 | } | 994 | } |
1046 | 995 | ||
1047 | static struct usb_os_desc_ext_prop_attribute ext_prop_type = | 996 | CONFIGFS_ATTR(ext_prop_, type); |
1048 | __CONFIGFS_ATTR(type, S_IRUGO | S_IWUSR, | 997 | CONFIGFS_ATTR(ext_prop_, data); |
1049 | ext_prop_type_show, ext_prop_type_store); | ||
1050 | |||
1051 | static struct usb_os_desc_ext_prop_attribute ext_prop_data = | ||
1052 | __CONFIGFS_ATTR(data, S_IRUGO | S_IWUSR, | ||
1053 | ext_prop_data_show, ext_prop_data_store); | ||
1054 | 998 | ||
1055 | static struct configfs_attribute *ext_prop_attrs[] = { | 999 | static struct configfs_attribute *ext_prop_attrs[] = { |
1056 | &ext_prop_type.attr, | 1000 | &ext_prop_attr_type, |
1057 | &ext_prop_data.attr, | 1001 | &ext_prop_attr_data, |
1058 | NULL, | 1002 | NULL, |
1059 | }; | 1003 | }; |
1060 | 1004 | ||
@@ -1067,8 +1011,6 @@ static void usb_os_desc_ext_prop_release(struct config_item *item) | |||
1067 | 1011 | ||
1068 | static struct configfs_item_operations ext_prop_ops = { | 1012 | static struct configfs_item_operations ext_prop_ops = { |
1069 | .release = usb_os_desc_ext_prop_release, | 1013 | .release = usb_os_desc_ext_prop_release, |
1070 | .show_attribute = usb_os_desc_ext_prop_attr_show, | ||
1071 | .store_attribute = usb_os_desc_ext_prop_attr_store, | ||
1072 | }; | 1014 | }; |
1073 | 1015 | ||
1074 | static struct config_item *ext_prop_make( | 1016 | static struct config_item *ext_prop_make( |
@@ -1137,21 +1079,17 @@ static struct configfs_group_operations interf_grp_ops = { | |||
1137 | .drop_item = &ext_prop_drop, | 1079 | .drop_item = &ext_prop_drop, |
1138 | }; | 1080 | }; |
1139 | 1081 | ||
1140 | static struct configfs_item_operations interf_item_ops = { | 1082 | static ssize_t interf_grp_compatible_id_show(struct config_item *item, |
1141 | .show_attribute = usb_os_desc_attr_show, | ||
1142 | .store_attribute = usb_os_desc_attr_store, | ||
1143 | }; | ||
1144 | |||
1145 | static ssize_t interf_grp_compatible_id_show(struct usb_os_desc *desc, | ||
1146 | char *page) | 1083 | char *page) |
1147 | { | 1084 | { |
1148 | memcpy(page, desc->ext_compat_id, 8); | 1085 | memcpy(page, to_usb_os_desc(item)->ext_compat_id, 8); |
1149 | return 8; | 1086 | return 8; |
1150 | } | 1087 | } |
1151 | 1088 | ||
1152 | static ssize_t interf_grp_compatible_id_store(struct usb_os_desc *desc, | 1089 | static ssize_t interf_grp_compatible_id_store(struct config_item *item, |
1153 | const char *page, size_t len) | 1090 | const char *page, size_t len) |
1154 | { | 1091 | { |
1092 | struct usb_os_desc *desc = to_usb_os_desc(item); | ||
1155 | int l; | 1093 | int l; |
1156 | 1094 | ||
1157 | l = min_t(int, 8, len); | 1095 | l = min_t(int, 8, len); |
@@ -1167,21 +1105,17 @@ static ssize_t interf_grp_compatible_id_store(struct usb_os_desc *desc, | |||
1167 | return len; | 1105 | return len; |
1168 | } | 1106 | } |
1169 | 1107 | ||
1170 | static struct usb_os_desc_attribute interf_grp_attr_compatible_id = | 1108 | static ssize_t interf_grp_sub_compatible_id_show(struct config_item *item, |
1171 | __CONFIGFS_ATTR(compatible_id, S_IRUGO | S_IWUSR, | ||
1172 | interf_grp_compatible_id_show, | ||
1173 | interf_grp_compatible_id_store); | ||
1174 | |||
1175 | static ssize_t interf_grp_sub_compatible_id_show(struct usb_os_desc *desc, | ||
1176 | char *page) | 1109 | char *page) |
1177 | { | 1110 | { |
1178 | memcpy(page, desc->ext_compat_id + 8, 8); | 1111 | memcpy(page, to_usb_os_desc(item)->ext_compat_id + 8, 8); |
1179 | return 8; | 1112 | return 8; |
1180 | } | 1113 | } |
1181 | 1114 | ||
1182 | static ssize_t interf_grp_sub_compatible_id_store(struct usb_os_desc *desc, | 1115 | static ssize_t interf_grp_sub_compatible_id_store(struct config_item *item, |
1183 | const char *page, size_t len) | 1116 | const char *page, size_t len) |
1184 | { | 1117 | { |
1118 | struct usb_os_desc *desc = to_usb_os_desc(item); | ||
1185 | int l; | 1119 | int l; |
1186 | 1120 | ||
1187 | l = min_t(int, 8, len); | 1121 | l = min_t(int, 8, len); |
@@ -1197,14 +1131,12 @@ static ssize_t interf_grp_sub_compatible_id_store(struct usb_os_desc *desc, | |||
1197 | return len; | 1131 | return len; |
1198 | } | 1132 | } |
1199 | 1133 | ||
1200 | static struct usb_os_desc_attribute interf_grp_attr_sub_compatible_id = | 1134 | CONFIGFS_ATTR(interf_grp_, compatible_id); |
1201 | __CONFIGFS_ATTR(sub_compatible_id, S_IRUGO | S_IWUSR, | 1135 | CONFIGFS_ATTR(interf_grp_, sub_compatible_id); |
1202 | interf_grp_sub_compatible_id_show, | ||
1203 | interf_grp_sub_compatible_id_store); | ||
1204 | 1136 | ||
1205 | static struct configfs_attribute *interf_grp_attrs[] = { | 1137 | static struct configfs_attribute *interf_grp_attrs[] = { |
1206 | &interf_grp_attr_compatible_id.attr, | 1138 | &interf_grp_attr_compatible_id, |
1207 | &interf_grp_attr_sub_compatible_id.attr, | 1139 | &interf_grp_attr_sub_compatible_id, |
1208 | NULL | 1140 | NULL |
1209 | }; | 1141 | }; |
1210 | 1142 | ||
@@ -1242,7 +1174,6 @@ int usb_os_desc_prepare_interf_dir(struct config_group *parent, | |||
1242 | f_default_groups[0] = os_desc_group; | 1174 | f_default_groups[0] = os_desc_group; |
1243 | 1175 | ||
1244 | os_desc_group->default_groups = interface_groups; | 1176 | os_desc_group->default_groups = interface_groups; |
1245 | interface_type->ct_item_ops = &interf_item_ops; | ||
1246 | interface_type->ct_group_ops = &interf_grp_ops; | 1177 | interface_type->ct_group_ops = &interf_grp_ops; |
1247 | interface_type->ct_attrs = interf_grp_attrs; | 1178 | interface_type->ct_attrs = interf_grp_attrs; |
1248 | interface_type->ct_owner = owner; | 1179 | interface_type->ct_owner = owner; |
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index 22e723d12d36..2fa1e80a3ce7 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c | |||
@@ -761,21 +761,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item) | |||
761 | func_inst.group); | 761 | func_inst.group); |
762 | } | 762 | } |
763 | 763 | ||
764 | CONFIGFS_ATTR_STRUCT(f_serial_opts); | ||
765 | static ssize_t f_acm_attr_show(struct config_item *item, | ||
766 | struct configfs_attribute *attr, | ||
767 | char *page) | ||
768 | { | ||
769 | struct f_serial_opts *opts = to_f_serial_opts(item); | ||
770 | struct f_serial_opts_attribute *f_serial_opts_attr = | ||
771 | container_of(attr, struct f_serial_opts_attribute, attr); | ||
772 | ssize_t ret = 0; | ||
773 | |||
774 | if (f_serial_opts_attr->show) | ||
775 | ret = f_serial_opts_attr->show(opts, page); | ||
776 | return ret; | ||
777 | } | ||
778 | |||
779 | static void acm_attr_release(struct config_item *item) | 764 | static void acm_attr_release(struct config_item *item) |
780 | { | 765 | { |
781 | struct f_serial_opts *opts = to_f_serial_opts(item); | 766 | struct f_serial_opts *opts = to_f_serial_opts(item); |
@@ -785,20 +770,17 @@ static void acm_attr_release(struct config_item *item) | |||
785 | 770 | ||
786 | static struct configfs_item_operations acm_item_ops = { | 771 | static struct configfs_item_operations acm_item_ops = { |
787 | .release = acm_attr_release, | 772 | .release = acm_attr_release, |
788 | .show_attribute = f_acm_attr_show, | ||
789 | }; | 773 | }; |
790 | 774 | ||
791 | static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page) | 775 | static ssize_t f_acm_port_num_show(struct config_item *item, char *page) |
792 | { | 776 | { |
793 | return sprintf(page, "%u\n", opts->port_num); | 777 | return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); |
794 | } | 778 | } |
795 | 779 | ||
796 | static struct f_serial_opts_attribute f_acm_port_num = | 780 | CONFIGFS_ATTR_RO(f_acm_port_, num); |
797 | __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show); | ||
798 | |||
799 | 781 | ||
800 | static struct configfs_attribute *acm_attrs[] = { | 782 | static struct configfs_attribute *acm_attrs[] = { |
801 | &f_acm_port_num.attr, | 783 | &f_acm_port_attr_num, |
802 | NULL, | 784 | NULL, |
803 | }; | 785 | }; |
804 | 786 | ||
diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 4abca70cdaab..7ad60ee41914 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c | |||
@@ -838,10 +838,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm); | |||
838 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm); | 838 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm); |
839 | 839 | ||
840 | static struct configfs_attribute *ecm_attrs[] = { | 840 | static struct configfs_attribute *ecm_attrs[] = { |
841 | &f_ecm_opts_dev_addr.attr, | 841 | &ecm_opts_attr_dev_addr, |
842 | &f_ecm_opts_host_addr.attr, | 842 | &ecm_opts_attr_host_addr, |
843 | &f_ecm_opts_qmult.attr, | 843 | &ecm_opts_attr_qmult, |
844 | &f_ecm_opts_ifname.attr, | 844 | &ecm_opts_attr_ifname, |
845 | NULL, | 845 | NULL, |
846 | }; | 846 | }; |
847 | 847 | ||
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c index 9a55757c729b..cad35a502d3f 100644 --- a/drivers/usb/gadget/function/f_eem.c +++ b/drivers/usb/gadget/function/f_eem.c | |||
@@ -545,10 +545,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem); | |||
545 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem); | 545 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem); |
546 | 546 | ||
547 | static struct configfs_attribute *eem_attrs[] = { | 547 | static struct configfs_attribute *eem_attrs[] = { |
548 | &f_eem_opts_dev_addr.attr, | 548 | &eem_opts_attr_dev_addr, |
549 | &f_eem_opts_host_addr.attr, | 549 | &eem_opts_attr_host_addr, |
550 | &f_eem_opts_qmult.attr, | 550 | &eem_opts_attr_qmult, |
551 | &f_eem_opts_ifname.attr, | 551 | &eem_opts_attr_ifname, |
552 | NULL, | 552 | NULL, |
553 | }; | 553 | }; |
554 | 554 | ||
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index 21fcf18f53a0..99285b416308 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c | |||
@@ -705,9 +705,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct config_item *item) | |||
705 | func_inst.group); | 705 | func_inst.group); |
706 | } | 706 | } |
707 | 707 | ||
708 | CONFIGFS_ATTR_STRUCT(f_hid_opts); | ||
709 | CONFIGFS_ATTR_OPS(f_hid_opts); | ||
710 | |||
711 | static void hid_attr_release(struct config_item *item) | 708 | static void hid_attr_release(struct config_item *item) |
712 | { | 709 | { |
713 | struct f_hid_opts *opts = to_f_hid_opts(item); | 710 | struct f_hid_opts *opts = to_f_hid_opts(item); |
@@ -717,13 +714,12 @@ static void hid_attr_release(struct config_item *item) | |||
717 | 714 | ||
718 | static struct configfs_item_operations hidg_item_ops = { | 715 | static struct configfs_item_operations hidg_item_ops = { |
719 | .release = hid_attr_release, | 716 | .release = hid_attr_release, |
720 | .show_attribute = f_hid_opts_attr_show, | ||
721 | .store_attribute = f_hid_opts_attr_store, | ||
722 | }; | 717 | }; |
723 | 718 | ||
724 | #define F_HID_OPT(name, prec, limit) \ | 719 | #define F_HID_OPT(name, prec, limit) \ |
725 | static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\ | 720 | static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\ |
726 | { \ | 721 | { \ |
722 | struct f_hid_opts *opts = to_f_hid_opts(item); \ | ||
727 | int result; \ | 723 | int result; \ |
728 | \ | 724 | \ |
729 | mutex_lock(&opts->lock); \ | 725 | mutex_lock(&opts->lock); \ |
@@ -733,9 +729,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\ | |||
733 | return result; \ | 729 | return result; \ |
734 | } \ | 730 | } \ |
735 | \ | 731 | \ |
736 | static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts, \ | 732 | static ssize_t f_hid_opts_##name##_store(struct config_item *item, \ |
737 | const char *page, size_t len) \ | 733 | const char *page, size_t len) \ |
738 | { \ | 734 | { \ |
735 | struct f_hid_opts *opts = to_f_hid_opts(item); \ | ||
739 | int ret; \ | 736 | int ret; \ |
740 | u##prec num; \ | 737 | u##prec num; \ |
741 | \ | 738 | \ |
@@ -761,16 +758,15 @@ end: \ | |||
761 | return ret; \ | 758 | return ret; \ |
762 | } \ | 759 | } \ |
763 | \ | 760 | \ |
764 | static struct f_hid_opts_attribute f_hid_opts_##name = \ | 761 | CONFIGFS_ATTR(f_hid_opts_, name) |
765 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\ | ||
766 | f_hid_opts_##name##_store) | ||
767 | 762 | ||
768 | F_HID_OPT(subclass, 8, 255); | 763 | F_HID_OPT(subclass, 8, 255); |
769 | F_HID_OPT(protocol, 8, 255); | 764 | F_HID_OPT(protocol, 8, 255); |
770 | F_HID_OPT(report_length, 16, 65535); | 765 | F_HID_OPT(report_length, 16, 65535); |
771 | 766 | ||
772 | static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page) | 767 | static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char *page) |
773 | { | 768 | { |
769 | struct f_hid_opts *opts = to_f_hid_opts(item); | ||
774 | int result; | 770 | int result; |
775 | 771 | ||
776 | mutex_lock(&opts->lock); | 772 | mutex_lock(&opts->lock); |
@@ -781,9 +777,10 @@ static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page) | |||
781 | return result; | 777 | return result; |
782 | } | 778 | } |
783 | 779 | ||
784 | static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts, | 780 | static ssize_t f_hid_opts_report_desc_store(struct config_item *item, |
785 | const char *page, size_t len) | 781 | const char *page, size_t len) |
786 | { | 782 | { |
783 | struct f_hid_opts *opts = to_f_hid_opts(item); | ||
787 | int ret = -EBUSY; | 784 | int ret = -EBUSY; |
788 | char *d; | 785 | char *d; |
789 | 786 | ||
@@ -810,16 +807,13 @@ end: | |||
810 | return ret; | 807 | return ret; |
811 | } | 808 | } |
812 | 809 | ||
813 | static struct f_hid_opts_attribute f_hid_opts_report_desc = | 810 | CONFIGFS_ATTR(f_hid_opts_, report_desc); |
814 | __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR, | ||
815 | f_hid_opts_report_desc_show, | ||
816 | f_hid_opts_report_desc_store); | ||
817 | 811 | ||
818 | static struct configfs_attribute *hid_attrs[] = { | 812 | static struct configfs_attribute *hid_attrs[] = { |
819 | &f_hid_opts_subclass.attr, | 813 | &f_hid_opts_attr_subclass, |
820 | &f_hid_opts_protocol.attr, | 814 | &f_hid_opts_attr_protocol, |
821 | &f_hid_opts_report_length.attr, | 815 | &f_hid_opts_attr_report_length, |
822 | &f_hid_opts_report_desc.attr, | 816 | &f_hid_opts_attr_report_desc, |
823 | NULL, | 817 | NULL, |
824 | }; | 818 | }; |
825 | 819 | ||
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c index 6b2102bc0699..23933bdf2d9d 100644 --- a/drivers/usb/gadget/function/f_loopback.c +++ b/drivers/usb/gadget/function/f_loopback.c | |||
@@ -465,9 +465,6 @@ static inline struct f_lb_opts *to_f_lb_opts(struct config_item *item) | |||
465 | func_inst.group); | 465 | func_inst.group); |
466 | } | 466 | } |
467 | 467 | ||
468 | CONFIGFS_ATTR_STRUCT(f_lb_opts); | ||
469 | CONFIGFS_ATTR_OPS(f_lb_opts); | ||
470 | |||
471 | static void lb_attr_release(struct config_item *item) | 468 | static void lb_attr_release(struct config_item *item) |
472 | { | 469 | { |
473 | struct f_lb_opts *lb_opts = to_f_lb_opts(item); | 470 | struct f_lb_opts *lb_opts = to_f_lb_opts(item); |
@@ -477,12 +474,11 @@ static void lb_attr_release(struct config_item *item) | |||
477 | 474 | ||
478 | static struct configfs_item_operations lb_item_ops = { | 475 | static struct configfs_item_operations lb_item_ops = { |
479 | .release = lb_attr_release, | 476 | .release = lb_attr_release, |
480 | .show_attribute = f_lb_opts_attr_show, | ||
481 | .store_attribute = f_lb_opts_attr_store, | ||
482 | }; | 477 | }; |
483 | 478 | ||
484 | static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page) | 479 | static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page) |
485 | { | 480 | { |
481 | struct f_lb_opts *opts = to_f_lb_opts(item); | ||
486 | int result; | 482 | int result; |
487 | 483 | ||
488 | mutex_lock(&opts->lock); | 484 | mutex_lock(&opts->lock); |
@@ -492,9 +488,10 @@ static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page) | |||
492 | return result; | 488 | return result; |
493 | } | 489 | } |
494 | 490 | ||
495 | static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts, | 491 | static ssize_t f_lb_opts_qlen_store(struct config_item *item, |
496 | const char *page, size_t len) | 492 | const char *page, size_t len) |
497 | { | 493 | { |
494 | struct f_lb_opts *opts = to_f_lb_opts(item); | ||
498 | int ret; | 495 | int ret; |
499 | u32 num; | 496 | u32 num; |
500 | 497 | ||
@@ -515,13 +512,11 @@ end: | |||
515 | return ret; | 512 | return ret; |
516 | } | 513 | } |
517 | 514 | ||
518 | static struct f_lb_opts_attribute f_lb_opts_qlen = | 515 | CONFIGFS_ATTR(f_lb_opts_, qlen); |
519 | __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR, | ||
520 | f_lb_opts_qlen_show, | ||
521 | f_lb_opts_qlen_store); | ||
522 | 516 | ||
523 | static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page) | 517 | static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page) |
524 | { | 518 | { |
519 | struct f_lb_opts *opts = to_f_lb_opts(item); | ||
525 | int result; | 520 | int result; |
526 | 521 | ||
527 | mutex_lock(&opts->lock); | 522 | mutex_lock(&opts->lock); |
@@ -531,9 +526,10 @@ static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page) | |||
531 | return result; | 526 | return result; |
532 | } | 527 | } |
533 | 528 | ||
534 | static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts, | 529 | static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item, |
535 | const char *page, size_t len) | 530 | const char *page, size_t len) |
536 | { | 531 | { |
532 | struct f_lb_opts *opts = to_f_lb_opts(item); | ||
537 | int ret; | 533 | int ret; |
538 | u32 num; | 534 | u32 num; |
539 | 535 | ||
@@ -554,14 +550,11 @@ end: | |||
554 | return ret; | 550 | return ret; |
555 | } | 551 | } |
556 | 552 | ||
557 | static struct f_lb_opts_attribute f_lb_opts_bulk_buflen = | 553 | CONFIGFS_ATTR(f_lb_opts_, bulk_buflen); |
558 | __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR, | ||
559 | f_lb_opts_bulk_buflen_show, | ||
560 | f_lb_opts_bulk_buflen_store); | ||
561 | 554 | ||
562 | static struct configfs_attribute *lb_attrs[] = { | 555 | static struct configfs_attribute *lb_attrs[] = { |
563 | &f_lb_opts_qlen.attr, | 556 | &f_lb_opts_attr_qlen, |
564 | &f_lb_opts_bulk_buflen.attr, | 557 | &f_lb_opts_attr_bulk_buflen, |
565 | NULL, | 558 | NULL, |
566 | }; | 559 | }; |
567 | 560 | ||
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index 5ec533826621..223ccf89d226 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c | |||
@@ -3140,9 +3140,6 @@ static inline struct fsg_opts *to_fsg_opts(struct config_item *item) | |||
3140 | func_inst.group); | 3140 | func_inst.group); |
3141 | } | 3141 | } |
3142 | 3142 | ||
3143 | CONFIGFS_ATTR_STRUCT(fsg_lun_opts); | ||
3144 | CONFIGFS_ATTR_OPS(fsg_lun_opts); | ||
3145 | |||
3146 | static void fsg_lun_attr_release(struct config_item *item) | 3143 | static void fsg_lun_attr_release(struct config_item *item) |
3147 | { | 3144 | { |
3148 | struct fsg_lun_opts *lun_opts; | 3145 | struct fsg_lun_opts *lun_opts; |
@@ -3153,110 +3150,93 @@ static void fsg_lun_attr_release(struct config_item *item) | |||
3153 | 3150 | ||
3154 | static struct configfs_item_operations fsg_lun_item_ops = { | 3151 | static struct configfs_item_operations fsg_lun_item_ops = { |
3155 | .release = fsg_lun_attr_release, | 3152 | .release = fsg_lun_attr_release, |
3156 | .show_attribute = fsg_lun_opts_attr_show, | ||
3157 | .store_attribute = fsg_lun_opts_attr_store, | ||
3158 | }; | 3153 | }; |
3159 | 3154 | ||
3160 | static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page) | 3155 | static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page) |
3161 | { | 3156 | { |
3162 | struct fsg_opts *fsg_opts; | 3157 | struct fsg_lun_opts *opts = to_fsg_lun_opts(item); |
3163 | 3158 | struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | |
3164 | fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | ||
3165 | 3159 | ||
3166 | return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page); | 3160 | return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page); |
3167 | } | 3161 | } |
3168 | 3162 | ||
3169 | static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts, | 3163 | static ssize_t fsg_lun_opts_file_store(struct config_item *item, |
3170 | const char *page, size_t len) | 3164 | const char *page, size_t len) |
3171 | { | 3165 | { |
3172 | struct fsg_opts *fsg_opts; | 3166 | struct fsg_lun_opts *opts = to_fsg_lun_opts(item); |
3173 | 3167 | struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | |
3174 | fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | ||
3175 | 3168 | ||
3176 | return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len); | 3169 | return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len); |
3177 | } | 3170 | } |
3178 | 3171 | ||
3179 | static struct fsg_lun_opts_attribute fsg_lun_opts_file = | 3172 | CONFIGFS_ATTR(fsg_lun_opts_, file); |
3180 | __CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show, | ||
3181 | fsg_lun_opts_file_store); | ||
3182 | 3173 | ||
3183 | static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page) | 3174 | static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page) |
3184 | { | 3175 | { |
3185 | return fsg_show_ro(opts->lun, page); | 3176 | return fsg_show_ro(to_fsg_lun_opts(item)->lun, page); |
3186 | } | 3177 | } |
3187 | 3178 | ||
3188 | static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts, | 3179 | static ssize_t fsg_lun_opts_ro_store(struct config_item *item, |
3189 | const char *page, size_t len) | 3180 | const char *page, size_t len) |
3190 | { | 3181 | { |
3191 | struct fsg_opts *fsg_opts; | 3182 | struct fsg_lun_opts *opts = to_fsg_lun_opts(item); |
3192 | 3183 | struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | |
3193 | fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | ||
3194 | 3184 | ||
3195 | return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len); | 3185 | return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len); |
3196 | } | 3186 | } |
3197 | 3187 | ||
3198 | static struct fsg_lun_opts_attribute fsg_lun_opts_ro = | 3188 | CONFIGFS_ATTR(fsg_lun_opts_, ro); |
3199 | __CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show, | ||
3200 | fsg_lun_opts_ro_store); | ||
3201 | 3189 | ||
3202 | static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts, | 3190 | static ssize_t fsg_lun_opts_removable_show(struct config_item *item, |
3203 | char *page) | 3191 | char *page) |
3204 | { | 3192 | { |
3205 | return fsg_show_removable(opts->lun, page); | 3193 | return fsg_show_removable(to_fsg_lun_opts(item)->lun, page); |
3206 | } | 3194 | } |
3207 | 3195 | ||
3208 | static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts, | 3196 | static ssize_t fsg_lun_opts_removable_store(struct config_item *item, |
3209 | const char *page, size_t len) | 3197 | const char *page, size_t len) |
3210 | { | 3198 | { |
3211 | return fsg_store_removable(opts->lun, page, len); | 3199 | return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len); |
3212 | } | 3200 | } |
3213 | 3201 | ||
3214 | static struct fsg_lun_opts_attribute fsg_lun_opts_removable = | 3202 | CONFIGFS_ATTR(fsg_lun_opts_, removable); |
3215 | __CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR, | ||
3216 | fsg_lun_opts_removable_show, | ||
3217 | fsg_lun_opts_removable_store); | ||
3218 | 3203 | ||
3219 | static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page) | 3204 | static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page) |
3220 | { | 3205 | { |
3221 | return fsg_show_cdrom(opts->lun, page); | 3206 | return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page); |
3222 | } | 3207 | } |
3223 | 3208 | ||
3224 | static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts, | 3209 | static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item, |
3225 | const char *page, size_t len) | 3210 | const char *page, size_t len) |
3226 | { | 3211 | { |
3227 | struct fsg_opts *fsg_opts; | 3212 | struct fsg_lun_opts *opts = to_fsg_lun_opts(item); |
3228 | 3213 | struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | |
3229 | fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); | ||
3230 | 3214 | ||
3231 | return fsg_store_cdrom(opts->lun, &fsg_opts->common->filesem, page, | 3215 | return fsg_store_cdrom(opts->lun, &fsg_opts->common->filesem, page, |
3232 | len); | 3216 | len); |
3233 | } | 3217 | } |
3234 | 3218 | ||
3235 | static struct fsg_lun_opts_attribute fsg_lun_opts_cdrom = | 3219 | CONFIGFS_ATTR(fsg_lun_opts_, cdrom); |
3236 | __CONFIGFS_ATTR(cdrom, S_IRUGO | S_IWUSR, fsg_lun_opts_cdrom_show, | ||
3237 | fsg_lun_opts_cdrom_store); | ||
3238 | 3220 | ||
3239 | static ssize_t fsg_lun_opts_nofua_show(struct fsg_lun_opts *opts, char *page) | 3221 | static ssize_t fsg_lun_opts_nofua_show(struct config_item *item, char *page) |
3240 | { | 3222 | { |
3241 | return fsg_show_nofua(opts->lun, page); | 3223 | return fsg_show_nofua(to_fsg_lun_opts(item)->lun, page); |
3242 | } | 3224 | } |
3243 | 3225 | ||
3244 | static ssize_t fsg_lun_opts_nofua_store(struct fsg_lun_opts *opts, | 3226 | static ssize_t fsg_lun_opts_nofua_store(struct config_item *item, |
3245 | const char *page, size_t len) | 3227 | const char *page, size_t len) |
3246 | { | 3228 | { |
3247 | return fsg_store_nofua(opts->lun, page, len); | 3229 | return fsg_store_nofua(to_fsg_lun_opts(item)->lun, page, len); |
3248 | } | 3230 | } |
3249 | 3231 | ||
3250 | static struct fsg_lun_opts_attribute fsg_lun_opts_nofua = | 3232 | CONFIGFS_ATTR(fsg_lun_opts_, nofua); |
3251 | __CONFIGFS_ATTR(nofua, S_IRUGO | S_IWUSR, fsg_lun_opts_nofua_show, | ||
3252 | fsg_lun_opts_nofua_store); | ||
3253 | 3233 | ||
3254 | static struct configfs_attribute *fsg_lun_attrs[] = { | 3234 | static struct configfs_attribute *fsg_lun_attrs[] = { |
3255 | &fsg_lun_opts_file.attr, | 3235 | &fsg_lun_opts_attr_file, |
3256 | &fsg_lun_opts_ro.attr, | 3236 | &fsg_lun_opts_attr_ro, |
3257 | &fsg_lun_opts_removable.attr, | 3237 | &fsg_lun_opts_attr_removable, |
3258 | &fsg_lun_opts_cdrom.attr, | 3238 | &fsg_lun_opts_attr_cdrom, |
3259 | &fsg_lun_opts_nofua.attr, | 3239 | &fsg_lun_opts_attr_nofua, |
3260 | NULL, | 3240 | NULL, |
3261 | }; | 3241 | }; |
3262 | 3242 | ||
@@ -3348,9 +3328,6 @@ static void fsg_lun_drop(struct config_group *group, struct config_item *item) | |||
3348 | config_item_put(item); | 3328 | config_item_put(item); |
3349 | } | 3329 | } |
3350 | 3330 | ||
3351 | CONFIGFS_ATTR_STRUCT(fsg_opts); | ||
3352 | CONFIGFS_ATTR_OPS(fsg_opts); | ||
3353 | |||
3354 | static void fsg_attr_release(struct config_item *item) | 3331 | static void fsg_attr_release(struct config_item *item) |
3355 | { | 3332 | { |
3356 | struct fsg_opts *opts = to_fsg_opts(item); | 3333 | struct fsg_opts *opts = to_fsg_opts(item); |
@@ -3360,12 +3337,11 @@ static void fsg_attr_release(struct config_item *item) | |||
3360 | 3337 | ||
3361 | static struct configfs_item_operations fsg_item_ops = { | 3338 | static struct configfs_item_operations fsg_item_ops = { |
3362 | .release = fsg_attr_release, | 3339 | .release = fsg_attr_release, |
3363 | .show_attribute = fsg_opts_attr_show, | ||
3364 | .store_attribute = fsg_opts_attr_store, | ||
3365 | }; | 3340 | }; |
3366 | 3341 | ||
3367 | static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page) | 3342 | static ssize_t fsg_opts_stall_show(struct config_item *item, char *page) |
3368 | { | 3343 | { |
3344 | struct fsg_opts *opts = to_fsg_opts(item); | ||
3369 | int result; | 3345 | int result; |
3370 | 3346 | ||
3371 | mutex_lock(&opts->lock); | 3347 | mutex_lock(&opts->lock); |
@@ -3375,9 +3351,10 @@ static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page) | |||
3375 | return result; | 3351 | return result; |
3376 | } | 3352 | } |
3377 | 3353 | ||
3378 | static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page, | 3354 | static ssize_t fsg_opts_stall_store(struct config_item *item, const char *page, |
3379 | size_t len) | 3355 | size_t len) |
3380 | { | 3356 | { |
3357 | struct fsg_opts *opts = to_fsg_opts(item); | ||
3381 | int ret; | 3358 | int ret; |
3382 | bool stall; | 3359 | bool stall; |
3383 | 3360 | ||
@@ -3399,13 +3376,12 @@ static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page, | |||
3399 | return ret; | 3376 | return ret; |
3400 | } | 3377 | } |
3401 | 3378 | ||
3402 | static struct fsg_opts_attribute fsg_opts_stall = | 3379 | CONFIGFS_ATTR(fsg_opts_, stall); |
3403 | __CONFIGFS_ATTR(stall, S_IRUGO | S_IWUSR, fsg_opts_stall_show, | ||
3404 | fsg_opts_stall_store); | ||
3405 | 3380 | ||
3406 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 3381 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
3407 | static ssize_t fsg_opts_num_buffers_show(struct fsg_opts *opts, char *page) | 3382 | static ssize_t fsg_opts_num_buffers_show(struct config_item *item, char *page) |
3408 | { | 3383 | { |
3384 | struct fsg_opts *opts = to_fsg_opts(item); | ||
3409 | int result; | 3385 | int result; |
3410 | 3386 | ||
3411 | mutex_lock(&opts->lock); | 3387 | mutex_lock(&opts->lock); |
@@ -3415,9 +3391,10 @@ static ssize_t fsg_opts_num_buffers_show(struct fsg_opts *opts, char *page) | |||
3415 | return result; | 3391 | return result; |
3416 | } | 3392 | } |
3417 | 3393 | ||
3418 | static ssize_t fsg_opts_num_buffers_store(struct fsg_opts *opts, | 3394 | static ssize_t fsg_opts_num_buffers_store(struct config_item *item, |
3419 | const char *page, size_t len) | 3395 | const char *page, size_t len) |
3420 | { | 3396 | { |
3397 | struct fsg_opts *opts = to_fsg_opts(item); | ||
3421 | int ret; | 3398 | int ret; |
3422 | u8 num; | 3399 | u8 num; |
3423 | 3400 | ||
@@ -3442,17 +3419,13 @@ end: | |||
3442 | return ret; | 3419 | return ret; |
3443 | } | 3420 | } |
3444 | 3421 | ||
3445 | static struct fsg_opts_attribute fsg_opts_num_buffers = | 3422 | CONFIGFS_ATTR(fsg_opts_, num_buffers); |
3446 | __CONFIGFS_ATTR(num_buffers, S_IRUGO | S_IWUSR, | ||
3447 | fsg_opts_num_buffers_show, | ||
3448 | fsg_opts_num_buffers_store); | ||
3449 | |||
3450 | #endif | 3423 | #endif |
3451 | 3424 | ||
3452 | static struct configfs_attribute *fsg_attrs[] = { | 3425 | static struct configfs_attribute *fsg_attrs[] = { |
3453 | &fsg_opts_stall.attr, | 3426 | &fsg_opts_attr_stall, |
3454 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 3427 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
3455 | &fsg_opts_num_buffers.attr, | 3428 | &fsg_opts_attr_num_buffers, |
3456 | #endif | 3429 | #endif |
3457 | NULL, | 3430 | NULL, |
3458 | }; | 3431 | }; |
diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index ce3c8a629266..42acb45e1ab4 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c | |||
@@ -902,9 +902,6 @@ static inline struct f_midi_opts *to_f_midi_opts(struct config_item *item) | |||
902 | func_inst.group); | 902 | func_inst.group); |
903 | } | 903 | } |
904 | 904 | ||
905 | CONFIGFS_ATTR_STRUCT(f_midi_opts); | ||
906 | CONFIGFS_ATTR_OPS(f_midi_opts); | ||
907 | |||
908 | static void midi_attr_release(struct config_item *item) | 905 | static void midi_attr_release(struct config_item *item) |
909 | { | 906 | { |
910 | struct f_midi_opts *opts = to_f_midi_opts(item); | 907 | struct f_midi_opts *opts = to_f_midi_opts(item); |
@@ -914,13 +911,12 @@ static void midi_attr_release(struct config_item *item) | |||
914 | 911 | ||
915 | static struct configfs_item_operations midi_item_ops = { | 912 | static struct configfs_item_operations midi_item_ops = { |
916 | .release = midi_attr_release, | 913 | .release = midi_attr_release, |
917 | .show_attribute = f_midi_opts_attr_show, | ||
918 | .store_attribute = f_midi_opts_attr_store, | ||
919 | }; | 914 | }; |
920 | 915 | ||
921 | #define F_MIDI_OPT(name, test_limit, limit) \ | 916 | #define F_MIDI_OPT(name, test_limit, limit) \ |
922 | static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) \ | 917 | static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) \ |
923 | { \ | 918 | { \ |
919 | struct f_midi_opts *opts = to_f_midi_opts(item); \ | ||
924 | int result; \ | 920 | int result; \ |
925 | \ | 921 | \ |
926 | mutex_lock(&opts->lock); \ | 922 | mutex_lock(&opts->lock); \ |
@@ -930,9 +926,10 @@ static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) \ | |||
930 | return result; \ | 926 | return result; \ |
931 | } \ | 927 | } \ |
932 | \ | 928 | \ |
933 | static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts, \ | 929 | static ssize_t f_midi_opts_##name##_store(struct config_item *item, \ |
934 | const char *page, size_t len) \ | 930 | const char *page, size_t len) \ |
935 | { \ | 931 | { \ |
932 | struct f_midi_opts *opts = to_f_midi_opts(item); \ | ||
936 | int ret; \ | 933 | int ret; \ |
937 | u32 num; \ | 934 | u32 num; \ |
938 | \ | 935 | \ |
@@ -958,9 +955,7 @@ end: \ | |||
958 | return ret; \ | 955 | return ret; \ |
959 | } \ | 956 | } \ |
960 | \ | 957 | \ |
961 | static struct f_midi_opts_attribute f_midi_opts_##name = \ | 958 | CONFIGFS_ATTR(f_midi_opts_, name); |
962 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \ | ||
963 | f_midi_opts_##name##_store) | ||
964 | 959 | ||
965 | F_MIDI_OPT(index, true, SNDRV_CARDS); | 960 | F_MIDI_OPT(index, true, SNDRV_CARDS); |
966 | F_MIDI_OPT(buflen, false, 0); | 961 | F_MIDI_OPT(buflen, false, 0); |
@@ -968,8 +963,9 @@ F_MIDI_OPT(qlen, false, 0); | |||
968 | F_MIDI_OPT(in_ports, true, MAX_PORTS); | 963 | F_MIDI_OPT(in_ports, true, MAX_PORTS); |
969 | F_MIDI_OPT(out_ports, true, MAX_PORTS); | 964 | F_MIDI_OPT(out_ports, true, MAX_PORTS); |
970 | 965 | ||
971 | static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page) | 966 | static ssize_t f_midi_opts_id_show(struct config_item *item, char *page) |
972 | { | 967 | { |
968 | struct f_midi_opts *opts = to_f_midi_opts(item); | ||
973 | int result; | 969 | int result; |
974 | 970 | ||
975 | mutex_lock(&opts->lock); | 971 | mutex_lock(&opts->lock); |
@@ -985,9 +981,10 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page) | |||
985 | return result; | 981 | return result; |
986 | } | 982 | } |
987 | 983 | ||
988 | static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts, | 984 | static ssize_t f_midi_opts_id_store(struct config_item *item, |
989 | const char *page, size_t len) | 985 | const char *page, size_t len) |
990 | { | 986 | { |
987 | struct f_midi_opts *opts = to_f_midi_opts(item); | ||
991 | int ret; | 988 | int ret; |
992 | char *c; | 989 | char *c; |
993 | 990 | ||
@@ -1012,17 +1009,15 @@ end: | |||
1012 | return ret; | 1009 | return ret; |
1013 | } | 1010 | } |
1014 | 1011 | ||
1015 | static struct f_midi_opts_attribute f_midi_opts_id = | 1012 | CONFIGFS_ATTR(f_midi_opts_, id); |
1016 | __CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show, | ||
1017 | f_midi_opts_id_store); | ||
1018 | 1013 | ||
1019 | static struct configfs_attribute *midi_attrs[] = { | 1014 | static struct configfs_attribute *midi_attrs[] = { |
1020 | &f_midi_opts_index.attr, | 1015 | &f_midi_opts_attr_index, |
1021 | &f_midi_opts_buflen.attr, | 1016 | &f_midi_opts_attr_buflen, |
1022 | &f_midi_opts_qlen.attr, | 1017 | &f_midi_opts_attr_qlen, |
1023 | &f_midi_opts_in_ports.attr, | 1018 | &f_midi_opts_attr_in_ports, |
1024 | &f_midi_opts_out_ports.attr, | 1019 | &f_midi_opts_attr_out_ports, |
1025 | &f_midi_opts_id.attr, | 1020 | &f_midi_opts_attr_id, |
1026 | NULL, | 1021 | NULL, |
1027 | }; | 1022 | }; |
1028 | 1023 | ||
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index b6f7ed7d48a7..7ad798ace1e5 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c | |||
@@ -1488,10 +1488,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm); | |||
1488 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); | 1488 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); |
1489 | 1489 | ||
1490 | static struct configfs_attribute *ncm_attrs[] = { | 1490 | static struct configfs_attribute *ncm_attrs[] = { |
1491 | &f_ncm_opts_dev_addr.attr, | 1491 | &ncm_opts_attr_dev_addr, |
1492 | &f_ncm_opts_host_addr.attr, | 1492 | &ncm_opts_attr_host_addr, |
1493 | &f_ncm_opts_qmult.attr, | 1493 | &ncm_opts_attr_qmult, |
1494 | &f_ncm_opts_ifname.attr, | 1494 | &ncm_opts_attr_ifname, |
1495 | NULL, | 1495 | NULL, |
1496 | }; | 1496 | }; |
1497 | 1497 | ||
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index 1c3d30ad2f92..d6396e0909ee 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c | |||
@@ -387,22 +387,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item) | |||
387 | func_inst.group); | 387 | func_inst.group); |
388 | } | 388 | } |
389 | 389 | ||
390 | CONFIGFS_ATTR_STRUCT(f_serial_opts); | ||
391 | static ssize_t f_obex_attr_show(struct config_item *item, | ||
392 | struct configfs_attribute *attr, | ||
393 | char *page) | ||
394 | { | ||
395 | struct f_serial_opts *opts = to_f_serial_opts(item); | ||
396 | struct f_serial_opts_attribute *f_serial_opts_attr = | ||
397 | container_of(attr, struct f_serial_opts_attribute, attr); | ||
398 | ssize_t ret = 0; | ||
399 | |||
400 | if (f_serial_opts_attr->show) | ||
401 | ret = f_serial_opts_attr->show(opts, page); | ||
402 | |||
403 | return ret; | ||
404 | } | ||
405 | |||
406 | static void obex_attr_release(struct config_item *item) | 390 | static void obex_attr_release(struct config_item *item) |
407 | { | 391 | { |
408 | struct f_serial_opts *opts = to_f_serial_opts(item); | 392 | struct f_serial_opts *opts = to_f_serial_opts(item); |
@@ -412,19 +396,17 @@ static void obex_attr_release(struct config_item *item) | |||
412 | 396 | ||
413 | static struct configfs_item_operations obex_item_ops = { | 397 | static struct configfs_item_operations obex_item_ops = { |
414 | .release = obex_attr_release, | 398 | .release = obex_attr_release, |
415 | .show_attribute = f_obex_attr_show, | ||
416 | }; | 399 | }; |
417 | 400 | ||
418 | static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page) | 401 | static ssize_t f_obex_port_num_show(struct config_item *item, char *page) |
419 | { | 402 | { |
420 | return sprintf(page, "%u\n", opts->port_num); | 403 | return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); |
421 | } | 404 | } |
422 | 405 | ||
423 | static struct f_serial_opts_attribute f_obex_port_num = | 406 | CONFIGFS_ATTR_RO(f_obex_, port_num); |
424 | __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show); | ||
425 | 407 | ||
426 | static struct configfs_attribute *acm_attrs[] = { | 408 | static struct configfs_attribute *acm_attrs[] = { |
427 | &f_obex_port_num.attr, | 409 | &f_obex_attr_port_num, |
428 | NULL, | 410 | NULL, |
429 | }; | 411 | }; |
430 | 412 | ||
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c index 62a198754029..157441dbfeba 100644 --- a/drivers/usb/gadget/function/f_phonet.c +++ b/drivers/usb/gadget/function/f_phonet.c | |||
@@ -583,21 +583,6 @@ static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item) | |||
583 | func_inst.group); | 583 | func_inst.group); |
584 | } | 584 | } |
585 | 585 | ||
586 | CONFIGFS_ATTR_STRUCT(f_phonet_opts); | ||
587 | static ssize_t f_phonet_attr_show(struct config_item *item, | ||
588 | struct configfs_attribute *attr, | ||
589 | char *page) | ||
590 | { | ||
591 | struct f_phonet_opts *opts = to_f_phonet_opts(item); | ||
592 | struct f_phonet_opts_attribute *f_phonet_opts_attr = | ||
593 | container_of(attr, struct f_phonet_opts_attribute, attr); | ||
594 | ssize_t ret = 0; | ||
595 | |||
596 | if (f_phonet_opts_attr->show) | ||
597 | ret = f_phonet_opts_attr->show(opts, page); | ||
598 | return ret; | ||
599 | } | ||
600 | |||
601 | static void phonet_attr_release(struct config_item *item) | 586 | static void phonet_attr_release(struct config_item *item) |
602 | { | 587 | { |
603 | struct f_phonet_opts *opts = to_f_phonet_opts(item); | 588 | struct f_phonet_opts *opts = to_f_phonet_opts(item); |
@@ -607,19 +592,17 @@ static void phonet_attr_release(struct config_item *item) | |||
607 | 592 | ||
608 | static struct configfs_item_operations phonet_item_ops = { | 593 | static struct configfs_item_operations phonet_item_ops = { |
609 | .release = phonet_attr_release, | 594 | .release = phonet_attr_release, |
610 | .show_attribute = f_phonet_attr_show, | ||
611 | }; | 595 | }; |
612 | 596 | ||
613 | static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page) | 597 | static ssize_t f_phonet_ifname_show(struct config_item *item, char *page) |
614 | { | 598 | { |
615 | return gether_get_ifname(opts->net, page, PAGE_SIZE); | 599 | return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE); |
616 | } | 600 | } |
617 | 601 | ||
618 | static struct f_phonet_opts_attribute f_phonet_ifname = | 602 | CONFIGFS_ATTR_RO(f_phonet_, ifname); |
619 | __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show); | ||
620 | 603 | ||
621 | static struct configfs_attribute *phonet_attrs[] = { | 604 | static struct configfs_attribute *phonet_attrs[] = { |
622 | &f_phonet_ifname.attr, | 605 | &f_phonet_attr_ifname, |
623 | NULL, | 606 | NULL, |
624 | }; | 607 | }; |
625 | 608 | ||
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 7fb3209ed52c..0fbfb2b2aa08 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c | |||
@@ -1146,9 +1146,6 @@ static inline struct f_printer_opts | |||
1146 | func_inst.group); | 1146 | func_inst.group); |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | CONFIGFS_ATTR_STRUCT(f_printer_opts); | ||
1150 | CONFIGFS_ATTR_OPS(f_printer_opts); | ||
1151 | |||
1152 | static void printer_attr_release(struct config_item *item) | 1149 | static void printer_attr_release(struct config_item *item) |
1153 | { | 1150 | { |
1154 | struct f_printer_opts *opts = to_f_printer_opts(item); | 1151 | struct f_printer_opts *opts = to_f_printer_opts(item); |
@@ -1158,13 +1155,12 @@ static void printer_attr_release(struct config_item *item) | |||
1158 | 1155 | ||
1159 | static struct configfs_item_operations printer_item_ops = { | 1156 | static struct configfs_item_operations printer_item_ops = { |
1160 | .release = printer_attr_release, | 1157 | .release = printer_attr_release, |
1161 | .show_attribute = f_printer_opts_attr_show, | ||
1162 | .store_attribute = f_printer_opts_attr_store, | ||
1163 | }; | 1158 | }; |
1164 | 1159 | ||
1165 | static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, | 1160 | static ssize_t f_printer_opts_pnp_string_show(struct config_item *item, |
1166 | char *page) | 1161 | char *page) |
1167 | { | 1162 | { |
1163 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1168 | int result; | 1164 | int result; |
1169 | 1165 | ||
1170 | mutex_lock(&opts->lock); | 1166 | mutex_lock(&opts->lock); |
@@ -1174,9 +1170,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, | |||
1174 | return result; | 1170 | return result; |
1175 | } | 1171 | } |
1176 | 1172 | ||
1177 | static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, | 1173 | static ssize_t f_printer_opts_pnp_string_store(struct config_item *item, |
1178 | const char *page, size_t len) | 1174 | const char *page, size_t len) |
1179 | { | 1175 | { |
1176 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1180 | int result, l; | 1177 | int result, l; |
1181 | 1178 | ||
1182 | mutex_lock(&opts->lock); | 1179 | mutex_lock(&opts->lock); |
@@ -1189,14 +1186,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, | |||
1189 | return result; | 1186 | return result; |
1190 | } | 1187 | } |
1191 | 1188 | ||
1192 | static struct f_printer_opts_attribute f_printer_opts_pnp_string = | 1189 | CONFIGFS_ATTR(f_printer_opts_, pnp_string); |
1193 | __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR, | ||
1194 | f_printer_opts_pnp_string_show, | ||
1195 | f_printer_opts_pnp_string_store); | ||
1196 | 1190 | ||
1197 | static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, | 1191 | static ssize_t f_printer_opts_q_len_show(struct config_item *item, |
1198 | char *page) | 1192 | char *page) |
1199 | { | 1193 | { |
1194 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1200 | int result; | 1195 | int result; |
1201 | 1196 | ||
1202 | mutex_lock(&opts->lock); | 1197 | mutex_lock(&opts->lock); |
@@ -1206,9 +1201,10 @@ static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, | |||
1206 | return result; | 1201 | return result; |
1207 | } | 1202 | } |
1208 | 1203 | ||
1209 | static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts, | 1204 | static ssize_t f_printer_opts_q_len_store(struct config_item *item, |
1210 | const char *page, size_t len) | 1205 | const char *page, size_t len) |
1211 | { | 1206 | { |
1207 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1212 | int ret; | 1208 | int ret; |
1213 | u16 num; | 1209 | u16 num; |
1214 | 1210 | ||
@@ -1229,13 +1225,11 @@ end: | |||
1229 | return ret; | 1225 | return ret; |
1230 | } | 1226 | } |
1231 | 1227 | ||
1232 | static struct f_printer_opts_attribute f_printer_opts_q_len = | 1228 | CONFIGFS_ATTR(f_printer_opts_, q_len); |
1233 | __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show, | ||
1234 | f_printer_opts_q_len_store); | ||
1235 | 1229 | ||
1236 | static struct configfs_attribute *printer_attrs[] = { | 1230 | static struct configfs_attribute *printer_attrs[] = { |
1237 | &f_printer_opts_pnp_string.attr, | 1231 | &f_printer_opts_attr_pnp_string, |
1238 | &f_printer_opts_q_len.attr, | 1232 | &f_printer_opts_attr_q_len, |
1239 | NULL, | 1233 | NULL, |
1240 | }; | 1234 | }; |
1241 | 1235 | ||
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index fd301ed9e294..e587767e374c 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c | |||
@@ -864,10 +864,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis); | |||
864 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis); | 864 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis); |
865 | 865 | ||
866 | static struct configfs_attribute *rndis_attrs[] = { | 866 | static struct configfs_attribute *rndis_attrs[] = { |
867 | &f_rndis_opts_dev_addr.attr, | 867 | &rndis_opts_attr_dev_addr, |
868 | &f_rndis_opts_host_addr.attr, | 868 | &rndis_opts_attr_host_addr, |
869 | &f_rndis_opts_qmult.attr, | 869 | &rndis_opts_attr_qmult, |
870 | &f_rndis_opts_ifname.attr, | 870 | &rndis_opts_attr_ifname, |
871 | NULL, | 871 | NULL, |
872 | }; | 872 | }; |
873 | 873 | ||
diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c index ba705e047d7e..6bb44d613bab 100644 --- a/drivers/usb/gadget/function/f_serial.c +++ b/drivers/usb/gadget/function/f_serial.c | |||
@@ -258,22 +258,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item) | |||
258 | func_inst.group); | 258 | func_inst.group); |
259 | } | 259 | } |
260 | 260 | ||
261 | CONFIGFS_ATTR_STRUCT(f_serial_opts); | ||
262 | static ssize_t f_serial_attr_show(struct config_item *item, | ||
263 | struct configfs_attribute *attr, | ||
264 | char *page) | ||
265 | { | ||
266 | struct f_serial_opts *opts = to_f_serial_opts(item); | ||
267 | struct f_serial_opts_attribute *f_serial_opts_attr = | ||
268 | container_of(attr, struct f_serial_opts_attribute, attr); | ||
269 | ssize_t ret = 0; | ||
270 | |||
271 | if (f_serial_opts_attr->show) | ||
272 | ret = f_serial_opts_attr->show(opts, page); | ||
273 | |||
274 | return ret; | ||
275 | } | ||
276 | |||
277 | static void serial_attr_release(struct config_item *item) | 261 | static void serial_attr_release(struct config_item *item) |
278 | { | 262 | { |
279 | struct f_serial_opts *opts = to_f_serial_opts(item); | 263 | struct f_serial_opts *opts = to_f_serial_opts(item); |
@@ -283,19 +267,17 @@ static void serial_attr_release(struct config_item *item) | |||
283 | 267 | ||
284 | static struct configfs_item_operations serial_item_ops = { | 268 | static struct configfs_item_operations serial_item_ops = { |
285 | .release = serial_attr_release, | 269 | .release = serial_attr_release, |
286 | .show_attribute = f_serial_attr_show, | ||
287 | }; | 270 | }; |
288 | 271 | ||
289 | static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page) | 272 | static ssize_t f_serial_port_num_show(struct config_item *item, char *page) |
290 | { | 273 | { |
291 | return sprintf(page, "%u\n", opts->port_num); | 274 | return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); |
292 | } | 275 | } |
293 | 276 | ||
294 | static struct f_serial_opts_attribute f_serial_port_num = | 277 | CONFIGFS_ATTR_RO(f_serial_, port_num); |
295 | __CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show); | ||
296 | 278 | ||
297 | static struct configfs_attribute *acm_attrs[] = { | 279 | static struct configfs_attribute *acm_attrs[] = { |
298 | &f_serial_port_num.attr, | 280 | &f_serial_attr_port_num, |
299 | NULL, | 281 | NULL, |
300 | }; | 282 | }; |
301 | 283 | ||
diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c index d7646d3acd63..9f3ced62d916 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c | |||
@@ -889,9 +889,6 @@ static inline struct f_ss_opts *to_f_ss_opts(struct config_item *item) | |||
889 | func_inst.group); | 889 | func_inst.group); |
890 | } | 890 | } |
891 | 891 | ||
892 | CONFIGFS_ATTR_STRUCT(f_ss_opts); | ||
893 | CONFIGFS_ATTR_OPS(f_ss_opts); | ||
894 | |||
895 | static void ss_attr_release(struct config_item *item) | 892 | static void ss_attr_release(struct config_item *item) |
896 | { | 893 | { |
897 | struct f_ss_opts *ss_opts = to_f_ss_opts(item); | 894 | struct f_ss_opts *ss_opts = to_f_ss_opts(item); |
@@ -901,12 +898,11 @@ static void ss_attr_release(struct config_item *item) | |||
901 | 898 | ||
902 | static struct configfs_item_operations ss_item_ops = { | 899 | static struct configfs_item_operations ss_item_ops = { |
903 | .release = ss_attr_release, | 900 | .release = ss_attr_release, |
904 | .show_attribute = f_ss_opts_attr_show, | ||
905 | .store_attribute = f_ss_opts_attr_store, | ||
906 | }; | 901 | }; |
907 | 902 | ||
908 | static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page) | 903 | static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page) |
909 | { | 904 | { |
905 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
910 | int result; | 906 | int result; |
911 | 907 | ||
912 | mutex_lock(&opts->lock); | 908 | mutex_lock(&opts->lock); |
@@ -916,9 +912,10 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page) | |||
916 | return result; | 912 | return result; |
917 | } | 913 | } |
918 | 914 | ||
919 | static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts, | 915 | static ssize_t f_ss_opts_pattern_store(struct config_item *item, |
920 | const char *page, size_t len) | 916 | const char *page, size_t len) |
921 | { | 917 | { |
918 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
922 | int ret; | 919 | int ret; |
923 | u8 num; | 920 | u8 num; |
924 | 921 | ||
@@ -944,13 +941,11 @@ end: | |||
944 | return ret; | 941 | return ret; |
945 | } | 942 | } |
946 | 943 | ||
947 | static struct f_ss_opts_attribute f_ss_opts_pattern = | 944 | CONFIGFS_ATTR(f_ss_opts_, pattern); |
948 | __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR, | ||
949 | f_ss_opts_pattern_show, | ||
950 | f_ss_opts_pattern_store); | ||
951 | 945 | ||
952 | static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page) | 946 | static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char *page) |
953 | { | 947 | { |
948 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
954 | int result; | 949 | int result; |
955 | 950 | ||
956 | mutex_lock(&opts->lock); | 951 | mutex_lock(&opts->lock); |
@@ -960,9 +955,10 @@ static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page) | |||
960 | return result; | 955 | return result; |
961 | } | 956 | } |
962 | 957 | ||
963 | static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts, | 958 | static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item, |
964 | const char *page, size_t len) | 959 | const char *page, size_t len) |
965 | { | 960 | { |
961 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
966 | int ret; | 962 | int ret; |
967 | u8 num; | 963 | u8 num; |
968 | 964 | ||
@@ -988,13 +984,11 @@ end: | |||
988 | return ret; | 984 | return ret; |
989 | } | 985 | } |
990 | 986 | ||
991 | static struct f_ss_opts_attribute f_ss_opts_isoc_interval = | 987 | CONFIGFS_ATTR(f_ss_opts_, isoc_interval); |
992 | __CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR, | ||
993 | f_ss_opts_isoc_interval_show, | ||
994 | f_ss_opts_isoc_interval_store); | ||
995 | 988 | ||
996 | static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char *page) | 989 | static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char *page) |
997 | { | 990 | { |
991 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
998 | int result; | 992 | int result; |
999 | 993 | ||
1000 | mutex_lock(&opts->lock); | 994 | mutex_lock(&opts->lock); |
@@ -1004,9 +998,10 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char *page) | |||
1004 | return result; | 998 | return result; |
1005 | } | 999 | } |
1006 | 1000 | ||
1007 | static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts, | 1001 | static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item, |
1008 | const char *page, size_t len) | 1002 | const char *page, size_t len) |
1009 | { | 1003 | { |
1004 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1010 | int ret; | 1005 | int ret; |
1011 | u16 num; | 1006 | u16 num; |
1012 | 1007 | ||
@@ -1032,13 +1027,11 @@ end: | |||
1032 | return ret; | 1027 | return ret; |
1033 | } | 1028 | } |
1034 | 1029 | ||
1035 | static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket = | 1030 | CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket); |
1036 | __CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR, | ||
1037 | f_ss_opts_isoc_maxpacket_show, | ||
1038 | f_ss_opts_isoc_maxpacket_store); | ||
1039 | 1031 | ||
1040 | static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page) | 1032 | static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page) |
1041 | { | 1033 | { |
1034 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1042 | int result; | 1035 | int result; |
1043 | 1036 | ||
1044 | mutex_lock(&opts->lock); | 1037 | mutex_lock(&opts->lock); |
@@ -1048,9 +1041,10 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page) | |||
1048 | return result; | 1041 | return result; |
1049 | } | 1042 | } |
1050 | 1043 | ||
1051 | static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts, | 1044 | static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item, |
1052 | const char *page, size_t len) | 1045 | const char *page, size_t len) |
1053 | { | 1046 | { |
1047 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1054 | int ret; | 1048 | int ret; |
1055 | u8 num; | 1049 | u8 num; |
1056 | 1050 | ||
@@ -1076,13 +1070,11 @@ end: | |||
1076 | return ret; | 1070 | return ret; |
1077 | } | 1071 | } |
1078 | 1072 | ||
1079 | static struct f_ss_opts_attribute f_ss_opts_isoc_mult = | 1073 | CONFIGFS_ATTR(f_ss_opts_, isoc_mult); |
1080 | __CONFIGFS_ATTR(isoc_mult, S_IRUGO | S_IWUSR, | ||
1081 | f_ss_opts_isoc_mult_show, | ||
1082 | f_ss_opts_isoc_mult_store); | ||
1083 | 1074 | ||
1084 | static ssize_t f_ss_opts_isoc_maxburst_show(struct f_ss_opts *opts, char *page) | 1075 | static ssize_t f_ss_opts_isoc_maxburst_show(struct config_item *item, char *page) |
1085 | { | 1076 | { |
1077 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1086 | int result; | 1078 | int result; |
1087 | 1079 | ||
1088 | mutex_lock(&opts->lock); | 1080 | mutex_lock(&opts->lock); |
@@ -1092,9 +1084,10 @@ static ssize_t f_ss_opts_isoc_maxburst_show(struct f_ss_opts *opts, char *page) | |||
1092 | return result; | 1084 | return result; |
1093 | } | 1085 | } |
1094 | 1086 | ||
1095 | static ssize_t f_ss_opts_isoc_maxburst_store(struct f_ss_opts *opts, | 1087 | static ssize_t f_ss_opts_isoc_maxburst_store(struct config_item *item, |
1096 | const char *page, size_t len) | 1088 | const char *page, size_t len) |
1097 | { | 1089 | { |
1090 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1098 | int ret; | 1091 | int ret; |
1099 | u8 num; | 1092 | u8 num; |
1100 | 1093 | ||
@@ -1120,13 +1113,11 @@ end: | |||
1120 | return ret; | 1113 | return ret; |
1121 | } | 1114 | } |
1122 | 1115 | ||
1123 | static struct f_ss_opts_attribute f_ss_opts_isoc_maxburst = | 1116 | CONFIGFS_ATTR(f_ss_opts_, isoc_maxburst); |
1124 | __CONFIGFS_ATTR(isoc_maxburst, S_IRUGO | S_IWUSR, | ||
1125 | f_ss_opts_isoc_maxburst_show, | ||
1126 | f_ss_opts_isoc_maxburst_store); | ||
1127 | 1117 | ||
1128 | static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page) | 1118 | static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *page) |
1129 | { | 1119 | { |
1120 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1130 | int result; | 1121 | int result; |
1131 | 1122 | ||
1132 | mutex_lock(&opts->lock); | 1123 | mutex_lock(&opts->lock); |
@@ -1136,9 +1127,10 @@ static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page) | |||
1136 | return result; | 1127 | return result; |
1137 | } | 1128 | } |
1138 | 1129 | ||
1139 | static ssize_t f_ss_opts_bulk_buflen_store(struct f_ss_opts *opts, | 1130 | static ssize_t f_ss_opts_bulk_buflen_store(struct config_item *item, |
1140 | const char *page, size_t len) | 1131 | const char *page, size_t len) |
1141 | { | 1132 | { |
1133 | struct f_ss_opts *opts = to_f_ss_opts(item); | ||
1142 | int ret; | 1134 | int ret; |
1143 | u32 num; | 1135 | u32 num; |
1144 | 1136 | ||
@@ -1159,18 +1151,15 @@ end: | |||
1159 | return ret; | 1151 | return ret; |
1160 | } | 1152 | } |
1161 | 1153 | ||
1162 | static struct f_ss_opts_attribute f_ss_opts_bulk_buflen = | 1154 | CONFIGFS_ATTR(f_ss_opts_, bulk_buflen); |
1163 | __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR, | ||
1164 | f_ss_opts_bulk_buflen_show, | ||
1165 | f_ss_opts_bulk_buflen_store); | ||
1166 | 1155 | ||
1167 | static struct configfs_attribute *ss_attrs[] = { | 1156 | static struct configfs_attribute *ss_attrs[] = { |
1168 | &f_ss_opts_pattern.attr, | 1157 | &f_ss_opts_attr_pattern, |
1169 | &f_ss_opts_isoc_interval.attr, | 1158 | &f_ss_opts_attr_isoc_interval, |
1170 | &f_ss_opts_isoc_maxpacket.attr, | 1159 | &f_ss_opts_attr_isoc_maxpacket, |
1171 | &f_ss_opts_isoc_mult.attr, | 1160 | &f_ss_opts_attr_isoc_mult, |
1172 | &f_ss_opts_isoc_maxburst.attr, | 1161 | &f_ss_opts_attr_isoc_maxburst, |
1173 | &f_ss_opts_bulk_buflen.attr, | 1162 | &f_ss_opts_attr_bulk_buflen, |
1174 | NULL, | 1163 | NULL, |
1175 | }; | 1164 | }; |
1176 | 1165 | ||
diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c index 2e66e624e6e1..829c78de9eba 100644 --- a/drivers/usb/gadget/function/f_subset.c +++ b/drivers/usb/gadget/function/f_subset.c | |||
@@ -405,10 +405,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether); | |||
405 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether); | 405 | USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether); |
406 | 406 | ||
407 | static struct configfs_attribute *gether_attrs[] = { | 407 | static struct configfs_attribute *gether_attrs[] = { |
408 | &f_gether_opts_dev_addr.attr, | 408 | &gether_opts_attr_dev_addr, |
409 | &f_gether_opts_host_addr.attr, | 409 | &gether_opts_attr_host_addr, |
410 | &f_gether_opts_qmult.attr, | 410 | &gether_opts_attr_qmult, |
411 | &f_gether_opts_ifname.attr, | 411 | &gether_opts_attr_ifname, |
412 | NULL, | 412 | NULL, |
413 | }; | 413 | }; |
414 | 414 | ||
diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c index 8ee701924d29..6a2346b99f55 100644 --- a/drivers/usb/gadget/function/f_uac1.c +++ b/drivers/usb/gadget/function/f_uac1.c | |||
@@ -769,9 +769,6 @@ static inline struct f_uac1_opts *to_f_uac1_opts(struct config_item *item) | |||
769 | func_inst.group); | 769 | func_inst.group); |
770 | } | 770 | } |
771 | 771 | ||
772 | CONFIGFS_ATTR_STRUCT(f_uac1_opts); | ||
773 | CONFIGFS_ATTR_OPS(f_uac1_opts); | ||
774 | |||
775 | static void f_uac1_attr_release(struct config_item *item) | 772 | static void f_uac1_attr_release(struct config_item *item) |
776 | { | 773 | { |
777 | struct f_uac1_opts *opts = to_f_uac1_opts(item); | 774 | struct f_uac1_opts *opts = to_f_uac1_opts(item); |
@@ -781,14 +778,13 @@ static void f_uac1_attr_release(struct config_item *item) | |||
781 | 778 | ||
782 | static struct configfs_item_operations f_uac1_item_ops = { | 779 | static struct configfs_item_operations f_uac1_item_ops = { |
783 | .release = f_uac1_attr_release, | 780 | .release = f_uac1_attr_release, |
784 | .show_attribute = f_uac1_opts_attr_show, | ||
785 | .store_attribute = f_uac1_opts_attr_store, | ||
786 | }; | 781 | }; |
787 | 782 | ||
788 | #define UAC1_INT_ATTRIBUTE(name) \ | 783 | #define UAC1_INT_ATTRIBUTE(name) \ |
789 | static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ | 784 | static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ |
790 | char *page) \ | 785 | char *page) \ |
791 | { \ | 786 | { \ |
787 | struct f_uac1_opts *opts = to_f_uac1_opts(item); \ | ||
792 | int result; \ | 788 | int result; \ |
793 | \ | 789 | \ |
794 | mutex_lock(&opts->lock); \ | 790 | mutex_lock(&opts->lock); \ |
@@ -798,9 +794,10 @@ static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ | |||
798 | return result; \ | 794 | return result; \ |
799 | } \ | 795 | } \ |
800 | \ | 796 | \ |
801 | static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \ | 797 | static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ |
802 | const char *page, size_t len) \ | 798 | const char *page, size_t len) \ |
803 | { \ | 799 | { \ |
800 | struct f_uac1_opts *opts = to_f_uac1_opts(item); \ | ||
804 | int ret; \ | 801 | int ret; \ |
805 | u32 num; \ | 802 | u32 num; \ |
806 | \ | 803 | \ |
@@ -822,19 +819,17 @@ end: \ | |||
822 | return ret; \ | 819 | return ret; \ |
823 | } \ | 820 | } \ |
824 | \ | 821 | \ |
825 | static struct f_uac1_opts_attribute f_uac1_opts_##name = \ | 822 | CONFIGFS_ATTR(f_uac1_opts_, name) |
826 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
827 | f_uac1_opts_##name##_show, \ | ||
828 | f_uac1_opts_##name##_store) | ||
829 | 823 | ||
830 | UAC1_INT_ATTRIBUTE(req_buf_size); | 824 | UAC1_INT_ATTRIBUTE(req_buf_size); |
831 | UAC1_INT_ATTRIBUTE(req_count); | 825 | UAC1_INT_ATTRIBUTE(req_count); |
832 | UAC1_INT_ATTRIBUTE(audio_buf_size); | 826 | UAC1_INT_ATTRIBUTE(audio_buf_size); |
833 | 827 | ||
834 | #define UAC1_STR_ATTRIBUTE(name) \ | 828 | #define UAC1_STR_ATTRIBUTE(name) \ |
835 | static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ | 829 | static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ |
836 | char *page) \ | 830 | char *page) \ |
837 | { \ | 831 | { \ |
832 | struct f_uac1_opts *opts = to_f_uac1_opts(item); \ | ||
838 | int result; \ | 833 | int result; \ |
839 | \ | 834 | \ |
840 | mutex_lock(&opts->lock); \ | 835 | mutex_lock(&opts->lock); \ |
@@ -844,9 +839,10 @@ static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ | |||
844 | return result; \ | 839 | return result; \ |
845 | } \ | 840 | } \ |
846 | \ | 841 | \ |
847 | static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \ | 842 | static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ |
848 | const char *page, size_t len) \ | 843 | const char *page, size_t len) \ |
849 | { \ | 844 | { \ |
845 | struct f_uac1_opts *opts = to_f_uac1_opts(item); \ | ||
850 | int ret = -EBUSY; \ | 846 | int ret = -EBUSY; \ |
851 | char *tmp; \ | 847 | char *tmp; \ |
852 | \ | 848 | \ |
@@ -870,22 +866,19 @@ end: \ | |||
870 | return ret; \ | 866 | return ret; \ |
871 | } \ | 867 | } \ |
872 | \ | 868 | \ |
873 | static struct f_uac1_opts_attribute f_uac1_opts_##name = \ | 869 | CONFIGFS_ATTR(f_uac1_opts_, name) |
874 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
875 | f_uac1_opts_##name##_show, \ | ||
876 | f_uac1_opts_##name##_store) | ||
877 | 870 | ||
878 | UAC1_STR_ATTRIBUTE(fn_play); | 871 | UAC1_STR_ATTRIBUTE(fn_play); |
879 | UAC1_STR_ATTRIBUTE(fn_cap); | 872 | UAC1_STR_ATTRIBUTE(fn_cap); |
880 | UAC1_STR_ATTRIBUTE(fn_cntl); | 873 | UAC1_STR_ATTRIBUTE(fn_cntl); |
881 | 874 | ||
882 | static struct configfs_attribute *f_uac1_attrs[] = { | 875 | static struct configfs_attribute *f_uac1_attrs[] = { |
883 | &f_uac1_opts_req_buf_size.attr, | 876 | &f_uac1_opts_attr_req_buf_size, |
884 | &f_uac1_opts_req_count.attr, | 877 | &f_uac1_opts_attr_req_count, |
885 | &f_uac1_opts_audio_buf_size.attr, | 878 | &f_uac1_opts_attr_audio_buf_size, |
886 | &f_uac1_opts_fn_play.attr, | 879 | &f_uac1_opts_attr_fn_play, |
887 | &f_uac1_opts_fn_cap.attr, | 880 | &f_uac1_opts_attr_fn_cap, |
888 | &f_uac1_opts_fn_cntl.attr, | 881 | &f_uac1_opts_attr_fn_cntl, |
889 | NULL, | 882 | NULL, |
890 | }; | 883 | }; |
891 | 884 | ||
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 63336e269898..044ca79d3cb5 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
@@ -1439,9 +1439,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct config_item *item) | |||
1439 | func_inst.group); | 1439 | func_inst.group); |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | CONFIGFS_ATTR_STRUCT(f_uac2_opts); | ||
1443 | CONFIGFS_ATTR_OPS(f_uac2_opts); | ||
1444 | |||
1445 | static void f_uac2_attr_release(struct config_item *item) | 1442 | static void f_uac2_attr_release(struct config_item *item) |
1446 | { | 1443 | { |
1447 | struct f_uac2_opts *opts = to_f_uac2_opts(item); | 1444 | struct f_uac2_opts *opts = to_f_uac2_opts(item); |
@@ -1451,14 +1448,13 @@ static void f_uac2_attr_release(struct config_item *item) | |||
1451 | 1448 | ||
1452 | static struct configfs_item_operations f_uac2_item_ops = { | 1449 | static struct configfs_item_operations f_uac2_item_ops = { |
1453 | .release = f_uac2_attr_release, | 1450 | .release = f_uac2_attr_release, |
1454 | .show_attribute = f_uac2_opts_attr_show, | ||
1455 | .store_attribute = f_uac2_opts_attr_store, | ||
1456 | }; | 1451 | }; |
1457 | 1452 | ||
1458 | #define UAC2_ATTRIBUTE(name) \ | 1453 | #define UAC2_ATTRIBUTE(name) \ |
1459 | static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \ | 1454 | static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \ |
1460 | char *page) \ | 1455 | char *page) \ |
1461 | { \ | 1456 | { \ |
1457 | struct f_uac2_opts *opts = to_f_uac2_opts(item); \ | ||
1462 | int result; \ | 1458 | int result; \ |
1463 | \ | 1459 | \ |
1464 | mutex_lock(&opts->lock); \ | 1460 | mutex_lock(&opts->lock); \ |
@@ -1468,9 +1464,10 @@ static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \ | |||
1468 | return result; \ | 1464 | return result; \ |
1469 | } \ | 1465 | } \ |
1470 | \ | 1466 | \ |
1471 | static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts, \ | 1467 | static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \ |
1472 | const char *page, size_t len) \ | 1468 | const char *page, size_t len) \ |
1473 | { \ | 1469 | { \ |
1470 | struct f_uac2_opts *opts = to_f_uac2_opts(item); \ | ||
1474 | int ret; \ | 1471 | int ret; \ |
1475 | u32 num; \ | 1472 | u32 num; \ |
1476 | \ | 1473 | \ |
@@ -1492,10 +1489,7 @@ end: \ | |||
1492 | return ret; \ | 1489 | return ret; \ |
1493 | } \ | 1490 | } \ |
1494 | \ | 1491 | \ |
1495 | static struct f_uac2_opts_attribute f_uac2_opts_##name = \ | 1492 | CONFIGFS_ATTR(f_uac2_opts_, name) |
1496 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
1497 | f_uac2_opts_##name##_show, \ | ||
1498 | f_uac2_opts_##name##_store) | ||
1499 | 1493 | ||
1500 | UAC2_ATTRIBUTE(p_chmask); | 1494 | UAC2_ATTRIBUTE(p_chmask); |
1501 | UAC2_ATTRIBUTE(p_srate); | 1495 | UAC2_ATTRIBUTE(p_srate); |
@@ -1505,12 +1499,12 @@ UAC2_ATTRIBUTE(c_srate); | |||
1505 | UAC2_ATTRIBUTE(c_ssize); | 1499 | UAC2_ATTRIBUTE(c_ssize); |
1506 | 1500 | ||
1507 | static struct configfs_attribute *f_uac2_attrs[] = { | 1501 | static struct configfs_attribute *f_uac2_attrs[] = { |
1508 | &f_uac2_opts_p_chmask.attr, | 1502 | &f_uac2_opts_attr_p_chmask, |
1509 | &f_uac2_opts_p_srate.attr, | 1503 | &f_uac2_opts_attr_p_srate, |
1510 | &f_uac2_opts_p_ssize.attr, | 1504 | &f_uac2_opts_attr_p_ssize, |
1511 | &f_uac2_opts_c_chmask.attr, | 1505 | &f_uac2_opts_attr_c_chmask, |
1512 | &f_uac2_opts_c_srate.attr, | 1506 | &f_uac2_opts_attr_c_srate, |
1513 | &f_uac2_opts_c_ssize.attr, | 1507 | &f_uac2_opts_attr_c_ssize, |
1514 | NULL, | 1508 | NULL, |
1515 | }; | 1509 | }; |
1516 | 1510 | ||
diff --git a/drivers/usb/gadget/function/u_ether_configfs.h b/drivers/usb/gadget/function/u_ether_configfs.h index bcbd30146cfd..4f47289fcf7c 100644 --- a/drivers/usb/gadget/function/u_ether_configfs.h +++ b/drivers/usb/gadget/function/u_ether_configfs.h | |||
@@ -17,9 +17,6 @@ | |||
17 | #define __U_ETHER_CONFIGFS_H | 17 | #define __U_ETHER_CONFIGFS_H |
18 | 18 | ||
19 | #define USB_ETHERNET_CONFIGFS_ITEM(_f_) \ | 19 | #define USB_ETHERNET_CONFIGFS_ITEM(_f_) \ |
20 | CONFIGFS_ATTR_STRUCT(f_##_f_##_opts); \ | ||
21 | CONFIGFS_ATTR_OPS(f_##_f_##_opts); \ | ||
22 | \ | ||
23 | static void _f_##_attr_release(struct config_item *item) \ | 20 | static void _f_##_attr_release(struct config_item *item) \ |
24 | { \ | 21 | { \ |
25 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | 22 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ |
@@ -29,14 +26,13 @@ | |||
29 | \ | 26 | \ |
30 | static struct configfs_item_operations _f_##_item_ops = { \ | 27 | static struct configfs_item_operations _f_##_item_ops = { \ |
31 | .release = _f_##_attr_release, \ | 28 | .release = _f_##_attr_release, \ |
32 | .show_attribute = f_##_f_##_opts_attr_show, \ | ||
33 | .store_attribute = f_##_f_##_opts_attr_store, \ | ||
34 | } | 29 | } |
35 | 30 | ||
36 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \ | 31 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \ |
37 | static ssize_t _f_##_opts_dev_addr_show(struct f_##_f_##_opts *opts, \ | 32 | static ssize_t _f_##_opts_dev_addr_show(struct config_item *item, \ |
38 | char *page) \ | 33 | char *page) \ |
39 | { \ | 34 | { \ |
35 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
40 | int result; \ | 36 | int result; \ |
41 | \ | 37 | \ |
42 | mutex_lock(&opts->lock); \ | 38 | mutex_lock(&opts->lock); \ |
@@ -46,9 +42,10 @@ | |||
46 | return result; \ | 42 | return result; \ |
47 | } \ | 43 | } \ |
48 | \ | 44 | \ |
49 | static ssize_t _f_##_opts_dev_addr_store(struct f_##_f_##_opts *opts, \ | 45 | static ssize_t _f_##_opts_dev_addr_store(struct config_item *item, \ |
50 | const char *page, size_t len)\ | 46 | const char *page, size_t len)\ |
51 | { \ | 47 | { \ |
48 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
52 | int ret; \ | 49 | int ret; \ |
53 | \ | 50 | \ |
54 | mutex_lock(&opts->lock); \ | 51 | mutex_lock(&opts->lock); \ |
@@ -64,15 +61,13 @@ | |||
64 | return ret; \ | 61 | return ret; \ |
65 | } \ | 62 | } \ |
66 | \ | 63 | \ |
67 | static struct f_##_f_##_opts_attribute f_##_f_##_opts_dev_addr = \ | 64 | CONFIGFS_ATTR(_f_##_opts_, dev_addr) |
68 | __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, \ | ||
69 | _f_##_opts_dev_addr_show, \ | ||
70 | _f_##_opts_dev_addr_store) | ||
71 | 65 | ||
72 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \ | 66 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \ |
73 | static ssize_t _f_##_opts_host_addr_show(struct f_##_f_##_opts *opts, \ | 67 | static ssize_t _f_##_opts_host_addr_show(struct config_item *item, \ |
74 | char *page) \ | 68 | char *page) \ |
75 | { \ | 69 | { \ |
70 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
76 | int result; \ | 71 | int result; \ |
77 | \ | 72 | \ |
78 | mutex_lock(&opts->lock); \ | 73 | mutex_lock(&opts->lock); \ |
@@ -82,9 +77,10 @@ | |||
82 | return result; \ | 77 | return result; \ |
83 | } \ | 78 | } \ |
84 | \ | 79 | \ |
85 | static ssize_t _f_##_opts_host_addr_store(struct f_##_f_##_opts *opts, \ | 80 | static ssize_t _f_##_opts_host_addr_store(struct config_item *item, \ |
86 | const char *page, size_t len)\ | 81 | const char *page, size_t len)\ |
87 | { \ | 82 | { \ |
83 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
88 | int ret; \ | 84 | int ret; \ |
89 | \ | 85 | \ |
90 | mutex_lock(&opts->lock); \ | 86 | mutex_lock(&opts->lock); \ |
@@ -100,15 +96,13 @@ | |||
100 | return ret; \ | 96 | return ret; \ |
101 | } \ | 97 | } \ |
102 | \ | 98 | \ |
103 | static struct f_##_f_##_opts_attribute f_##_f_##_opts_host_addr = \ | 99 | CONFIGFS_ATTR(_f_##_opts_, host_addr) |
104 | __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, \ | ||
105 | _f_##_opts_host_addr_show, \ | ||
106 | _f_##_opts_host_addr_store) | ||
107 | 100 | ||
108 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \ | 101 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \ |
109 | static ssize_t _f_##_opts_qmult_show(struct f_##_f_##_opts *opts, \ | 102 | static ssize_t _f_##_opts_qmult_show(struct config_item *item, \ |
110 | char *page) \ | 103 | char *page) \ |
111 | { \ | 104 | { \ |
105 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
112 | unsigned qmult; \ | 106 | unsigned qmult; \ |
113 | \ | 107 | \ |
114 | mutex_lock(&opts->lock); \ | 108 | mutex_lock(&opts->lock); \ |
@@ -117,9 +111,10 @@ | |||
117 | return sprintf(page, "%d", qmult); \ | 111 | return sprintf(page, "%d", qmult); \ |
118 | } \ | 112 | } \ |
119 | \ | 113 | \ |
120 | static ssize_t _f_##_opts_qmult_store(struct f_##_f_##_opts *opts, \ | 114 | static ssize_t _f_##_opts_qmult_store(struct config_item *item, \ |
121 | const char *page, size_t len)\ | 115 | const char *page, size_t len)\ |
122 | { \ | 116 | { \ |
117 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
123 | u8 val; \ | 118 | u8 val; \ |
124 | int ret; \ | 119 | int ret; \ |
125 | \ | 120 | \ |
@@ -140,15 +135,13 @@ out: \ | |||
140 | return ret; \ | 135 | return ret; \ |
141 | } \ | 136 | } \ |
142 | \ | 137 | \ |
143 | static struct f_##_f_##_opts_attribute f_##_f_##_opts_qmult = \ | 138 | CONFIGFS_ATTR(_f_##_opts_, qmult) |
144 | __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, \ | ||
145 | _f_##_opts_qmult_show, \ | ||
146 | _f_##_opts_qmult_store) | ||
147 | 139 | ||
148 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \ | 140 | #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \ |
149 | static ssize_t _f_##_opts_ifname_show(struct f_##_f_##_opts *opts, \ | 141 | static ssize_t _f_##_opts_ifname_show(struct config_item *item, \ |
150 | char *page) \ | 142 | char *page) \ |
151 | { \ | 143 | { \ |
144 | struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ | ||
152 | int ret; \ | 145 | int ret; \ |
153 | \ | 146 | \ |
154 | mutex_lock(&opts->lock); \ | 147 | mutex_lock(&opts->lock); \ |
@@ -158,7 +151,6 @@ out: \ | |||
158 | return ret; \ | 151 | return ret; \ |
159 | } \ | 152 | } \ |
160 | \ | 153 | \ |
161 | static struct f_##_f_##_opts_attribute f_##_f_##_opts_ifname = \ | 154 | CONFIGFS_ATTR_RO(_f_##_opts_, ifname) |
162 | __CONFIGFS_ATTR_RO(ifname, _f_##_opts_ifname_show) | ||
163 | 155 | ||
164 | #endif /* __U_ETHER_CONFIGFS_H */ | 156 | #endif /* __U_ETHER_CONFIGFS_H */ |
diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 3c0467bcb14f..289ebca316d3 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c | |||
@@ -17,19 +17,21 @@ | |||
17 | 17 | ||
18 | #define UVCG_STREAMING_CONTROL_SIZE 1 | 18 | #define UVCG_STREAMING_CONTROL_SIZE 1 |
19 | 19 | ||
20 | #define CONFIGFS_ATTR_OPS_RO(_item) \ | 20 | #define UVC_ATTR(prefix, cname, aname) \ |
21 | static ssize_t _item##_attr_show(struct config_item *item, \ | 21 | static struct configfs_attribute prefix##attr_##cname = { \ |
22 | struct configfs_attribute *attr, \ | 22 | .ca_name = __stringify(aname), \ |
23 | char *page) \ | 23 | .ca_mode = S_IRUGO, \ |
24 | { \ | 24 | .ca_owner = THIS_MODULE, \ |
25 | struct _item *_item = to_##_item(item); \ | 25 | .show = prefix##cname##_show, \ |
26 | struct _item##_attribute *_item##_attr = \ | 26 | .store = prefix##cname##_store, \ |
27 | container_of(attr, struct _item##_attribute, attr); \ | 27 | } |
28 | ssize_t ret = 0; \ | 28 | |
29 | \ | 29 | #define UVC_ATTR_RO(prefix, cname, aname) \ |
30 | if (_item##_attr->show) \ | 30 | static struct configfs_attribute prefix##attr_##cname = { \ |
31 | ret = _item##_attr->show(_item, page); \ | 31 | .ca_name = __stringify(aname), \ |
32 | return ret; \ | 32 | .ca_mode = S_IRUGO, \ |
33 | .ca_owner = THIS_MODULE, \ | ||
34 | .show = prefix##cname##_show, \ | ||
33 | } | 35 | } |
34 | 36 | ||
35 | static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item); | 37 | static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item); |
@@ -48,18 +50,11 @@ static struct uvcg_control_header *to_uvcg_control_header(struct config_item *it | |||
48 | return container_of(item, struct uvcg_control_header, item); | 50 | return container_of(item, struct uvcg_control_header, item); |
49 | } | 51 | } |
50 | 52 | ||
51 | CONFIGFS_ATTR_STRUCT(uvcg_control_header); | ||
52 | CONFIGFS_ATTR_OPS(uvcg_control_header); | ||
53 | |||
54 | static struct configfs_item_operations uvcg_control_header_item_ops = { | ||
55 | .show_attribute = uvcg_control_header_attr_show, | ||
56 | .store_attribute = uvcg_control_header_attr_store, | ||
57 | }; | ||
58 | |||
59 | #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \ | 53 | #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \ |
60 | static ssize_t uvcg_control_header_##cname##_show( \ | 54 | static ssize_t uvcg_control_header_##cname##_show( \ |
61 | struct uvcg_control_header *ch, char *page) \ | 55 | struct config_item *item, char *page) \ |
62 | { \ | 56 | { \ |
57 | struct uvcg_control_header *ch = to_uvcg_control_header(item); \ | ||
63 | struct f_uvc_opts *opts; \ | 58 | struct f_uvc_opts *opts; \ |
64 | struct config_item *opts_item; \ | 59 | struct config_item *opts_item; \ |
65 | struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ | 60 | struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ |
@@ -79,9 +74,10 @@ static ssize_t uvcg_control_header_##cname##_show( \ | |||
79 | } \ | 74 | } \ |
80 | \ | 75 | \ |
81 | static ssize_t \ | 76 | static ssize_t \ |
82 | uvcg_control_header_##cname##_store(struct uvcg_control_header *ch, \ | 77 | uvcg_control_header_##cname##_store(struct config_item *item, \ |
83 | const char *page, size_t len) \ | 78 | const char *page, size_t len) \ |
84 | { \ | 79 | { \ |
80 | struct uvcg_control_header *ch = to_uvcg_control_header(item); \ | ||
85 | struct f_uvc_opts *opts; \ | 81 | struct f_uvc_opts *opts; \ |
86 | struct config_item *opts_item; \ | 82 | struct config_item *opts_item; \ |
87 | struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ | 83 | struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ |
@@ -115,11 +111,7 @@ end: \ | |||
115 | return ret; \ | 111 | return ret; \ |
116 | } \ | 112 | } \ |
117 | \ | 113 | \ |
118 | static struct uvcg_control_header_attribute \ | 114 | UVC_ATTR(uvcg_control_header_, cname, aname) |
119 | uvcg_control_header_##cname = \ | ||
120 | __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ | ||
121 | uvcg_control_header_##cname##_show, \ | ||
122 | uvcg_control_header_##cname##_store) | ||
123 | 115 | ||
124 | UVCG_CTRL_HDR_ATTR(bcd_uvc, bcdUVC, le16_to_cpu, kstrtou16, u16, cpu_to_le16, | 116 | UVCG_CTRL_HDR_ATTR(bcd_uvc, bcdUVC, le16_to_cpu, kstrtou16, u16, cpu_to_le16, |
125 | 0xffff); | 117 | 0xffff); |
@@ -130,13 +122,12 @@ UVCG_CTRL_HDR_ATTR(dw_clock_frequency, dwClockFrequency, le32_to_cpu, kstrtou32, | |||
130 | #undef UVCG_CTRL_HDR_ATTR | 122 | #undef UVCG_CTRL_HDR_ATTR |
131 | 123 | ||
132 | static struct configfs_attribute *uvcg_control_header_attrs[] = { | 124 | static struct configfs_attribute *uvcg_control_header_attrs[] = { |
133 | &uvcg_control_header_bcd_uvc.attr, | 125 | &uvcg_control_header_attr_bcd_uvc, |
134 | &uvcg_control_header_dw_clock_frequency.attr, | 126 | &uvcg_control_header_attr_dw_clock_frequency, |
135 | NULL, | 127 | NULL, |
136 | }; | 128 | }; |
137 | 129 | ||
138 | static struct config_item_type uvcg_control_header_type = { | 130 | static struct config_item_type uvcg_control_header_type = { |
139 | .ct_item_ops = &uvcg_control_header_item_ops, | ||
140 | .ct_attrs = uvcg_control_header_attrs, | 131 | .ct_attrs = uvcg_control_header_attrs, |
141 | .ct_owner = THIS_MODULE, | 132 | .ct_owner = THIS_MODULE, |
142 | }; | 133 | }; |
@@ -196,17 +187,11 @@ static inline struct uvcg_default_processing | |||
196 | struct uvcg_default_processing, group); | 187 | struct uvcg_default_processing, group); |
197 | } | 188 | } |
198 | 189 | ||
199 | CONFIGFS_ATTR_STRUCT(uvcg_default_processing); | ||
200 | CONFIGFS_ATTR_OPS_RO(uvcg_default_processing); | ||
201 | |||
202 | static struct configfs_item_operations uvcg_default_processing_item_ops = { | ||
203 | .show_attribute = uvcg_default_processing_attr_show, | ||
204 | }; | ||
205 | |||
206 | #define UVCG_DEFAULT_PROCESSING_ATTR(cname, aname, conv) \ | 190 | #define UVCG_DEFAULT_PROCESSING_ATTR(cname, aname, conv) \ |
207 | static ssize_t uvcg_default_processing_##cname##_show( \ | 191 | static ssize_t uvcg_default_processing_##cname##_show( \ |
208 | struct uvcg_default_processing *dp, char *page) \ | 192 | struct config_item *item, char *page) \ |
209 | { \ | 193 | { \ |
194 | struct uvcg_default_processing *dp = to_uvcg_default_processing(item); \ | ||
210 | struct f_uvc_opts *opts; \ | 195 | struct f_uvc_opts *opts; \ |
211 | struct config_item *opts_item; \ | 196 | struct config_item *opts_item; \ |
212 | struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; \ | 197 | struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; \ |
@@ -227,9 +212,7 @@ static ssize_t uvcg_default_processing_##cname##_show( \ | |||
227 | return result; \ | 212 | return result; \ |
228 | } \ | 213 | } \ |
229 | \ | 214 | \ |
230 | static struct uvcg_default_processing_attribute \ | 215 | UVC_ATTR_RO(uvcg_default_processing_, cname, aname) |
231 | uvcg_default_processing_##cname = \ | ||
232 | __CONFIGFS_ATTR_RO(aname, uvcg_default_processing_##cname##_show) | ||
233 | 216 | ||
234 | #define identity_conv(x) (x) | 217 | #define identity_conv(x) (x) |
235 | 218 | ||
@@ -243,8 +226,9 @@ UVCG_DEFAULT_PROCESSING_ATTR(i_processing, iProcessing, identity_conv); | |||
243 | #undef UVCG_DEFAULT_PROCESSING_ATTR | 226 | #undef UVCG_DEFAULT_PROCESSING_ATTR |
244 | 227 | ||
245 | static ssize_t uvcg_default_processing_bm_controls_show( | 228 | static ssize_t uvcg_default_processing_bm_controls_show( |
246 | struct uvcg_default_processing *dp, char *page) | 229 | struct config_item *item, char *page) |
247 | { | 230 | { |
231 | struct uvcg_default_processing *dp = to_uvcg_default_processing(item); | ||
248 | struct f_uvc_opts *opts; | 232 | struct f_uvc_opts *opts; |
249 | struct config_item *opts_item; | 233 | struct config_item *opts_item; |
250 | struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; | 234 | struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; |
@@ -270,22 +254,18 @@ static ssize_t uvcg_default_processing_bm_controls_show( | |||
270 | return result; | 254 | return result; |
271 | } | 255 | } |
272 | 256 | ||
273 | static struct uvcg_default_processing_attribute | 257 | UVC_ATTR_RO(uvcg_default_processing_, bm_controls, bmControls); |
274 | uvcg_default_processing_bm_controls = | ||
275 | __CONFIGFS_ATTR_RO(bmControls, | ||
276 | uvcg_default_processing_bm_controls_show); | ||
277 | 258 | ||
278 | static struct configfs_attribute *uvcg_default_processing_attrs[] = { | 259 | static struct configfs_attribute *uvcg_default_processing_attrs[] = { |
279 | &uvcg_default_processing_b_unit_id.attr, | 260 | &uvcg_default_processing_attr_b_unit_id, |
280 | &uvcg_default_processing_b_source_id.attr, | 261 | &uvcg_default_processing_attr_b_source_id, |
281 | &uvcg_default_processing_w_max_multiplier.attr, | 262 | &uvcg_default_processing_attr_w_max_multiplier, |
282 | &uvcg_default_processing_bm_controls.attr, | 263 | &uvcg_default_processing_attr_bm_controls, |
283 | &uvcg_default_processing_i_processing.attr, | 264 | &uvcg_default_processing_attr_i_processing, |
284 | NULL, | 265 | NULL, |
285 | }; | 266 | }; |
286 | 267 | ||
287 | static struct config_item_type uvcg_default_processing_type = { | 268 | static struct config_item_type uvcg_default_processing_type = { |
288 | .ct_item_ops = &uvcg_default_processing_item_ops, | ||
289 | .ct_attrs = uvcg_default_processing_attrs, | 269 | .ct_attrs = uvcg_default_processing_attrs, |
290 | .ct_owner = THIS_MODULE, | 270 | .ct_owner = THIS_MODULE, |
291 | }; | 271 | }; |
@@ -318,17 +298,11 @@ static inline struct uvcg_default_camera | |||
318 | struct uvcg_default_camera, group); | 298 | struct uvcg_default_camera, group); |
319 | } | 299 | } |
320 | 300 | ||
321 | CONFIGFS_ATTR_STRUCT(uvcg_default_camera); | ||
322 | CONFIGFS_ATTR_OPS_RO(uvcg_default_camera); | ||
323 | |||
324 | static struct configfs_item_operations uvcg_default_camera_item_ops = { | ||
325 | .show_attribute = uvcg_default_camera_attr_show, | ||
326 | }; | ||
327 | |||
328 | #define UVCG_DEFAULT_CAMERA_ATTR(cname, aname, conv) \ | 301 | #define UVCG_DEFAULT_CAMERA_ATTR(cname, aname, conv) \ |
329 | static ssize_t uvcg_default_camera_##cname##_show( \ | 302 | static ssize_t uvcg_default_camera_##cname##_show( \ |
330 | struct uvcg_default_camera *dc, char *page) \ | 303 | struct config_item *item, char *page) \ |
331 | { \ | 304 | { \ |
305 | struct uvcg_default_camera *dc = to_uvcg_default_camera(item); \ | ||
332 | struct f_uvc_opts *opts; \ | 306 | struct f_uvc_opts *opts; \ |
333 | struct config_item *opts_item; \ | 307 | struct config_item *opts_item; \ |
334 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ | 308 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ |
@@ -351,9 +325,7 @@ static ssize_t uvcg_default_camera_##cname##_show( \ | |||
351 | return result; \ | 325 | return result; \ |
352 | } \ | 326 | } \ |
353 | \ | 327 | \ |
354 | static struct uvcg_default_camera_attribute \ | 328 | UVC_ATTR_RO(uvcg_default_camera_, cname, aname) |
355 | uvcg_default_camera_##cname = \ | ||
356 | __CONFIGFS_ATTR_RO(aname, uvcg_default_camera_##cname##_show) | ||
357 | 329 | ||
358 | #define identity_conv(x) (x) | 330 | #define identity_conv(x) (x) |
359 | 331 | ||
@@ -373,8 +345,9 @@ UVCG_DEFAULT_CAMERA_ATTR(w_ocular_focal_length, wOcularFocalLength, | |||
373 | #undef UVCG_DEFAULT_CAMERA_ATTR | 345 | #undef UVCG_DEFAULT_CAMERA_ATTR |
374 | 346 | ||
375 | static ssize_t uvcg_default_camera_bm_controls_show( | 347 | static ssize_t uvcg_default_camera_bm_controls_show( |
376 | struct uvcg_default_camera *dc, char *page) | 348 | struct config_item *item, char *page) |
377 | { | 349 | { |
350 | struct uvcg_default_camera *dc = to_uvcg_default_camera(item); | ||
378 | struct f_uvc_opts *opts; | 351 | struct f_uvc_opts *opts; |
379 | struct config_item *opts_item; | 352 | struct config_item *opts_item; |
380 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; | 353 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; |
@@ -400,24 +373,21 @@ static ssize_t uvcg_default_camera_bm_controls_show( | |||
400 | return result; | 373 | return result; |
401 | } | 374 | } |
402 | 375 | ||
403 | static struct uvcg_default_camera_attribute | 376 | UVC_ATTR_RO(uvcg_default_camera_, bm_controls, bmControls); |
404 | uvcg_default_camera_bm_controls = | ||
405 | __CONFIGFS_ATTR_RO(bmControls, uvcg_default_camera_bm_controls_show); | ||
406 | 377 | ||
407 | static struct configfs_attribute *uvcg_default_camera_attrs[] = { | 378 | static struct configfs_attribute *uvcg_default_camera_attrs[] = { |
408 | &uvcg_default_camera_b_terminal_id.attr, | 379 | &uvcg_default_camera_attr_b_terminal_id, |
409 | &uvcg_default_camera_w_terminal_type.attr, | 380 | &uvcg_default_camera_attr_w_terminal_type, |
410 | &uvcg_default_camera_b_assoc_terminal.attr, | 381 | &uvcg_default_camera_attr_b_assoc_terminal, |
411 | &uvcg_default_camera_i_terminal.attr, | 382 | &uvcg_default_camera_attr_i_terminal, |
412 | &uvcg_default_camera_w_objective_focal_length_min.attr, | 383 | &uvcg_default_camera_attr_w_objective_focal_length_min, |
413 | &uvcg_default_camera_w_objective_focal_length_max.attr, | 384 | &uvcg_default_camera_attr_w_objective_focal_length_max, |
414 | &uvcg_default_camera_w_ocular_focal_length.attr, | 385 | &uvcg_default_camera_attr_w_ocular_focal_length, |
415 | &uvcg_default_camera_bm_controls.attr, | 386 | &uvcg_default_camera_attr_bm_controls, |
416 | NULL, | 387 | NULL, |
417 | }; | 388 | }; |
418 | 389 | ||
419 | static struct config_item_type uvcg_default_camera_type = { | 390 | static struct config_item_type uvcg_default_camera_type = { |
420 | .ct_item_ops = &uvcg_default_camera_item_ops, | ||
421 | .ct_attrs = uvcg_default_camera_attrs, | 391 | .ct_attrs = uvcg_default_camera_attrs, |
422 | .ct_owner = THIS_MODULE, | 392 | .ct_owner = THIS_MODULE, |
423 | }; | 393 | }; |
@@ -450,17 +420,11 @@ static inline struct uvcg_default_output | |||
450 | struct uvcg_default_output, group); | 420 | struct uvcg_default_output, group); |
451 | } | 421 | } |
452 | 422 | ||
453 | CONFIGFS_ATTR_STRUCT(uvcg_default_output); | ||
454 | CONFIGFS_ATTR_OPS_RO(uvcg_default_output); | ||
455 | |||
456 | static struct configfs_item_operations uvcg_default_output_item_ops = { | ||
457 | .show_attribute = uvcg_default_output_attr_show, | ||
458 | }; | ||
459 | |||
460 | #define UVCG_DEFAULT_OUTPUT_ATTR(cname, aname, conv) \ | 423 | #define UVCG_DEFAULT_OUTPUT_ATTR(cname, aname, conv) \ |
461 | static ssize_t uvcg_default_output_##cname##_show( \ | 424 | static ssize_t uvcg_default_output_##cname##_show( \ |
462 | struct uvcg_default_output *dout, char *page) \ | 425 | struct config_item *item, char *page) \ |
463 | { \ | 426 | { \ |
427 | struct uvcg_default_output *dout = to_uvcg_default_output(item); \ | ||
464 | struct f_uvc_opts *opts; \ | 428 | struct f_uvc_opts *opts; \ |
465 | struct config_item *opts_item; \ | 429 | struct config_item *opts_item; \ |
466 | struct mutex *su_mutex = &dout->group.cg_subsys->su_mutex; \ | 430 | struct mutex *su_mutex = &dout->group.cg_subsys->su_mutex; \ |
@@ -483,9 +447,7 @@ static ssize_t uvcg_default_output_##cname##_show( \ | |||
483 | return result; \ | 447 | return result; \ |
484 | } \ | 448 | } \ |
485 | \ | 449 | \ |
486 | static struct uvcg_default_output_attribute \ | 450 | UVC_ATTR_RO(uvcg_default_output_, cname, aname) |
487 | uvcg_default_output_##cname = \ | ||
488 | __CONFIGFS_ATTR_RO(aname, uvcg_default_output_##cname##_show) | ||
489 | 451 | ||
490 | #define identity_conv(x) (x) | 452 | #define identity_conv(x) (x) |
491 | 453 | ||
@@ -500,16 +462,15 @@ UVCG_DEFAULT_OUTPUT_ATTR(i_terminal, iTerminal, identity_conv); | |||
500 | #undef UVCG_DEFAULT_OUTPUT_ATTR | 462 | #undef UVCG_DEFAULT_OUTPUT_ATTR |
501 | 463 | ||
502 | static struct configfs_attribute *uvcg_default_output_attrs[] = { | 464 | static struct configfs_attribute *uvcg_default_output_attrs[] = { |
503 | &uvcg_default_output_b_terminal_id.attr, | 465 | &uvcg_default_output_attr_b_terminal_id, |
504 | &uvcg_default_output_w_terminal_type.attr, | 466 | &uvcg_default_output_attr_w_terminal_type, |
505 | &uvcg_default_output_b_assoc_terminal.attr, | 467 | &uvcg_default_output_attr_b_assoc_terminal, |
506 | &uvcg_default_output_b_source_id.attr, | 468 | &uvcg_default_output_attr_b_source_id, |
507 | &uvcg_default_output_i_terminal.attr, | 469 | &uvcg_default_output_attr_i_terminal, |
508 | NULL, | 470 | NULL, |
509 | }; | 471 | }; |
510 | 472 | ||
511 | static struct config_item_type uvcg_default_output_type = { | 473 | static struct config_item_type uvcg_default_output_type = { |
512 | .ct_item_ops = &uvcg_default_output_item_ops, | ||
513 | .ct_attrs = uvcg_default_output_attrs, | 474 | .ct_attrs = uvcg_default_output_attrs, |
514 | .ct_owner = THIS_MODULE, | 475 | .ct_owner = THIS_MODULE, |
515 | }; | 476 | }; |
@@ -800,9 +761,6 @@ static struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item | |||
800 | return container_of(item, struct uvcg_streaming_header, item); | 761 | return container_of(item, struct uvcg_streaming_header, item); |
801 | } | 762 | } |
802 | 763 | ||
803 | CONFIGFS_ATTR_STRUCT(uvcg_streaming_header); | ||
804 | CONFIGFS_ATTR_OPS(uvcg_streaming_header); | ||
805 | |||
806 | static int uvcg_streaming_header_allow_link(struct config_item *src, | 764 | static int uvcg_streaming_header_allow_link(struct config_item *src, |
807 | struct config_item *target) | 765 | struct config_item *target) |
808 | { | 766 | { |
@@ -893,16 +851,15 @@ out: | |||
893 | } | 851 | } |
894 | 852 | ||
895 | static struct configfs_item_operations uvcg_streaming_header_item_ops = { | 853 | static struct configfs_item_operations uvcg_streaming_header_item_ops = { |
896 | .show_attribute = uvcg_streaming_header_attr_show, | ||
897 | .store_attribute = uvcg_streaming_header_attr_store, | ||
898 | .allow_link = uvcg_streaming_header_allow_link, | 854 | .allow_link = uvcg_streaming_header_allow_link, |
899 | .drop_link = uvcg_streaming_header_drop_link, | 855 | .drop_link = uvcg_streaming_header_drop_link, |
900 | }; | 856 | }; |
901 | 857 | ||
902 | #define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \ | 858 | #define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \ |
903 | static ssize_t uvcg_streaming_header_##cname##_show( \ | 859 | static ssize_t uvcg_streaming_header_##cname##_show( \ |
904 | struct uvcg_streaming_header *sh, char *page) \ | 860 | struct config_item *item, char *page) \ |
905 | { \ | 861 | { \ |
862 | struct uvcg_streaming_header *sh = to_uvcg_streaming_header(item); \ | ||
906 | struct f_uvc_opts *opts; \ | 863 | struct f_uvc_opts *opts; \ |
907 | struct config_item *opts_item; \ | 864 | struct config_item *opts_item; \ |
908 | struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\ | 865 | struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\ |
@@ -921,9 +878,7 @@ static ssize_t uvcg_streaming_header_##cname##_show( \ | |||
921 | return result; \ | 878 | return result; \ |
922 | } \ | 879 | } \ |
923 | \ | 880 | \ |
924 | static struct uvcg_streaming_header_attribute \ | 881 | UVC_ATTR_RO(uvcg_streaming_header_, cname, aname) |
925 | uvcg_streaming_header_##cname = \ | ||
926 | __CONFIGFS_ATTR_RO(aname, uvcg_streaming_header_##cname##_show) | ||
927 | 882 | ||
928 | #define identity_conv(x) (x) | 883 | #define identity_conv(x) (x) |
929 | 884 | ||
@@ -939,11 +894,11 @@ UVCG_STREAMING_HEADER_ATTR(b_trigger_usage, bTriggerUsage, identity_conv); | |||
939 | #undef UVCG_STREAMING_HEADER_ATTR | 894 | #undef UVCG_STREAMING_HEADER_ATTR |
940 | 895 | ||
941 | static struct configfs_attribute *uvcg_streaming_header_attrs[] = { | 896 | static struct configfs_attribute *uvcg_streaming_header_attrs[] = { |
942 | &uvcg_streaming_header_bm_info.attr, | 897 | &uvcg_streaming_header_attr_bm_info, |
943 | &uvcg_streaming_header_b_terminal_link.attr, | 898 | &uvcg_streaming_header_attr_b_terminal_link, |
944 | &uvcg_streaming_header_b_still_capture_method.attr, | 899 | &uvcg_streaming_header_attr_b_still_capture_method, |
945 | &uvcg_streaming_header_b_trigger_support.attr, | 900 | &uvcg_streaming_header_attr_b_trigger_support, |
946 | &uvcg_streaming_header_b_trigger_usage.attr, | 901 | &uvcg_streaming_header_attr_b_trigger_usage, |
947 | NULL, | 902 | NULL, |
948 | }; | 903 | }; |
949 | 904 | ||
@@ -1022,17 +977,10 @@ static struct uvcg_frame *to_uvcg_frame(struct config_item *item) | |||
1022 | return container_of(item, struct uvcg_frame, item); | 977 | return container_of(item, struct uvcg_frame, item); |
1023 | } | 978 | } |
1024 | 979 | ||
1025 | CONFIGFS_ATTR_STRUCT(uvcg_frame); | ||
1026 | CONFIGFS_ATTR_OPS(uvcg_frame); | ||
1027 | |||
1028 | static struct configfs_item_operations uvcg_frame_item_ops = { | ||
1029 | .show_attribute = uvcg_frame_attr_show, | ||
1030 | .store_attribute = uvcg_frame_attr_store, | ||
1031 | }; | ||
1032 | |||
1033 | #define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \ | 980 | #define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \ |
1034 | static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\ | 981 | static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\ |
1035 | { \ | 982 | { \ |
983 | struct uvcg_frame *f = to_uvcg_frame(item); \ | ||
1036 | struct f_uvc_opts *opts; \ | 984 | struct f_uvc_opts *opts; \ |
1037 | struct config_item *opts_item; \ | 985 | struct config_item *opts_item; \ |
1038 | struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\ | 986 | struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\ |
@@ -1051,9 +999,10 @@ static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\ | |||
1051 | return result; \ | 999 | return result; \ |
1052 | } \ | 1000 | } \ |
1053 | \ | 1001 | \ |
1054 | static ssize_t uvcg_frame_##cname##_store(struct uvcg_frame *f, \ | 1002 | static ssize_t uvcg_frame_##cname##_store(struct config_item *item, \ |
1055 | const char *page, size_t len)\ | 1003 | const char *page, size_t len)\ |
1056 | { \ | 1004 | { \ |
1005 | struct uvcg_frame *f = to_uvcg_frame(item); \ | ||
1057 | struct f_uvc_opts *opts; \ | 1006 | struct f_uvc_opts *opts; \ |
1058 | struct config_item *opts_item; \ | 1007 | struct config_item *opts_item; \ |
1059 | struct uvcg_format *fmt; \ | 1008 | struct uvcg_format *fmt; \ |
@@ -1085,11 +1034,7 @@ end: \ | |||
1085 | return ret; \ | 1034 | return ret; \ |
1086 | } \ | 1035 | } \ |
1087 | \ | 1036 | \ |
1088 | static struct uvcg_frame_attribute \ | 1037 | UVC_ATTR(uvcg_frame_, cname, aname); |
1089 | uvcg_frame_##cname = \ | ||
1090 | __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ | ||
1091 | uvcg_frame_##cname##_show, \ | ||
1092 | uvcg_frame_##cname##_store) | ||
1093 | 1038 | ||
1094 | #define noop_conversion(x) (x) | 1039 | #define noop_conversion(x) (x) |
1095 | 1040 | ||
@@ -1108,9 +1053,10 @@ UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval, | |||
1108 | 1053 | ||
1109 | #undef UVCG_FRAME_ATTR | 1054 | #undef UVCG_FRAME_ATTR |
1110 | 1055 | ||
1111 | static ssize_t uvcg_frame_dw_frame_interval_show(struct uvcg_frame *frm, | 1056 | static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item, |
1112 | char *page) | 1057 | char *page) |
1113 | { | 1058 | { |
1059 | struct uvcg_frame *frm = to_uvcg_frame(item); | ||
1114 | struct f_uvc_opts *opts; | 1060 | struct f_uvc_opts *opts; |
1115 | struct config_item *opts_item; | 1061 | struct config_item *opts_item; |
1116 | struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex; | 1062 | struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex; |
@@ -1185,9 +1131,10 @@ static int __uvcg_iter_frm_intrv(const char *page, size_t len, | |||
1185 | return 0; | 1131 | return 0; |
1186 | } | 1132 | } |
1187 | 1133 | ||
1188 | static ssize_t uvcg_frame_dw_frame_interval_store(struct uvcg_frame *ch, | 1134 | static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item, |
1189 | const char *page, size_t len) | 1135 | const char *page, size_t len) |
1190 | { | 1136 | { |
1137 | struct uvcg_frame *ch = to_uvcg_frame(item); | ||
1191 | struct f_uvc_opts *opts; | 1138 | struct f_uvc_opts *opts; |
1192 | struct config_item *opts_item; | 1139 | struct config_item *opts_item; |
1193 | struct uvcg_format *fmt; | 1140 | struct uvcg_format *fmt; |
@@ -1234,26 +1181,21 @@ end: | |||
1234 | return ret; | 1181 | return ret; |
1235 | } | 1182 | } |
1236 | 1183 | ||
1237 | static struct uvcg_frame_attribute | 1184 | UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval); |
1238 | uvcg_frame_dw_frame_interval = | ||
1239 | __CONFIGFS_ATTR(dwFrameInterval, S_IRUGO | S_IWUSR, | ||
1240 | uvcg_frame_dw_frame_interval_show, | ||
1241 | uvcg_frame_dw_frame_interval_store); | ||
1242 | 1185 | ||
1243 | static struct configfs_attribute *uvcg_frame_attrs[] = { | 1186 | static struct configfs_attribute *uvcg_frame_attrs[] = { |
1244 | &uvcg_frame_bm_capabilities.attr, | 1187 | &uvcg_frame_attr_bm_capabilities, |
1245 | &uvcg_frame_w_width.attr, | 1188 | &uvcg_frame_attr_w_width, |
1246 | &uvcg_frame_w_height.attr, | 1189 | &uvcg_frame_attr_w_height, |
1247 | &uvcg_frame_dw_min_bit_rate.attr, | 1190 | &uvcg_frame_attr_dw_min_bit_rate, |
1248 | &uvcg_frame_dw_max_bit_rate.attr, | 1191 | &uvcg_frame_attr_dw_max_bit_rate, |
1249 | &uvcg_frame_dw_max_video_frame_buffer_size.attr, | 1192 | &uvcg_frame_attr_dw_max_video_frame_buffer_size, |
1250 | &uvcg_frame_dw_default_frame_interval.attr, | 1193 | &uvcg_frame_attr_dw_default_frame_interval, |
1251 | &uvcg_frame_dw_frame_interval.attr, | 1194 | &uvcg_frame_attr_dw_frame_interval, |
1252 | NULL, | 1195 | NULL, |
1253 | }; | 1196 | }; |
1254 | 1197 | ||
1255 | static struct config_item_type uvcg_frame_type = { | 1198 | static struct config_item_type uvcg_frame_type = { |
1256 | .ct_item_ops = &uvcg_frame_item_ops, | ||
1257 | .ct_attrs = uvcg_frame_attrs, | 1199 | .ct_attrs = uvcg_frame_attrs, |
1258 | .ct_owner = THIS_MODULE, | 1200 | .ct_owner = THIS_MODULE, |
1259 | }; | 1201 | }; |
@@ -1333,22 +1275,15 @@ static struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item) | |||
1333 | struct uvcg_uncompressed, fmt); | 1275 | struct uvcg_uncompressed, fmt); |
1334 | } | 1276 | } |
1335 | 1277 | ||
1336 | CONFIGFS_ATTR_STRUCT(uvcg_uncompressed); | ||
1337 | CONFIGFS_ATTR_OPS(uvcg_uncompressed); | ||
1338 | |||
1339 | static struct configfs_item_operations uvcg_uncompressed_item_ops = { | ||
1340 | .show_attribute = uvcg_uncompressed_attr_show, | ||
1341 | .store_attribute = uvcg_uncompressed_attr_store, | ||
1342 | }; | ||
1343 | |||
1344 | static struct configfs_group_operations uvcg_uncompressed_group_ops = { | 1278 | static struct configfs_group_operations uvcg_uncompressed_group_ops = { |
1345 | .make_item = uvcg_frame_make, | 1279 | .make_item = uvcg_frame_make, |
1346 | .drop_item = uvcg_frame_drop, | 1280 | .drop_item = uvcg_frame_drop, |
1347 | }; | 1281 | }; |
1348 | 1282 | ||
1349 | static ssize_t uvcg_uncompressed_guid_format_show(struct uvcg_uncompressed *ch, | 1283 | static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item, |
1350 | char *page) | 1284 | char *page) |
1351 | { | 1285 | { |
1286 | struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item); | ||
1352 | struct f_uvc_opts *opts; | 1287 | struct f_uvc_opts *opts; |
1353 | struct config_item *opts_item; | 1288 | struct config_item *opts_item; |
1354 | struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; | 1289 | struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; |
@@ -1367,9 +1302,10 @@ static ssize_t uvcg_uncompressed_guid_format_show(struct uvcg_uncompressed *ch, | |||
1367 | return sizeof(ch->desc.guidFormat); | 1302 | return sizeof(ch->desc.guidFormat); |
1368 | } | 1303 | } |
1369 | 1304 | ||
1370 | static ssize_t uvcg_uncompressed_guid_format_store(struct uvcg_uncompressed *ch, | 1305 | static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item, |
1371 | const char *page, size_t len) | 1306 | const char *page, size_t len) |
1372 | { | 1307 | { |
1308 | struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item); | ||
1373 | struct f_uvc_opts *opts; | 1309 | struct f_uvc_opts *opts; |
1374 | struct config_item *opts_item; | 1310 | struct config_item *opts_item; |
1375 | struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; | 1311 | struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; |
@@ -1396,16 +1332,13 @@ end: | |||
1396 | return ret; | 1332 | return ret; |
1397 | } | 1333 | } |
1398 | 1334 | ||
1399 | static struct uvcg_uncompressed_attribute uvcg_uncompressed_guid_format = | 1335 | UVC_ATTR(uvcg_uncompressed_, guid_format, guidFormat); |
1400 | __CONFIGFS_ATTR(guidFormat, S_IRUGO | S_IWUSR, | ||
1401 | uvcg_uncompressed_guid_format_show, | ||
1402 | uvcg_uncompressed_guid_format_store); | ||
1403 | |||
1404 | 1336 | ||
1405 | #define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \ | 1337 | #define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \ |
1406 | static ssize_t uvcg_uncompressed_##cname##_show( \ | 1338 | static ssize_t uvcg_uncompressed_##cname##_show( \ |
1407 | struct uvcg_uncompressed *u, char *page) \ | 1339 | struct config_item *item, char *page) \ |
1408 | { \ | 1340 | { \ |
1341 | struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ | ||
1409 | struct f_uvc_opts *opts; \ | 1342 | struct f_uvc_opts *opts; \ |
1410 | struct config_item *opts_item; \ | 1343 | struct config_item *opts_item; \ |
1411 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1344 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1424,14 +1357,13 @@ static ssize_t uvcg_uncompressed_##cname##_show( \ | |||
1424 | return result; \ | 1357 | return result; \ |
1425 | } \ | 1358 | } \ |
1426 | \ | 1359 | \ |
1427 | static struct uvcg_uncompressed_attribute \ | 1360 | UVC_ATTR_RO(uvcg_uncompressed_, cname, aname); |
1428 | uvcg_uncompressed_##cname = \ | ||
1429 | __CONFIGFS_ATTR_RO(aname, uvcg_uncompressed_##cname##_show) | ||
1430 | 1361 | ||
1431 | #define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \ | 1362 | #define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \ |
1432 | static ssize_t uvcg_uncompressed_##cname##_show( \ | 1363 | static ssize_t uvcg_uncompressed_##cname##_show( \ |
1433 | struct uvcg_uncompressed *u, char *page) \ | 1364 | struct config_item *item, char *page) \ |
1434 | { \ | 1365 | { \ |
1366 | struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ | ||
1435 | struct f_uvc_opts *opts; \ | 1367 | struct f_uvc_opts *opts; \ |
1436 | struct config_item *opts_item; \ | 1368 | struct config_item *opts_item; \ |
1437 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1369 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1451,9 +1383,10 @@ static ssize_t uvcg_uncompressed_##cname##_show( \ | |||
1451 | } \ | 1383 | } \ |
1452 | \ | 1384 | \ |
1453 | static ssize_t \ | 1385 | static ssize_t \ |
1454 | uvcg_uncompressed_##cname##_store(struct uvcg_uncompressed *u, \ | 1386 | uvcg_uncompressed_##cname##_store(struct config_item *item, \ |
1455 | const char *page, size_t len) \ | 1387 | const char *page, size_t len) \ |
1456 | { \ | 1388 | { \ |
1389 | struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ | ||
1457 | struct f_uvc_opts *opts; \ | 1390 | struct f_uvc_opts *opts; \ |
1458 | struct config_item *opts_item; \ | 1391 | struct config_item *opts_item; \ |
1459 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1392 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1487,11 +1420,7 @@ end: \ | |||
1487 | return ret; \ | 1420 | return ret; \ |
1488 | } \ | 1421 | } \ |
1489 | \ | 1422 | \ |
1490 | static struct uvcg_uncompressed_attribute \ | 1423 | UVC_ATTR(uvcg_uncompressed_, cname, aname); |
1491 | uvcg_uncompressed_##cname = \ | ||
1492 | __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ | ||
1493 | uvcg_uncompressed_##cname##_show, \ | ||
1494 | uvcg_uncompressed_##cname##_store) | ||
1495 | 1424 | ||
1496 | #define identity_conv(x) (x) | 1425 | #define identity_conv(x) (x) |
1497 | 1426 | ||
@@ -1508,36 +1437,34 @@ UVCG_UNCOMPRESSED_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv); | |||
1508 | #undef UVCG_UNCOMPRESSED_ATTR_RO | 1437 | #undef UVCG_UNCOMPRESSED_ATTR_RO |
1509 | 1438 | ||
1510 | static inline ssize_t | 1439 | static inline ssize_t |
1511 | uvcg_uncompressed_bma_controls_show(struct uvcg_uncompressed *unc, char *page) | 1440 | uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page) |
1512 | { | 1441 | { |
1442 | struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item); | ||
1513 | return uvcg_format_bma_controls_show(&unc->fmt, page); | 1443 | return uvcg_format_bma_controls_show(&unc->fmt, page); |
1514 | } | 1444 | } |
1515 | 1445 | ||
1516 | static inline ssize_t | 1446 | static inline ssize_t |
1517 | uvcg_uncompressed_bma_controls_store(struct uvcg_uncompressed *ch, | 1447 | uvcg_uncompressed_bma_controls_store(struct config_item *item, |
1518 | const char *page, size_t len) | 1448 | const char *page, size_t len) |
1519 | { | 1449 | { |
1520 | return uvcg_format_bma_controls_store(&ch->fmt, page, len); | 1450 | struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item); |
1451 | return uvcg_format_bma_controls_store(&unc->fmt, page, len); | ||
1521 | } | 1452 | } |
1522 | 1453 | ||
1523 | static struct uvcg_uncompressed_attribute uvcg_uncompressed_bma_controls = | 1454 | UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls); |
1524 | __CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR, | ||
1525 | uvcg_uncompressed_bma_controls_show, | ||
1526 | uvcg_uncompressed_bma_controls_store); | ||
1527 | 1455 | ||
1528 | static struct configfs_attribute *uvcg_uncompressed_attrs[] = { | 1456 | static struct configfs_attribute *uvcg_uncompressed_attrs[] = { |
1529 | &uvcg_uncompressed_guid_format.attr, | 1457 | &uvcg_uncompressed_attr_guid_format, |
1530 | &uvcg_uncompressed_b_bits_per_pixel.attr, | 1458 | &uvcg_uncompressed_attr_b_bits_per_pixel, |
1531 | &uvcg_uncompressed_b_default_frame_index.attr, | 1459 | &uvcg_uncompressed_attr_b_default_frame_index, |
1532 | &uvcg_uncompressed_b_aspect_ratio_x.attr, | 1460 | &uvcg_uncompressed_attr_b_aspect_ratio_x, |
1533 | &uvcg_uncompressed_b_aspect_ratio_y.attr, | 1461 | &uvcg_uncompressed_attr_b_aspect_ratio_y, |
1534 | &uvcg_uncompressed_bm_interface_flags.attr, | 1462 | &uvcg_uncompressed_attr_bm_interface_flags, |
1535 | &uvcg_uncompressed_bma_controls.attr, | 1463 | &uvcg_uncompressed_attr_bma_controls, |
1536 | NULL, | 1464 | NULL, |
1537 | }; | 1465 | }; |
1538 | 1466 | ||
1539 | static struct config_item_type uvcg_uncompressed_type = { | 1467 | static struct config_item_type uvcg_uncompressed_type = { |
1540 | .ct_item_ops = &uvcg_uncompressed_item_ops, | ||
1541 | .ct_group_ops = &uvcg_uncompressed_group_ops, | 1468 | .ct_group_ops = &uvcg_uncompressed_group_ops, |
1542 | .ct_attrs = uvcg_uncompressed_attrs, | 1469 | .ct_attrs = uvcg_uncompressed_attrs, |
1543 | .ct_owner = THIS_MODULE, | 1470 | .ct_owner = THIS_MODULE, |
@@ -1605,22 +1532,15 @@ static struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item) | |||
1605 | struct uvcg_mjpeg, fmt); | 1532 | struct uvcg_mjpeg, fmt); |
1606 | } | 1533 | } |
1607 | 1534 | ||
1608 | CONFIGFS_ATTR_STRUCT(uvcg_mjpeg); | ||
1609 | CONFIGFS_ATTR_OPS(uvcg_mjpeg); | ||
1610 | |||
1611 | static struct configfs_item_operations uvcg_mjpeg_item_ops = { | ||
1612 | .show_attribute = uvcg_mjpeg_attr_show, | ||
1613 | .store_attribute = uvcg_mjpeg_attr_store, | ||
1614 | }; | ||
1615 | |||
1616 | static struct configfs_group_operations uvcg_mjpeg_group_ops = { | 1535 | static struct configfs_group_operations uvcg_mjpeg_group_ops = { |
1617 | .make_item = uvcg_frame_make, | 1536 | .make_item = uvcg_frame_make, |
1618 | .drop_item = uvcg_frame_drop, | 1537 | .drop_item = uvcg_frame_drop, |
1619 | }; | 1538 | }; |
1620 | 1539 | ||
1621 | #define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \ | 1540 | #define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \ |
1622 | static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ | 1541 | static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\ |
1623 | { \ | 1542 | { \ |
1543 | struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ | ||
1624 | struct f_uvc_opts *opts; \ | 1544 | struct f_uvc_opts *opts; \ |
1625 | struct config_item *opts_item; \ | 1545 | struct config_item *opts_item; \ |
1626 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1546 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1639,13 +1559,12 @@ static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ | |||
1639 | return result; \ | 1559 | return result; \ |
1640 | } \ | 1560 | } \ |
1641 | \ | 1561 | \ |
1642 | static struct uvcg_mjpeg_attribute \ | 1562 | UVC_ATTR_RO(uvcg_mjpeg_, cname, aname) |
1643 | uvcg_mjpeg_##cname = \ | ||
1644 | __CONFIGFS_ATTR_RO(aname, uvcg_mjpeg_##cname##_show) | ||
1645 | 1563 | ||
1646 | #define UVCG_MJPEG_ATTR(cname, aname, conv) \ | 1564 | #define UVCG_MJPEG_ATTR(cname, aname, conv) \ |
1647 | static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ | 1565 | static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\ |
1648 | { \ | 1566 | { \ |
1567 | struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ | ||
1649 | struct f_uvc_opts *opts; \ | 1568 | struct f_uvc_opts *opts; \ |
1650 | struct config_item *opts_item; \ | 1569 | struct config_item *opts_item; \ |
1651 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1570 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1665,9 +1584,10 @@ static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ | |||
1665 | } \ | 1584 | } \ |
1666 | \ | 1585 | \ |
1667 | static ssize_t \ | 1586 | static ssize_t \ |
1668 | uvcg_mjpeg_##cname##_store(struct uvcg_mjpeg *u, \ | 1587 | uvcg_mjpeg_##cname##_store(struct config_item *item, \ |
1669 | const char *page, size_t len) \ | 1588 | const char *page, size_t len) \ |
1670 | { \ | 1589 | { \ |
1590 | struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ | ||
1671 | struct f_uvc_opts *opts; \ | 1591 | struct f_uvc_opts *opts; \ |
1672 | struct config_item *opts_item; \ | 1592 | struct config_item *opts_item; \ |
1673 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ | 1593 | struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ |
@@ -1701,11 +1621,7 @@ end: \ | |||
1701 | return ret; \ | 1621 | return ret; \ |
1702 | } \ | 1622 | } \ |
1703 | \ | 1623 | \ |
1704 | static struct uvcg_mjpeg_attribute \ | 1624 | UVC_ATTR(uvcg_mjpeg_, cname, aname) |
1705 | uvcg_mjpeg_##cname = \ | ||
1706 | __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ | ||
1707 | uvcg_mjpeg_##cname##_show, \ | ||
1708 | uvcg_mjpeg_##cname##_store) | ||
1709 | 1625 | ||
1710 | #define identity_conv(x) (x) | 1626 | #define identity_conv(x) (x) |
1711 | 1627 | ||
@@ -1722,35 +1638,33 @@ UVCG_MJPEG_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv); | |||
1722 | #undef UVCG_MJPEG_ATTR_RO | 1638 | #undef UVCG_MJPEG_ATTR_RO |
1723 | 1639 | ||
1724 | static inline ssize_t | 1640 | static inline ssize_t |
1725 | uvcg_mjpeg_bma_controls_show(struct uvcg_mjpeg *unc, char *page) | 1641 | uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page) |
1726 | { | 1642 | { |
1727 | return uvcg_format_bma_controls_show(&unc->fmt, page); | 1643 | struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); |
1644 | return uvcg_format_bma_controls_show(&u->fmt, page); | ||
1728 | } | 1645 | } |
1729 | 1646 | ||
1730 | static inline ssize_t | 1647 | static inline ssize_t |
1731 | uvcg_mjpeg_bma_controls_store(struct uvcg_mjpeg *ch, | 1648 | uvcg_mjpeg_bma_controls_store(struct config_item *item, |
1732 | const char *page, size_t len) | 1649 | const char *page, size_t len) |
1733 | { | 1650 | { |
1734 | return uvcg_format_bma_controls_store(&ch->fmt, page, len); | 1651 | struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); |
1652 | return uvcg_format_bma_controls_store(&u->fmt, page, len); | ||
1735 | } | 1653 | } |
1736 | 1654 | ||
1737 | static struct uvcg_mjpeg_attribute uvcg_mjpeg_bma_controls = | 1655 | UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls); |
1738 | __CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR, | ||
1739 | uvcg_mjpeg_bma_controls_show, | ||
1740 | uvcg_mjpeg_bma_controls_store); | ||
1741 | 1656 | ||
1742 | static struct configfs_attribute *uvcg_mjpeg_attrs[] = { | 1657 | static struct configfs_attribute *uvcg_mjpeg_attrs[] = { |
1743 | &uvcg_mjpeg_b_default_frame_index.attr, | 1658 | &uvcg_mjpeg_attr_b_default_frame_index, |
1744 | &uvcg_mjpeg_bm_flags.attr, | 1659 | &uvcg_mjpeg_attr_bm_flags, |
1745 | &uvcg_mjpeg_b_aspect_ratio_x.attr, | 1660 | &uvcg_mjpeg_attr_b_aspect_ratio_x, |
1746 | &uvcg_mjpeg_b_aspect_ratio_y.attr, | 1661 | &uvcg_mjpeg_attr_b_aspect_ratio_y, |
1747 | &uvcg_mjpeg_bm_interface_flags.attr, | 1662 | &uvcg_mjpeg_attr_bm_interface_flags, |
1748 | &uvcg_mjpeg_bma_controls.attr, | 1663 | &uvcg_mjpeg_attr_bma_controls, |
1749 | NULL, | 1664 | NULL, |
1750 | }; | 1665 | }; |
1751 | 1666 | ||
1752 | static struct config_item_type uvcg_mjpeg_type = { | 1667 | static struct config_item_type uvcg_mjpeg_type = { |
1753 | .ct_item_ops = &uvcg_mjpeg_item_ops, | ||
1754 | .ct_group_ops = &uvcg_mjpeg_group_ops, | 1668 | .ct_group_ops = &uvcg_mjpeg_group_ops, |
1755 | .ct_attrs = uvcg_mjpeg_attrs, | 1669 | .ct_attrs = uvcg_mjpeg_attrs, |
1756 | .ct_owner = THIS_MODULE, | 1670 | .ct_owner = THIS_MODULE, |
@@ -1811,17 +1725,12 @@ static inline struct uvcg_default_color_matching | |||
1811 | struct uvcg_default_color_matching, group); | 1725 | struct uvcg_default_color_matching, group); |
1812 | } | 1726 | } |
1813 | 1727 | ||
1814 | CONFIGFS_ATTR_STRUCT(uvcg_default_color_matching); | ||
1815 | CONFIGFS_ATTR_OPS_RO(uvcg_default_color_matching); | ||
1816 | |||
1817 | static struct configfs_item_operations uvcg_default_color_matching_item_ops = { | ||
1818 | .show_attribute = uvcg_default_color_matching_attr_show, | ||
1819 | }; | ||
1820 | |||
1821 | #define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \ | 1728 | #define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \ |
1822 | static ssize_t uvcg_default_color_matching_##cname##_show( \ | 1729 | static ssize_t uvcg_default_color_matching_##cname##_show( \ |
1823 | struct uvcg_default_color_matching *dc, char *page) \ | 1730 | struct config_item *item, char *page) \ |
1824 | { \ | 1731 | { \ |
1732 | struct uvcg_default_color_matching *dc = \ | ||
1733 | to_uvcg_default_color_matching(item); \ | ||
1825 | struct f_uvc_opts *opts; \ | 1734 | struct f_uvc_opts *opts; \ |
1826 | struct config_item *opts_item; \ | 1735 | struct config_item *opts_item; \ |
1827 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ | 1736 | struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ |
@@ -1842,9 +1751,7 @@ static ssize_t uvcg_default_color_matching_##cname##_show( \ | |||
1842 | return result; \ | 1751 | return result; \ |
1843 | } \ | 1752 | } \ |
1844 | \ | 1753 | \ |
1845 | static struct uvcg_default_color_matching_attribute \ | 1754 | UVC_ATTR_RO(uvcg_default_color_matching_, cname, aname) |
1846 | uvcg_default_color_matching_##cname = \ | ||
1847 | __CONFIGFS_ATTR_RO(aname, uvcg_default_color_matching_##cname##_show) | ||
1848 | 1755 | ||
1849 | #define identity_conv(x) (x) | 1756 | #define identity_conv(x) (x) |
1850 | 1757 | ||
@@ -1860,14 +1767,13 @@ UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_matrix_coefficients, bMatrixCoefficients, | |||
1860 | #undef UVCG_DEFAULT_COLOR_MATCHING_ATTR | 1767 | #undef UVCG_DEFAULT_COLOR_MATCHING_ATTR |
1861 | 1768 | ||
1862 | static struct configfs_attribute *uvcg_default_color_matching_attrs[] = { | 1769 | static struct configfs_attribute *uvcg_default_color_matching_attrs[] = { |
1863 | &uvcg_default_color_matching_b_color_primaries.attr, | 1770 | &uvcg_default_color_matching_attr_b_color_primaries, |
1864 | &uvcg_default_color_matching_b_transfer_characteristics.attr, | 1771 | &uvcg_default_color_matching_attr_b_transfer_characteristics, |
1865 | &uvcg_default_color_matching_b_matrix_coefficients.attr, | 1772 | &uvcg_default_color_matching_attr_b_matrix_coefficients, |
1866 | NULL, | 1773 | NULL, |
1867 | }; | 1774 | }; |
1868 | 1775 | ||
1869 | static struct config_item_type uvcg_default_color_matching_type = { | 1776 | static struct config_item_type uvcg_default_color_matching_type = { |
1870 | .ct_item_ops = &uvcg_default_color_matching_item_ops, | ||
1871 | .ct_attrs = uvcg_default_color_matching_attrs, | 1777 | .ct_attrs = uvcg_default_color_matching_attrs, |
1872 | .ct_owner = THIS_MODULE, | 1778 | .ct_owner = THIS_MODULE, |
1873 | }; | 1779 | }; |
@@ -2285,9 +2191,6 @@ static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item) | |||
2285 | func_inst.group); | 2191 | func_inst.group); |
2286 | } | 2192 | } |
2287 | 2193 | ||
2288 | CONFIGFS_ATTR_STRUCT(f_uvc_opts); | ||
2289 | CONFIGFS_ATTR_OPS(f_uvc_opts); | ||
2290 | |||
2291 | static void uvc_attr_release(struct config_item *item) | 2194 | static void uvc_attr_release(struct config_item *item) |
2292 | { | 2195 | { |
2293 | struct f_uvc_opts *opts = to_f_uvc_opts(item); | 2196 | struct f_uvc_opts *opts = to_f_uvc_opts(item); |
@@ -2297,14 +2200,13 @@ static void uvc_attr_release(struct config_item *item) | |||
2297 | 2200 | ||
2298 | static struct configfs_item_operations uvc_item_ops = { | 2201 | static struct configfs_item_operations uvc_item_ops = { |
2299 | .release = uvc_attr_release, | 2202 | .release = uvc_attr_release, |
2300 | .show_attribute = f_uvc_opts_attr_show, | ||
2301 | .store_attribute = f_uvc_opts_attr_store, | ||
2302 | }; | 2203 | }; |
2303 | 2204 | ||
2304 | #define UVCG_OPTS_ATTR(cname, conv, str2u, uxx, vnoc, limit) \ | 2205 | #define UVCG_OPTS_ATTR(cname, conv, str2u, uxx, vnoc, limit) \ |
2305 | static ssize_t f_uvc_opts_##cname##_show( \ | 2206 | static ssize_t f_uvc_opts_##cname##_show( \ |
2306 | struct f_uvc_opts *opts, char *page) \ | 2207 | struct config_item *item, char *page) \ |
2307 | { \ | 2208 | { \ |
2209 | struct f_uvc_opts *opts = to_f_uvc_opts(item); \ | ||
2308 | int result; \ | 2210 | int result; \ |
2309 | \ | 2211 | \ |
2310 | mutex_lock(&opts->lock); \ | 2212 | mutex_lock(&opts->lock); \ |
@@ -2315,9 +2217,10 @@ static ssize_t f_uvc_opts_##cname##_show( \ | |||
2315 | } \ | 2217 | } \ |
2316 | \ | 2218 | \ |
2317 | static ssize_t \ | 2219 | static ssize_t \ |
2318 | f_uvc_opts_##cname##_store(struct f_uvc_opts *opts, \ | 2220 | f_uvc_opts_##cname##_store(struct config_item *item, \ |
2319 | const char *page, size_t len) \ | 2221 | const char *page, size_t len) \ |
2320 | { \ | 2222 | { \ |
2223 | struct f_uvc_opts *opts = to_f_uvc_opts(item); \ | ||
2321 | int ret; \ | 2224 | int ret; \ |
2322 | uxx num; \ | 2225 | uxx num; \ |
2323 | \ | 2226 | \ |
@@ -2342,11 +2245,7 @@ end: \ | |||
2342 | return ret; \ | 2245 | return ret; \ |
2343 | } \ | 2246 | } \ |
2344 | \ | 2247 | \ |
2345 | static struct f_uvc_opts_attribute \ | 2248 | UVC_ATTR(f_uvc_opts_, cname, aname) |
2346 | f_uvc_opts_attribute_##cname = \ | ||
2347 | __CONFIGFS_ATTR(cname, S_IRUGO | S_IWUSR, \ | ||
2348 | f_uvc_opts_##cname##_show, \ | ||
2349 | f_uvc_opts_##cname##_store) | ||
2350 | 2249 | ||
2351 | #define identity_conv(x) (x) | 2250 | #define identity_conv(x) (x) |
2352 | 2251 | ||
@@ -2362,9 +2261,9 @@ UVCG_OPTS_ATTR(streaming_maxburst, identity_conv, kstrtou8, u8, identity_conv, | |||
2362 | #undef UVCG_OPTS_ATTR | 2261 | #undef UVCG_OPTS_ATTR |
2363 | 2262 | ||
2364 | static struct configfs_attribute *uvc_attrs[] = { | 2263 | static struct configfs_attribute *uvc_attrs[] = { |
2365 | &f_uvc_opts_attribute_streaming_interval.attr, | 2264 | &f_uvc_opts_attr_streaming_interval, |
2366 | &f_uvc_opts_attribute_streaming_maxpacket.attr, | 2265 | &f_uvc_opts_attr_streaming_maxpacket, |
2367 | &f_uvc_opts_attribute_streaming_maxburst.attr, | 2266 | &f_uvc_opts_attr_streaming_maxburst, |
2368 | NULL, | 2267 | NULL, |
2369 | }; | 2268 | }; |
2370 | 2269 | ||
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c index 778e42abb3cb..22e56158d585 100644 --- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c +++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include <scsi/scsi_tcq.h> | 19 | #include <scsi/scsi_tcq.h> |
20 | #include <target/target_core_base.h> | 20 | #include <target/target_core_base.h> |
21 | #include <target/target_core_fabric.h> | 21 | #include <target/target_core_fabric.h> |
22 | #include <target/target_core_fabric_configfs.h> | ||
23 | #include <target/configfs_macros.h> | ||
24 | #include <asm/unaligned.h> | 22 | #include <asm/unaligned.h> |
25 | 23 | ||
26 | #include "tcm_usb_gadget.h" | 24 | #include "tcm_usb_gadget.h" |
@@ -1467,23 +1465,21 @@ static void usbg_drop_tport(struct se_wwn *wwn) | |||
1467 | /* | 1465 | /* |
1468 | * If somebody feels like dropping the version property, go ahead. | 1466 | * If somebody feels like dropping the version property, go ahead. |
1469 | */ | 1467 | */ |
1470 | static ssize_t usbg_wwn_show_attr_version( | 1468 | static ssize_t usbg_wwn_version_show(struct config_item *item, char *page) |
1471 | struct target_fabric_configfs *tf, | ||
1472 | char *page) | ||
1473 | { | 1469 | { |
1474 | return sprintf(page, "usb-gadget fabric module\n"); | 1470 | return sprintf(page, "usb-gadget fabric module\n"); |
1475 | } | 1471 | } |
1476 | TF_WWN_ATTR_RO(usbg, version); | 1472 | |
1473 | CONFIGFS_ATTR_RO(usbg_wwn_, version); | ||
1477 | 1474 | ||
1478 | static struct configfs_attribute *usbg_wwn_attrs[] = { | 1475 | static struct configfs_attribute *usbg_wwn_attrs[] = { |
1479 | &usbg_wwn_version.attr, | 1476 | &usbg_wwn_attr_version, |
1480 | NULL, | 1477 | NULL, |
1481 | }; | 1478 | }; |
1482 | 1479 | ||
1483 | static ssize_t tcm_usbg_tpg_show_enable( | 1480 | static ssize_t tcm_usbg_tpg_enable_show(struct config_item *item, char *page) |
1484 | struct se_portal_group *se_tpg, | ||
1485 | char *page) | ||
1486 | { | 1481 | { |
1482 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1487 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); | 1483 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); |
1488 | 1484 | ||
1489 | return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect); | 1485 | return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect); |
@@ -1492,11 +1488,10 @@ static ssize_t tcm_usbg_tpg_show_enable( | |||
1492 | static int usbg_attach(struct usbg_tpg *); | 1488 | static int usbg_attach(struct usbg_tpg *); |
1493 | static void usbg_detach(struct usbg_tpg *); | 1489 | static void usbg_detach(struct usbg_tpg *); |
1494 | 1490 | ||
1495 | static ssize_t tcm_usbg_tpg_store_enable( | 1491 | static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item, |
1496 | struct se_portal_group *se_tpg, | 1492 | const char *page, size_t count) |
1497 | const char *page, | ||
1498 | size_t count) | ||
1499 | { | 1493 | { |
1494 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1500 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); | 1495 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); |
1501 | unsigned long op; | 1496 | unsigned long op; |
1502 | ssize_t ret; | 1497 | ssize_t ret; |
@@ -1523,12 +1518,10 @@ static ssize_t tcm_usbg_tpg_store_enable( | |||
1523 | out: | 1518 | out: |
1524 | return count; | 1519 | return count; |
1525 | } | 1520 | } |
1526 | TF_TPG_BASE_ATTR(tcm_usbg, enable, S_IRUGO | S_IWUSR); | ||
1527 | 1521 | ||
1528 | static ssize_t tcm_usbg_tpg_show_nexus( | 1522 | static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page) |
1529 | struct se_portal_group *se_tpg, | ||
1530 | char *page) | ||
1531 | { | 1523 | { |
1524 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1532 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); | 1525 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); |
1533 | struct tcm_usbg_nexus *tv_nexus; | 1526 | struct tcm_usbg_nexus *tv_nexus; |
1534 | ssize_t ret; | 1527 | ssize_t ret; |
@@ -1636,11 +1629,10 @@ out: | |||
1636 | return ret; | 1629 | return ret; |
1637 | } | 1630 | } |
1638 | 1631 | ||
1639 | static ssize_t tcm_usbg_tpg_store_nexus( | 1632 | static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item, |
1640 | struct se_portal_group *se_tpg, | 1633 | const char *page, size_t count) |
1641 | const char *page, | ||
1642 | size_t count) | ||
1643 | { | 1634 | { |
1635 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1644 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); | 1636 | struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); |
1645 | unsigned char i_port[USBG_NAMELEN], *ptr; | 1637 | unsigned char i_port[USBG_NAMELEN], *ptr; |
1646 | int ret; | 1638 | int ret; |
@@ -1670,11 +1662,13 @@ static ssize_t tcm_usbg_tpg_store_nexus( | |||
1670 | return ret; | 1662 | return ret; |
1671 | return count; | 1663 | return count; |
1672 | } | 1664 | } |
1673 | TF_TPG_BASE_ATTR(tcm_usbg, nexus, S_IRUGO | S_IWUSR); | 1665 | |
1666 | CONFIGFS_ATTR(tcm_usbg_tpg_, enable); | ||
1667 | CONFIGFS_ATTR(tcm_usbg_tpg_, nexus); | ||
1674 | 1668 | ||
1675 | static struct configfs_attribute *usbg_base_attrs[] = { | 1669 | static struct configfs_attribute *usbg_base_attrs[] = { |
1676 | &tcm_usbg_tpg_enable.attr, | 1670 | &tcm_usbg_tpg_attr_enable, |
1677 | &tcm_usbg_tpg_nexus.attr, | 1671 | &tcm_usbg_tpg_attr_nexus, |
1678 | NULL, | 1672 | NULL, |
1679 | }; | 1673 | }; |
1680 | 1674 | ||
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index e25a23692822..29cfc57d496e 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
@@ -42,8 +42,6 @@ | |||
42 | #include <scsi/scsi_proto.h> | 42 | #include <scsi/scsi_proto.h> |
43 | #include <target/target_core_base.h> | 43 | #include <target/target_core_base.h> |
44 | #include <target/target_core_fabric.h> | 44 | #include <target/target_core_fabric.h> |
45 | #include <target/target_core_fabric_configfs.h> | ||
46 | #include <target/configfs_macros.h> | ||
47 | #include <linux/vhost.h> | 45 | #include <linux/vhost.h> |
48 | #include <linux/virtio_scsi.h> | 46 | #include <linux/virtio_scsi.h> |
49 | #include <linux/llist.h> | 47 | #include <linux/llist.h> |
@@ -1684,11 +1682,10 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus, | |||
1684 | } | 1682 | } |
1685 | } | 1683 | } |
1686 | 1684 | ||
1687 | static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type( | 1685 | static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_store( |
1688 | struct se_portal_group *se_tpg, | 1686 | struct config_item *item, const char *page, size_t count) |
1689 | const char *page, | ||
1690 | size_t count) | ||
1691 | { | 1687 | { |
1688 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
1692 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, | 1689 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, |
1693 | struct vhost_scsi_tpg, se_tpg); | 1690 | struct vhost_scsi_tpg, se_tpg); |
1694 | unsigned long val; | 1691 | unsigned long val; |
@@ -1707,19 +1704,20 @@ static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type( | |||
1707 | return count; | 1704 | return count; |
1708 | } | 1705 | } |
1709 | 1706 | ||
1710 | static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type( | 1707 | static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_show( |
1711 | struct se_portal_group *se_tpg, | 1708 | struct config_item *item, char *page) |
1712 | char *page) | ||
1713 | { | 1709 | { |
1710 | struct se_portal_group *se_tpg = attrib_to_tpg(item); | ||
1714 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, | 1711 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, |
1715 | struct vhost_scsi_tpg, se_tpg); | 1712 | struct vhost_scsi_tpg, se_tpg); |
1716 | 1713 | ||
1717 | return sprintf(page, "%d\n", tpg->tv_fabric_prot_type); | 1714 | return sprintf(page, "%d\n", tpg->tv_fabric_prot_type); |
1718 | } | 1715 | } |
1719 | TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR); | 1716 | |
1717 | CONFIGFS_ATTR(vhost_scsi_tpg_attrib_, fabric_prot_type); | ||
1720 | 1718 | ||
1721 | static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = { | 1719 | static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = { |
1722 | &vhost_scsi_tpg_attrib_fabric_prot_type.attr, | 1720 | &vhost_scsi_tpg_attrib_attr_fabric_prot_type, |
1723 | NULL, | 1721 | NULL, |
1724 | }; | 1722 | }; |
1725 | 1723 | ||
@@ -1867,9 +1865,9 @@ static int vhost_scsi_drop_nexus(struct vhost_scsi_tpg *tpg) | |||
1867 | return 0; | 1865 | return 0; |
1868 | } | 1866 | } |
1869 | 1867 | ||
1870 | static ssize_t vhost_scsi_tpg_show_nexus(struct se_portal_group *se_tpg, | 1868 | static ssize_t vhost_scsi_tpg_nexus_show(struct config_item *item, char *page) |
1871 | char *page) | ||
1872 | { | 1869 | { |
1870 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1873 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, | 1871 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, |
1874 | struct vhost_scsi_tpg, se_tpg); | 1872 | struct vhost_scsi_tpg, se_tpg); |
1875 | struct vhost_scsi_nexus *tv_nexus; | 1873 | struct vhost_scsi_nexus *tv_nexus; |
@@ -1888,10 +1886,10 @@ static ssize_t vhost_scsi_tpg_show_nexus(struct se_portal_group *se_tpg, | |||
1888 | return ret; | 1886 | return ret; |
1889 | } | 1887 | } |
1890 | 1888 | ||
1891 | static ssize_t vhost_scsi_tpg_store_nexus(struct se_portal_group *se_tpg, | 1889 | static ssize_t vhost_scsi_tpg_nexus_store(struct config_item *item, |
1892 | const char *page, | 1890 | const char *page, size_t count) |
1893 | size_t count) | ||
1894 | { | 1891 | { |
1892 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1895 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, | 1893 | struct vhost_scsi_tpg *tpg = container_of(se_tpg, |
1896 | struct vhost_scsi_tpg, se_tpg); | 1894 | struct vhost_scsi_tpg, se_tpg); |
1897 | struct vhost_scsi_tport *tport_wwn = tpg->tport; | 1895 | struct vhost_scsi_tport *tport_wwn = tpg->tport; |
@@ -1966,10 +1964,10 @@ check_newline: | |||
1966 | return count; | 1964 | return count; |
1967 | } | 1965 | } |
1968 | 1966 | ||
1969 | TF_TPG_BASE_ATTR(vhost_scsi, nexus, S_IRUGO | S_IWUSR); | 1967 | CONFIGFS_ATTR(vhost_scsi_tpg_, nexus); |
1970 | 1968 | ||
1971 | static struct configfs_attribute *vhost_scsi_tpg_attrs[] = { | 1969 | static struct configfs_attribute *vhost_scsi_tpg_attrs[] = { |
1972 | &vhost_scsi_tpg_nexus.attr, | 1970 | &vhost_scsi_tpg_attr_nexus, |
1973 | NULL, | 1971 | NULL, |
1974 | }; | 1972 | }; |
1975 | 1973 | ||
@@ -2105,18 +2103,17 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn) | |||
2105 | } | 2103 | } |
2106 | 2104 | ||
2107 | static ssize_t | 2105 | static ssize_t |
2108 | vhost_scsi_wwn_show_attr_version(struct target_fabric_configfs *tf, | 2106 | vhost_scsi_wwn_version_show(struct config_item *item, char *page) |
2109 | char *page) | ||
2110 | { | 2107 | { |
2111 | return sprintf(page, "TCM_VHOST fabric module %s on %s/%s" | 2108 | return sprintf(page, "TCM_VHOST fabric module %s on %s/%s" |
2112 | "on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname, | 2109 | "on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname, |
2113 | utsname()->machine); | 2110 | utsname()->machine); |
2114 | } | 2111 | } |
2115 | 2112 | ||
2116 | TF_WWN_ATTR_RO(vhost_scsi, version); | 2113 | CONFIGFS_ATTR_RO(vhost_scsi_wwn_, version); |
2117 | 2114 | ||
2118 | static struct configfs_attribute *vhost_scsi_wwn_attrs[] = { | 2115 | static struct configfs_attribute *vhost_scsi_wwn_attrs[] = { |
2119 | &vhost_scsi_wwn_version.attr, | 2116 | &vhost_scsi_wwn_attr_version, |
2120 | NULL, | 2117 | NULL, |
2121 | }; | 2118 | }; |
2122 | 2119 | ||
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 9eeefd7cad41..43bcae852546 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c | |||
@@ -53,7 +53,6 @@ | |||
53 | 53 | ||
54 | #include <target/target_core_base.h> | 54 | #include <target/target_core_base.h> |
55 | #include <target/target_core_fabric.h> | 55 | #include <target/target_core_fabric.h> |
56 | #include <target/target_core_fabric_configfs.h> | ||
57 | 56 | ||
58 | #include <asm/hypervisor.h> | 57 | #include <asm/hypervisor.h> |
59 | 58 | ||
@@ -1438,9 +1437,10 @@ static void scsiback_aborted_task(struct se_cmd *se_cmd) | |||
1438 | { | 1437 | { |
1439 | } | 1438 | } |
1440 | 1439 | ||
1441 | static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg, | 1440 | static ssize_t scsiback_tpg_param_alias_show(struct config_item *item, |
1442 | char *page) | 1441 | char *page) |
1443 | { | 1442 | { |
1443 | struct se_portal_group *se_tpg = param_to_tpg(item); | ||
1444 | struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, | 1444 | struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, |
1445 | se_tpg); | 1445 | se_tpg); |
1446 | ssize_t rb; | 1446 | ssize_t rb; |
@@ -1452,9 +1452,10 @@ static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg, | |||
1452 | return rb; | 1452 | return rb; |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | static ssize_t scsiback_tpg_param_store_alias(struct se_portal_group *se_tpg, | 1455 | static ssize_t scsiback_tpg_param_alias_store(struct config_item *item, |
1456 | const char *page, size_t count) | 1456 | const char *page, size_t count) |
1457 | { | 1457 | { |
1458 | struct se_portal_group *se_tpg = param_to_tpg(item); | ||
1458 | struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, | 1459 | struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, |
1459 | se_tpg); | 1460 | se_tpg); |
1460 | int len; | 1461 | int len; |
@@ -1474,10 +1475,10 @@ static ssize_t scsiback_tpg_param_store_alias(struct se_portal_group *se_tpg, | |||
1474 | return count; | 1475 | return count; |
1475 | } | 1476 | } |
1476 | 1477 | ||
1477 | TF_TPG_PARAM_ATTR(scsiback, alias, S_IRUGO | S_IWUSR); | 1478 | CONFIGFS_ATTR(scsiback_tpg_param_, alias); |
1478 | 1479 | ||
1479 | static struct configfs_attribute *scsiback_param_attrs[] = { | 1480 | static struct configfs_attribute *scsiback_param_attrs[] = { |
1480 | &scsiback_tpg_param_alias.attr, | 1481 | &scsiback_tpg_param_attr_alias, |
1481 | NULL, | 1482 | NULL, |
1482 | }; | 1483 | }; |
1483 | 1484 | ||
@@ -1585,9 +1586,9 @@ static int scsiback_drop_nexus(struct scsiback_tpg *tpg) | |||
1585 | return 0; | 1586 | return 0; |
1586 | } | 1587 | } |
1587 | 1588 | ||
1588 | static ssize_t scsiback_tpg_show_nexus(struct se_portal_group *se_tpg, | 1589 | static ssize_t scsiback_tpg_nexus_show(struct config_item *item, char *page) |
1589 | char *page) | ||
1590 | { | 1590 | { |
1591 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1591 | struct scsiback_tpg *tpg = container_of(se_tpg, | 1592 | struct scsiback_tpg *tpg = container_of(se_tpg, |
1592 | struct scsiback_tpg, se_tpg); | 1593 | struct scsiback_tpg, se_tpg); |
1593 | struct scsiback_nexus *tv_nexus; | 1594 | struct scsiback_nexus *tv_nexus; |
@@ -1606,10 +1607,10 @@ static ssize_t scsiback_tpg_show_nexus(struct se_portal_group *se_tpg, | |||
1606 | return ret; | 1607 | return ret; |
1607 | } | 1608 | } |
1608 | 1609 | ||
1609 | static ssize_t scsiback_tpg_store_nexus(struct se_portal_group *se_tpg, | 1610 | static ssize_t scsiback_tpg_nexus_store(struct config_item *item, |
1610 | const char *page, | 1611 | const char *page, size_t count) |
1611 | size_t count) | ||
1612 | { | 1612 | { |
1613 | struct se_portal_group *se_tpg = to_tpg(item); | ||
1613 | struct scsiback_tpg *tpg = container_of(se_tpg, | 1614 | struct scsiback_tpg *tpg = container_of(se_tpg, |
1614 | struct scsiback_tpg, se_tpg); | 1615 | struct scsiback_tpg, se_tpg); |
1615 | struct scsiback_tport *tport_wwn = tpg->tport; | 1616 | struct scsiback_tport *tport_wwn = tpg->tport; |
@@ -1681,26 +1682,25 @@ check_newline: | |||
1681 | return count; | 1682 | return count; |
1682 | } | 1683 | } |
1683 | 1684 | ||
1684 | TF_TPG_BASE_ATTR(scsiback, nexus, S_IRUGO | S_IWUSR); | 1685 | CONFIGFS_ATTR(scsiback_tpg_, nexus); |
1685 | 1686 | ||
1686 | static struct configfs_attribute *scsiback_tpg_attrs[] = { | 1687 | static struct configfs_attribute *scsiback_tpg_attrs[] = { |
1687 | &scsiback_tpg_nexus.attr, | 1688 | &scsiback_tpg_attr_nexus, |
1688 | NULL, | 1689 | NULL, |
1689 | }; | 1690 | }; |
1690 | 1691 | ||
1691 | static ssize_t | 1692 | static ssize_t |
1692 | scsiback_wwn_show_attr_version(struct target_fabric_configfs *tf, | 1693 | scsiback_wwn_version_show(struct config_item *item, char *page) |
1693 | char *page) | ||
1694 | { | 1694 | { |
1695 | return sprintf(page, "xen-pvscsi fabric module %s on %s/%s on " | 1695 | return sprintf(page, "xen-pvscsi fabric module %s on %s/%s on " |
1696 | UTS_RELEASE"\n", | 1696 | UTS_RELEASE"\n", |
1697 | VSCSI_VERSION, utsname()->sysname, utsname()->machine); | 1697 | VSCSI_VERSION, utsname()->sysname, utsname()->machine); |
1698 | } | 1698 | } |
1699 | 1699 | ||
1700 | TF_WWN_ATTR_RO(scsiback, version); | 1700 | CONFIGFS_ATTR_RO(scsiback_wwn_, version); |
1701 | 1701 | ||
1702 | static struct configfs_attribute *scsiback_wwn_attrs[] = { | 1702 | static struct configfs_attribute *scsiback_wwn_attrs[] = { |
1703 | &scsiback_wwn_version.attr, | 1703 | &scsiback_wwn_attr_version, |
1704 | NULL, | 1704 | NULL, |
1705 | }; | 1705 | }; |
1706 | 1706 | ||