Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending

Pull SCSI target updates from Nicholas Bellinger:
"This series contains HCH's changes to absorb configfs attribute
->show() + ->store() function pointer usage from it's original
tree-wide consumers, into common configfs code.

It includes usb-gadget, target w/ drivers, netconsole and ocfs2
changes to realize the improved simplicity, that now renders the
original include/target/configfs_macros.h CPP magic for fabric drivers
and others, unnecessary and obsolete.

And with common code in place, new configfs attributes can be added
easier than ever before.

Note, there are further improvements in-flight from other folks for
v4.5 code in configfs land, plus number of target fixes for post -rc1
code"

In the meantime, a new user of the now-removed old configfs API came in
through the char/misc tree in commit 7bd1d4093c2f ("stm class: Introduce
an abstraction for System Trace Module devices").

This merge resolution comes from Alexander Shishkin, who updated his stm
class tracing abstraction to account for the removal of the old
show_attribute and store_attribute methods in commit 517982229f78
("configfs: remove old API") from this pull. As Alexander says about
that patch:

"There's no need to keep an extra wrapper structure per item and the
awkward show_attribute/store_attribute item ops are no longer needed.

This patch converts policy code to the new api, all the while making
the code quite a bit smaller and easier on the eyes.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>"

That patch was folded into the merge so that the tree should be fully
bisectable.

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: (23 commits)
configfs: remove old API
ocfs2/cluster: use per-attribute show and store methods
ocfs2/cluster: move locking into attribute store methods
netconsole: use per-attribute show and store methods
target: use per-attribute show and store methods
spear13xx_pcie_gadget: use per-attribute show and store methods
dlm: use per-attribute show and store methods
usb-gadget/f_serial: use per-attribute show and store methods
usb-gadget/f_phonet: use per-attribute show and store methods
usb-gadget/f_obex: use per-attribute show and store methods
usb-gadget/f_uac2: use per-attribute show and store methods
usb-gadget/f_uac1: use per-attribute show and store methods
usb-gadget/f_mass_storage: use per-attribute show and store methods
usb-gadget/f_sourcesink: use per-attribute show and store methods
usb-gadget/f_printer: use per-attribute show and store methods
usb-gadget/f_midi: use per-attribute show and store methods
usb-gadget/f_loopback: use per-attribute show and store methods
usb-gadget/ether: use per-attribute show and store methods
usb-gadget/f_acm: use per-attribute show and store methods
usb-gadget/f_hid: use per-attribute show and store methods
...

+2688 -5527
-2
Documentation/filesystems/Makefile
··· 1 - subdir-y := configfs 2 - 3 1 # List of programs to build 4 2 hostprogs-y := dnotify_test 5 3
-3
Documentation/filesystems/configfs/Makefile
··· 1 - ifneq ($(CONFIG_CONFIGFS_FS),) 2 - obj-m += configfs_example_explicit.o configfs_example_macros.o 3 - endif
+11 -27
Documentation/filesystems/configfs/configfs.txt
··· 160 160 161 161 struct configfs_item_operations { 162 162 void (*release)(struct config_item *); 163 - ssize_t (*show_attribute)(struct config_item *, 164 - struct configfs_attribute *, 165 - char *); 166 - ssize_t (*store_attribute)(struct config_item *, 167 - struct configfs_attribute *, 168 - const char *, size_t); 169 163 int (*allow_link)(struct config_item *src, 170 164 struct config_item *target); 171 165 int (*drop_link)(struct config_item *src, ··· 177 183 operations can be performed on a config_item. All items that have been 178 184 allocated dynamically will need to provide the ct_item_ops->release() 179 185 method. This method is called when the config_item's reference count 180 - reaches zero. Items that wish to display an attribute need to provide 181 - the ct_item_ops->show_attribute() method. Similarly, storing a new 182 - attribute value uses the store_attribute() method. 186 + reaches zero. 183 187 184 188 [struct configfs_attribute] 185 189 ··· 185 193 char *ca_name; 186 194 struct module *ca_owner; 187 195 umode_t ca_mode; 196 + ssize_t (*show)(struct config_item *, char *); 197 + ssize_t (*store)(struct config_item *, const char *, size_t); 188 198 }; 189 199 190 200 When a config_item wants an attribute to appear as a file in the item's ··· 196 202 attribute file will appear with the configfs_attribute->ca_name 197 203 filename. configfs_attribute->ca_mode specifies the file permissions. 198 204 199 - If an attribute is readable and the config_item provides a 200 - ct_item_ops->show_attribute() method, that method will be called 201 - whenever userspace asks for a read(2) on the attribute. The converse 202 - will happen for write(2). 205 + If an attribute is readable and provides a ->show method, that method will 206 + be called whenever userspace asks for a read(2) on the attribute. If an 207 + attribute is writable and provides a ->store method, that method will be 208 + be called whenever userspace asks for a write(2) on the attribute. 203 209 204 210 [struct config_group] 205 211 ··· 305 311 [An Example] 306 312 307 313 The best example of these basic concepts is the simple_children 308 - subsystem/group and the simple_child item in configfs_example_explicit.c 309 - and configfs_example_macros.c. It shows a trivial object displaying and 310 - storing an attribute, and a simple group creating and destroying these 311 - children. 312 - 313 - The only difference between configfs_example_explicit.c and 314 - configfs_example_macros.c is how the attributes of the childless item 315 - are defined. The childless item has extended attributes, each with 316 - their own show()/store() operation. This follows a convention commonly 317 - used in sysfs. configfs_example_explicit.c creates these attributes 318 - by explicitly defining the structures involved. Conversely 319 - configfs_example_macros.c uses some convenience macros from configfs.h 320 - to define the attributes. These macros are similar to their sysfs 321 - counterparts. 314 + subsystem/group and the simple_child item in 315 + samples/configfs/configfs_sample.c. It shows a trivial object displaying 316 + and storing an attribute, and a simple group creating and destroying 317 + these children. 322 318 323 319 [Hierarchy Navigation and the Subsystem Mutex] 324 320
+53 -132
Documentation/filesystems/configfs/configfs_example_explicit.c samples/configfs/configfs_sample.c
··· 1 1 /* 2 2 * vim: noexpandtab ts=8 sts=0 sw=8: 3 3 * 4 - * configfs_example_explicit.c - This file is a demonstration module 5 - * containing a number of configfs subsystems. It explicitly defines 6 - * each structure without using the helper macros defined in 7 - * configfs.h. 4 + * configfs_example_macros.c - This file is a demonstration module 5 + * containing a number of configfs subsystems. It uses the helper 6 + * macros defined by configfs.h 8 7 * 9 8 * This program is free software; you can redistribute it and/or 10 9 * modify it under the terms of the GNU General Public ··· 52 53 int storeme; 53 54 }; 54 55 55 - struct childless_attribute { 56 - struct configfs_attribute attr; 57 - ssize_t (*show)(struct childless *, char *); 58 - ssize_t (*store)(struct childless *, const char *, size_t); 59 - }; 60 - 61 56 static inline struct childless *to_childless(struct config_item *item) 62 57 { 63 - return item ? container_of(to_configfs_subsystem(to_config_group(item)), struct childless, subsys) : NULL; 58 + return item ? container_of(to_configfs_subsystem(to_config_group(item)), 59 + struct childless, subsys) : NULL; 64 60 } 65 61 66 - static ssize_t childless_showme_read(struct childless *childless, 67 - char *page) 62 + static ssize_t childless_showme_show(struct config_item *item, char *page) 68 63 { 64 + struct childless *childless = to_childless(item); 69 65 ssize_t pos; 70 66 71 67 pos = sprintf(page, "%d\n", childless->showme); ··· 69 75 return pos; 70 76 } 71 77 72 - static ssize_t childless_storeme_read(struct childless *childless, 73 - char *page) 78 + static ssize_t childless_storeme_show(struct config_item *item, char *page) 74 79 { 75 - return sprintf(page, "%d\n", childless->storeme); 80 + return sprintf(page, "%d\n", to_childless(item)->storeme); 76 81 } 77 82 78 - static ssize_t childless_storeme_write(struct childless *childless, 79 - const char *page, 80 - size_t count) 83 + static ssize_t childless_storeme_store(struct config_item *item, 84 + const char *page, size_t count) 81 85 { 86 + struct childless *childless = to_childless(item); 82 87 unsigned long tmp; 83 88 char *p = (char *) page; 84 89 85 90 tmp = simple_strtoul(p, &p, 10); 86 - if ((*p != '\0') && (*p != '\n')) 91 + if (!p || (*p && (*p != '\n'))) 87 92 return -EINVAL; 88 93 89 94 if (tmp > INT_MAX) ··· 93 100 return count; 94 101 } 95 102 96 - static ssize_t childless_description_read(struct childless *childless, 97 - char *page) 103 + static ssize_t childless_description_show(struct config_item *item, char *page) 98 104 { 99 105 return sprintf(page, 100 106 "[01-childless]\n" ··· 104 112 "than a directory in /proc.\n"); 105 113 } 106 114 107 - static struct childless_attribute childless_attr_showme = { 108 - .attr = { .ca_owner = THIS_MODULE, .ca_name = "showme", .ca_mode = S_IRUGO }, 109 - .show = childless_showme_read, 110 - }; 111 - static struct childless_attribute childless_attr_storeme = { 112 - .attr = { .ca_owner = THIS_MODULE, .ca_name = "storeme", .ca_mode = S_IRUGO | S_IWUSR }, 113 - .show = childless_storeme_read, 114 - .store = childless_storeme_write, 115 - }; 116 - static struct childless_attribute childless_attr_description = { 117 - .attr = { .ca_owner = THIS_MODULE, .ca_name = "description", .ca_mode = S_IRUGO }, 118 - .show = childless_description_read, 119 - }; 115 + CONFIGFS_ATTR_RO(childless_, showme); 116 + CONFIGFS_ATTR(childless_, storeme); 117 + CONFIGFS_ATTR_RO(childless_, description); 120 118 121 119 static struct configfs_attribute *childless_attrs[] = { 122 - &childless_attr_showme.attr, 123 - &childless_attr_storeme.attr, 124 - &childless_attr_description.attr, 120 + &childless_attr_showme, 121 + &childless_attr_storeme, 122 + &childless_attr_description, 125 123 NULL, 126 124 }; 127 125 128 - static ssize_t childless_attr_show(struct config_item *item, 129 - struct configfs_attribute *attr, 130 - char *page) 131 - { 132 - struct childless *childless = to_childless(item); 133 - struct childless_attribute *childless_attr = 134 - container_of(attr, struct childless_attribute, attr); 135 - ssize_t ret = 0; 136 - 137 - if (childless_attr->show) 138 - ret = childless_attr->show(childless, page); 139 - return ret; 140 - } 141 - 142 - static ssize_t childless_attr_store(struct config_item *item, 143 - struct configfs_attribute *attr, 144 - const char *page, size_t count) 145 - { 146 - struct childless *childless = to_childless(item); 147 - struct childless_attribute *childless_attr = 148 - container_of(attr, struct childless_attribute, attr); 149 - ssize_t ret = -EINVAL; 150 - 151 - if (childless_attr->store) 152 - ret = childless_attr->store(childless, page, count); 153 - return ret; 154 - } 155 - 156 - static struct configfs_item_operations childless_item_ops = { 157 - .show_attribute = childless_attr_show, 158 - .store_attribute = childless_attr_store, 159 - }; 160 - 161 126 static struct config_item_type childless_type = { 162 - .ct_item_ops = &childless_item_ops, 163 127 .ct_attrs = childless_attrs, 164 128 .ct_owner = THIS_MODULE, 165 129 }; ··· 153 205 return item ? container_of(item, struct simple_child, item) : NULL; 154 206 } 155 207 156 - static struct configfs_attribute simple_child_attr_storeme = { 157 - .ca_owner = THIS_MODULE, 158 - .ca_name = "storeme", 159 - .ca_mode = S_IRUGO | S_IWUSR, 160 - }; 161 - 162 - static struct configfs_attribute *simple_child_attrs[] = { 163 - &simple_child_attr_storeme, 164 - NULL, 165 - }; 166 - 167 - static ssize_t simple_child_attr_show(struct config_item *item, 168 - struct configfs_attribute *attr, 169 - char *page) 208 + static ssize_t simple_child_storeme_show(struct config_item *item, char *page) 170 209 { 171 - ssize_t count; 172 - struct simple_child *simple_child = to_simple_child(item); 173 - 174 - count = sprintf(page, "%d\n", simple_child->storeme); 175 - 176 - return count; 210 + return sprintf(page, "%d\n", to_simple_child(item)->storeme); 177 211 } 178 212 179 - static ssize_t simple_child_attr_store(struct config_item *item, 180 - struct configfs_attribute *attr, 181 - const char *page, size_t count) 213 + static ssize_t simple_child_storeme_store(struct config_item *item, 214 + const char *page, size_t count) 182 215 { 183 216 struct simple_child *simple_child = to_simple_child(item); 184 217 unsigned long tmp; ··· 177 248 return count; 178 249 } 179 250 251 + CONFIGFS_ATTR(simple_child_, storeme); 252 + 253 + static struct configfs_attribute *simple_child_attrs[] = { 254 + &simple_child_attr_storeme, 255 + NULL, 256 + }; 257 + 180 258 static void simple_child_release(struct config_item *item) 181 259 { 182 260 kfree(to_simple_child(item)); ··· 191 255 192 256 static struct configfs_item_operations simple_child_item_ops = { 193 257 .release = simple_child_release, 194 - .show_attribute = simple_child_attr_show, 195 - .store_attribute = simple_child_attr_store, 196 258 }; 197 259 198 260 static struct config_item_type simple_child_type = { ··· 206 272 207 273 static inline struct simple_children *to_simple_children(struct config_item *item) 208 274 { 209 - return item ? container_of(to_config_group(item), struct simple_children, group) : NULL; 275 + return item ? container_of(to_config_group(item), 276 + struct simple_children, group) : NULL; 210 277 } 211 278 212 - static struct config_item *simple_children_make_item(struct config_group *group, const char *name) 279 + static struct config_item *simple_children_make_item(struct config_group *group, 280 + const char *name) 213 281 { 214 282 struct simple_child *simple_child; 215 283 ··· 227 291 return &simple_child->item; 228 292 } 229 293 230 - static struct configfs_attribute simple_children_attr_description = { 231 - .ca_owner = THIS_MODULE, 232 - .ca_name = "description", 233 - .ca_mode = S_IRUGO, 234 - }; 235 - 236 - static struct configfs_attribute *simple_children_attrs[] = { 237 - &simple_children_attr_description, 238 - NULL, 239 - }; 240 - 241 - static ssize_t simple_children_attr_show(struct config_item *item, 242 - struct configfs_attribute *attr, 243 - char *page) 294 + static ssize_t simple_children_description_show(struct config_item *item, 295 + char *page) 244 296 { 245 297 return sprintf(page, 246 298 "[02-simple-children]\n" ··· 237 313 "items have only one attribute that is readable and writeable.\n"); 238 314 } 239 315 316 + CONFIGFS_ATTR_RO(simple_children_, description); 317 + 318 + static struct configfs_attribute *simple_children_attrs[] = { 319 + &simple_children_attr_description, 320 + NULL, 321 + }; 322 + 240 323 static void simple_children_release(struct config_item *item) 241 324 { 242 325 kfree(to_simple_children(item)); ··· 251 320 252 321 static struct configfs_item_operations simple_children_item_ops = { 253 322 .release = simple_children_release, 254 - .show_attribute = simple_children_attr_show, 255 323 }; 256 324 257 325 /* ··· 290 360 * children of its own. 291 361 */ 292 362 293 - static struct config_group *group_children_make_group(struct config_group *group, const char *name) 363 + static struct config_group *group_children_make_group( 364 + struct config_group *group, const char *name) 294 365 { 295 366 struct simple_children *simple_children; 296 367 ··· 306 375 return &simple_children->group; 307 376 } 308 377 309 - static struct configfs_attribute group_children_attr_description = { 310 - .ca_owner = THIS_MODULE, 311 - .ca_name = "description", 312 - .ca_mode = S_IRUGO, 313 - }; 314 - 315 - static struct configfs_attribute *group_children_attrs[] = { 316 - &group_children_attr_description, 317 - NULL, 318 - }; 319 - 320 - static ssize_t group_children_attr_show(struct config_item *item, 321 - struct configfs_attribute *attr, 322 - char *page) 378 + static ssize_t group_children_description_show(struct config_item *item, 379 + char *page) 323 380 { 324 381 return sprintf(page, 325 382 "[03-group-children]\n" ··· 316 397 "groups are like the subsystem simple-children.\n"); 317 398 } 318 399 319 - static struct configfs_item_operations group_children_item_ops = { 320 - .show_attribute = group_children_attr_show, 400 + CONFIGFS_ATTR_RO(group_children_, description); 401 + 402 + static struct configfs_attribute *group_children_attrs[] = { 403 + &group_children_attr_description, 404 + NULL, 321 405 }; 322 406 323 407 /* ··· 332 410 }; 333 411 334 412 static struct config_item_type group_children_type = { 335 - .ct_item_ops = &group_children_item_ops, 336 413 .ct_group_ops = &group_children_group_ops, 337 414 .ct_attrs = group_children_attrs, 338 415 .ct_owner = THIS_MODULE,
-446
Documentation/filesystems/configfs/configfs_example_macros.c
··· 1 - /* 2 - * vim: noexpandtab ts=8 sts=0 sw=8: 3 - * 4 - * configfs_example_macros.c - This file is a demonstration module 5 - * containing a number of configfs subsystems. It uses the helper 6 - * macros defined by configfs.h 7 - * 8 - * This program is free software; you can redistribute it and/or 9 - * modify it under the terms of the GNU General Public 10 - * License as published by the Free Software Foundation; either 11 - * version 2 of the License, or (at your option) any later version. 12 - * 13 - * This program is distributed in the hope that it will be useful, 14 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 - * General Public License for more details. 17 - * 18 - * You should have received a copy of the GNU General Public 19 - * License along with this program; if not, write to the 20 - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 - * Boston, MA 021110-1307, USA. 22 - * 23 - * Based on sysfs: 24 - * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel 25 - * 26 - * configfs Copyright (C) 2005 Oracle. All rights reserved. 27 - */ 28 - 29 - #include <linux/init.h> 30 - #include <linux/module.h> 31 - #include <linux/slab.h> 32 - 33 - #include <linux/configfs.h> 34 - 35 - 36 - 37 - /* 38 - * 01-childless 39 - * 40 - * This first example is a childless subsystem. It cannot create 41 - * any config_items. It just has attributes. 42 - * 43 - * Note that we are enclosing the configfs_subsystem inside a container. 44 - * This is not necessary if a subsystem has no attributes directly 45 - * on the subsystem. See the next example, 02-simple-children, for 46 - * such a subsystem. 47 - */ 48 - 49 - struct childless { 50 - struct configfs_subsystem subsys; 51 - int showme; 52 - int storeme; 53 - }; 54 - 55 - static inline struct childless *to_childless(struct config_item *item) 56 - { 57 - return item ? container_of(to_configfs_subsystem(to_config_group(item)), struct childless, subsys) : NULL; 58 - } 59 - 60 - CONFIGFS_ATTR_STRUCT(childless); 61 - #define CHILDLESS_ATTR(_name, _mode, _show, _store) \ 62 - struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR(_name, _mode, _show, _store) 63 - #define CHILDLESS_ATTR_RO(_name, _show) \ 64 - struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR_RO(_name, _show); 65 - 66 - static ssize_t childless_showme_read(struct childless *childless, 67 - char *page) 68 - { 69 - ssize_t pos; 70 - 71 - pos = sprintf(page, "%d\n", childless->showme); 72 - childless->showme++; 73 - 74 - return pos; 75 - } 76 - 77 - static ssize_t childless_storeme_read(struct childless *childless, 78 - char *page) 79 - { 80 - return sprintf(page, "%d\n", childless->storeme); 81 - } 82 - 83 - static ssize_t childless_storeme_write(struct childless *childless, 84 - const char *page, 85 - size_t count) 86 - { 87 - unsigned long tmp; 88 - char *p = (char *) page; 89 - 90 - tmp = simple_strtoul(p, &p, 10); 91 - if (!p || (*p && (*p != '\n'))) 92 - return -EINVAL; 93 - 94 - if (tmp > INT_MAX) 95 - return -ERANGE; 96 - 97 - childless->storeme = tmp; 98 - 99 - return count; 100 - } 101 - 102 - static ssize_t childless_description_read(struct childless *childless, 103 - char *page) 104 - { 105 - return sprintf(page, 106 - "[01-childless]\n" 107 - "\n" 108 - "The childless subsystem is the simplest possible subsystem in\n" 109 - "configfs. It does not support the creation of child config_items.\n" 110 - "It only has a few attributes. In fact, it isn't much different\n" 111 - "than a directory in /proc.\n"); 112 - } 113 - 114 - CHILDLESS_ATTR_RO(showme, childless_showme_read); 115 - CHILDLESS_ATTR(storeme, S_IRUGO | S_IWUSR, childless_storeme_read, 116 - childless_storeme_write); 117 - CHILDLESS_ATTR_RO(description, childless_description_read); 118 - 119 - static struct configfs_attribute *childless_attrs[] = { 120 - &childless_attr_showme.attr, 121 - &childless_attr_storeme.attr, 122 - &childless_attr_description.attr, 123 - NULL, 124 - }; 125 - 126 - CONFIGFS_ATTR_OPS(childless); 127 - static struct configfs_item_operations childless_item_ops = { 128 - .show_attribute = childless_attr_show, 129 - .store_attribute = childless_attr_store, 130 - }; 131 - 132 - static struct config_item_type childless_type = { 133 - .ct_item_ops = &childless_item_ops, 134 - .ct_attrs = childless_attrs, 135 - .ct_owner = THIS_MODULE, 136 - }; 137 - 138 - static struct childless childless_subsys = { 139 - .subsys = { 140 - .su_group = { 141 - .cg_item = { 142 - .ci_namebuf = "01-childless", 143 - .ci_type = &childless_type, 144 - }, 145 - }, 146 - }, 147 - }; 148 - 149 - 150 - /* ----------------------------------------------------------------- */ 151 - 152 - /* 153 - * 02-simple-children 154 - * 155 - * This example merely has a simple one-attribute child. Note that 156 - * there is no extra attribute structure, as the child's attribute is 157 - * known from the get-go. Also, there is no container for the 158 - * subsystem, as it has no attributes of its own. 159 - */ 160 - 161 - struct simple_child { 162 - struct config_item item; 163 - int storeme; 164 - }; 165 - 166 - static inline struct simple_child *to_simple_child(struct config_item *item) 167 - { 168 - return item ? container_of(item, struct simple_child, item) : NULL; 169 - } 170 - 171 - static struct configfs_attribute simple_child_attr_storeme = { 172 - .ca_owner = THIS_MODULE, 173 - .ca_name = "storeme", 174 - .ca_mode = S_IRUGO | S_IWUSR, 175 - }; 176 - 177 - static struct configfs_attribute *simple_child_attrs[] = { 178 - &simple_child_attr_storeme, 179 - NULL, 180 - }; 181 - 182 - static ssize_t simple_child_attr_show(struct config_item *item, 183 - struct configfs_attribute *attr, 184 - char *page) 185 - { 186 - ssize_t count; 187 - struct simple_child *simple_child = to_simple_child(item); 188 - 189 - count = sprintf(page, "%d\n", simple_child->storeme); 190 - 191 - return count; 192 - } 193 - 194 - static ssize_t simple_child_attr_store(struct config_item *item, 195 - struct configfs_attribute *attr, 196 - const char *page, size_t count) 197 - { 198 - struct simple_child *simple_child = to_simple_child(item); 199 - unsigned long tmp; 200 - char *p = (char *) page; 201 - 202 - tmp = simple_strtoul(p, &p, 10); 203 - if (!p || (*p && (*p != '\n'))) 204 - return -EINVAL; 205 - 206 - if (tmp > INT_MAX) 207 - return -ERANGE; 208 - 209 - simple_child->storeme = tmp; 210 - 211 - return count; 212 - } 213 - 214 - static void simple_child_release(struct config_item *item) 215 - { 216 - kfree(to_simple_child(item)); 217 - } 218 - 219 - static struct configfs_item_operations simple_child_item_ops = { 220 - .release = simple_child_release, 221 - .show_attribute = simple_child_attr_show, 222 - .store_attribute = simple_child_attr_store, 223 - }; 224 - 225 - static struct config_item_type simple_child_type = { 226 - .ct_item_ops = &simple_child_item_ops, 227 - .ct_attrs = simple_child_attrs, 228 - .ct_owner = THIS_MODULE, 229 - }; 230 - 231 - 232 - struct simple_children { 233 - struct config_group group; 234 - }; 235 - 236 - static inline struct simple_children *to_simple_children(struct config_item *item) 237 - { 238 - return item ? container_of(to_config_group(item), struct simple_children, group) : NULL; 239 - } 240 - 241 - static struct config_item *simple_children_make_item(struct config_group *group, const char *name) 242 - { 243 - struct simple_child *simple_child; 244 - 245 - simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL); 246 - if (!simple_child) 247 - return ERR_PTR(-ENOMEM); 248 - 249 - config_item_init_type_name(&simple_child->item, name, 250 - &simple_child_type); 251 - 252 - simple_child->storeme = 0; 253 - 254 - return &simple_child->item; 255 - } 256 - 257 - static struct configfs_attribute simple_children_attr_description = { 258 - .ca_owner = THIS_MODULE, 259 - .ca_name = "description", 260 - .ca_mode = S_IRUGO, 261 - }; 262 - 263 - static struct configfs_attribute *simple_children_attrs[] = { 264 - &simple_children_attr_description, 265 - NULL, 266 - }; 267 - 268 - static ssize_t simple_children_attr_show(struct config_item *item, 269 - struct configfs_attribute *attr, 270 - char *page) 271 - { 272 - return sprintf(page, 273 - "[02-simple-children]\n" 274 - "\n" 275 - "This subsystem allows the creation of child config_items. These\n" 276 - "items have only one attribute that is readable and writeable.\n"); 277 - } 278 - 279 - static void simple_children_release(struct config_item *item) 280 - { 281 - kfree(to_simple_children(item)); 282 - } 283 - 284 - static struct configfs_item_operations simple_children_item_ops = { 285 - .release = simple_children_release, 286 - .show_attribute = simple_children_attr_show, 287 - }; 288 - 289 - /* 290 - * Note that, since no extra work is required on ->drop_item(), 291 - * no ->drop_item() is provided. 292 - */ 293 - static struct configfs_group_operations simple_children_group_ops = { 294 - .make_item = simple_children_make_item, 295 - }; 296 - 297 - static struct config_item_type simple_children_type = { 298 - .ct_item_ops = &simple_children_item_ops, 299 - .ct_group_ops = &simple_children_group_ops, 300 - .ct_attrs = simple_children_attrs, 301 - .ct_owner = THIS_MODULE, 302 - }; 303 - 304 - static struct configfs_subsystem simple_children_subsys = { 305 - .su_group = { 306 - .cg_item = { 307 - .ci_namebuf = "02-simple-children", 308 - .ci_type = &simple_children_type, 309 - }, 310 - }, 311 - }; 312 - 313 - 314 - /* ----------------------------------------------------------------- */ 315 - 316 - /* 317 - * 03-group-children 318 - * 319 - * This example reuses the simple_children group from above. However, 320 - * the simple_children group is not the subsystem itself, it is a 321 - * child of the subsystem. Creation of a group in the subsystem creates 322 - * a new simple_children group. That group can then have simple_child 323 - * children of its own. 324 - */ 325 - 326 - static struct config_group *group_children_make_group(struct config_group *group, const char *name) 327 - { 328 - struct simple_children *simple_children; 329 - 330 - simple_children = kzalloc(sizeof(struct simple_children), 331 - GFP_KERNEL); 332 - if (!simple_children) 333 - return ERR_PTR(-ENOMEM); 334 - 335 - config_group_init_type_name(&simple_children->group, name, 336 - &simple_children_type); 337 - 338 - return &simple_children->group; 339 - } 340 - 341 - static struct configfs_attribute group_children_attr_description = { 342 - .ca_owner = THIS_MODULE, 343 - .ca_name = "description", 344 - .ca_mode = S_IRUGO, 345 - }; 346 - 347 - static struct configfs_attribute *group_children_attrs[] = { 348 - &group_children_attr_description, 349 - NULL, 350 - }; 351 - 352 - static ssize_t group_children_attr_show(struct config_item *item, 353 - struct configfs_attribute *attr, 354 - char *page) 355 - { 356 - return sprintf(page, 357 - "[03-group-children]\n" 358 - "\n" 359 - "This subsystem allows the creation of child config_groups. These\n" 360 - "groups are like the subsystem simple-children.\n"); 361 - } 362 - 363 - static struct configfs_item_operations group_children_item_ops = { 364 - .show_attribute = group_children_attr_show, 365 - }; 366 - 367 - /* 368 - * Note that, since no extra work is required on ->drop_item(), 369 - * no ->drop_item() is provided. 370 - */ 371 - static struct configfs_group_operations group_children_group_ops = { 372 - .make_group = group_children_make_group, 373 - }; 374 - 375 - static struct config_item_type group_children_type = { 376 - .ct_item_ops = &group_children_item_ops, 377 - .ct_group_ops = &group_children_group_ops, 378 - .ct_attrs = group_children_attrs, 379 - .ct_owner = THIS_MODULE, 380 - }; 381 - 382 - static struct configfs_subsystem group_children_subsys = { 383 - .su_group = { 384 - .cg_item = { 385 - .ci_namebuf = "03-group-children", 386 - .ci_type = &group_children_type, 387 - }, 388 - }, 389 - }; 390 - 391 - /* ----------------------------------------------------------------- */ 392 - 393 - /* 394 - * We're now done with our subsystem definitions. 395 - * For convenience in this module, here's a list of them all. It 396 - * allows the init function to easily register them. Most modules 397 - * will only have one subsystem, and will only call register_subsystem 398 - * on it directly. 399 - */ 400 - static struct configfs_subsystem *example_subsys[] = { 401 - &childless_subsys.subsys, 402 - &simple_children_subsys, 403 - &group_children_subsys, 404 - NULL, 405 - }; 406 - 407 - static int __init configfs_example_init(void) 408 - { 409 - int ret; 410 - int i; 411 - struct configfs_subsystem *subsys; 412 - 413 - for (i = 0; example_subsys[i]; i++) { 414 - subsys = example_subsys[i]; 415 - 416 - config_group_init(&subsys->su_group); 417 - mutex_init(&subsys->su_mutex); 418 - ret = configfs_register_subsystem(subsys); 419 - if (ret) { 420 - printk(KERN_ERR "Error %d while registering subsystem %s\n", 421 - ret, 422 - subsys->su_group.cg_item.ci_namebuf); 423 - goto out_unregister; 424 - } 425 - } 426 - 427 - return 0; 428 - 429 - out_unregister: 430 - for (i--; i >= 0; i--) 431 - configfs_unregister_subsystem(example_subsys[i]); 432 - 433 - return ret; 434 - } 435 - 436 - static void __exit configfs_example_exit(void) 437 - { 438 - int i; 439 - 440 - for (i = 0; example_subsys[i]; i++) 441 - configfs_unregister_subsystem(example_subsys[i]); 442 - } 443 - 444 - module_init(configfs_example_init); 445 - module_exit(configfs_example_exit); 446 - MODULE_LICENSE("GPL");
-17
Documentation/target/tcm_mod_builder.py
··· 203 203 buf += "#include <scsi/scsi_proto.h>\n\n" 204 204 buf += "#include <target/target_core_base.h>\n" 205 205 buf += "#include <target/target_core_fabric.h>\n" 206 - buf += "#include <target/target_core_fabric_configfs.h>\n" 207 - buf += "#include <target/configfs_macros.h>\n\n" 208 206 buf += "#include \"" + fabric_mod_name + "_base.h\"\n" 209 207 buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n" 210 208 ··· 281 283 buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n" 282 284 buf += " kfree(" + fabric_mod_port + ");\n" 283 285 buf += "}\n\n" 284 - buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n" 285 - buf += " struct target_fabric_configfs *tf,\n" 286 - buf += " char *page)\n" 287 - buf += "{\n" 288 - buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n" 289 - buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n" 290 - buf += " utsname()->machine);\n" 291 - buf += "}\n\n" 292 - buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n" 293 - buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n" 294 - buf += " &" + fabric_mod_name + "_wwn_version.attr,\n" 295 - buf += " NULL,\n" 296 - buf += "};\n\n" 297 286 298 287 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n" 299 288 buf += " .module = THIS_MODULE,\n" ··· 313 328 buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" 314 329 buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" 315 330 buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" 316 - buf += "\n" 317 - buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs,\n" 318 331 buf += "};\n\n" 319 332 320 333 buf += "static int __init " + fabric_mod_name + "_init(void)\n"
+24 -81
drivers/hwtracing/stm/policy.c
··· 76 76 NULL; 77 77 } 78 78 79 - static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node, 80 - char *page) 79 + static ssize_t 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 83 ssize_t count; 83 84 84 85 count = sprintf(page, "%u %u\n", policy_node->first_master, ··· 89 88 } 90 89 91 90 static ssize_t 92 - stp_policy_node_masters_store(struct stp_policy_node *policy_node, 93 - const char *page, size_t count) 91 + stp_policy_node_masters_store(struct config_item *item, const char *page, 92 + size_t count) 94 93 { 94 + struct stp_policy_node *policy_node = to_stp_policy_node(item); 95 95 unsigned int first, last; 96 96 struct stm_device *stm; 97 97 char *p = (char *)page; ··· 125 123 } 126 124 127 125 static ssize_t 128 - stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page) 126 + stp_policy_node_channels_show(struct config_item *item, char *page) 129 127 { 128 + struct stp_policy_node *policy_node = to_stp_policy_node(item); 130 129 ssize_t count; 131 130 132 131 count = sprintf(page, "%u %u\n", policy_node->first_channel, ··· 137 134 } 138 135 139 136 static ssize_t 140 - stp_policy_node_channels_store(struct stp_policy_node *policy_node, 141 - const char *page, size_t count) 137 + stp_policy_node_channels_store(struct config_item *item, const char *page, 138 + size_t count) 142 139 { 140 + struct stp_policy_node *policy_node = to_stp_policy_node(item); 143 141 unsigned int first, last; 144 142 struct stm_device *stm; 145 143 char *p = (char *)page; ··· 175 171 kfree(to_stp_policy_node(item)); 176 172 } 177 173 178 - struct stp_policy_node_attribute { 179 - struct configfs_attribute attr; 180 - ssize_t (*show)(struct stp_policy_node *, char *); 181 - ssize_t (*store)(struct stp_policy_node *, const char *, size_t); 182 - }; 183 - 184 - static ssize_t stp_policy_node_attr_show(struct config_item *item, 185 - struct configfs_attribute *attr, 186 - char *page) 187 - { 188 - struct stp_policy_node *policy_node = to_stp_policy_node(item); 189 - struct stp_policy_node_attribute *pn_attr = 190 - container_of(attr, struct stp_policy_node_attribute, attr); 191 - ssize_t count = 0; 192 - 193 - if (pn_attr->show) 194 - count = pn_attr->show(policy_node, page); 195 - 196 - return count; 197 - } 198 - 199 - static ssize_t stp_policy_node_attr_store(struct config_item *item, 200 - struct configfs_attribute *attr, 201 - const char *page, size_t len) 202 - { 203 - struct stp_policy_node *policy_node = to_stp_policy_node(item); 204 - struct stp_policy_node_attribute *pn_attr = 205 - container_of(attr, struct stp_policy_node_attribute, attr); 206 - ssize_t count = -EINVAL; 207 - 208 - if (pn_attr->store) 209 - count = pn_attr->store(policy_node, page, len); 210 - 211 - return count; 212 - } 213 - 214 174 static struct configfs_item_operations stp_policy_node_item_ops = { 215 175 .release = stp_policy_node_release, 216 - .show_attribute = stp_policy_node_attr_show, 217 - .store_attribute = stp_policy_node_attr_store, 218 176 }; 219 177 220 - static struct stp_policy_node_attribute stp_policy_node_attr_range = { 221 - .attr = { 222 - .ca_owner = THIS_MODULE, 223 - .ca_name = "masters", 224 - .ca_mode = S_IRUGO | S_IWUSR, 225 - }, 226 - .show = stp_policy_node_masters_show, 227 - .store = stp_policy_node_masters_store, 228 - }; 229 - 230 - static struct stp_policy_node_attribute stp_policy_node_attr_channels = { 231 - .attr = { 232 - .ca_owner = THIS_MODULE, 233 - .ca_name = "channels", 234 - .ca_mode = S_IRUGO | S_IWUSR, 235 - }, 236 - .show = stp_policy_node_channels_show, 237 - .store = stp_policy_node_channels_store, 238 - }; 178 + CONFIGFS_ATTR(stp_policy_node_, masters); 179 + CONFIGFS_ATTR(stp_policy_node_, channels); 239 180 240 181 static struct configfs_attribute *stp_policy_node_attrs[] = { 241 - &stp_policy_node_attr_range.attr, 242 - &stp_policy_node_attr_channels.attr, 182 + &stp_policy_node_attr_masters, 183 + &stp_policy_node_attr_channels, 243 184 NULL, 244 185 }; 245 186 ··· 247 298 /* 248 299 * Root group: policies. 249 300 */ 250 - static struct configfs_attribute stp_policy_attr_device = { 251 - .ca_owner = THIS_MODULE, 252 - .ca_name = "device", 253 - .ca_mode = S_IRUGO, 254 - }; 255 - 256 - static struct configfs_attribute *stp_policy_attrs[] = { 257 - &stp_policy_attr_device, 258 - NULL, 259 - }; 260 - 261 - static ssize_t stp_policy_attr_show(struct config_item *item, 262 - struct configfs_attribute *attr, 263 - char *page) 301 + static ssize_t stp_policy_device_show(struct config_item *item, 302 + char *page) 264 303 { 265 304 struct stp_policy *policy = to_stp_policy(item); 266 305 ssize_t count; ··· 260 323 261 324 return count; 262 325 } 326 + 327 + CONFIGFS_ATTR_RO(stp_policy_, device); 328 + 329 + static struct configfs_attribute *stp_policy_attrs[] = { 330 + &stp_policy_attr_device, 331 + NULL, 332 + }; 263 333 264 334 void stp_policy_unbind(struct stp_policy *policy) 265 335 { ··· 294 350 295 351 static struct configfs_item_operations stp_policy_item_ops = { 296 352 .release = stp_policy_release, 297 - .show_attribute = stp_policy_attr_show, 298 353 }; 299 354 300 355 static struct configfs_group_operations stp_policy_group_ops = {
+34 -44
drivers/infiniband/ulp/srpt/ib_srpt.c
··· 43 43 #include <linux/atomic.h> 44 44 #include <scsi/scsi_proto.h> 45 45 #include <scsi/scsi_tcq.h> 46 - #include <target/configfs_macros.h> 47 46 #include <target/target_core_base.h> 48 - #include <target/target_core_fabric_configfs.h> 49 47 #include <target/target_core_fabric.h> 50 48 #include "ib_srpt.h" 51 49 ··· 3544 3546 spin_unlock_irq(&sport->port_acl_lock); 3545 3547 } 3546 3548 3547 - static ssize_t srpt_tpg_attrib_show_srp_max_rdma_size( 3548 - struct se_portal_group *se_tpg, 3549 - char *page) 3549 + static ssize_t srpt_tpg_attrib_srp_max_rdma_size_show(struct config_item *item, 3550 + char *page) 3550 3551 { 3552 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3551 3553 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3552 3554 3553 3555 return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size); 3554 3556 } 3555 3557 3556 - static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size( 3557 - struct se_portal_group *se_tpg, 3558 - const char *page, 3559 - size_t count) 3558 + static ssize_t srpt_tpg_attrib_srp_max_rdma_size_store(struct config_item *item, 3559 + const char *page, size_t count) 3560 3560 { 3561 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3561 3562 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3562 3563 unsigned long val; 3563 3564 int ret; ··· 3581 3584 return count; 3582 3585 } 3583 3586 3584 - TF_TPG_ATTRIB_ATTR(srpt, srp_max_rdma_size, S_IRUGO | S_IWUSR); 3585 - 3586 - static ssize_t srpt_tpg_attrib_show_srp_max_rsp_size( 3587 - struct se_portal_group *se_tpg, 3588 - char *page) 3587 + static ssize_t srpt_tpg_attrib_srp_max_rsp_size_show(struct config_item *item, 3588 + char *page) 3589 3589 { 3590 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3590 3591 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3591 3592 3592 3593 return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size); 3593 3594 } 3594 3595 3595 - static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size( 3596 - struct se_portal_group *se_tpg, 3597 - const char *page, 3598 - size_t count) 3596 + static ssize_t srpt_tpg_attrib_srp_max_rsp_size_store(struct config_item *item, 3597 + const char *page, size_t count) 3599 3598 { 3599 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3600 3600 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3601 3601 unsigned long val; 3602 3602 int ret; ··· 3618 3624 return count; 3619 3625 } 3620 3626 3621 - TF_TPG_ATTRIB_ATTR(srpt, srp_max_rsp_size, S_IRUGO | S_IWUSR); 3622 - 3623 - static ssize_t srpt_tpg_attrib_show_srp_sq_size( 3624 - struct se_portal_group *se_tpg, 3625 - char *page) 3627 + static ssize_t srpt_tpg_attrib_srp_sq_size_show(struct config_item *item, 3628 + char *page) 3626 3629 { 3630 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3627 3631 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3628 3632 3629 3633 return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size); 3630 3634 } 3631 3635 3632 - static ssize_t srpt_tpg_attrib_store_srp_sq_size( 3633 - struct se_portal_group *se_tpg, 3634 - const char *page, 3635 - size_t count) 3636 + static ssize_t srpt_tpg_attrib_srp_sq_size_store(struct config_item *item, 3637 + const char *page, size_t count) 3636 3638 { 3639 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 3637 3640 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3638 3641 unsigned long val; 3639 3642 int ret; ··· 3655 3664 return count; 3656 3665 } 3657 3666 3658 - TF_TPG_ATTRIB_ATTR(srpt, srp_sq_size, S_IRUGO | S_IWUSR); 3667 + CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rdma_size); 3668 + CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rsp_size); 3669 + CONFIGFS_ATTR(srpt_tpg_attrib_, srp_sq_size); 3659 3670 3660 3671 static struct configfs_attribute *srpt_tpg_attrib_attrs[] = { 3661 - &srpt_tpg_attrib_srp_max_rdma_size.attr, 3662 - &srpt_tpg_attrib_srp_max_rsp_size.attr, 3663 - &srpt_tpg_attrib_srp_sq_size.attr, 3672 + &srpt_tpg_attrib_attr_srp_max_rdma_size, 3673 + &srpt_tpg_attrib_attr_srp_max_rsp_size, 3674 + &srpt_tpg_attrib_attr_srp_sq_size, 3664 3675 NULL, 3665 3676 }; 3666 3677 3667 - static ssize_t srpt_tpg_show_enable( 3668 - struct se_portal_group *se_tpg, 3669 - char *page) 3678 + static ssize_t srpt_tpg_enable_show(struct config_item *item, char *page) 3670 3679 { 3680 + struct se_portal_group *se_tpg = to_tpg(item); 3671 3681 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3672 3682 3673 3683 return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0); 3674 3684 } 3675 3685 3676 - static ssize_t srpt_tpg_store_enable( 3677 - struct se_portal_group *se_tpg, 3678 - const char *page, 3679 - size_t count) 3686 + static ssize_t srpt_tpg_enable_store(struct config_item *item, 3687 + const char *page, size_t count) 3680 3688 { 3689 + struct se_portal_group *se_tpg = to_tpg(item); 3681 3690 struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1); 3682 3691 unsigned long tmp; 3683 3692 int ret; ··· 3700 3709 return count; 3701 3710 } 3702 3711 3703 - TF_TPG_BASE_ATTR(srpt, enable, S_IRUGO | S_IWUSR); 3712 + CONFIGFS_ATTR(srpt_tpg_, enable); 3704 3713 3705 3714 static struct configfs_attribute *srpt_tpg_attrs[] = { 3706 - &srpt_tpg_enable.attr, 3715 + &srpt_tpg_attr_enable, 3707 3716 NULL, 3708 3717 }; 3709 3718 ··· 3773 3782 pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item)); 3774 3783 } 3775 3784 3776 - static ssize_t srpt_wwn_show_attr_version(struct target_fabric_configfs *tf, 3777 - char *buf) 3785 + static ssize_t srpt_wwn_version_show(struct config_item *item, char *buf) 3778 3786 { 3779 3787 return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION); 3780 3788 } 3781 3789 3782 - TF_WWN_ATTR_RO(srpt, version); 3790 + CONFIGFS_ATTR_RO(srpt_wwn_, version); 3783 3791 3784 3792 static struct configfs_attribute *srpt_wwn_attrs[] = { 3785 - &srpt_wwn_version.attr, 3793 + &srpt_wwn_attr_version, 3786 3794 NULL, 3787 3795 }; 3788 3796
+71 -145
drivers/misc/spear13xx_pcie_gadget.c
··· 220 220 /* 221 221 * configfs interfaces show/store functions 222 222 */ 223 - static ssize_t pcie_gadget_show_link( 224 - struct spear_pcie_gadget_config *config, 225 - char *buf) 223 + 224 + static struct pcie_gadget_target *to_target(struct config_item *item) 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 235 if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID)) 230 236 return sprintf(buf, "UP"); ··· 238 232 return sprintf(buf, "DOWN"); 239 233 } 240 234 241 - static ssize_t pcie_gadget_store_link( 242 - struct spear_pcie_gadget_config *config, 235 + static ssize_t pcie_gadget_link_store(struct config_item *item, 243 236 const char *buf, size_t count) 244 237 { 245 - struct pcie_app_reg __iomem *app_reg = config->va_app_base; 238 + struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; 246 239 247 240 if (sysfs_streq(buf, "UP")) 248 241 writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID), ··· 255 250 return count; 256 251 } 257 252 258 - static ssize_t pcie_gadget_show_int_type( 259 - struct spear_pcie_gadget_config *config, 260 - char *buf) 253 + static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf) 261 254 { 262 - return sprintf(buf, "%s", config->int_type); 255 + return sprintf(buf, "%s", to_target(item)->int_type); 263 256 } 264 257 265 - static ssize_t pcie_gadget_store_int_type( 266 - struct spear_pcie_gadget_config *config, 258 + static ssize_t pcie_gadget_int_type_store(struct config_item *item, 267 259 const char *buf, size_t count) 268 260 { 261 + struct spear_pcie_gadget_config *config = to_target(item) 269 262 u32 cap, vec, flags; 270 263 ulong vector; 271 264 ··· 291 288 return count; 292 289 } 293 290 294 - static ssize_t pcie_gadget_show_no_of_msi( 295 - struct spear_pcie_gadget_config *config, 296 - char *buf) 291 + static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf) 297 292 { 298 - struct pcie_app_reg __iomem *app_reg = config->va_app_base; 293 + struct spear_pcie_gadget_config *config = to_target(item) 294 + struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; 299 295 u32 cap, vec, flags; 300 296 ulong vector; 301 297 ··· 315 313 return sprintf(buf, "%lu", vector); 316 314 } 317 315 318 - static ssize_t pcie_gadget_store_no_of_msi( 319 - struct spear_pcie_gadget_config *config, 316 + static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item, 320 317 const char *buf, size_t count) 321 318 { 322 319 int ret; 323 320 324 - ret = kstrtoul(buf, 0, &config->requested_msi); 321 + ret = kstrtoul(buf, 0, &to_target(item)->requested_msi); 325 322 if (ret) 326 323 return ret; 327 324 ··· 330 329 return count; 331 330 } 332 331 333 - static ssize_t pcie_gadget_store_inta( 334 - struct spear_pcie_gadget_config *config, 332 + static ssize_t pcie_gadget_inta_store(struct config_item *item, 335 333 const char *buf, size_t count) 336 334 { 337 - struct pcie_app_reg __iomem *app_reg = config->va_app_base; 335 + struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; 338 336 ulong en; 339 337 int ret; 340 338 ··· 351 351 return count; 352 352 } 353 353 354 - static ssize_t pcie_gadget_store_send_msi( 355 - struct spear_pcie_gadget_config *config, 354 + static ssize_t pcie_gadget_send_msi_store(struct config_item *item, 356 355 const char *buf, size_t count) 357 356 { 357 + struct spear_pcie_gadget_config *config = to_target(item) 358 358 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 359 359 ulong vector; 360 360 u32 ven_msi; ··· 388 388 return count; 389 389 } 390 390 391 - static ssize_t pcie_gadget_show_vendor_id( 392 - struct spear_pcie_gadget_config *config, 393 - char *buf) 391 + static ssize_t pcie_gadget_vendor_id_show(struct config_item *item, char *buf) 394 392 { 395 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 397 return sprintf(buf, "%x", id); 400 398 } 401 399 402 - static ssize_t pcie_gadget_store_vendor_id( 403 - struct spear_pcie_gadget_config *config, 400 + static ssize_t pcie_gadget_vendor_id_store(struct config_item *item, 404 401 const char *buf, size_t count) 405 402 { 406 403 ulong id; ··· 407 410 if (ret) 408 411 return ret; 409 412 410 - spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id); 413 + spear_dbi_write_reg(to_target(item), PCI_VENDOR_ID, 2, id); 411 414 412 415 return count; 413 416 } 414 417 415 - static ssize_t pcie_gadget_show_device_id( 416 - struct spear_pcie_gadget_config *config, 417 - char *buf) 418 + static ssize_t pcie_gadget_device_id_show(struct config_item *item, char *buf) 418 419 { 419 420 u32 id; 420 421 421 - spear_dbi_read_reg(config, PCI_DEVICE_ID, 2, &id); 422 + spear_dbi_read_reg(to_target(item), PCI_DEVICE_ID, 2, &id); 422 423 423 424 return sprintf(buf, "%x", id); 424 425 } 425 426 426 - static ssize_t pcie_gadget_store_device_id( 427 - struct spear_pcie_gadget_config *config, 427 + static ssize_t pcie_gadget_device_id_store(struct config_item *item, 428 428 const char *buf, size_t count) 429 429 { 430 430 ulong id; ··· 431 437 if (ret) 432 438 return ret; 433 439 434 - spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id); 440 + spear_dbi_write_reg(to_target(item), PCI_DEVICE_ID, 2, id); 435 441 436 442 return count; 437 443 } 438 444 439 - static ssize_t pcie_gadget_show_bar0_size( 440 - struct spear_pcie_gadget_config *config, 441 - char *buf) 445 + static ssize_t pcie_gadget_bar0_size_show(struct config_item *item, char *buf) 442 446 { 443 - return sprintf(buf, "%lx", config->bar0_size); 447 + return sprintf(buf, "%lx", to_target(item)->bar0_size); 444 448 } 445 449 446 - static ssize_t pcie_gadget_store_bar0_size( 447 - struct spear_pcie_gadget_config *config, 450 + static ssize_t pcie_gadget_bar0_size_store(struct config_item *item, 448 451 const char *buf, size_t count) 449 452 { 453 + struct spear_pcie_gadget_config *config = to_target(item) 450 454 ulong size; 451 455 u32 pos, pos1; 452 456 u32 no_of_bit = 0; ··· 481 489 return count; 482 490 } 483 491 484 - static ssize_t pcie_gadget_show_bar0_address( 485 - struct spear_pcie_gadget_config *config, 492 + static ssize_t pcie_gadget_bar0_address_show(struct config_item *item, 486 493 char *buf) 487 494 { 488 - struct pcie_app_reg __iomem *app_reg = config->va_app_base; 495 + struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base; 489 496 490 497 u32 address = readl(&app_reg->pim0_mem_addr_start); 491 498 492 499 return sprintf(buf, "%x", address); 493 500 } 494 501 495 - static ssize_t pcie_gadget_store_bar0_address( 496 - struct spear_pcie_gadget_config *config, 502 + static ssize_t pcie_gadget_bar0_address_store(struct config_item *item, 497 503 const char *buf, size_t count) 498 504 { 505 + struct spear_pcie_gadget_config *config = to_target(item) 499 506 struct pcie_app_reg __iomem *app_reg = config->va_app_base; 500 507 ulong address; 501 508 int ret; ··· 515 524 return count; 516 525 } 517 526 518 - static ssize_t pcie_gadget_show_bar0_rw_offset( 519 - struct spear_pcie_gadget_config *config, 527 + static ssize_t pcie_gadget_bar0_rw_offset_show(struct config_item *item, 520 528 char *buf) 521 529 { 522 - return sprintf(buf, "%lx", config->bar0_rw_offset); 530 + return sprintf(buf, "%lx", to_target(item)->bar0_rw_offset); 523 531 } 524 532 525 - static ssize_t pcie_gadget_store_bar0_rw_offset( 526 - struct spear_pcie_gadget_config *config, 533 + static ssize_t pcie_gadget_bar0_rw_offset_store(struct config_item *item, 527 534 const char *buf, size_t count) 528 535 { 529 536 ulong offset; ··· 534 545 if (offset % 4) 535 546 return -EINVAL; 536 547 537 - config->bar0_rw_offset = offset; 548 + to_target(item)->bar0_rw_offset = offset; 538 549 539 550 return count; 540 551 } 541 552 542 - static ssize_t pcie_gadget_show_bar0_data( 543 - struct spear_pcie_gadget_config *config, 544 - char *buf) 553 + static ssize_t pcie_gadget_bar0_data_show(struct config_item *item, char *buf) 545 554 { 555 + struct spear_pcie_gadget_config *config = to_target(item) 546 556 ulong data; 547 557 548 558 if (!config->va_bar0_address) ··· 552 564 return sprintf(buf, "%lx", data); 553 565 } 554 566 555 - static ssize_t pcie_gadget_store_bar0_data( 556 - struct spear_pcie_gadget_config *config, 567 + static ssize_t pcie_gadget_bar0_data_store(struct config_item *item, 557 568 const char *buf, size_t count) 558 569 { 570 + struct spear_pcie_gadget_config *config = to_target(item) 559 571 ulong data; 560 572 int ret; 561 573 ··· 571 583 return count; 572 584 } 573 585 574 - /* 575 - * Attribute definitions. 576 - */ 577 - 578 - #define PCIE_GADGET_TARGET_ATTR_RO(_name) \ 579 - static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ 580 - __CONFIGFS_ATTR(_name, S_IRUGO, pcie_gadget_show_##_name, NULL) 581 - 582 - #define PCIE_GADGET_TARGET_ATTR_WO(_name) \ 583 - static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ 584 - __CONFIGFS_ATTR(_name, S_IWUSR, NULL, pcie_gadget_store_##_name) 585 - 586 - #define PCIE_GADGET_TARGET_ATTR_RW(_name) \ 587 - static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \ 588 - __CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, pcie_gadget_show_##_name, \ 589 - pcie_gadget_store_##_name) 590 - PCIE_GADGET_TARGET_ATTR_RW(link); 591 - PCIE_GADGET_TARGET_ATTR_RW(int_type); 592 - PCIE_GADGET_TARGET_ATTR_RW(no_of_msi); 593 - PCIE_GADGET_TARGET_ATTR_WO(inta); 594 - PCIE_GADGET_TARGET_ATTR_WO(send_msi); 595 - PCIE_GADGET_TARGET_ATTR_RW(vendor_id); 596 - PCIE_GADGET_TARGET_ATTR_RW(device_id); 597 - PCIE_GADGET_TARGET_ATTR_RW(bar0_size); 598 - PCIE_GADGET_TARGET_ATTR_RW(bar0_address); 599 - PCIE_GADGET_TARGET_ATTR_RW(bar0_rw_offset); 600 - PCIE_GADGET_TARGET_ATTR_RW(bar0_data); 586 + CONFIGFS_ATTR(pcie_gadget_, link); 587 + CONFIGFS_ATTR(pcie_gadget_, int_type); 588 + CONFIGFS_ATTR(pcie_gadget_, no_of_msi); 589 + CONFIGFS_ATTR_WO(pcie_gadget_, inta); 590 + CONFIGFS_ATTR_WO(pcie_gadget_, send_msi); 591 + CONFIGFS_ATTR(pcie_gadget_, vendor_id); 592 + CONFIGFS_ATTR(pcie_gadget_, device_id); 593 + CONFIGFS_ATTR(pcie_gadget_, bar0_size); 594 + CONFIGFS_ATTR(pcie_gadget_, bar0_address); 595 + CONFIGFS_ATTR(pcie_gadget_, bar0_rw_offset); 596 + CONFIGFS_ATTR(pcie_gadget_, bar0_data); 601 597 602 598 static struct configfs_attribute *pcie_gadget_target_attrs[] = { 603 - &pcie_gadget_target_link.attr, 604 - &pcie_gadget_target_int_type.attr, 605 - &pcie_gadget_target_no_of_msi.attr, 606 - &pcie_gadget_target_inta.attr, 607 - &pcie_gadget_target_send_msi.attr, 608 - &pcie_gadget_target_vendor_id.attr, 609 - &pcie_gadget_target_device_id.attr, 610 - &pcie_gadget_target_bar0_size.attr, 611 - &pcie_gadget_target_bar0_address.attr, 612 - &pcie_gadget_target_bar0_rw_offset.attr, 613 - &pcie_gadget_target_bar0_data.attr, 599 + &pcie_gadget_attr_link, 600 + &pcie_gadget_attr_int_type, 601 + &pcie_gadget_attr_no_of_msi, 602 + &pcie_gadget_attr_inta, 603 + &pcie_gadget_attr_send_msi, 604 + &pcie_gadget_attr_vendor_id, 605 + &pcie_gadget_attr_device_id, 606 + &pcie_gadget_attr_bar0_size, 607 + &pcie_gadget_attr_bar0_address, 608 + &pcie_gadget_attr_bar0_rw_offset, 609 + &pcie_gadget_attr_bar0_data, 614 610 NULL, 615 - }; 616 - 617 - static struct pcie_gadget_target *to_target(struct config_item *item) 618 - { 619 - return item ? 620 - container_of(to_configfs_subsystem(to_config_group(item)), 621 - struct pcie_gadget_target, subsys) : NULL; 622 - } 623 - 624 - /* 625 - * Item operations and type for pcie_gadget_target. 626 - */ 627 - 628 - static ssize_t pcie_gadget_target_attr_show(struct config_item *item, 629 - struct configfs_attribute *attr, 630 - char *buf) 631 - { 632 - ssize_t ret = -EINVAL; 633 - struct pcie_gadget_target *target = to_target(item); 634 - struct pcie_gadget_target_attr *t_attr = 635 - container_of(attr, struct pcie_gadget_target_attr, attr); 636 - 637 - if (t_attr->show) 638 - ret = t_attr->show(&target->config, buf); 639 - return ret; 640 - } 641 - 642 - static ssize_t pcie_gadget_target_attr_store(struct config_item *item, 643 - struct configfs_attribute *attr, 644 - const char *buf, 645 - size_t count) 646 - { 647 - ssize_t ret = -EINVAL; 648 - struct pcie_gadget_target *target = to_target(item); 649 - struct pcie_gadget_target_attr *t_attr = 650 - container_of(attr, struct pcie_gadget_target_attr, attr); 651 - 652 - if (t_attr->store) 653 - ret = t_attr->store(&target->config, buf, count); 654 - return ret; 655 - } 656 - 657 - static struct configfs_item_operations pcie_gadget_target_item_ops = { 658 - .show_attribute = pcie_gadget_target_attr_show, 659 - .store_attribute = pcie_gadget_target_attr_store, 660 611 }; 661 612 662 613 static struct config_item_type pcie_gadget_target_type = { 663 614 .ct_attrs = pcie_gadget_target_attrs, 664 - .ct_item_ops = &pcie_gadget_target_item_ops, 665 615 .ct_owner = THIS_MODULE, 666 616 }; 667 617
+132 -139
drivers/net/netconsole.c
··· 244 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 247 static struct netconsole_target *to_target(struct config_item *item) 257 248 { 258 249 return item ? ··· 255 264 * Attribute operations for netconsole_target. 256 265 */ 257 266 258 - static ssize_t show_enabled(struct netconsole_target *nt, char *buf) 267 + static ssize_t enabled_show(struct config_item *item, char *buf) 259 268 { 260 - return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled); 269 + return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled); 261 270 } 262 271 263 - static ssize_t show_extended(struct netconsole_target *nt, char *buf) 272 + static ssize_t extended_show(struct config_item *item, char *buf) 264 273 { 265 - return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended); 274 + return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended); 266 275 } 267 276 268 - static ssize_t show_dev_name(struct netconsole_target *nt, char *buf) 277 + static ssize_t dev_name_show(struct config_item *item, char *buf) 269 278 { 270 - return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name); 279 + return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name); 271 280 } 272 281 273 - static ssize_t show_local_port(struct netconsole_target *nt, char *buf) 282 + static ssize_t local_port_show(struct config_item *item, char *buf) 274 283 { 275 - return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port); 284 + return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port); 276 285 } 277 286 278 - static ssize_t show_remote_port(struct netconsole_target *nt, char *buf) 287 + static ssize_t remote_port_show(struct config_item *item, char *buf) 279 288 { 280 - return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port); 289 + return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.remote_port); 281 290 } 282 291 283 - static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) 292 + static ssize_t local_ip_show(struct config_item *item, char *buf) 284 293 { 294 + struct netconsole_target *nt = to_target(item); 295 + 285 296 if (nt->np.ipv6) 286 297 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); 287 298 else 288 299 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); 289 300 } 290 301 291 - static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) 302 + static ssize_t remote_ip_show(struct config_item *item, char *buf) 292 303 { 304 + struct netconsole_target *nt = to_target(item); 305 + 293 306 if (nt->np.ipv6) 294 307 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); 295 308 else 296 309 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); 297 310 } 298 311 299 - static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) 312 + static ssize_t local_mac_show(struct config_item *item, char *buf) 300 313 { 301 - struct net_device *dev = nt->np.dev; 314 + struct net_device *dev = to_target(item)->np.dev; 302 315 static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 303 316 304 317 return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast); 305 318 } 306 319 307 - static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) 320 + static ssize_t remote_mac_show(struct config_item *item, char *buf) 308 321 { 309 - return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac); 322 + return snprintf(buf, PAGE_SIZE, "%pM\n", to_target(item)->np.remote_mac); 310 323 } 311 324 312 325 /* ··· 320 325 * would enable him to dynamically add new netpoll targets for new 321 326 * network interfaces as and when they come up). 322 327 */ 323 - static ssize_t store_enabled(struct netconsole_target *nt, 324 - const char *buf, 325 - size_t count) 328 + static ssize_t enabled_store(struct config_item *item, 329 + const char *buf, size_t count) 326 330 { 331 + struct netconsole_target *nt = to_target(item); 327 332 unsigned long flags; 328 333 int enabled; 329 334 int err; 330 335 336 + mutex_lock(&dynamic_netconsole_mutex); 331 337 err = kstrtoint(buf, 10, &enabled); 332 338 if (err < 0) 333 - return err; 339 + goto out_unlock; 340 + 341 + err = -EINVAL; 334 342 if (enabled < 0 || enabled > 1) 335 - return -EINVAL; 343 + goto out_unlock; 336 344 if ((bool)enabled == nt->enabled) { 337 345 pr_info("network logging has already %s\n", 338 346 nt->enabled ? "started" : "stopped"); 339 - return -EINVAL; 347 + goto out_unlock; 340 348 } 341 349 342 350 if (enabled) { /* true */ ··· 356 358 357 359 err = netpoll_setup(&nt->np); 358 360 if (err) 359 - return err; 361 + goto out_unlock; 360 362 361 363 pr_info("netconsole: network logging started\n"); 362 364 } else { /* false */ ··· 372 374 373 375 nt->enabled = enabled; 374 376 377 + mutex_unlock(&dynamic_netconsole_mutex); 375 378 return strnlen(buf, count); 379 + out_unlock: 380 + mutex_unlock(&dynamic_netconsole_mutex); 381 + return err; 376 382 } 377 383 378 - static ssize_t store_extended(struct netconsole_target *nt, 379 - const char *buf, 380 - size_t count) 384 + static ssize_t extended_store(struct config_item *item, const char *buf, 385 + size_t count) 381 386 { 387 + struct netconsole_target *nt = to_target(item); 382 388 int extended; 383 389 int err; 384 390 391 + mutex_lock(&dynamic_netconsole_mutex); 385 392 if (nt->enabled) { 386 393 pr_err("target (%s) is enabled, disable to update parameters\n", 387 394 config_item_name(&nt->item)); 388 - return -EINVAL; 395 + err = -EINVAL; 396 + goto out_unlock; 389 397 } 390 398 391 399 err = kstrtoint(buf, 10, &extended); 392 400 if (err < 0) 393 - return err; 394 - if (extended < 0 || extended > 1) 395 - return -EINVAL; 401 + goto out_unlock; 402 + if (extended < 0 || extended > 1) { 403 + err = -EINVAL; 404 + goto out_unlock; 405 + } 396 406 397 407 nt->extended = extended; 398 408 409 + mutex_unlock(&dynamic_netconsole_mutex); 399 410 return strnlen(buf, count); 411 + out_unlock: 412 + mutex_unlock(&dynamic_netconsole_mutex); 413 + return err; 400 414 } 401 415 402 - static ssize_t store_dev_name(struct netconsole_target *nt, 403 - const char *buf, 404 - size_t count) 416 + static ssize_t dev_name_store(struct config_item *item, const char *buf, 417 + size_t count) 405 418 { 419 + struct netconsole_target *nt = to_target(item); 406 420 size_t len; 407 421 422 + mutex_lock(&dynamic_netconsole_mutex); 408 423 if (nt->enabled) { 409 424 pr_err("target (%s) is enabled, disable to update parameters\n", 410 425 config_item_name(&nt->item)); 426 + mutex_unlock(&dynamic_netconsole_mutex); 411 427 return -EINVAL; 412 428 } 413 429 ··· 432 420 if (nt->np.dev_name[len - 1] == '\n') 433 421 nt->np.dev_name[len - 1] = '\0'; 434 422 423 + mutex_unlock(&dynamic_netconsole_mutex); 435 424 return strnlen(buf, count); 436 425 } 437 426 438 - static ssize_t store_local_port(struct netconsole_target *nt, 439 - const char *buf, 440 - size_t count) 427 + static ssize_t local_port_store(struct config_item *item, const char *buf, 428 + size_t count) 441 429 { 442 - int rv; 430 + struct netconsole_target *nt = to_target(item); 431 + int rv = -EINVAL; 443 432 433 + mutex_lock(&dynamic_netconsole_mutex); 444 434 if (nt->enabled) { 445 435 pr_err("target (%s) is enabled, disable to update parameters\n", 446 436 config_item_name(&nt->item)); 447 - return -EINVAL; 437 + goto out_unlock; 448 438 } 449 439 450 440 rv = kstrtou16(buf, 10, &nt->np.local_port); 451 441 if (rv < 0) 452 - return rv; 442 + goto out_unlock; 443 + mutex_unlock(&dynamic_netconsole_mutex); 453 444 return strnlen(buf, count); 445 + out_unlock: 446 + mutex_unlock(&dynamic_netconsole_mutex); 447 + return rv; 454 448 } 455 449 456 - static ssize_t store_remote_port(struct netconsole_target *nt, 457 - const char *buf, 458 - size_t count) 450 + static ssize_t remote_port_store(struct config_item *item, 451 + const char *buf, size_t count) 459 452 { 460 - int rv; 453 + struct netconsole_target *nt = to_target(item); 454 + int rv = -EINVAL; 461 455 456 + mutex_lock(&dynamic_netconsole_mutex); 462 457 if (nt->enabled) { 463 458 pr_err("target (%s) is enabled, disable to update parameters\n", 464 459 config_item_name(&nt->item)); 465 - return -EINVAL; 460 + goto out_unlock; 466 461 } 467 462 468 463 rv = kstrtou16(buf, 10, &nt->np.remote_port); 469 464 if (rv < 0) 470 - return rv; 465 + goto out_unlock; 466 + mutex_unlock(&dynamic_netconsole_mutex); 471 467 return strnlen(buf, count); 468 + out_unlock: 469 + mutex_unlock(&dynamic_netconsole_mutex); 470 + return rv; 472 471 } 473 472 474 - static ssize_t store_local_ip(struct netconsole_target *nt, 475 - const char *buf, 476 - size_t count) 473 + static ssize_t local_ip_store(struct config_item *item, const char *buf, 474 + size_t count) 477 475 { 476 + struct netconsole_target *nt = to_target(item); 477 + 478 + mutex_lock(&dynamic_netconsole_mutex); 478 479 if (nt->enabled) { 479 480 pr_err("target (%s) is enabled, disable to update parameters\n", 480 481 config_item_name(&nt->item)); 481 - return -EINVAL; 482 + goto out_unlock; 482 483 } 483 484 484 485 if (strnchr(buf, count, ':')) { ··· 499 474 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { 500 475 if (*end && *end != '\n') { 501 476 pr_err("invalid IPv6 address at: <%c>\n", *end); 502 - return -EINVAL; 477 + goto out_unlock; 503 478 } 504 479 nt->np.ipv6 = true; 505 480 } else 506 - return -EINVAL; 481 + goto out_unlock; 507 482 } else { 508 483 if (!nt->np.ipv6) { 509 484 nt->np.local_ip.ip = in_aton(buf); 510 485 } else 511 - return -EINVAL; 486 + goto out_unlock; 512 487 } 513 488 489 + mutex_unlock(&dynamic_netconsole_mutex); 514 490 return strnlen(buf, count); 491 + out_unlock: 492 + mutex_unlock(&dynamic_netconsole_mutex); 493 + return -EINVAL; 515 494 } 516 495 517 - static ssize_t store_remote_ip(struct netconsole_target *nt, 518 - const char *buf, 519 - size_t count) 496 + static ssize_t remote_ip_store(struct config_item *item, const char *buf, 497 + size_t count) 520 498 { 499 + struct netconsole_target *nt = to_target(item); 500 + 501 + mutex_lock(&dynamic_netconsole_mutex); 521 502 if (nt->enabled) { 522 503 pr_err("target (%s) is enabled, disable to update parameters\n", 523 504 config_item_name(&nt->item)); 524 - return -EINVAL; 505 + goto out_unlock; 525 506 } 526 507 527 508 if (strnchr(buf, count, ':')) { ··· 535 504 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { 536 505 if (*end && *end != '\n') { 537 506 pr_err("invalid IPv6 address at: <%c>\n", *end); 538 - return -EINVAL; 507 + goto out_unlock; 539 508 } 540 509 nt->np.ipv6 = true; 541 510 } else 542 - return -EINVAL; 511 + goto out_unlock; 543 512 } else { 544 513 if (!nt->np.ipv6) { 545 514 nt->np.remote_ip.ip = in_aton(buf); 546 515 } else 547 - return -EINVAL; 516 + goto out_unlock; 548 517 } 549 518 519 + mutex_unlock(&dynamic_netconsole_mutex); 550 520 return strnlen(buf, count); 521 + out_unlock: 522 + mutex_unlock(&dynamic_netconsole_mutex); 523 + return -EINVAL; 551 524 } 552 525 553 - static ssize_t store_remote_mac(struct netconsole_target *nt, 554 - const char *buf, 555 - size_t count) 526 + static ssize_t remote_mac_store(struct config_item *item, const char *buf, 527 + size_t count) 556 528 { 529 + struct netconsole_target *nt = to_target(item); 557 530 u8 remote_mac[ETH_ALEN]; 558 531 532 + mutex_lock(&dynamic_netconsole_mutex); 559 533 if (nt->enabled) { 560 534 pr_err("target (%s) is enabled, disable to update parameters\n", 561 535 config_item_name(&nt->item)); 562 - return -EINVAL; 536 + goto out_unlock; 563 537 } 564 538 565 539 if (!mac_pton(buf, remote_mac)) 566 - return -EINVAL; 540 + goto out_unlock; 567 541 if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n') 568 - return -EINVAL; 542 + goto out_unlock; 569 543 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN); 570 544 545 + mutex_unlock(&dynamic_netconsole_mutex); 571 546 return strnlen(buf, count); 547 + out_unlock: 548 + mutex_unlock(&dynamic_netconsole_mutex); 549 + return -EINVAL; 572 550 } 573 551 574 - /* 575 - * Attribute definitions for netconsole_target. 576 - */ 577 - 578 - #define NETCONSOLE_TARGET_ATTR_RO(_name) \ 579 - static struct netconsole_target_attr netconsole_target_##_name = \ 580 - __CONFIGFS_ATTR(_name, S_IRUGO, show_##_name, NULL) 581 - 582 - #define NETCONSOLE_TARGET_ATTR_RW(_name) \ 583 - static struct netconsole_target_attr netconsole_target_##_name = \ 584 - __CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, show_##_name, store_##_name) 585 - 586 - NETCONSOLE_TARGET_ATTR_RW(enabled); 587 - NETCONSOLE_TARGET_ATTR_RW(extended); 588 - NETCONSOLE_TARGET_ATTR_RW(dev_name); 589 - NETCONSOLE_TARGET_ATTR_RW(local_port); 590 - NETCONSOLE_TARGET_ATTR_RW(remote_port); 591 - NETCONSOLE_TARGET_ATTR_RW(local_ip); 592 - NETCONSOLE_TARGET_ATTR_RW(remote_ip); 593 - NETCONSOLE_TARGET_ATTR_RO(local_mac); 594 - NETCONSOLE_TARGET_ATTR_RW(remote_mac); 552 + CONFIGFS_ATTR(, enabled); 553 + CONFIGFS_ATTR(, extended); 554 + CONFIGFS_ATTR(, dev_name); 555 + CONFIGFS_ATTR(, local_port); 556 + CONFIGFS_ATTR(, remote_port); 557 + CONFIGFS_ATTR(, local_ip); 558 + CONFIGFS_ATTR(, remote_ip); 559 + CONFIGFS_ATTR_RO(, local_mac); 560 + CONFIGFS_ATTR(, remote_mac); 595 561 596 562 static struct configfs_attribute *netconsole_target_attrs[] = { 597 - &netconsole_target_enabled.attr, 598 - &netconsole_target_extended.attr, 599 - &netconsole_target_dev_name.attr, 600 - &netconsole_target_local_port.attr, 601 - &netconsole_target_remote_port.attr, 602 - &netconsole_target_local_ip.attr, 603 - &netconsole_target_remote_ip.attr, 604 - &netconsole_target_local_mac.attr, 605 - &netconsole_target_remote_mac.attr, 563 + &attr_enabled, 564 + &attr_extended, 565 + &attr_dev_name, 566 + &attr_local_port, 567 + &attr_remote_port, 568 + &attr_local_ip, 569 + &attr_remote_ip, 570 + &attr_local_mac, 571 + &attr_remote_mac, 606 572 NULL, 607 573 }; 608 574 ··· 612 584 kfree(to_target(item)); 613 585 } 614 586 615 - static ssize_t netconsole_target_attr_show(struct config_item *item, 616 - struct configfs_attribute *attr, 617 - char *buf) 618 - { 619 - ssize_t ret = -EINVAL; 620 - struct netconsole_target *nt = to_target(item); 621 - struct netconsole_target_attr *na = 622 - container_of(attr, struct netconsole_target_attr, attr); 623 - 624 - if (na->show) 625 - ret = na->show(nt, buf); 626 - 627 - return ret; 628 - } 629 - 630 - static ssize_t netconsole_target_attr_store(struct config_item *item, 631 - struct configfs_attribute *attr, 632 - const char *buf, 633 - size_t count) 634 - { 635 - ssize_t ret = -EINVAL; 636 - struct netconsole_target *nt = to_target(item); 637 - struct netconsole_target_attr *na = 638 - container_of(attr, struct netconsole_target_attr, attr); 639 - 640 - mutex_lock(&dynamic_netconsole_mutex); 641 - if (na->store) 642 - ret = na->store(nt, buf, count); 643 - mutex_unlock(&dynamic_netconsole_mutex); 644 - 645 - return ret; 646 - } 647 - 648 587 static struct configfs_item_operations netconsole_target_item_ops = { 649 588 .release = netconsole_target_release, 650 - .show_attribute = netconsole_target_attr_show, 651 - .store_attribute = netconsole_target_attr_store, 652 589 }; 653 590 654 591 static struct config_item_type netconsole_target_type = {
+51 -102
drivers/scsi/qla2xxx/tcm_qla2xxx.c
··· 43 43 #include <scsi/scsi_cmnd.h> 44 44 #include <target/target_core_base.h> 45 45 #include <target/target_core_fabric.h> 46 - #include <target/target_core_fabric_configfs.h> 47 - #include <target/configfs_macros.h> 48 46 49 47 #include "qla_def.h" 50 48 #include "qla_target.h" ··· 727 729 728 730 #define DEF_QLA_TPG_ATTRIB(name) \ 729 731 \ 730 - static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \ 731 - struct se_portal_group *se_tpg, \ 732 - char *page) \ 732 + static ssize_t tcm_qla2xxx_tpg_attrib_##name##_show( \ 733 + struct config_item *item, char *page) \ 733 734 { \ 735 + struct se_portal_group *se_tpg = attrib_to_tpg(item); \ 734 736 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ 735 737 struct tcm_qla2xxx_tpg, se_tpg); \ 736 738 \ 737 739 return sprintf(page, "%u\n", tpg->tpg_attrib.name); \ 738 740 } \ 739 741 \ 740 - static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \ 741 - struct se_portal_group *se_tpg, \ 742 - const char *page, \ 743 - size_t count) \ 742 + static ssize_t tcm_qla2xxx_tpg_attrib_##name##_store( \ 743 + struct config_item *item, const char *page, size_t count) \ 744 744 { \ 745 + struct se_portal_group *se_tpg = attrib_to_tpg(item); \ 745 746 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ 746 747 struct tcm_qla2xxx_tpg, se_tpg); \ 748 + struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \ 747 749 unsigned long val; \ 748 750 int ret; \ 749 751 \ ··· 753 755 " ret: %d\n", ret); \ 754 756 return -EINVAL; \ 755 757 } \ 756 - ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \ 757 - \ 758 - return (!ret) ? count : -EINVAL; \ 759 - } 760 - 761 - #define DEF_QLA_TPG_ATTR_BOOL(_name) \ 762 - \ 763 - static int tcm_qla2xxx_set_attrib_##_name( \ 764 - struct tcm_qla2xxx_tpg *tpg, \ 765 - unsigned long val) \ 766 - { \ 767 - struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \ 768 758 \ 769 759 if ((val != 0) && (val != 1)) { \ 770 760 pr_err("Illegal boolean value %lu\n", val); \ 771 761 return -EINVAL; \ 772 762 } \ 773 763 \ 774 - a->_name = val; \ 775 - return 0; \ 776 - } 764 + a->name = val; \ 765 + \ 766 + return count; \ 767 + } \ 768 + CONFIGFS_ATTR(tcm_qla2xxx_tpg_attrib_, name) 777 769 778 - #define QLA_TPG_ATTR(_name, _mode) \ 779 - TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode); 780 - 781 - /* 782 - * Define tcm_qla2xxx_tpg_attrib_s_generate_node_acls 783 - */ 784 - DEF_QLA_TPG_ATTR_BOOL(generate_node_acls); 785 770 DEF_QLA_TPG_ATTRIB(generate_node_acls); 786 - QLA_TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR); 787 - 788 - /* 789 - Define tcm_qla2xxx_attrib_s_cache_dynamic_acls 790 - */ 791 - DEF_QLA_TPG_ATTR_BOOL(cache_dynamic_acls); 792 771 DEF_QLA_TPG_ATTRIB(cache_dynamic_acls); 793 - QLA_TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR); 794 - 795 - /* 796 - * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_write_protect 797 - */ 798 - DEF_QLA_TPG_ATTR_BOOL(demo_mode_write_protect); 799 772 DEF_QLA_TPG_ATTRIB(demo_mode_write_protect); 800 - QLA_TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); 801 - 802 - /* 803 - * Define tcm_qla2xxx_tpg_attrib_s_prod_mode_write_protect 804 - */ 805 - DEF_QLA_TPG_ATTR_BOOL(prod_mode_write_protect); 806 773 DEF_QLA_TPG_ATTRIB(prod_mode_write_protect); 807 - QLA_TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); 808 - 809 - /* 810 - * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_login_only 811 - */ 812 - DEF_QLA_TPG_ATTR_BOOL(demo_mode_login_only); 813 774 DEF_QLA_TPG_ATTRIB(demo_mode_login_only); 814 - QLA_TPG_ATTR(demo_mode_login_only, S_IRUGO | S_IWUSR); 815 775 816 776 static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = { 817 - &tcm_qla2xxx_tpg_attrib_generate_node_acls.attr, 818 - &tcm_qla2xxx_tpg_attrib_cache_dynamic_acls.attr, 819 - &tcm_qla2xxx_tpg_attrib_demo_mode_write_protect.attr, 820 - &tcm_qla2xxx_tpg_attrib_prod_mode_write_protect.attr, 821 - &tcm_qla2xxx_tpg_attrib_demo_mode_login_only.attr, 777 + &tcm_qla2xxx_tpg_attrib_attr_generate_node_acls, 778 + &tcm_qla2xxx_tpg_attrib_attr_cache_dynamic_acls, 779 + &tcm_qla2xxx_tpg_attrib_attr_demo_mode_write_protect, 780 + &tcm_qla2xxx_tpg_attrib_attr_prod_mode_write_protect, 781 + &tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only, 822 782 NULL, 823 783 }; 824 784 825 785 /* End items for tcm_qla2xxx_tpg_attrib_cit */ 826 786 827 - static ssize_t tcm_qla2xxx_tpg_show_enable( 828 - struct se_portal_group *se_tpg, 829 - char *page) 787 + static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item, 788 + char *page) 830 789 { 790 + struct se_portal_group *se_tpg = to_tpg(item); 831 791 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 832 792 struct tcm_qla2xxx_tpg, se_tpg); 833 793 ··· 821 865 complete(&base_tpg->tpg_base_comp); 822 866 } 823 867 824 - static ssize_t tcm_qla2xxx_tpg_store_enable( 825 - struct se_portal_group *se_tpg, 826 - const char *page, 827 - size_t count) 868 + static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item, 869 + const char *page, size_t count) 828 870 { 871 + struct se_portal_group *se_tpg = to_tpg(item); 829 872 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 830 873 struct tcm_qla2xxx_tpg, se_tpg); 831 874 unsigned long op; ··· 864 909 return count; 865 910 } 866 911 867 - TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR); 868 - 869 - static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions( 870 - struct se_portal_group *se_tpg, 871 - char *page) 912 + static ssize_t tcm_qla2xxx_tpg_dynamic_sessions_show(struct config_item *item, 913 + char *page) 872 914 { 873 - return target_show_dynamic_sessions(se_tpg, page); 915 + return target_show_dynamic_sessions(to_tpg(item), page); 874 916 } 875 917 876 - TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions); 877 - 878 - static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type( 879 - struct se_portal_group *se_tpg, 880 - const char *page, 881 - size_t count) 918 + static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_store(struct config_item *item, 919 + const char *page, size_t count) 882 920 { 921 + struct se_portal_group *se_tpg = to_tpg(item); 883 922 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 884 923 struct tcm_qla2xxx_tpg, se_tpg); 885 924 unsigned long val; ··· 892 943 return count; 893 944 } 894 945 895 - static ssize_t tcm_qla2xxx_tpg_show_fabric_prot_type( 896 - struct se_portal_group *se_tpg, 897 - char *page) 946 + static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_show(struct config_item *item, 947 + char *page) 898 948 { 949 + struct se_portal_group *se_tpg = to_tpg(item); 899 950 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 900 951 struct tcm_qla2xxx_tpg, se_tpg); 901 952 902 953 return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type); 903 954 } 904 - TF_TPG_BASE_ATTR(tcm_qla2xxx, fabric_prot_type, S_IRUGO | S_IWUSR); 955 + 956 + CONFIGFS_ATTR_WO(tcm_qla2xxx_tpg_, enable); 957 + CONFIGFS_ATTR_RO(tcm_qla2xxx_tpg_, dynamic_sessions); 958 + CONFIGFS_ATTR(tcm_qla2xxx_tpg_, fabric_prot_type); 905 959 906 960 static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = { 907 - &tcm_qla2xxx_tpg_enable.attr, 908 - &tcm_qla2xxx_tpg_dynamic_sessions.attr, 909 - &tcm_qla2xxx_tpg_fabric_prot_type.attr, 961 + &tcm_qla2xxx_tpg_attr_enable, 962 + &tcm_qla2xxx_tpg_attr_dynamic_sessions, 963 + &tcm_qla2xxx_tpg_attr_fabric_prot_type, 910 964 NULL, 911 965 }; 912 966 ··· 982 1030 kfree(tpg); 983 1031 } 984 1032 985 - static ssize_t tcm_qla2xxx_npiv_tpg_show_enable( 986 - struct se_portal_group *se_tpg, 987 - char *page) 1033 + static ssize_t tcm_qla2xxx_npiv_tpg_enable_show(struct config_item *item, 1034 + char *page) 988 1035 { 989 - return tcm_qla2xxx_tpg_show_enable(se_tpg, page); 1036 + return tcm_qla2xxx_tpg_enable_show(item, page); 990 1037 } 991 1038 992 - static ssize_t tcm_qla2xxx_npiv_tpg_store_enable( 993 - struct se_portal_group *se_tpg, 994 - const char *page, 995 - size_t count) 1039 + static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item, 1040 + const char *page, size_t count) 996 1041 { 1042 + struct se_portal_group *se_tpg = to_tpg(item); 997 1043 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; 998 1044 struct tcm_qla2xxx_lport *lport = container_of(se_wwn, 999 1045 struct tcm_qla2xxx_lport, lport_wwn); ··· 1027 1077 return count; 1028 1078 } 1029 1079 1030 - TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR); 1080 + CONFIGFS_ATTR(tcm_qla2xxx_npiv_tpg_, enable); 1031 1081 1032 1082 static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { 1033 - &tcm_qla2xxx_npiv_tpg_enable.attr, 1083 + &tcm_qla2xxx_npiv_tpg_attr_enable, 1034 1084 NULL, 1035 1085 }; 1036 1086 ··· 1733 1783 } 1734 1784 1735 1785 1736 - static ssize_t tcm_qla2xxx_wwn_show_attr_version( 1737 - struct target_fabric_configfs *tf, 1738 - char *page) 1786 + static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item, 1787 + char *page) 1739 1788 { 1740 1789 return sprintf(page, 1741 1790 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " ··· 1742 1793 utsname()->machine); 1743 1794 } 1744 1795 1745 - TF_WWN_ATTR_RO(tcm_qla2xxx, version); 1796 + CONFIGFS_ATTR_RO(tcm_qla2xxx_wwn_, version); 1746 1797 1747 1798 static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = { 1748 - &tcm_qla2xxx_wwn_version.attr, 1799 + &tcm_qla2xxx_wwn_attr_version, 1749 1800 NULL, 1750 1801 }; 1751 1802
+270 -519
drivers/target/iscsi/iscsi_target_configfs.c
··· 23 23 #include <linux/inet.h> 24 24 #include <target/target_core_base.h> 25 25 #include <target/target_core_fabric.h> 26 - #include <target/target_core_fabric_configfs.h> 27 - #include <target/configfs_macros.h> 28 26 #include <target/iscsi/iscsi_transport.h> 29 27 30 28 #include <target/iscsi/iscsi_target_core.h> ··· 35 37 #include "iscsi_target.h" 36 38 #include <target/iscsi/iscsi_target_stat.h> 37 39 38 - struct lio_target_configfs_attribute { 39 - struct configfs_attribute attr; 40 - ssize_t (*show)(void *, char *); 41 - ssize_t (*store)(void *, const char *, size_t); 42 - }; 43 40 44 41 /* Start items for lio_target_portal_cit */ 45 42 46 - static ssize_t lio_target_np_show_sctp( 47 - struct se_tpg_np *se_tpg_np, 48 - char *page) 43 + static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item) 49 44 { 50 - struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 51 - struct iscsi_tpg_np, se_tpg_np); 45 + return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np); 46 + } 47 + 48 + static ssize_t lio_target_np_sctp_show(struct config_item *item, char *page) 49 + { 50 + struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); 52 51 struct iscsi_tpg_np *tpg_np_sctp; 53 52 ssize_t rb; 54 53 ··· 58 63 return rb; 59 64 } 60 65 61 - static ssize_t lio_target_np_store_sctp( 62 - struct se_tpg_np *se_tpg_np, 63 - const char *page, 64 - size_t count) 66 + static ssize_t lio_target_np_sctp_store(struct config_item *item, 67 + const char *page, size_t count) 65 68 { 69 + struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); 66 70 struct iscsi_np *np; 67 71 struct iscsi_portal_group *tpg; 68 - struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 69 - struct iscsi_tpg_np, se_tpg_np); 70 72 struct iscsi_tpg_np *tpg_np_sctp = NULL; 71 73 u32 op; 72 74 int ret; ··· 111 119 return -EINVAL; 112 120 } 113 121 114 - TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR); 115 - 116 - static ssize_t lio_target_np_show_iser( 117 - struct se_tpg_np *se_tpg_np, 118 - char *page) 122 + static ssize_t lio_target_np_iser_show(struct config_item *item, char *page) 119 123 { 120 - struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 121 - struct iscsi_tpg_np, se_tpg_np); 124 + struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); 122 125 struct iscsi_tpg_np *tpg_np_iser; 123 126 ssize_t rb; 124 127 ··· 126 139 return rb; 127 140 } 128 141 129 - static ssize_t lio_target_np_store_iser( 130 - struct se_tpg_np *se_tpg_np, 131 - const char *page, 132 - size_t count) 142 + static ssize_t lio_target_np_iser_store(struct config_item *item, 143 + const char *page, size_t count) 133 144 { 145 + struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item); 134 146 struct iscsi_np *np; 135 147 struct iscsi_portal_group *tpg; 136 - struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np, 137 - struct iscsi_tpg_np, se_tpg_np); 138 148 struct iscsi_tpg_np *tpg_np_iser = NULL; 139 149 char *endptr; 140 150 u32 op; ··· 182 198 return rc; 183 199 } 184 200 185 - TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR); 201 + CONFIGFS_ATTR(lio_target_np_, sctp); 202 + CONFIGFS_ATTR(lio_target_np_, iser); 186 203 187 204 static struct configfs_attribute *lio_target_portal_attrs[] = { 188 - &lio_target_np_sctp.attr, 189 - &lio_target_np_iser.attr, 205 + &lio_target_np_attr_sctp, 206 + &lio_target_np_attr_iser, 190 207 NULL, 191 208 }; 192 209 ··· 345 360 346 361 /* Start items for lio_target_nacl_attrib_cit */ 347 362 348 - #define DEF_NACL_ATTRIB(name) \ 349 - static ssize_t iscsi_nacl_attrib_show_##name( \ 350 - struct se_node_acl *se_nacl, \ 351 - char *page) \ 363 + #define ISCSI_NACL_ATTR(name) \ 364 + static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\ 365 + char *page) \ 352 366 { \ 367 + struct se_node_acl *se_nacl = attrib_to_nacl(item); \ 353 368 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ 354 369 se_node_acl); \ 355 370 \ 356 371 return sprintf(page, "%u\n", nacl->node_attrib.name); \ 357 372 } \ 358 373 \ 359 - static ssize_t iscsi_nacl_attrib_store_##name( \ 360 - struct se_node_acl *se_nacl, \ 361 - const char *page, \ 362 - size_t count) \ 374 + static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\ 375 + const char *page, size_t count) \ 363 376 { \ 377 + struct se_node_acl *se_nacl = attrib_to_nacl(item); \ 364 378 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \ 365 379 se_node_acl); \ 366 380 u32 val; \ ··· 373 389 return ret; \ 374 390 \ 375 391 return count; \ 376 - } 392 + } \ 393 + \ 394 + CONFIGFS_ATTR(iscsi_nacl_attrib_, name) 377 395 378 - #define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode); 379 - /* 380 - * Define iscsi_node_attrib_s_dataout_timeout 381 - */ 382 - DEF_NACL_ATTRIB(dataout_timeout); 383 - NACL_ATTR(dataout_timeout, S_IRUGO | S_IWUSR); 384 - /* 385 - * Define iscsi_node_attrib_s_dataout_timeout_retries 386 - */ 387 - DEF_NACL_ATTRIB(dataout_timeout_retries); 388 - NACL_ATTR(dataout_timeout_retries, S_IRUGO | S_IWUSR); 389 - /* 390 - * Define iscsi_node_attrib_s_default_erl 391 - */ 392 - DEF_NACL_ATTRIB(default_erl); 393 - NACL_ATTR(default_erl, S_IRUGO | S_IWUSR); 394 - /* 395 - * Define iscsi_node_attrib_s_nopin_timeout 396 - */ 397 - DEF_NACL_ATTRIB(nopin_timeout); 398 - NACL_ATTR(nopin_timeout, S_IRUGO | S_IWUSR); 399 - /* 400 - * Define iscsi_node_attrib_s_nopin_response_timeout 401 - */ 402 - DEF_NACL_ATTRIB(nopin_response_timeout); 403 - NACL_ATTR(nopin_response_timeout, S_IRUGO | S_IWUSR); 404 - /* 405 - * Define iscsi_node_attrib_s_random_datain_pdu_offsets 406 - */ 407 - DEF_NACL_ATTRIB(random_datain_pdu_offsets); 408 - NACL_ATTR(random_datain_pdu_offsets, S_IRUGO | S_IWUSR); 409 - /* 410 - * Define iscsi_node_attrib_s_random_datain_seq_offsets 411 - */ 412 - DEF_NACL_ATTRIB(random_datain_seq_offsets); 413 - NACL_ATTR(random_datain_seq_offsets, S_IRUGO | S_IWUSR); 414 - /* 415 - * Define iscsi_node_attrib_s_random_r2t_offsets 416 - */ 417 - DEF_NACL_ATTRIB(random_r2t_offsets); 418 - NACL_ATTR(random_r2t_offsets, S_IRUGO | S_IWUSR); 396 + ISCSI_NACL_ATTR(dataout_timeout); 397 + ISCSI_NACL_ATTR(dataout_timeout_retries); 398 + ISCSI_NACL_ATTR(default_erl); 399 + ISCSI_NACL_ATTR(nopin_timeout); 400 + ISCSI_NACL_ATTR(nopin_response_timeout); 401 + ISCSI_NACL_ATTR(random_datain_pdu_offsets); 402 + ISCSI_NACL_ATTR(random_datain_seq_offsets); 403 + ISCSI_NACL_ATTR(random_r2t_offsets); 419 404 420 405 static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = { 421 - &iscsi_nacl_attrib_dataout_timeout.attr, 422 - &iscsi_nacl_attrib_dataout_timeout_retries.attr, 423 - &iscsi_nacl_attrib_default_erl.attr, 424 - &iscsi_nacl_attrib_nopin_timeout.attr, 425 - &iscsi_nacl_attrib_nopin_response_timeout.attr, 426 - &iscsi_nacl_attrib_random_datain_pdu_offsets.attr, 427 - &iscsi_nacl_attrib_random_datain_seq_offsets.attr, 428 - &iscsi_nacl_attrib_random_r2t_offsets.attr, 406 + &iscsi_nacl_attrib_attr_dataout_timeout, 407 + &iscsi_nacl_attrib_attr_dataout_timeout_retries, 408 + &iscsi_nacl_attrib_attr_default_erl, 409 + &iscsi_nacl_attrib_attr_nopin_timeout, 410 + &iscsi_nacl_attrib_attr_nopin_response_timeout, 411 + &iscsi_nacl_attrib_attr_random_datain_pdu_offsets, 412 + &iscsi_nacl_attrib_attr_random_datain_seq_offsets, 413 + &iscsi_nacl_attrib_attr_random_r2t_offsets, 429 414 NULL, 430 415 }; 431 416 ··· 403 450 /* Start items for lio_target_nacl_auth_cit */ 404 451 405 452 #define __DEF_NACL_AUTH_STR(prefix, name, flags) \ 406 - static ssize_t __iscsi_##prefix##_show_##name( \ 453 + static ssize_t __iscsi_##prefix##_##name##_show( \ 407 454 struct iscsi_node_acl *nacl, \ 408 455 char *page) \ 409 456 { \ ··· 414 461 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ 415 462 } \ 416 463 \ 417 - static ssize_t __iscsi_##prefix##_store_##name( \ 464 + static ssize_t __iscsi_##prefix##_##name##_store( \ 418 465 struct iscsi_node_acl *nacl, \ 419 466 const char *page, \ 420 467 size_t count) \ ··· 440 487 return count; \ 441 488 } 442 489 490 + #define DEF_NACL_AUTH_STR(name, flags) \ 491 + __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \ 492 + static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \ 493 + char *page) \ 494 + { \ 495 + struct se_node_acl *nacl = auth_to_nacl(item); \ 496 + return __iscsi_nacl_auth_##name##_show(container_of(nacl, \ 497 + struct iscsi_node_acl, se_node_acl), page); \ 498 + } \ 499 + static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \ 500 + const char *page, size_t count) \ 501 + { \ 502 + struct se_node_acl *nacl = auth_to_nacl(item); \ 503 + return __iscsi_nacl_auth_##name##_store(container_of(nacl, \ 504 + struct iscsi_node_acl, se_node_acl), page, count); \ 505 + } \ 506 + \ 507 + CONFIGFS_ATTR(iscsi_nacl_auth_, name) 508 + 509 + /* 510 + * One-way authentication userid 511 + */ 512 + DEF_NACL_AUTH_STR(userid, NAF_USERID_SET); 513 + DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET); 514 + DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 515 + DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 516 + 443 517 #define __DEF_NACL_AUTH_INT(prefix, name) \ 444 - static ssize_t __iscsi_##prefix##_show_##name( \ 518 + static ssize_t __iscsi_##prefix##_##name##_show( \ 445 519 struct iscsi_node_acl *nacl, \ 446 520 char *page) \ 447 521 { \ ··· 480 500 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ 481 501 } 482 502 483 - #define DEF_NACL_AUTH_STR(name, flags) \ 484 - __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \ 485 - static ssize_t iscsi_nacl_auth_show_##name( \ 486 - struct se_node_acl *nacl, \ 487 - char *page) \ 488 - { \ 489 - return __iscsi_nacl_auth_show_##name(container_of(nacl, \ 490 - struct iscsi_node_acl, se_node_acl), page); \ 491 - } \ 492 - static ssize_t iscsi_nacl_auth_store_##name( \ 493 - struct se_node_acl *nacl, \ 494 - const char *page, \ 495 - size_t count) \ 496 - { \ 497 - return __iscsi_nacl_auth_store_##name(container_of(nacl, \ 498 - struct iscsi_node_acl, se_node_acl), page, count); \ 499 - } 500 - 501 503 #define DEF_NACL_AUTH_INT(name) \ 502 504 __DEF_NACL_AUTH_INT(nacl_auth, name) \ 503 - static ssize_t iscsi_nacl_auth_show_##name( \ 504 - struct se_node_acl *nacl, \ 505 - char *page) \ 505 + static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \ 506 + char *page) \ 506 507 { \ 507 - return __iscsi_nacl_auth_show_##name(container_of(nacl, \ 508 - struct iscsi_node_acl, se_node_acl), page); \ 509 - } 508 + struct se_node_acl *nacl = auth_to_nacl(item); \ 509 + return __iscsi_nacl_auth_##name##_show(container_of(nacl, \ 510 + struct iscsi_node_acl, se_node_acl), page); \ 511 + } \ 512 + \ 513 + CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name) 510 514 511 - #define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode); 512 - #define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name); 513 - 514 - /* 515 - * One-way authentication userid 516 - */ 517 - DEF_NACL_AUTH_STR(userid, NAF_USERID_SET); 518 - AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 519 - /* 520 - * One-way authentication password 521 - */ 522 - DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET); 523 - AUTH_ATTR(password, S_IRUGO | S_IWUSR); 524 - /* 525 - * Enforce mutual authentication 526 - */ 527 515 DEF_NACL_AUTH_INT(authenticate_target); 528 - AUTH_ATTR_RO(authenticate_target); 529 - /* 530 - * Mutual authentication userid 531 - */ 532 - DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 533 - AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 534 - /* 535 - * Mutual authentication password 536 - */ 537 - DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 538 - AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 539 516 540 517 static struct configfs_attribute *lio_target_nacl_auth_attrs[] = { 541 - &iscsi_nacl_auth_userid.attr, 542 - &iscsi_nacl_auth_password.attr, 543 - &iscsi_nacl_auth_authenticate_target.attr, 544 - &iscsi_nacl_auth_userid_mutual.attr, 545 - &iscsi_nacl_auth_password_mutual.attr, 518 + &iscsi_nacl_auth_attr_userid, 519 + &iscsi_nacl_auth_attr_password, 520 + &iscsi_nacl_auth_attr_authenticate_target, 521 + &iscsi_nacl_auth_attr_userid_mutual, 522 + &iscsi_nacl_auth_attr_password_mutual, 546 523 NULL, 547 524 }; 548 525 ··· 507 570 508 571 /* Start items for lio_target_nacl_param_cit */ 509 572 510 - #define DEF_NACL_PARAM(name) \ 511 - static ssize_t iscsi_nacl_param_show_##name( \ 512 - struct se_node_acl *se_nacl, \ 513 - char *page) \ 573 + #define ISCSI_NACL_PARAM(name) \ 574 + static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \ 575 + char *page) \ 514 576 { \ 577 + struct se_node_acl *se_nacl = param_to_nacl(item); \ 515 578 struct iscsi_session *sess; \ 516 579 struct se_session *se_sess; \ 517 580 ssize_t rb; \ ··· 529 592 spin_unlock_bh(&se_nacl->nacl_sess_lock); \ 530 593 \ 531 594 return rb; \ 532 - } 595 + } \ 596 + \ 597 + CONFIGFS_ATTR_RO(iscsi_nacl_param_, name) 533 598 534 - #define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name); 535 - 536 - DEF_NACL_PARAM(MaxConnections); 537 - NACL_PARAM_ATTR(MaxConnections); 538 - 539 - DEF_NACL_PARAM(InitialR2T); 540 - NACL_PARAM_ATTR(InitialR2T); 541 - 542 - DEF_NACL_PARAM(ImmediateData); 543 - NACL_PARAM_ATTR(ImmediateData); 544 - 545 - DEF_NACL_PARAM(MaxBurstLength); 546 - NACL_PARAM_ATTR(MaxBurstLength); 547 - 548 - DEF_NACL_PARAM(FirstBurstLength); 549 - NACL_PARAM_ATTR(FirstBurstLength); 550 - 551 - DEF_NACL_PARAM(DefaultTime2Wait); 552 - NACL_PARAM_ATTR(DefaultTime2Wait); 553 - 554 - DEF_NACL_PARAM(DefaultTime2Retain); 555 - NACL_PARAM_ATTR(DefaultTime2Retain); 556 - 557 - DEF_NACL_PARAM(MaxOutstandingR2T); 558 - NACL_PARAM_ATTR(MaxOutstandingR2T); 559 - 560 - DEF_NACL_PARAM(DataPDUInOrder); 561 - NACL_PARAM_ATTR(DataPDUInOrder); 562 - 563 - DEF_NACL_PARAM(DataSequenceInOrder); 564 - NACL_PARAM_ATTR(DataSequenceInOrder); 565 - 566 - DEF_NACL_PARAM(ErrorRecoveryLevel); 567 - NACL_PARAM_ATTR(ErrorRecoveryLevel); 599 + ISCSI_NACL_PARAM(MaxConnections); 600 + ISCSI_NACL_PARAM(InitialR2T); 601 + ISCSI_NACL_PARAM(ImmediateData); 602 + ISCSI_NACL_PARAM(MaxBurstLength); 603 + ISCSI_NACL_PARAM(FirstBurstLength); 604 + ISCSI_NACL_PARAM(DefaultTime2Wait); 605 + ISCSI_NACL_PARAM(DefaultTime2Retain); 606 + ISCSI_NACL_PARAM(MaxOutstandingR2T); 607 + ISCSI_NACL_PARAM(DataPDUInOrder); 608 + ISCSI_NACL_PARAM(DataSequenceInOrder); 609 + ISCSI_NACL_PARAM(ErrorRecoveryLevel); 568 610 569 611 static struct configfs_attribute *lio_target_nacl_param_attrs[] = { 570 - &iscsi_nacl_param_MaxConnections.attr, 571 - &iscsi_nacl_param_InitialR2T.attr, 572 - &iscsi_nacl_param_ImmediateData.attr, 573 - &iscsi_nacl_param_MaxBurstLength.attr, 574 - &iscsi_nacl_param_FirstBurstLength.attr, 575 - &iscsi_nacl_param_DefaultTime2Wait.attr, 576 - &iscsi_nacl_param_DefaultTime2Retain.attr, 577 - &iscsi_nacl_param_MaxOutstandingR2T.attr, 578 - &iscsi_nacl_param_DataPDUInOrder.attr, 579 - &iscsi_nacl_param_DataSequenceInOrder.attr, 580 - &iscsi_nacl_param_ErrorRecoveryLevel.attr, 612 + &iscsi_nacl_param_attr_MaxConnections, 613 + &iscsi_nacl_param_attr_InitialR2T, 614 + &iscsi_nacl_param_attr_ImmediateData, 615 + &iscsi_nacl_param_attr_MaxBurstLength, 616 + &iscsi_nacl_param_attr_FirstBurstLength, 617 + &iscsi_nacl_param_attr_DefaultTime2Wait, 618 + &iscsi_nacl_param_attr_DefaultTime2Retain, 619 + &iscsi_nacl_param_attr_MaxOutstandingR2T, 620 + &iscsi_nacl_param_attr_DataPDUInOrder, 621 + &iscsi_nacl_param_attr_DataSequenceInOrder, 622 + &iscsi_nacl_param_attr_ErrorRecoveryLevel, 581 623 NULL, 582 624 }; 583 625 ··· 564 648 565 649 /* Start items for lio_target_acl_cit */ 566 650 567 - static ssize_t lio_target_nacl_show_info( 568 - struct se_node_acl *se_nacl, 569 - char *page) 651 + static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page) 570 652 { 653 + struct se_node_acl *se_nacl = acl_to_nacl(item); 571 654 struct iscsi_session *sess; 572 655 struct iscsi_conn *conn; 573 656 struct se_session *se_sess; ··· 681 766 return rb; 682 767 } 683 768 684 - TF_NACL_BASE_ATTR_RO(lio_target, info); 685 - 686 - static ssize_t lio_target_nacl_show_cmdsn_depth( 687 - struct se_node_acl *se_nacl, 688 - char *page) 769 + static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item, 770 + char *page) 689 771 { 690 - return sprintf(page, "%u\n", se_nacl->queue_depth); 772 + return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth); 691 773 } 692 774 693 - static ssize_t lio_target_nacl_store_cmdsn_depth( 694 - struct se_node_acl *se_nacl, 695 - const char *page, 696 - size_t count) 775 + static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item, 776 + const char *page, size_t count) 697 777 { 778 + struct se_node_acl *se_nacl = acl_to_nacl(item); 698 779 struct se_portal_group *se_tpg = se_nacl->se_tpg; 699 780 struct iscsi_portal_group *tpg = container_of(se_tpg, 700 781 struct iscsi_portal_group, tpg_se_tpg); ··· 740 829 return (!ret) ? count : (ssize_t)ret; 741 830 } 742 831 743 - TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR); 744 - 745 - static ssize_t lio_target_nacl_show_tag( 746 - struct se_node_acl *se_nacl, 747 - char *page) 832 + static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page) 748 833 { 749 - return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag); 834 + return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag); 750 835 } 751 836 752 - static ssize_t lio_target_nacl_store_tag( 753 - struct se_node_acl *se_nacl, 754 - const char *page, 755 - size_t count) 837 + static ssize_t lio_target_nacl_tag_store(struct config_item *item, 838 + const char *page, size_t count) 756 839 { 840 + struct se_node_acl *se_nacl = acl_to_nacl(item); 757 841 int ret; 758 842 759 843 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page); ··· 758 852 return count; 759 853 } 760 854 761 - TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR); 855 + CONFIGFS_ATTR_RO(lio_target_nacl_, info); 856 + CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth); 857 + CONFIGFS_ATTR(lio_target_nacl_, tag); 762 858 763 859 static struct configfs_attribute *lio_target_initiator_attrs[] = { 764 - &lio_target_nacl_info.attr, 765 - &lio_target_nacl_cmdsn_depth.attr, 766 - &lio_target_nacl_tag.attr, 860 + &lio_target_nacl_attr_info, 861 + &lio_target_nacl_attr_cmdsn_depth, 862 + &lio_target_nacl_attr_tag, 767 863 NULL, 768 864 }; 769 865 ··· 815 907 816 908 #define DEF_TPG_ATTRIB(name) \ 817 909 \ 818 - static ssize_t iscsi_tpg_attrib_show_##name( \ 819 - struct se_portal_group *se_tpg, \ 820 - char *page) \ 910 + static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \ 911 + char *page) \ 821 912 { \ 913 + struct se_portal_group *se_tpg = attrib_to_tpg(item); \ 822 914 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 823 915 struct iscsi_portal_group, tpg_se_tpg); \ 824 916 ssize_t rb; \ ··· 831 923 return rb; \ 832 924 } \ 833 925 \ 834 - static ssize_t iscsi_tpg_attrib_store_##name( \ 835 - struct se_portal_group *se_tpg, \ 836 - const char *page, \ 837 - size_t count) \ 926 + static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\ 927 + const char *page, size_t count) \ 838 928 { \ 929 + struct se_portal_group *se_tpg = attrib_to_tpg(item); \ 839 930 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 840 931 struct iscsi_portal_group, tpg_se_tpg); \ 841 932 u32 val; \ ··· 855 948 out: \ 856 949 iscsit_put_tpg(tpg); \ 857 950 return ret; \ 858 - } 951 + } \ 952 + CONFIGFS_ATTR(iscsi_tpg_attrib_, name) 859 953 860 - #define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode); 861 - 862 - /* 863 - * Define iscsi_tpg_attrib_s_authentication 864 - */ 865 954 DEF_TPG_ATTRIB(authentication); 866 - TPG_ATTR(authentication, S_IRUGO | S_IWUSR); 867 - /* 868 - * Define iscsi_tpg_attrib_s_login_timeout 869 - */ 870 955 DEF_TPG_ATTRIB(login_timeout); 871 - TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR); 872 - /* 873 - * Define iscsi_tpg_attrib_s_netif_timeout 874 - */ 875 956 DEF_TPG_ATTRIB(netif_timeout); 876 - TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR); 877 - /* 878 - * Define iscsi_tpg_attrib_s_generate_node_acls 879 - */ 880 957 DEF_TPG_ATTRIB(generate_node_acls); 881 - TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR); 882 - /* 883 - * Define iscsi_tpg_attrib_s_default_cmdsn_depth 884 - */ 885 958 DEF_TPG_ATTRIB(default_cmdsn_depth); 886 - TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR); 887 - /* 888 - Define iscsi_tpg_attrib_s_cache_dynamic_acls 889 - */ 890 959 DEF_TPG_ATTRIB(cache_dynamic_acls); 891 - TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR); 892 - /* 893 - * Define iscsi_tpg_attrib_s_demo_mode_write_protect 894 - */ 895 960 DEF_TPG_ATTRIB(demo_mode_write_protect); 896 - TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR); 897 - /* 898 - * Define iscsi_tpg_attrib_s_prod_mode_write_protect 899 - */ 900 961 DEF_TPG_ATTRIB(prod_mode_write_protect); 901 - TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR); 902 - /* 903 - * Define iscsi_tpg_attrib_s_demo_mode_discovery, 904 - */ 905 962 DEF_TPG_ATTRIB(demo_mode_discovery); 906 - TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR); 907 - /* 908 - * Define iscsi_tpg_attrib_s_default_erl 909 - */ 910 963 DEF_TPG_ATTRIB(default_erl); 911 - TPG_ATTR(default_erl, S_IRUGO | S_IWUSR); 912 - /* 913 - * Define iscsi_tpg_attrib_s_t10_pi 914 - */ 915 964 DEF_TPG_ATTRIB(t10_pi); 916 - TPG_ATTR(t10_pi, S_IRUGO | S_IWUSR); 917 - /* 918 - * Define iscsi_tpg_attrib_s_fabric_prot_type 919 - */ 920 965 DEF_TPG_ATTRIB(fabric_prot_type); 921 - TPG_ATTR(fabric_prot_type, S_IRUGO | S_IWUSR); 922 - /* 923 - * Define iscsi_tpg_attrib_s_tpg_enabled_sendtargets 924 - */ 925 966 DEF_TPG_ATTRIB(tpg_enabled_sendtargets); 926 - TPG_ATTR(tpg_enabled_sendtargets, S_IRUGO | S_IWUSR); 927 967 928 968 static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = { 929 - &iscsi_tpg_attrib_authentication.attr, 930 - &iscsi_tpg_attrib_login_timeout.attr, 931 - &iscsi_tpg_attrib_netif_timeout.attr, 932 - &iscsi_tpg_attrib_generate_node_acls.attr, 933 - &iscsi_tpg_attrib_default_cmdsn_depth.attr, 934 - &iscsi_tpg_attrib_cache_dynamic_acls.attr, 935 - &iscsi_tpg_attrib_demo_mode_write_protect.attr, 936 - &iscsi_tpg_attrib_prod_mode_write_protect.attr, 937 - &iscsi_tpg_attrib_demo_mode_discovery.attr, 938 - &iscsi_tpg_attrib_default_erl.attr, 939 - &iscsi_tpg_attrib_t10_pi.attr, 940 - &iscsi_tpg_attrib_fabric_prot_type.attr, 941 - &iscsi_tpg_attrib_tpg_enabled_sendtargets.attr, 969 + &iscsi_tpg_attrib_attr_authentication, 970 + &iscsi_tpg_attrib_attr_login_timeout, 971 + &iscsi_tpg_attrib_attr_netif_timeout, 972 + &iscsi_tpg_attrib_attr_generate_node_acls, 973 + &iscsi_tpg_attrib_attr_default_cmdsn_depth, 974 + &iscsi_tpg_attrib_attr_cache_dynamic_acls, 975 + &iscsi_tpg_attrib_attr_demo_mode_write_protect, 976 + &iscsi_tpg_attrib_attr_prod_mode_write_protect, 977 + &iscsi_tpg_attrib_attr_demo_mode_discovery, 978 + &iscsi_tpg_attrib_attr_default_erl, 979 + &iscsi_tpg_attrib_attr_t10_pi, 980 + &iscsi_tpg_attrib_attr_fabric_prot_type, 981 + &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets, 942 982 NULL, 943 983 }; 944 984 ··· 894 1040 /* Start items for lio_target_tpg_auth_cit */ 895 1041 896 1042 #define __DEF_TPG_AUTH_STR(prefix, name, flags) \ 897 - static ssize_t __iscsi_##prefix##_show_##name( \ 898 - struct se_portal_group *se_tpg, \ 899 - char *page) \ 1043 + static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \ 1044 + char *page) \ 900 1045 { \ 901 1046 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 902 1047 struct iscsi_portal_group, tpg_se_tpg); \ ··· 907 1054 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \ 908 1055 } \ 909 1056 \ 910 - static ssize_t __iscsi_##prefix##_store_##name( \ 911 - struct se_portal_group *se_tpg, \ 912 - const char *page, \ 913 - size_t count) \ 1057 + static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\ 1058 + const char *page, size_t count) \ 914 1059 { \ 915 1060 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 916 1061 struct iscsi_portal_group, tpg_se_tpg); \ ··· 932 1081 return count; \ 933 1082 } 934 1083 1084 + #define DEF_TPG_AUTH_STR(name, flags) \ 1085 + __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \ 1086 + static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \ 1087 + char *page) \ 1088 + { \ 1089 + return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \ 1090 + } \ 1091 + \ 1092 + static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \ 1093 + const char *page, size_t count) \ 1094 + { \ 1095 + return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \ 1096 + } \ 1097 + \ 1098 + CONFIGFS_ATTR(iscsi_tpg_auth_, name); 1099 + 1100 + 1101 + DEF_TPG_AUTH_STR(userid, NAF_USERID_SET); 1102 + DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET); 1103 + DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1104 + DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1105 + 935 1106 #define __DEF_TPG_AUTH_INT(prefix, name) \ 936 - static ssize_t __iscsi_##prefix##_show_##name( \ 937 - struct se_portal_group *se_tpg, \ 938 - char *page) \ 1107 + static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \ 1108 + char *page) \ 939 1109 { \ 940 1110 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 941 1111 struct iscsi_portal_group, tpg_se_tpg); \ ··· 968 1096 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \ 969 1097 } 970 1098 971 - #define DEF_TPG_AUTH_STR(name, flags) \ 972 - __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \ 973 - static ssize_t iscsi_tpg_auth_show_##name( \ 974 - struct se_portal_group *se_tpg, \ 975 - char *page) \ 976 - { \ 977 - return __iscsi_tpg_auth_show_##name(se_tpg, page); \ 978 - } \ 979 - \ 980 - static ssize_t iscsi_tpg_auth_store_##name( \ 981 - struct se_portal_group *se_tpg, \ 982 - const char *page, \ 983 - size_t count) \ 984 - { \ 985 - return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \ 986 - } 987 - 988 1099 #define DEF_TPG_AUTH_INT(name) \ 989 1100 __DEF_TPG_AUTH_INT(tpg_auth, name) \ 990 - static ssize_t iscsi_tpg_auth_show_##name( \ 991 - struct se_portal_group *se_tpg, \ 992 - char *page) \ 1101 + static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \ 1102 + char *page) \ 993 1103 { \ 994 - return __iscsi_tpg_auth_show_##name(se_tpg, page); \ 995 - } 1104 + return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \ 1105 + } \ 1106 + CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name); 996 1107 997 - #define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode); 998 - #define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name); 999 - 1000 - /* 1001 - * * One-way authentication userid 1002 - * */ 1003 - DEF_TPG_AUTH_STR(userid, NAF_USERID_SET); 1004 - TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 1005 - /* 1006 - * * One-way authentication password 1007 - * */ 1008 - DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET); 1009 - TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR); 1010 - /* 1011 - * * Enforce mutual authentication 1012 - * */ 1013 1108 DEF_TPG_AUTH_INT(authenticate_target); 1014 - TPG_AUTH_ATTR_RO(authenticate_target); 1015 - /* 1016 - * * Mutual authentication userid 1017 - * */ 1018 - DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1019 - TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 1020 - /* 1021 - * * Mutual authentication password 1022 - * */ 1023 - DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1024 - TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 1025 1109 1026 1110 static struct configfs_attribute *lio_target_tpg_auth_attrs[] = { 1027 - &iscsi_tpg_auth_userid.attr, 1028 - &iscsi_tpg_auth_password.attr, 1029 - &iscsi_tpg_auth_authenticate_target.attr, 1030 - &iscsi_tpg_auth_userid_mutual.attr, 1031 - &iscsi_tpg_auth_password_mutual.attr, 1111 + &iscsi_tpg_auth_attr_userid, 1112 + &iscsi_tpg_auth_attr_password, 1113 + &iscsi_tpg_auth_attr_authenticate_target, 1114 + &iscsi_tpg_auth_attr_userid_mutual, 1115 + &iscsi_tpg_auth_attr_password_mutual, 1032 1116 NULL, 1033 1117 }; 1034 1118 ··· 993 1165 /* Start items for lio_target_tpg_param_cit */ 994 1166 995 1167 #define DEF_TPG_PARAM(name) \ 996 - static ssize_t iscsi_tpg_param_show_##name( \ 997 - struct se_portal_group *se_tpg, \ 998 - char *page) \ 1168 + static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \ 1169 + char *page) \ 999 1170 { \ 1171 + struct se_portal_group *se_tpg = param_to_tpg(item); \ 1000 1172 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1001 1173 struct iscsi_portal_group, tpg_se_tpg); \ 1002 1174 struct iscsi_param *param; \ ··· 1016 1188 iscsit_put_tpg(tpg); \ 1017 1189 return rb; \ 1018 1190 } \ 1019 - static ssize_t iscsi_tpg_param_store_##name( \ 1020 - struct se_portal_group *se_tpg, \ 1021 - const char *page, \ 1022 - size_t count) \ 1191 + static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \ 1192 + const char *page, size_t count) \ 1023 1193 { \ 1194 + struct se_portal_group *se_tpg = param_to_tpg(item); \ 1024 1195 struct iscsi_portal_group *tpg = container_of(se_tpg, \ 1025 1196 struct iscsi_portal_group, tpg_se_tpg); \ 1026 1197 char *buf; \ ··· 1047 1220 out: \ 1048 1221 kfree(buf); \ 1049 1222 iscsit_put_tpg(tpg); \ 1050 - return -EINVAL; \ 1051 - } 1052 - 1053 - #define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode); 1223 + return -EINVAL; \ 1224 + } \ 1225 + CONFIGFS_ATTR(iscsi_tpg_param_, name) 1054 1226 1055 1227 DEF_TPG_PARAM(AuthMethod); 1056 - TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR); 1057 - 1058 1228 DEF_TPG_PARAM(HeaderDigest); 1059 - TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR); 1060 - 1061 1229 DEF_TPG_PARAM(DataDigest); 1062 - TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR); 1063 - 1064 1230 DEF_TPG_PARAM(MaxConnections); 1065 - TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR); 1066 - 1067 1231 DEF_TPG_PARAM(TargetAlias); 1068 - TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR); 1069 - 1070 1232 DEF_TPG_PARAM(InitialR2T); 1071 - TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR); 1072 - 1073 1233 DEF_TPG_PARAM(ImmediateData); 1074 - TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR); 1075 - 1076 1234 DEF_TPG_PARAM(MaxRecvDataSegmentLength); 1077 - TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR); 1078 - 1079 1235 DEF_TPG_PARAM(MaxXmitDataSegmentLength); 1080 - TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR); 1081 - 1082 1236 DEF_TPG_PARAM(MaxBurstLength); 1083 - TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR); 1084 - 1085 1237 DEF_TPG_PARAM(FirstBurstLength); 1086 - TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR); 1087 - 1088 1238 DEF_TPG_PARAM(DefaultTime2Wait); 1089 - TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR); 1090 - 1091 1239 DEF_TPG_PARAM(DefaultTime2Retain); 1092 - TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR); 1093 - 1094 1240 DEF_TPG_PARAM(MaxOutstandingR2T); 1095 - TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR); 1096 - 1097 1241 DEF_TPG_PARAM(DataPDUInOrder); 1098 - TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR); 1099 - 1100 1242 DEF_TPG_PARAM(DataSequenceInOrder); 1101 - TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR); 1102 - 1103 1243 DEF_TPG_PARAM(ErrorRecoveryLevel); 1104 - TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR); 1105 - 1106 1244 DEF_TPG_PARAM(IFMarker); 1107 - TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR); 1108 - 1109 1245 DEF_TPG_PARAM(OFMarker); 1110 - TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR); 1111 - 1112 1246 DEF_TPG_PARAM(IFMarkInt); 1113 - TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR); 1114 - 1115 1247 DEF_TPG_PARAM(OFMarkInt); 1116 - TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR); 1117 1248 1118 1249 static struct configfs_attribute *lio_target_tpg_param_attrs[] = { 1119 - &iscsi_tpg_param_AuthMethod.attr, 1120 - &iscsi_tpg_param_HeaderDigest.attr, 1121 - &iscsi_tpg_param_DataDigest.attr, 1122 - &iscsi_tpg_param_MaxConnections.attr, 1123 - &iscsi_tpg_param_TargetAlias.attr, 1124 - &iscsi_tpg_param_InitialR2T.attr, 1125 - &iscsi_tpg_param_ImmediateData.attr, 1126 - &iscsi_tpg_param_MaxRecvDataSegmentLength.attr, 1127 - &iscsi_tpg_param_MaxXmitDataSegmentLength.attr, 1128 - &iscsi_tpg_param_MaxBurstLength.attr, 1129 - &iscsi_tpg_param_FirstBurstLength.attr, 1130 - &iscsi_tpg_param_DefaultTime2Wait.attr, 1131 - &iscsi_tpg_param_DefaultTime2Retain.attr, 1132 - &iscsi_tpg_param_MaxOutstandingR2T.attr, 1133 - &iscsi_tpg_param_DataPDUInOrder.attr, 1134 - &iscsi_tpg_param_DataSequenceInOrder.attr, 1135 - &iscsi_tpg_param_ErrorRecoveryLevel.attr, 1136 - &iscsi_tpg_param_IFMarker.attr, 1137 - &iscsi_tpg_param_OFMarker.attr, 1138 - &iscsi_tpg_param_IFMarkInt.attr, 1139 - &iscsi_tpg_param_OFMarkInt.attr, 1250 + &iscsi_tpg_param_attr_AuthMethod, 1251 + &iscsi_tpg_param_attr_HeaderDigest, 1252 + &iscsi_tpg_param_attr_DataDigest, 1253 + &iscsi_tpg_param_attr_MaxConnections, 1254 + &iscsi_tpg_param_attr_TargetAlias, 1255 + &iscsi_tpg_param_attr_InitialR2T, 1256 + &iscsi_tpg_param_attr_ImmediateData, 1257 + &iscsi_tpg_param_attr_MaxRecvDataSegmentLength, 1258 + &iscsi_tpg_param_attr_MaxXmitDataSegmentLength, 1259 + &iscsi_tpg_param_attr_MaxBurstLength, 1260 + &iscsi_tpg_param_attr_FirstBurstLength, 1261 + &iscsi_tpg_param_attr_DefaultTime2Wait, 1262 + &iscsi_tpg_param_attr_DefaultTime2Retain, 1263 + &iscsi_tpg_param_attr_MaxOutstandingR2T, 1264 + &iscsi_tpg_param_attr_DataPDUInOrder, 1265 + &iscsi_tpg_param_attr_DataSequenceInOrder, 1266 + &iscsi_tpg_param_attr_ErrorRecoveryLevel, 1267 + &iscsi_tpg_param_attr_IFMarker, 1268 + &iscsi_tpg_param_attr_OFMarker, 1269 + &iscsi_tpg_param_attr_IFMarkInt, 1270 + &iscsi_tpg_param_attr_OFMarkInt, 1140 1271 NULL, 1141 1272 }; 1142 1273 ··· 1102 1317 1103 1318 /* Start items for lio_target_tpg_cit */ 1104 1319 1105 - static ssize_t lio_target_tpg_show_enable( 1106 - struct se_portal_group *se_tpg, 1107 - char *page) 1320 + static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page) 1108 1321 { 1322 + struct se_portal_group *se_tpg = to_tpg(item); 1109 1323 struct iscsi_portal_group *tpg = container_of(se_tpg, 1110 1324 struct iscsi_portal_group, tpg_se_tpg); 1111 1325 ssize_t len; ··· 1117 1333 return len; 1118 1334 } 1119 1335 1120 - static ssize_t lio_target_tpg_store_enable( 1121 - struct se_portal_group *se_tpg, 1122 - const char *page, 1123 - size_t count) 1336 + static ssize_t lio_target_tpg_enable_store(struct config_item *item, 1337 + const char *page, size_t count) 1124 1338 { 1339 + struct se_portal_group *se_tpg = to_tpg(item); 1125 1340 struct iscsi_portal_group *tpg = container_of(se_tpg, 1126 1341 struct iscsi_portal_group, tpg_se_tpg); 1127 1342 u32 op; ··· 1158 1375 return -EINVAL; 1159 1376 } 1160 1377 1161 - TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR); 1162 1378 1163 - static ssize_t lio_target_tpg_show_dynamic_sessions( 1164 - struct se_portal_group *se_tpg, 1165 - char *page) 1379 + static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item, 1380 + char *page) 1166 1381 { 1167 - return target_show_dynamic_sessions(se_tpg, page); 1382 + return target_show_dynamic_sessions(to_tpg(item), page); 1168 1383 } 1169 1384 1170 - TF_TPG_BASE_ATTR_RO(lio_target, dynamic_sessions); 1385 + CONFIGFS_ATTR(lio_target_tpg_, enable); 1386 + CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions); 1171 1387 1172 1388 static struct configfs_attribute *lio_target_tpg_attrs[] = { 1173 - &lio_target_tpg_enable.attr, 1174 - &lio_target_tpg_dynamic_sessions.attr, 1389 + &lio_target_tpg_attr_enable, 1390 + &lio_target_tpg_attr_dynamic_sessions, 1175 1391 NULL, 1176 1392 }; 1177 1393 ··· 1245 1463 1246 1464 /* Start LIO-Target TIQN struct contig_item lio_target_cit */ 1247 1465 1248 - static ssize_t lio_target_wwn_show_attr_lio_version( 1249 - struct target_fabric_configfs *tf, 1250 - char *page) 1466 + static ssize_t lio_target_wwn_lio_version_show(struct config_item *item, 1467 + char *page) 1251 1468 { 1252 1469 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n"); 1253 1470 } 1254 1471 1255 - TF_WWN_ATTR_RO(lio_target, lio_version); 1472 + CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version); 1256 1473 1257 1474 static struct configfs_attribute *lio_target_wwn_attrs[] = { 1258 - &lio_target_wwn_lio_version.attr, 1475 + &lio_target_wwn_attr_lio_version, 1259 1476 NULL, 1260 1477 }; 1261 1478 ··· 1333 1552 1334 1553 #define DEF_DISC_AUTH_STR(name, flags) \ 1335 1554 __DEF_NACL_AUTH_STR(disc, name, flags) \ 1336 - static ssize_t iscsi_disc_show_##name( \ 1337 - struct target_fabric_configfs *tf, \ 1338 - char *page) \ 1555 + static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \ 1339 1556 { \ 1340 - return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ 1557 + return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\ 1341 1558 page); \ 1342 1559 } \ 1343 - static ssize_t iscsi_disc_store_##name( \ 1344 - struct target_fabric_configfs *tf, \ 1345 - const char *page, \ 1346 - size_t count) \ 1560 + static ssize_t iscsi_disc_##name##_store(struct config_item *item, \ 1561 + const char *page, size_t count) \ 1347 1562 { \ 1348 - return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \ 1563 + return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \ 1349 1564 page, count); \ 1350 - } 1565 + \ 1566 + } \ 1567 + CONFIGFS_ATTR(iscsi_disc_, name) 1568 + 1569 + DEF_DISC_AUTH_STR(userid, NAF_USERID_SET); 1570 + DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET); 1571 + DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1572 + DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1351 1573 1352 1574 #define DEF_DISC_AUTH_INT(name) \ 1353 1575 __DEF_NACL_AUTH_INT(disc, name) \ 1354 - static ssize_t iscsi_disc_show_##name( \ 1355 - struct target_fabric_configfs *tf, \ 1356 - char *page) \ 1576 + static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \ 1357 1577 { \ 1358 - return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \ 1578 + return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \ 1359 1579 page); \ 1360 - } 1580 + } \ 1581 + CONFIGFS_ATTR_RO(iscsi_disc_, name) 1361 1582 1362 - #define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode) 1363 - #define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name) 1364 - 1365 - /* 1366 - * One-way authentication userid 1367 - */ 1368 - DEF_DISC_AUTH_STR(userid, NAF_USERID_SET); 1369 - DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR); 1370 - /* 1371 - * One-way authentication password 1372 - */ 1373 - DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET); 1374 - DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR); 1375 - /* 1376 - * Enforce mutual authentication 1377 - */ 1378 1583 DEF_DISC_AUTH_INT(authenticate_target); 1379 - DISC_AUTH_ATTR_RO(authenticate_target); 1380 - /* 1381 - * Mutual authentication userid 1382 - */ 1383 - DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET); 1384 - DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR); 1385 - /* 1386 - * Mutual authentication password 1387 - */ 1388 - DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET); 1389 - DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR); 1390 1584 1391 - /* 1392 - * enforce_discovery_auth 1393 - */ 1394 - static ssize_t iscsi_disc_show_enforce_discovery_auth( 1395 - struct target_fabric_configfs *tf, 1396 - char *page) 1585 + 1586 + static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item, 1587 + char *page) 1397 1588 { 1398 1589 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth; 1399 1590 1400 1591 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth); 1401 1592 } 1402 1593 1403 - static ssize_t iscsi_disc_store_enforce_discovery_auth( 1404 - struct target_fabric_configfs *tf, 1405 - const char *page, 1406 - size_t count) 1594 + static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item, 1595 + const char *page, size_t count) 1407 1596 { 1408 1597 struct iscsi_param *param; 1409 1598 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg; ··· 1428 1677 return count; 1429 1678 } 1430 1679 1431 - DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR); 1680 + CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth); 1432 1681 1433 1682 static struct configfs_attribute *lio_target_discovery_auth_attrs[] = { 1434 - &iscsi_disc_userid.attr, 1435 - &iscsi_disc_password.attr, 1436 - &iscsi_disc_authenticate_target.attr, 1437 - &iscsi_disc_userid_mutual.attr, 1438 - &iscsi_disc_password_mutual.attr, 1439 - &iscsi_disc_enforce_discovery_auth.attr, 1683 + &iscsi_disc_attr_userid, 1684 + &iscsi_disc_attr_password, 1685 + &iscsi_disc_attr_authenticate_target, 1686 + &iscsi_disc_attr_userid_mutual, 1687 + &iscsi_disc_attr_password_mutual, 1688 + &iscsi_disc_attr_enforce_discovery_auth, 1440 1689 NULL, 1441 1690 }; 1442 1691
+263 -405
drivers/target/iscsi/iscsi_target_stat.c
··· 21 21 #include <linux/export.h> 22 22 #include <scsi/iscsi_proto.h> 23 23 #include <target/target_core_base.h> 24 - #include <target/configfs_macros.h> 25 24 26 25 #include <target/iscsi/iscsi_target_core.h> 27 26 #include "iscsi_target_parameters.h" ··· 49 50 /* 50 51 * Instance Attributes Table 51 52 */ 52 - CONFIGFS_EATTR_STRUCT(iscsi_stat_instance, iscsi_wwn_stat_grps); 53 - #define ISCSI_STAT_INSTANCE_ATTR(_name, _mode) \ 54 - static struct iscsi_stat_instance_attribute \ 55 - iscsi_stat_instance_##_name = \ 56 - __CONFIGFS_EATTR(_name, _mode, \ 57 - iscsi_stat_instance_show_attr_##_name, \ 58 - iscsi_stat_instance_store_attr_##_name); 59 - 60 - #define ISCSI_STAT_INSTANCE_ATTR_RO(_name) \ 61 - static struct iscsi_stat_instance_attribute \ 62 - iscsi_stat_instance_##_name = \ 63 - __CONFIGFS_EATTR_RO(_name, \ 64 - iscsi_stat_instance_show_attr_##_name); 65 - 66 - static ssize_t iscsi_stat_instance_show_attr_inst( 67 - struct iscsi_wwn_stat_grps *igrps, char *page) 53 + static struct iscsi_tiqn *iscsi_instance_tiqn(struct config_item *item) 68 54 { 69 - struct iscsi_tiqn *tiqn = container_of(igrps, 70 - struct iscsi_tiqn, tiqn_stat_grps); 71 - 72 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 55 + struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), 56 + struct iscsi_wwn_stat_grps, iscsi_instance_group); 57 + return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); 73 58 } 74 - ISCSI_STAT_INSTANCE_ATTR_RO(inst); 75 59 76 - static ssize_t iscsi_stat_instance_show_attr_min_ver( 77 - struct iscsi_wwn_stat_grps *igrps, char *page) 60 + static ssize_t iscsi_stat_instance_inst_show(struct config_item *item, 61 + char *page) 62 + { 63 + return snprintf(page, PAGE_SIZE, "%u\n", 64 + iscsi_instance_tiqn(item)->tiqn_index); 65 + } 66 + 67 + static ssize_t iscsi_stat_instance_min_ver_show(struct config_item *item, 68 + char *page) 78 69 { 79 70 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); 80 71 } 81 - ISCSI_STAT_INSTANCE_ATTR_RO(min_ver); 82 72 83 - static ssize_t iscsi_stat_instance_show_attr_max_ver( 84 - struct iscsi_wwn_stat_grps *igrps, char *page) 73 + static ssize_t iscsi_stat_instance_max_ver_show(struct config_item *item, 74 + char *page) 85 75 { 86 76 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DRAFT20_VERSION); 87 77 } 88 - ISCSI_STAT_INSTANCE_ATTR_RO(max_ver); 89 78 90 - static ssize_t iscsi_stat_instance_show_attr_portals( 91 - struct iscsi_wwn_stat_grps *igrps, char *page) 79 + static ssize_t iscsi_stat_instance_portals_show(struct config_item *item, 80 + char *page) 92 81 { 93 - struct iscsi_tiqn *tiqn = container_of(igrps, 94 - struct iscsi_tiqn, tiqn_stat_grps); 95 - 96 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_num_tpg_nps); 82 + return snprintf(page, PAGE_SIZE, "%u\n", 83 + iscsi_instance_tiqn(item)->tiqn_num_tpg_nps); 97 84 } 98 - ISCSI_STAT_INSTANCE_ATTR_RO(portals); 99 85 100 - static ssize_t iscsi_stat_instance_show_attr_nodes( 101 - struct iscsi_wwn_stat_grps *igrps, char *page) 86 + static ssize_t iscsi_stat_instance_nodes_show(struct config_item *item, 87 + char *page) 102 88 { 103 89 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_INST_NUM_NODES); 104 90 } 105 - ISCSI_STAT_INSTANCE_ATTR_RO(nodes); 106 91 107 - static ssize_t iscsi_stat_instance_show_attr_sessions( 108 - struct iscsi_wwn_stat_grps *igrps, char *page) 92 + static ssize_t iscsi_stat_instance_sessions_show(struct config_item *item, 93 + char *page) 109 94 { 110 - struct iscsi_tiqn *tiqn = container_of(igrps, 111 - struct iscsi_tiqn, tiqn_stat_grps); 112 - 113 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_nsessions); 95 + return snprintf(page, PAGE_SIZE, "%u\n", 96 + iscsi_instance_tiqn(item)->tiqn_nsessions); 114 97 } 115 - ISCSI_STAT_INSTANCE_ATTR_RO(sessions); 116 98 117 - static ssize_t iscsi_stat_instance_show_attr_fail_sess( 118 - struct iscsi_wwn_stat_grps *igrps, char *page) 99 + static ssize_t iscsi_stat_instance_fail_sess_show(struct config_item *item, 100 + char *page) 119 101 { 120 - struct iscsi_tiqn *tiqn = container_of(igrps, 121 - struct iscsi_tiqn, tiqn_stat_grps); 102 + struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); 122 103 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 123 104 u32 sess_err_count; 124 105 ··· 110 131 111 132 return snprintf(page, PAGE_SIZE, "%u\n", sess_err_count); 112 133 } 113 - ISCSI_STAT_INSTANCE_ATTR_RO(fail_sess); 114 134 115 - static ssize_t iscsi_stat_instance_show_attr_fail_type( 116 - struct iscsi_wwn_stat_grps *igrps, char *page) 135 + static ssize_t iscsi_stat_instance_fail_type_show(struct config_item *item, 136 + char *page) 117 137 { 118 - struct iscsi_tiqn *tiqn = container_of(igrps, 119 - struct iscsi_tiqn, tiqn_stat_grps); 138 + struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); 120 139 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 121 140 122 141 return snprintf(page, PAGE_SIZE, "%u\n", 123 142 sess_err->last_sess_failure_type); 124 143 } 125 - ISCSI_STAT_INSTANCE_ATTR_RO(fail_type); 126 144 127 - static ssize_t iscsi_stat_instance_show_attr_fail_rem_name( 128 - struct iscsi_wwn_stat_grps *igrps, char *page) 145 + static ssize_t iscsi_stat_instance_fail_rem_name_show(struct config_item *item, 146 + char *page) 129 147 { 130 - struct iscsi_tiqn *tiqn = container_of(igrps, 131 - struct iscsi_tiqn, tiqn_stat_grps); 148 + struct iscsi_tiqn *tiqn = iscsi_instance_tiqn(item); 132 149 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 133 150 134 151 return snprintf(page, PAGE_SIZE, "%s\n", 135 152 sess_err->last_sess_fail_rem_name[0] ? 136 153 sess_err->last_sess_fail_rem_name : NONE); 137 154 } 138 - ISCSI_STAT_INSTANCE_ATTR_RO(fail_rem_name); 139 155 140 - static ssize_t iscsi_stat_instance_show_attr_disc_time( 141 - struct iscsi_wwn_stat_grps *igrps, char *page) 156 + static ssize_t iscsi_stat_instance_disc_time_show(struct config_item *item, 157 + char *page) 142 158 { 143 159 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_DISCONTINUITY_TIME); 144 160 } 145 - ISCSI_STAT_INSTANCE_ATTR_RO(disc_time); 146 161 147 - static ssize_t iscsi_stat_instance_show_attr_description( 148 - struct iscsi_wwn_stat_grps *igrps, char *page) 162 + static ssize_t iscsi_stat_instance_description_show(struct config_item *item, 163 + char *page) 149 164 { 150 165 return snprintf(page, PAGE_SIZE, "%s\n", ISCSI_INST_DESCR); 151 166 } 152 - ISCSI_STAT_INSTANCE_ATTR_RO(description); 153 167 154 - static ssize_t iscsi_stat_instance_show_attr_vendor( 155 - struct iscsi_wwn_stat_grps *igrps, char *page) 168 + static ssize_t iscsi_stat_instance_vendor_show(struct config_item *item, 169 + char *page) 156 170 { 157 171 return snprintf(page, PAGE_SIZE, "Datera, Inc. iSCSI-Target\n"); 158 172 } 159 - ISCSI_STAT_INSTANCE_ATTR_RO(vendor); 160 173 161 - static ssize_t iscsi_stat_instance_show_attr_version( 162 - struct iscsi_wwn_stat_grps *igrps, char *page) 174 + static ssize_t iscsi_stat_instance_version_show(struct config_item *item, 175 + char *page) 163 176 { 164 177 return snprintf(page, PAGE_SIZE, "%s\n", ISCSIT_VERSION); 165 178 } 166 - ISCSI_STAT_INSTANCE_ATTR_RO(version); 167 179 168 - CONFIGFS_EATTR_OPS(iscsi_stat_instance, iscsi_wwn_stat_grps, 169 - iscsi_instance_group); 180 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, inst); 181 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, min_ver); 182 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, max_ver); 183 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, portals); 184 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, nodes); 185 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, sessions); 186 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_sess); 187 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_type); 188 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, fail_rem_name); 189 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, disc_time); 190 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, description); 191 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, vendor); 192 + CONFIGFS_ATTR_RO(iscsi_stat_instance_, version); 170 193 171 194 static struct configfs_attribute *iscsi_stat_instance_attrs[] = { 172 - &iscsi_stat_instance_inst.attr, 173 - &iscsi_stat_instance_min_ver.attr, 174 - &iscsi_stat_instance_max_ver.attr, 175 - &iscsi_stat_instance_portals.attr, 176 - &iscsi_stat_instance_nodes.attr, 177 - &iscsi_stat_instance_sessions.attr, 178 - &iscsi_stat_instance_fail_sess.attr, 179 - &iscsi_stat_instance_fail_type.attr, 180 - &iscsi_stat_instance_fail_rem_name.attr, 181 - &iscsi_stat_instance_disc_time.attr, 182 - &iscsi_stat_instance_description.attr, 183 - &iscsi_stat_instance_vendor.attr, 184 - &iscsi_stat_instance_version.attr, 195 + &iscsi_stat_instance_attr_inst, 196 + &iscsi_stat_instance_attr_min_ver, 197 + &iscsi_stat_instance_attr_max_ver, 198 + &iscsi_stat_instance_attr_portals, 199 + &iscsi_stat_instance_attr_nodes, 200 + &iscsi_stat_instance_attr_sessions, 201 + &iscsi_stat_instance_attr_fail_sess, 202 + &iscsi_stat_instance_attr_fail_type, 203 + &iscsi_stat_instance_attr_fail_rem_name, 204 + &iscsi_stat_instance_attr_disc_time, 205 + &iscsi_stat_instance_attr_description, 206 + &iscsi_stat_instance_attr_vendor, 207 + &iscsi_stat_instance_attr_version, 185 208 NULL, 186 209 }; 187 210 188 - static struct configfs_item_operations iscsi_stat_instance_item_ops = { 189 - .show_attribute = iscsi_stat_instance_attr_show, 190 - .store_attribute = iscsi_stat_instance_attr_store, 191 - }; 192 - 193 211 struct config_item_type iscsi_stat_instance_cit = { 194 - .ct_item_ops = &iscsi_stat_instance_item_ops, 195 212 .ct_attrs = iscsi_stat_instance_attrs, 196 213 .ct_owner = THIS_MODULE, 197 214 }; ··· 195 220 /* 196 221 * Instance Session Failure Stats Table 197 222 */ 198 - CONFIGFS_EATTR_STRUCT(iscsi_stat_sess_err, iscsi_wwn_stat_grps); 199 - #define ISCSI_STAT_SESS_ERR_ATTR(_name, _mode) \ 200 - static struct iscsi_stat_sess_err_attribute \ 201 - iscsi_stat_sess_err_##_name = \ 202 - __CONFIGFS_EATTR(_name, _mode, \ 203 - iscsi_stat_sess_err_show_attr_##_name, \ 204 - iscsi_stat_sess_err_store_attr_##_name); 205 - 206 - #define ISCSI_STAT_SESS_ERR_ATTR_RO(_name) \ 207 - static struct iscsi_stat_sess_err_attribute \ 208 - iscsi_stat_sess_err_##_name = \ 209 - __CONFIGFS_EATTR_RO(_name, \ 210 - iscsi_stat_sess_err_show_attr_##_name); 211 - 212 - static ssize_t iscsi_stat_sess_err_show_attr_inst( 213 - struct iscsi_wwn_stat_grps *igrps, char *page) 223 + static struct iscsi_tiqn *iscsi_sess_err_tiqn(struct config_item *item) 214 224 { 215 - struct iscsi_tiqn *tiqn = container_of(igrps, 216 - struct iscsi_tiqn, tiqn_stat_grps); 217 - 218 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 225 + struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), 226 + struct iscsi_wwn_stat_grps, iscsi_sess_err_group); 227 + return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); 219 228 } 220 - ISCSI_STAT_SESS_ERR_ATTR_RO(inst); 221 229 222 - static ssize_t iscsi_stat_sess_err_show_attr_digest_errors( 223 - struct iscsi_wwn_stat_grps *igrps, char *page) 230 + static ssize_t iscsi_stat_sess_err_inst_show(struct config_item *item, 231 + char *page) 224 232 { 225 - struct iscsi_tiqn *tiqn = container_of(igrps, 226 - struct iscsi_tiqn, tiqn_stat_grps); 233 + return snprintf(page, PAGE_SIZE, "%u\n", 234 + iscsi_sess_err_tiqn(item)->tiqn_index); 235 + } 236 + 237 + static ssize_t iscsi_stat_sess_err_digest_errors_show(struct config_item *item, 238 + char *page) 239 + { 240 + struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); 227 241 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 228 242 229 243 return snprintf(page, PAGE_SIZE, "%u\n", sess_err->digest_errors); 230 244 } 231 - ISCSI_STAT_SESS_ERR_ATTR_RO(digest_errors); 232 245 233 - static ssize_t iscsi_stat_sess_err_show_attr_cxn_errors( 234 - struct iscsi_wwn_stat_grps *igrps, char *page) 246 + static ssize_t iscsi_stat_sess_err_cxn_errors_show(struct config_item *item, 247 + char *page) 235 248 { 236 - struct iscsi_tiqn *tiqn = container_of(igrps, 237 - struct iscsi_tiqn, tiqn_stat_grps); 249 + struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); 238 250 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 239 251 240 252 return snprintf(page, PAGE_SIZE, "%u\n", sess_err->cxn_timeout_errors); 241 253 } 242 - ISCSI_STAT_SESS_ERR_ATTR_RO(cxn_errors); 243 254 244 - static ssize_t iscsi_stat_sess_err_show_attr_format_errors( 245 - struct iscsi_wwn_stat_grps *igrps, char *page) 255 + static ssize_t iscsi_stat_sess_err_format_errors_show(struct config_item *item, 256 + char *page) 246 257 { 247 - struct iscsi_tiqn *tiqn = container_of(igrps, 248 - struct iscsi_tiqn, tiqn_stat_grps); 258 + struct iscsi_tiqn *tiqn = iscsi_sess_err_tiqn(item); 249 259 struct iscsi_sess_err_stats *sess_err = &tiqn->sess_err_stats; 250 260 251 261 return snprintf(page, PAGE_SIZE, "%u\n", sess_err->pdu_format_errors); 252 262 } 253 - ISCSI_STAT_SESS_ERR_ATTR_RO(format_errors); 254 263 255 - CONFIGFS_EATTR_OPS(iscsi_stat_sess_err, iscsi_wwn_stat_grps, 256 - iscsi_sess_err_group); 264 + CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, inst); 265 + CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, digest_errors); 266 + CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, cxn_errors); 267 + CONFIGFS_ATTR_RO(iscsi_stat_sess_err_, format_errors); 257 268 258 269 static struct configfs_attribute *iscsi_stat_sess_err_attrs[] = { 259 - &iscsi_stat_sess_err_inst.attr, 260 - &iscsi_stat_sess_err_digest_errors.attr, 261 - &iscsi_stat_sess_err_cxn_errors.attr, 262 - &iscsi_stat_sess_err_format_errors.attr, 270 + &iscsi_stat_sess_err_attr_inst, 271 + &iscsi_stat_sess_err_attr_digest_errors, 272 + &iscsi_stat_sess_err_attr_cxn_errors, 273 + &iscsi_stat_sess_err_attr_format_errors, 263 274 NULL, 264 275 }; 265 276 266 - static struct configfs_item_operations iscsi_stat_sess_err_item_ops = { 267 - .show_attribute = iscsi_stat_sess_err_attr_show, 268 - .store_attribute = iscsi_stat_sess_err_attr_store, 269 - }; 270 - 271 277 struct config_item_type iscsi_stat_sess_err_cit = { 272 - .ct_item_ops = &iscsi_stat_sess_err_item_ops, 273 278 .ct_attrs = iscsi_stat_sess_err_attrs, 274 279 .ct_owner = THIS_MODULE, 275 280 }; ··· 257 302 /* 258 303 * Target Attributes Table 259 304 */ 260 - CONFIGFS_EATTR_STRUCT(iscsi_stat_tgt_attr, iscsi_wwn_stat_grps); 261 - #define ISCSI_STAT_TGT_ATTR(_name, _mode) \ 262 - static struct iscsi_stat_tgt_attr_attribute \ 263 - iscsi_stat_tgt_attr_##_name = \ 264 - __CONFIGFS_EATTR(_name, _mode, \ 265 - iscsi_stat_tgt-attr_show_attr_##_name, \ 266 - iscsi_stat_tgt_attr_store_attr_##_name); 267 - 268 - #define ISCSI_STAT_TGT_ATTR_RO(_name) \ 269 - static struct iscsi_stat_tgt_attr_attribute \ 270 - iscsi_stat_tgt_attr_##_name = \ 271 - __CONFIGFS_EATTR_RO(_name, \ 272 - iscsi_stat_tgt_attr_show_attr_##_name); 273 - 274 - static ssize_t iscsi_stat_tgt_attr_show_attr_inst( 275 - struct iscsi_wwn_stat_grps *igrps, char *page) 305 + static struct iscsi_tiqn *iscsi_tgt_attr_tiqn(struct config_item *item) 276 306 { 277 - struct iscsi_tiqn *tiqn = container_of(igrps, 278 - struct iscsi_tiqn, tiqn_stat_grps); 279 - 280 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 307 + struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), 308 + struct iscsi_wwn_stat_grps, iscsi_tgt_attr_group); 309 + return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); 281 310 } 282 - ISCSI_STAT_TGT_ATTR_RO(inst); 283 311 284 - static ssize_t iscsi_stat_tgt_attr_show_attr_indx( 285 - struct iscsi_wwn_stat_grps *igrps, char *page) 312 + static ssize_t iscsi_stat_tgt_attr_inst_show(struct config_item *item, 313 + char *page) 314 + { 315 + return snprintf(page, PAGE_SIZE, "%u\n", 316 + iscsi_tgt_attr_tiqn(item)->tiqn_index); 317 + } 318 + 319 + static ssize_t iscsi_stat_tgt_attr_indx_show(struct config_item *item, 320 + char *page) 286 321 { 287 322 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); 288 323 } 289 - ISCSI_STAT_TGT_ATTR_RO(indx); 290 324 291 - static ssize_t iscsi_stat_tgt_attr_show_attr_login_fails( 292 - struct iscsi_wwn_stat_grps *igrps, char *page) 325 + static ssize_t iscsi_stat_tgt_attr_login_fails_show(struct config_item *item, 326 + char *page) 293 327 { 294 - struct iscsi_tiqn *tiqn = container_of(igrps, 295 - struct iscsi_tiqn, tiqn_stat_grps); 328 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 296 329 struct iscsi_login_stats *lstat = &tiqn->login_stats; 297 330 u32 fail_count; 298 331 ··· 292 349 293 350 return snprintf(page, PAGE_SIZE, "%u\n", fail_count); 294 351 } 295 - ISCSI_STAT_TGT_ATTR_RO(login_fails); 296 352 297 - static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_time( 298 - struct iscsi_wwn_stat_grps *igrps, char *page) 353 + static ssize_t iscsi_stat_tgt_attr_last_fail_time_show(struct config_item *item, 354 + char *page) 299 355 { 300 - struct iscsi_tiqn *tiqn = container_of(igrps, 301 - struct iscsi_tiqn, tiqn_stat_grps); 356 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 302 357 struct iscsi_login_stats *lstat = &tiqn->login_stats; 303 358 u32 last_fail_time; 304 359 ··· 308 367 309 368 return snprintf(page, PAGE_SIZE, "%u\n", last_fail_time); 310 369 } 311 - ISCSI_STAT_TGT_ATTR_RO(last_fail_time); 312 370 313 - static ssize_t iscsi_stat_tgt_attr_show_attr_last_fail_type( 314 - struct iscsi_wwn_stat_grps *igrps, char *page) 371 + static ssize_t iscsi_stat_tgt_attr_last_fail_type_show(struct config_item *item, 372 + char *page) 315 373 { 316 - struct iscsi_tiqn *tiqn = container_of(igrps, 317 - struct iscsi_tiqn, tiqn_stat_grps); 374 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 318 375 struct iscsi_login_stats *lstat = &tiqn->login_stats; 319 376 u32 last_fail_type; 320 377 ··· 322 383 323 384 return snprintf(page, PAGE_SIZE, "%u\n", last_fail_type); 324 385 } 325 - ISCSI_STAT_TGT_ATTR_RO(last_fail_type); 326 386 327 - static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_name( 328 - struct iscsi_wwn_stat_grps *igrps, char *page) 387 + static ssize_t iscsi_stat_tgt_attr_fail_intr_name_show(struct config_item *item, 388 + char *page) 329 389 { 330 - struct iscsi_tiqn *tiqn = container_of(igrps, 331 - struct iscsi_tiqn, tiqn_stat_grps); 390 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 332 391 struct iscsi_login_stats *lstat = &tiqn->login_stats; 333 392 unsigned char buf[224]; 334 393 ··· 337 400 338 401 return snprintf(page, PAGE_SIZE, "%s\n", buf); 339 402 } 340 - ISCSI_STAT_TGT_ATTR_RO(fail_intr_name); 341 403 342 - static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr_type( 343 - struct iscsi_wwn_stat_grps *igrps, char *page) 404 + static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_type_show(struct config_item *item, 405 + char *page) 344 406 { 345 - struct iscsi_tiqn *tiqn = container_of(igrps, 346 - struct iscsi_tiqn, tiqn_stat_grps); 407 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 347 408 struct iscsi_login_stats *lstat = &tiqn->login_stats; 348 409 int ret; 349 410 ··· 354 419 355 420 return ret; 356 421 } 357 - ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr_type); 358 422 359 - static ssize_t iscsi_stat_tgt_attr_show_attr_fail_intr_addr( 360 - struct iscsi_wwn_stat_grps *igrps, char *page) 423 + static ssize_t iscsi_stat_tgt_attr_fail_intr_addr_show(struct config_item *item, 424 + char *page) 361 425 { 362 - struct iscsi_tiqn *tiqn = container_of(igrps, 363 - struct iscsi_tiqn, tiqn_stat_grps); 426 + struct iscsi_tiqn *tiqn = iscsi_tgt_attr_tiqn(item); 364 427 struct iscsi_login_stats *lstat = &tiqn->login_stats; 365 428 int ret; 366 429 ··· 368 435 369 436 return ret; 370 437 } 371 - ISCSI_STAT_TGT_ATTR_RO(fail_intr_addr); 372 438 373 - CONFIGFS_EATTR_OPS(iscsi_stat_tgt_attr, iscsi_wwn_stat_grps, 374 - iscsi_tgt_attr_group); 439 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, inst); 440 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, indx); 441 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, login_fails); 442 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, last_fail_time); 443 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, last_fail_type); 444 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_name); 445 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_addr_type); 446 + CONFIGFS_ATTR_RO(iscsi_stat_tgt_attr_, fail_intr_addr); 375 447 376 448 static struct configfs_attribute *iscsi_stat_tgt_attr_attrs[] = { 377 - &iscsi_stat_tgt_attr_inst.attr, 378 - &iscsi_stat_tgt_attr_indx.attr, 379 - &iscsi_stat_tgt_attr_login_fails.attr, 380 - &iscsi_stat_tgt_attr_last_fail_time.attr, 381 - &iscsi_stat_tgt_attr_last_fail_type.attr, 382 - &iscsi_stat_tgt_attr_fail_intr_name.attr, 383 - &iscsi_stat_tgt_attr_fail_intr_addr_type.attr, 384 - &iscsi_stat_tgt_attr_fail_intr_addr.attr, 449 + &iscsi_stat_tgt_attr_attr_inst, 450 + &iscsi_stat_tgt_attr_attr_indx, 451 + &iscsi_stat_tgt_attr_attr_login_fails, 452 + &iscsi_stat_tgt_attr_attr_last_fail_time, 453 + &iscsi_stat_tgt_attr_attr_last_fail_type, 454 + &iscsi_stat_tgt_attr_attr_fail_intr_name, 455 + &iscsi_stat_tgt_attr_attr_fail_intr_addr_type, 456 + &iscsi_stat_tgt_attr_attr_fail_intr_addr, 385 457 NULL, 386 458 }; 387 459 388 - static struct configfs_item_operations iscsi_stat_tgt_attr_item_ops = { 389 - .show_attribute = iscsi_stat_tgt_attr_attr_show, 390 - .store_attribute = iscsi_stat_tgt_attr_attr_store, 391 - }; 392 - 393 460 struct config_item_type iscsi_stat_tgt_attr_cit = { 394 - .ct_item_ops = &iscsi_stat_tgt_attr_item_ops, 395 461 .ct_attrs = iscsi_stat_tgt_attr_attrs, 396 462 .ct_owner = THIS_MODULE, 397 463 }; ··· 398 466 /* 399 467 * Target Login Stats Table 400 468 */ 401 - CONFIGFS_EATTR_STRUCT(iscsi_stat_login, iscsi_wwn_stat_grps); 402 - #define ISCSI_STAT_LOGIN(_name, _mode) \ 403 - static struct iscsi_stat_login_attribute \ 404 - iscsi_stat_login_##_name = \ 405 - __CONFIGFS_EATTR(_name, _mode, \ 406 - iscsi_stat_login_show_attr_##_name, \ 407 - iscsi_stat_login_store_attr_##_name); 408 - 409 - #define ISCSI_STAT_LOGIN_RO(_name) \ 410 - static struct iscsi_stat_login_attribute \ 411 - iscsi_stat_login_##_name = \ 412 - __CONFIGFS_EATTR_RO(_name, \ 413 - iscsi_stat_login_show_attr_##_name); 414 - 415 - static ssize_t iscsi_stat_login_show_attr_inst( 416 - struct iscsi_wwn_stat_grps *igrps, char *page) 469 + static struct iscsi_tiqn *iscsi_login_stat_tiqn(struct config_item *item) 417 470 { 418 - struct iscsi_tiqn *tiqn = container_of(igrps, 419 - struct iscsi_tiqn, tiqn_stat_grps); 420 - 421 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 471 + struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), 472 + struct iscsi_wwn_stat_grps, iscsi_login_stats_group); 473 + return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); 422 474 } 423 - ISCSI_STAT_LOGIN_RO(inst); 424 475 425 - static ssize_t iscsi_stat_login_show_attr_indx( 426 - struct iscsi_wwn_stat_grps *igrps, char *page) 476 + static ssize_t iscsi_stat_login_inst_show(struct config_item *item, char *page) 477 + { 478 + return snprintf(page, PAGE_SIZE, "%u\n", 479 + iscsi_login_stat_tiqn(item)->tiqn_index); 480 + } 481 + 482 + static ssize_t iscsi_stat_login_indx_show(struct config_item *item, 483 + char *page) 427 484 { 428 485 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); 429 486 } 430 - ISCSI_STAT_LOGIN_RO(indx); 431 487 432 - static ssize_t iscsi_stat_login_show_attr_accepts( 433 - struct iscsi_wwn_stat_grps *igrps, char *page) 488 + static ssize_t iscsi_stat_login_accepts_show(struct config_item *item, 489 + char *page) 434 490 { 435 - struct iscsi_tiqn *tiqn = container_of(igrps, 436 - struct iscsi_tiqn, tiqn_stat_grps); 491 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 437 492 struct iscsi_login_stats *lstat = &tiqn->login_stats; 438 493 ssize_t ret; 439 494 ··· 430 511 431 512 return ret; 432 513 } 433 - ISCSI_STAT_LOGIN_RO(accepts); 434 514 435 - static ssize_t iscsi_stat_login_show_attr_other_fails( 436 - struct iscsi_wwn_stat_grps *igrps, char *page) 515 + static ssize_t iscsi_stat_login_other_fails_show(struct config_item *item, 516 + char *page) 437 517 { 438 - struct iscsi_tiqn *tiqn = container_of(igrps, 439 - struct iscsi_tiqn, tiqn_stat_grps); 518 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 440 519 struct iscsi_login_stats *lstat = &tiqn->login_stats; 441 520 ssize_t ret; 442 521 ··· 444 527 445 528 return ret; 446 529 } 447 - ISCSI_STAT_LOGIN_RO(other_fails); 448 530 449 - static ssize_t iscsi_stat_login_show_attr_redirects( 450 - struct iscsi_wwn_stat_grps *igrps, char *page) 531 + static ssize_t iscsi_stat_login_redirects_show(struct config_item *item, 532 + char *page) 451 533 { 452 - struct iscsi_tiqn *tiqn = container_of(igrps, 453 - struct iscsi_tiqn, tiqn_stat_grps); 534 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 454 535 struct iscsi_login_stats *lstat = &tiqn->login_stats; 455 536 ssize_t ret; 456 537 ··· 458 543 459 544 return ret; 460 545 } 461 - ISCSI_STAT_LOGIN_RO(redirects); 462 546 463 - static ssize_t iscsi_stat_login_show_attr_authorize_fails( 464 - struct iscsi_wwn_stat_grps *igrps, char *page) 547 + static ssize_t iscsi_stat_login_authorize_fails_show(struct config_item *item, 548 + char *page) 465 549 { 466 - struct iscsi_tiqn *tiqn = container_of(igrps, 467 - struct iscsi_tiqn, tiqn_stat_grps); 550 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 468 551 struct iscsi_login_stats *lstat = &tiqn->login_stats; 469 552 ssize_t ret; 470 553 ··· 472 559 473 560 return ret; 474 561 } 475 - ISCSI_STAT_LOGIN_RO(authorize_fails); 476 562 477 - static ssize_t iscsi_stat_login_show_attr_authenticate_fails( 478 - struct iscsi_wwn_stat_grps *igrps, char *page) 563 + static ssize_t iscsi_stat_login_authenticate_fails_show( 564 + struct config_item *item, char *page) 479 565 { 480 - struct iscsi_tiqn *tiqn = container_of(igrps, 481 - struct iscsi_tiqn, tiqn_stat_grps); 566 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 482 567 struct iscsi_login_stats *lstat = &tiqn->login_stats; 483 568 ssize_t ret; 484 569 ··· 486 575 487 576 return ret; 488 577 } 489 - ISCSI_STAT_LOGIN_RO(authenticate_fails); 490 578 491 - static ssize_t iscsi_stat_login_show_attr_negotiate_fails( 492 - struct iscsi_wwn_stat_grps *igrps, char *page) 579 + static ssize_t iscsi_stat_login_negotiate_fails_show(struct config_item *item, 580 + char *page) 493 581 { 494 - struct iscsi_tiqn *tiqn = container_of(igrps, 495 - struct iscsi_tiqn, tiqn_stat_grps); 582 + struct iscsi_tiqn *tiqn = iscsi_login_stat_tiqn(item); 496 583 struct iscsi_login_stats *lstat = &tiqn->login_stats; 497 584 ssize_t ret; 498 585 ··· 500 591 501 592 return ret; 502 593 } 503 - ISCSI_STAT_LOGIN_RO(negotiate_fails); 504 594 505 - CONFIGFS_EATTR_OPS(iscsi_stat_login, iscsi_wwn_stat_grps, 506 - iscsi_login_stats_group); 595 + CONFIGFS_ATTR_RO(iscsi_stat_login_, inst); 596 + CONFIGFS_ATTR_RO(iscsi_stat_login_, indx); 597 + CONFIGFS_ATTR_RO(iscsi_stat_login_, accepts); 598 + CONFIGFS_ATTR_RO(iscsi_stat_login_, other_fails); 599 + CONFIGFS_ATTR_RO(iscsi_stat_login_, redirects); 600 + CONFIGFS_ATTR_RO(iscsi_stat_login_, authorize_fails); 601 + CONFIGFS_ATTR_RO(iscsi_stat_login_, authenticate_fails); 602 + CONFIGFS_ATTR_RO(iscsi_stat_login_, negotiate_fails); 507 603 508 604 static struct configfs_attribute *iscsi_stat_login_stats_attrs[] = { 509 - &iscsi_stat_login_inst.attr, 510 - &iscsi_stat_login_indx.attr, 511 - &iscsi_stat_login_accepts.attr, 512 - &iscsi_stat_login_other_fails.attr, 513 - &iscsi_stat_login_redirects.attr, 514 - &iscsi_stat_login_authorize_fails.attr, 515 - &iscsi_stat_login_authenticate_fails.attr, 516 - &iscsi_stat_login_negotiate_fails.attr, 605 + &iscsi_stat_login_attr_inst, 606 + &iscsi_stat_login_attr_indx, 607 + &iscsi_stat_login_attr_accepts, 608 + &iscsi_stat_login_attr_other_fails, 609 + &iscsi_stat_login_attr_redirects, 610 + &iscsi_stat_login_attr_authorize_fails, 611 + &iscsi_stat_login_attr_authenticate_fails, 612 + &iscsi_stat_login_attr_negotiate_fails, 517 613 NULL, 518 614 }; 519 615 520 - static struct configfs_item_operations iscsi_stat_login_stats_item_ops = { 521 - .show_attribute = iscsi_stat_login_attr_show, 522 - .store_attribute = iscsi_stat_login_attr_store, 523 - }; 524 - 525 616 struct config_item_type iscsi_stat_login_cit = { 526 - .ct_item_ops = &iscsi_stat_login_stats_item_ops, 527 617 .ct_attrs = iscsi_stat_login_stats_attrs, 528 618 .ct_owner = THIS_MODULE, 529 619 }; ··· 530 622 /* 531 623 * Target Logout Stats Table 532 624 */ 533 - 534 - CONFIGFS_EATTR_STRUCT(iscsi_stat_logout, iscsi_wwn_stat_grps); 535 - #define ISCSI_STAT_LOGOUT(_name, _mode) \ 536 - static struct iscsi_stat_logout_attribute \ 537 - iscsi_stat_logout_##_name = \ 538 - __CONFIGFS_EATTR(_name, _mode, \ 539 - iscsi_stat_logout_show_attr_##_name, \ 540 - iscsi_stat_logout_store_attr_##_name); 541 - 542 - #define ISCSI_STAT_LOGOUT_RO(_name) \ 543 - static struct iscsi_stat_logout_attribute \ 544 - iscsi_stat_logout_##_name = \ 545 - __CONFIGFS_EATTR_RO(_name, \ 546 - iscsi_stat_logout_show_attr_##_name); 547 - 548 - static ssize_t iscsi_stat_logout_show_attr_inst( 549 - struct iscsi_wwn_stat_grps *igrps, char *page) 625 + static struct iscsi_tiqn *iscsi_logout_stat_tiqn(struct config_item *item) 550 626 { 551 - struct iscsi_tiqn *tiqn = container_of(igrps, 552 - struct iscsi_tiqn, tiqn_stat_grps); 553 - 554 - return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 627 + struct iscsi_wwn_stat_grps *igrps = container_of(to_config_group(item), 628 + struct iscsi_wwn_stat_grps, iscsi_logout_stats_group); 629 + return container_of(igrps, struct iscsi_tiqn, tiqn_stat_grps); 555 630 } 556 - ISCSI_STAT_LOGOUT_RO(inst); 557 631 558 - static ssize_t iscsi_stat_logout_show_attr_indx( 559 - struct iscsi_wwn_stat_grps *igrps, char *page) 632 + static ssize_t iscsi_stat_logout_inst_show(struct config_item *item, char *page) 633 + { 634 + return snprintf(page, PAGE_SIZE, "%u\n", 635 + iscsi_logout_stat_tiqn(item)->tiqn_index); 636 + } 637 + 638 + static ssize_t iscsi_stat_logout_indx_show(struct config_item *item, char *page) 560 639 { 561 640 return snprintf(page, PAGE_SIZE, "%u\n", ISCSI_NODE_INDEX); 562 641 } 563 - ISCSI_STAT_LOGOUT_RO(indx); 564 642 565 - static ssize_t iscsi_stat_logout_show_attr_normal_logouts( 566 - struct iscsi_wwn_stat_grps *igrps, char *page) 643 + static ssize_t iscsi_stat_logout_normal_logouts_show(struct config_item *item, 644 + char *page) 567 645 { 568 - struct iscsi_tiqn *tiqn = container_of(igrps, 569 - struct iscsi_tiqn, tiqn_stat_grps); 646 + struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item); 570 647 struct iscsi_logout_stats *lstats = &tiqn->logout_stats; 571 648 572 649 return snprintf(page, PAGE_SIZE, "%u\n", lstats->normal_logouts); 573 650 } 574 - ISCSI_STAT_LOGOUT_RO(normal_logouts); 575 651 576 - static ssize_t iscsi_stat_logout_show_attr_abnormal_logouts( 577 - struct iscsi_wwn_stat_grps *igrps, char *page) 652 + static ssize_t iscsi_stat_logout_abnormal_logouts_show(struct config_item *item, 653 + char *page) 578 654 { 579 - struct iscsi_tiqn *tiqn = container_of(igrps, 580 - struct iscsi_tiqn, tiqn_stat_grps); 655 + struct iscsi_tiqn *tiqn = iscsi_logout_stat_tiqn(item); 581 656 struct iscsi_logout_stats *lstats = &tiqn->logout_stats; 582 657 583 658 return snprintf(page, PAGE_SIZE, "%u\n", lstats->abnormal_logouts); 584 659 } 585 - ISCSI_STAT_LOGOUT_RO(abnormal_logouts); 586 660 587 - CONFIGFS_EATTR_OPS(iscsi_stat_logout, iscsi_wwn_stat_grps, 588 - iscsi_logout_stats_group); 661 + CONFIGFS_ATTR_RO(iscsi_stat_logout_, inst); 662 + CONFIGFS_ATTR_RO(iscsi_stat_logout_, indx); 663 + CONFIGFS_ATTR_RO(iscsi_stat_logout_, normal_logouts); 664 + CONFIGFS_ATTR_RO(iscsi_stat_logout_, abnormal_logouts); 589 665 590 666 static struct configfs_attribute *iscsi_stat_logout_stats_attrs[] = { 591 - &iscsi_stat_logout_inst.attr, 592 - &iscsi_stat_logout_indx.attr, 593 - &iscsi_stat_logout_normal_logouts.attr, 594 - &iscsi_stat_logout_abnormal_logouts.attr, 667 + &iscsi_stat_logout_attr_inst, 668 + &iscsi_stat_logout_attr_indx, 669 + &iscsi_stat_logout_attr_normal_logouts, 670 + &iscsi_stat_logout_attr_abnormal_logouts, 595 671 NULL, 596 672 }; 597 673 598 - static struct configfs_item_operations iscsi_stat_logout_stats_item_ops = { 599 - .show_attribute = iscsi_stat_logout_attr_show, 600 - .store_attribute = iscsi_stat_logout_attr_store, 601 - }; 602 - 603 674 struct config_item_type iscsi_stat_logout_cit = { 604 - .ct_item_ops = &iscsi_stat_logout_stats_item_ops, 605 675 .ct_attrs = iscsi_stat_logout_stats_attrs, 606 676 .ct_owner = THIS_MODULE, 607 677 }; ··· 587 701 /* 588 702 * Session Stats Table 589 703 */ 590 - 591 - CONFIGFS_EATTR_STRUCT(iscsi_stat_sess, iscsi_node_stat_grps); 592 - #define ISCSI_STAT_SESS(_name, _mode) \ 593 - static struct iscsi_stat_sess_attribute \ 594 - iscsi_stat_sess_##_name = \ 595 - __CONFIGFS_EATTR(_name, _mode, \ 596 - iscsi_stat_sess_show_attr_##_name, \ 597 - iscsi_stat_sess_store_attr_##_name); 598 - 599 - #define ISCSI_STAT_SESS_RO(_name) \ 600 - static struct iscsi_stat_sess_attribute \ 601 - iscsi_stat_sess_##_name = \ 602 - __CONFIGFS_EATTR_RO(_name, \ 603 - iscsi_stat_sess_show_attr_##_name); 604 - 605 - static ssize_t iscsi_stat_sess_show_attr_inst( 606 - struct iscsi_node_stat_grps *igrps, char *page) 704 + static struct iscsi_node_acl *iscsi_stat_nacl(struct config_item *item) 607 705 { 608 - struct iscsi_node_acl *acl = container_of(igrps, 609 - struct iscsi_node_acl, node_stat_grps); 706 + struct iscsi_node_stat_grps *igrps = container_of(to_config_group(item), 707 + struct iscsi_node_stat_grps, iscsi_sess_stats_group); 708 + return container_of(igrps, struct iscsi_node_acl, node_stat_grps); 709 + } 710 + 711 + static ssize_t iscsi_stat_sess_inst_show(struct config_item *item, char *page) 712 + { 713 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 610 714 struct se_wwn *wwn = acl->se_node_acl.se_tpg->se_tpg_wwn; 611 715 struct iscsi_tiqn *tiqn = container_of(wwn, 612 716 struct iscsi_tiqn, tiqn_wwn); 613 717 614 718 return snprintf(page, PAGE_SIZE, "%u\n", tiqn->tiqn_index); 615 719 } 616 - ISCSI_STAT_SESS_RO(inst); 617 720 618 - static ssize_t iscsi_stat_sess_show_attr_node( 619 - struct iscsi_node_stat_grps *igrps, char *page) 721 + static ssize_t iscsi_stat_sess_node_show(struct config_item *item, char *page) 620 722 { 621 - struct iscsi_node_acl *acl = container_of(igrps, 622 - struct iscsi_node_acl, node_stat_grps); 723 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 623 724 struct se_node_acl *se_nacl = &acl->se_node_acl; 624 725 struct iscsi_session *sess; 625 726 struct se_session *se_sess; ··· 624 751 625 752 return ret; 626 753 } 627 - ISCSI_STAT_SESS_RO(node); 628 754 629 - static ssize_t iscsi_stat_sess_show_attr_indx( 630 - struct iscsi_node_stat_grps *igrps, char *page) 755 + static ssize_t iscsi_stat_sess_indx_show(struct config_item *item, char *page) 631 756 { 632 - struct iscsi_node_acl *acl = container_of(igrps, 633 - struct iscsi_node_acl, node_stat_grps); 757 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 634 758 struct se_node_acl *se_nacl = &acl->se_node_acl; 635 759 struct iscsi_session *sess; 636 760 struct se_session *se_sess; ··· 645 775 646 776 return ret; 647 777 } 648 - ISCSI_STAT_SESS_RO(indx); 649 778 650 - static ssize_t iscsi_stat_sess_show_attr_cmd_pdus( 651 - struct iscsi_node_stat_grps *igrps, char *page) 779 + static ssize_t iscsi_stat_sess_cmd_pdus_show(struct config_item *item, 780 + char *page) 652 781 { 653 - struct iscsi_node_acl *acl = container_of(igrps, 654 - struct iscsi_node_acl, node_stat_grps); 782 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 655 783 struct se_node_acl *se_nacl = &acl->se_node_acl; 656 784 struct iscsi_session *sess; 657 785 struct se_session *se_sess; ··· 667 799 668 800 return ret; 669 801 } 670 - ISCSI_STAT_SESS_RO(cmd_pdus); 671 802 672 - static ssize_t iscsi_stat_sess_show_attr_rsp_pdus( 673 - struct iscsi_node_stat_grps *igrps, char *page) 803 + static ssize_t iscsi_stat_sess_rsp_pdus_show(struct config_item *item, 804 + char *page) 674 805 { 675 - struct iscsi_node_acl *acl = container_of(igrps, 676 - struct iscsi_node_acl, node_stat_grps); 806 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 677 807 struct se_node_acl *se_nacl = &acl->se_node_acl; 678 808 struct iscsi_session *sess; 679 809 struct se_session *se_sess; ··· 689 823 690 824 return ret; 691 825 } 692 - ISCSI_STAT_SESS_RO(rsp_pdus); 693 826 694 - static ssize_t iscsi_stat_sess_show_attr_txdata_octs( 695 - struct iscsi_node_stat_grps *igrps, char *page) 827 + static ssize_t iscsi_stat_sess_txdata_octs_show(struct config_item *item, 828 + char *page) 696 829 { 697 - struct iscsi_node_acl *acl = container_of(igrps, 698 - struct iscsi_node_acl, node_stat_grps); 830 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 699 831 struct se_node_acl *se_nacl = &acl->se_node_acl; 700 832 struct iscsi_session *sess; 701 833 struct se_session *se_sess; ··· 711 847 712 848 return ret; 713 849 } 714 - ISCSI_STAT_SESS_RO(txdata_octs); 715 850 716 - static ssize_t iscsi_stat_sess_show_attr_rxdata_octs( 717 - struct iscsi_node_stat_grps *igrps, char *page) 851 + static ssize_t iscsi_stat_sess_rxdata_octs_show(struct config_item *item, 852 + char *page) 718 853 { 719 - struct iscsi_node_acl *acl = container_of(igrps, 720 - struct iscsi_node_acl, node_stat_grps); 854 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 721 855 struct se_node_acl *se_nacl = &acl->se_node_acl; 722 856 struct iscsi_session *sess; 723 857 struct se_session *se_sess; ··· 733 871 734 872 return ret; 735 873 } 736 - ISCSI_STAT_SESS_RO(rxdata_octs); 737 874 738 - static ssize_t iscsi_stat_sess_show_attr_conn_digest_errors( 739 - struct iscsi_node_stat_grps *igrps, char *page) 875 + static ssize_t iscsi_stat_sess_conn_digest_errors_show(struct config_item *item, 876 + char *page) 740 877 { 741 - struct iscsi_node_acl *acl = container_of(igrps, 742 - struct iscsi_node_acl, node_stat_grps); 878 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 743 879 struct se_node_acl *se_nacl = &acl->se_node_acl; 744 880 struct iscsi_session *sess; 745 881 struct se_session *se_sess; ··· 755 895 756 896 return ret; 757 897 } 758 - ISCSI_STAT_SESS_RO(conn_digest_errors); 759 898 760 - static ssize_t iscsi_stat_sess_show_attr_conn_timeout_errors( 761 - struct iscsi_node_stat_grps *igrps, char *page) 899 + static ssize_t iscsi_stat_sess_conn_timeout_errors_show( 900 + struct config_item *item, char *page) 762 901 { 763 - struct iscsi_node_acl *acl = container_of(igrps, 764 - struct iscsi_node_acl, node_stat_grps); 902 + struct iscsi_node_acl *acl = iscsi_stat_nacl(item); 765 903 struct se_node_acl *se_nacl = &acl->se_node_acl; 766 904 struct iscsi_session *sess; 767 905 struct se_session *se_sess; ··· 777 919 778 920 return ret; 779 921 } 780 - ISCSI_STAT_SESS_RO(conn_timeout_errors); 781 922 782 - CONFIGFS_EATTR_OPS(iscsi_stat_sess, iscsi_node_stat_grps, 783 - iscsi_sess_stats_group); 923 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, inst); 924 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, node); 925 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, indx); 926 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, cmd_pdus); 927 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, rsp_pdus); 928 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, txdata_octs); 929 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, rxdata_octs); 930 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, conn_digest_errors); 931 + CONFIGFS_ATTR_RO(iscsi_stat_sess_, conn_timeout_errors); 784 932 785 933 static struct configfs_attribute *iscsi_stat_sess_stats_attrs[] = { 786 - &iscsi_stat_sess_inst.attr, 787 - &iscsi_stat_sess_node.attr, 788 - &iscsi_stat_sess_indx.attr, 789 - &iscsi_stat_sess_cmd_pdus.attr, 790 - &iscsi_stat_sess_rsp_pdus.attr, 791 - &iscsi_stat_sess_txdata_octs.attr, 792 - &iscsi_stat_sess_rxdata_octs.attr, 793 - &iscsi_stat_sess_conn_digest_errors.attr, 794 - &iscsi_stat_sess_conn_timeout_errors.attr, 934 + &iscsi_stat_sess_attr_inst, 935 + &iscsi_stat_sess_attr_node, 936 + &iscsi_stat_sess_attr_indx, 937 + &iscsi_stat_sess_attr_cmd_pdus, 938 + &iscsi_stat_sess_attr_rsp_pdus, 939 + &iscsi_stat_sess_attr_txdata_octs, 940 + &iscsi_stat_sess_attr_rxdata_octs, 941 + &iscsi_stat_sess_attr_conn_digest_errors, 942 + &iscsi_stat_sess_attr_conn_timeout_errors, 795 943 NULL, 796 944 }; 797 945 798 - static struct configfs_item_operations iscsi_stat_sess_stats_item_ops = { 799 - .show_attribute = iscsi_stat_sess_attr_show, 800 - .store_attribute = iscsi_stat_sess_attr_store, 801 - }; 802 - 803 946 struct config_item_type iscsi_stat_sess_cit = { 804 - .ct_item_ops = &iscsi_stat_sess_stats_item_ops, 805 947 .ct_attrs = iscsi_stat_sess_stats_attrs, 806 948 .ct_owner = THIS_MODULE, 807 949 };
+26 -34
drivers/target/loopback/tcm_loop.c
··· 34 34 35 35 #include <target/target_core_base.h> 36 36 #include <target/target_core_fabric.h> 37 - #include <target/target_core_fabric_configfs.h> 38 37 39 38 #include "tcm_loop.h" 40 39 ··· 762 763 763 764 /* End items for tcm_loop_port_cit */ 764 765 765 - static ssize_t tcm_loop_tpg_attrib_show_fabric_prot_type( 766 - struct se_portal_group *se_tpg, 767 - char *page) 766 + static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_show( 767 + struct config_item *item, char *page) 768 768 { 769 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 769 770 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, 770 771 tl_se_tpg); 771 772 772 773 return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type); 773 774 } 774 775 775 - static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type( 776 - struct se_portal_group *se_tpg, 777 - const char *page, 778 - size_t count) 776 + static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_store( 777 + struct config_item *item, const char *page, size_t count) 779 778 { 779 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 780 780 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg, 781 781 tl_se_tpg); 782 782 unsigned long val; ··· 794 796 return count; 795 797 } 796 798 797 - TF_TPG_ATTRIB_ATTR(tcm_loop, fabric_prot_type, S_IRUGO | S_IWUSR); 799 + CONFIGFS_ATTR(tcm_loop_tpg_attrib_, fabric_prot_type); 798 800 799 801 static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = { 800 - &tcm_loop_tpg_attrib_fabric_prot_type.attr, 802 + &tcm_loop_tpg_attrib_attr_fabric_prot_type, 801 803 NULL, 802 804 }; 803 805 ··· 892 894 893 895 /* End items for tcm_loop_nexus_cit */ 894 896 895 - static ssize_t tcm_loop_tpg_show_nexus( 896 - struct se_portal_group *se_tpg, 897 - char *page) 897 + static ssize_t tcm_loop_tpg_nexus_show(struct config_item *item, char *page) 898 898 { 899 + struct se_portal_group *se_tpg = to_tpg(item); 899 900 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 900 901 struct tcm_loop_tpg, tl_se_tpg); 901 902 struct tcm_loop_nexus *tl_nexus; ··· 910 913 return ret; 911 914 } 912 915 913 - static ssize_t tcm_loop_tpg_store_nexus( 914 - struct se_portal_group *se_tpg, 915 - const char *page, 916 - size_t count) 916 + static ssize_t tcm_loop_tpg_nexus_store(struct config_item *item, 917 + const char *page, size_t count) 917 918 { 919 + struct se_portal_group *se_tpg = to_tpg(item); 918 920 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 919 921 struct tcm_loop_tpg, tl_se_tpg); 920 922 struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; ··· 988 992 return count; 989 993 } 990 994 991 - TF_TPG_BASE_ATTR(tcm_loop, nexus, S_IRUGO | S_IWUSR); 992 - 993 - static ssize_t tcm_loop_tpg_show_transport_status( 994 - struct se_portal_group *se_tpg, 995 - char *page) 995 + static ssize_t tcm_loop_tpg_transport_status_show(struct config_item *item, 996 + char *page) 996 997 { 998 + struct se_portal_group *se_tpg = to_tpg(item); 997 999 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 998 1000 struct tcm_loop_tpg, tl_se_tpg); 999 1001 const char *status = NULL; ··· 1014 1020 return ret; 1015 1021 } 1016 1022 1017 - static ssize_t tcm_loop_tpg_store_transport_status( 1018 - struct se_portal_group *se_tpg, 1019 - const char *page, 1020 - size_t count) 1023 + static ssize_t tcm_loop_tpg_transport_status_store(struct config_item *item, 1024 + const char *page, size_t count) 1021 1025 { 1026 + struct se_portal_group *se_tpg = to_tpg(item); 1022 1027 struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, 1023 1028 struct tcm_loop_tpg, tl_se_tpg); 1024 1029 ··· 1037 1044 return -EINVAL; 1038 1045 } 1039 1046 1040 - TF_TPG_BASE_ATTR(tcm_loop, transport_status, S_IRUGO | S_IWUSR); 1047 + CONFIGFS_ATTR(tcm_loop_tpg_, nexus); 1048 + CONFIGFS_ATTR(tcm_loop_tpg_, transport_status); 1041 1049 1042 1050 static struct configfs_attribute *tcm_loop_tpg_attrs[] = { 1043 - &tcm_loop_tpg_nexus.attr, 1044 - &tcm_loop_tpg_transport_status.attr, 1051 + &tcm_loop_tpg_attr_nexus, 1052 + &tcm_loop_tpg_attr_transport_status, 1045 1053 NULL, 1046 1054 }; 1047 1055 ··· 1210 1216 } 1211 1217 1212 1218 /* Start items for tcm_loop_cit */ 1213 - static ssize_t tcm_loop_wwn_show_attr_version( 1214 - struct target_fabric_configfs *tf, 1215 - char *page) 1219 + static ssize_t tcm_loop_wwn_version_show(struct config_item *item, char *page) 1216 1220 { 1217 1221 return sprintf(page, "TCM Loopback Fabric module %s\n", TCM_LOOP_VERSION); 1218 1222 } 1219 1223 1220 - TF_WWN_ATTR_RO(tcm_loop, version); 1224 + CONFIGFS_ATTR_RO(tcm_loop_wwn_, version); 1221 1225 1222 1226 static struct configfs_attribute *tcm_loop_wwn_attrs[] = { 1223 - &tcm_loop_wwn_version.attr, 1227 + &tcm_loop_wwn_attr_version, 1224 1228 NULL, 1225 1229 }; 1226 1230
+38 -49
drivers/target/sbp/sbp_target.c
··· 35 35 #include <target/target_core_base.h> 36 36 #include <target/target_core_backend.h> 37 37 #include <target/target_core_fabric.h> 38 - #include <target/target_core_fabric_configfs.h> 39 - #include <target/configfs_macros.h> 40 38 #include <asm/unaligned.h> 41 39 42 40 #include "sbp_target.h" ··· 2109 2111 kfree(tport); 2110 2112 } 2111 2113 2112 - static ssize_t sbp_wwn_show_attr_version( 2113 - struct target_fabric_configfs *tf, 2114 - char *page) 2114 + static ssize_t sbp_wwn_version_show(struct config_item *item, char *page) 2115 2115 { 2116 2116 return sprintf(page, "FireWire SBP fabric module %s\n", SBP_VERSION); 2117 2117 } 2118 2118 2119 - TF_WWN_ATTR_RO(sbp, version); 2119 + CONFIGFS_ATTR_RO(sbp_wwn_, version); 2120 2120 2121 2121 static struct configfs_attribute *sbp_wwn_attrs[] = { 2122 - &sbp_wwn_version.attr, 2122 + &sbp_wwn_attr_version, 2123 2123 NULL, 2124 2124 }; 2125 2125 2126 - static ssize_t sbp_tpg_show_directory_id( 2127 - struct se_portal_group *se_tpg, 2128 - char *page) 2126 + static ssize_t sbp_tpg_directory_id_show(struct config_item *item, char *page) 2129 2127 { 2128 + struct se_portal_group *se_tpg = to_tpg(item); 2130 2129 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2131 2130 struct sbp_tport *tport = tpg->tport; 2132 2131 ··· 2133 2138 return sprintf(page, "%06x\n", tport->directory_id); 2134 2139 } 2135 2140 2136 - static ssize_t sbp_tpg_store_directory_id( 2137 - struct se_portal_group *se_tpg, 2138 - const char *page, 2139 - size_t count) 2141 + static ssize_t sbp_tpg_directory_id_store(struct config_item *item, 2142 + const char *page, size_t count) 2140 2143 { 2144 + struct se_portal_group *se_tpg = to_tpg(item); 2141 2145 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2142 2146 struct sbp_tport *tport = tpg->tport; 2143 2147 unsigned long val; ··· 2160 2166 return count; 2161 2167 } 2162 2168 2163 - static ssize_t sbp_tpg_show_enable( 2164 - struct se_portal_group *se_tpg, 2165 - char *page) 2169 + static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page) 2166 2170 { 2171 + struct se_portal_group *se_tpg = to_tpg(item); 2167 2172 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2168 2173 struct sbp_tport *tport = tpg->tport; 2169 2174 return sprintf(page, "%d\n", tport->enable); 2170 2175 } 2171 2176 2172 - static ssize_t sbp_tpg_store_enable( 2173 - struct se_portal_group *se_tpg, 2174 - const char *page, 2175 - size_t count) 2177 + static ssize_t sbp_tpg_enable_store(struct config_item *item, 2178 + const char *page, size_t count) 2176 2179 { 2180 + struct se_portal_group *se_tpg = to_tpg(item); 2177 2181 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2178 2182 struct sbp_tport *tport = tpg->tport; 2179 2183 unsigned long val; ··· 2211 2219 return count; 2212 2220 } 2213 2221 2214 - TF_TPG_BASE_ATTR(sbp, directory_id, S_IRUGO | S_IWUSR); 2215 - TF_TPG_BASE_ATTR(sbp, enable, S_IRUGO | S_IWUSR); 2222 + CONFIGFS_ATTR(sbp_tpg_, directory_id); 2223 + CONFIGFS_ATTR(sbp_tpg_, enable); 2216 2224 2217 2225 static struct configfs_attribute *sbp_tpg_base_attrs[] = { 2218 - &sbp_tpg_directory_id.attr, 2219 - &sbp_tpg_enable.attr, 2226 + &sbp_tpg_attr_directory_id, 2227 + &sbp_tpg_attr_enable, 2220 2228 NULL, 2221 2229 }; 2222 2230 2223 - static ssize_t sbp_tpg_attrib_show_mgt_orb_timeout( 2224 - struct se_portal_group *se_tpg, 2231 + static ssize_t sbp_tpg_attrib_mgt_orb_timeout_show(struct config_item *item, 2225 2232 char *page) 2226 2233 { 2234 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2227 2235 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2228 2236 struct sbp_tport *tport = tpg->tport; 2229 2237 return sprintf(page, "%d\n", tport->mgt_orb_timeout); 2230 2238 } 2231 2239 2232 - static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout( 2233 - struct se_portal_group *se_tpg, 2234 - const char *page, 2235 - size_t count) 2240 + static ssize_t sbp_tpg_attrib_mgt_orb_timeout_store(struct config_item *item, 2241 + const char *page, size_t count) 2236 2242 { 2243 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2237 2244 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2238 2245 struct sbp_tport *tport = tpg->tport; 2239 2246 unsigned long val; ··· 2255 2264 return count; 2256 2265 } 2257 2266 2258 - static ssize_t sbp_tpg_attrib_show_max_reconnect_timeout( 2259 - struct se_portal_group *se_tpg, 2267 + static ssize_t sbp_tpg_attrib_max_reconnect_timeout_show(struct config_item *item, 2260 2268 char *page) 2261 2269 { 2270 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2262 2271 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2263 2272 struct sbp_tport *tport = tpg->tport; 2264 2273 return sprintf(page, "%d\n", tport->max_reconnect_timeout); 2265 2274 } 2266 2275 2267 - static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout( 2268 - struct se_portal_group *se_tpg, 2269 - const char *page, 2270 - size_t count) 2276 + static ssize_t sbp_tpg_attrib_max_reconnect_timeout_store(struct config_item *item, 2277 + const char *page, size_t count) 2271 2278 { 2279 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2272 2280 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2273 2281 struct sbp_tport *tport = tpg->tport; 2274 2282 unsigned long val; ··· 2290 2300 return count; 2291 2301 } 2292 2302 2293 - static ssize_t sbp_tpg_attrib_show_max_logins_per_lun( 2294 - struct se_portal_group *se_tpg, 2303 + static ssize_t sbp_tpg_attrib_max_logins_per_lun_show(struct config_item *item, 2295 2304 char *page) 2296 2305 { 2306 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2297 2307 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2298 2308 struct sbp_tport *tport = tpg->tport; 2299 2309 return sprintf(page, "%d\n", tport->max_logins_per_lun); 2300 2310 } 2301 2311 2302 - static ssize_t sbp_tpg_attrib_store_max_logins_per_lun( 2303 - struct se_portal_group *se_tpg, 2304 - const char *page, 2305 - size_t count) 2312 + static ssize_t sbp_tpg_attrib_max_logins_per_lun_store(struct config_item *item, 2313 + const char *page, size_t count) 2306 2314 { 2315 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 2307 2316 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2308 2317 struct sbp_tport *tport = tpg->tport; 2309 2318 unsigned long val; ··· 2319 2330 return count; 2320 2331 } 2321 2332 2322 - TF_TPG_ATTRIB_ATTR(sbp, mgt_orb_timeout, S_IRUGO | S_IWUSR); 2323 - TF_TPG_ATTRIB_ATTR(sbp, max_reconnect_timeout, S_IRUGO | S_IWUSR); 2324 - TF_TPG_ATTRIB_ATTR(sbp, max_logins_per_lun, S_IRUGO | S_IWUSR); 2333 + CONFIGFS_ATTR(sbp_tpg_attrib_, mgt_orb_timeout); 2334 + CONFIGFS_ATTR(sbp_tpg_attrib_, max_reconnect_timeout); 2335 + CONFIGFS_ATTR(sbp_tpg_attrib_, max_logins_per_lun); 2325 2336 2326 2337 static struct configfs_attribute *sbp_tpg_attrib_attrs[] = { 2327 - &sbp_tpg_attrib_mgt_orb_timeout.attr, 2328 - &sbp_tpg_attrib_max_reconnect_timeout.attr, 2329 - &sbp_tpg_attrib_max_logins_per_lun.attr, 2338 + &sbp_tpg_attrib_attr_mgt_orb_timeout, 2339 + &sbp_tpg_attrib_attr_max_reconnect_timeout, 2340 + &sbp_tpg_attrib_attr_max_logins_per_lun, 2330 2341 NULL, 2331 2342 }; 2332 2343
+444 -771
drivers/target/target_core_configfs.c
··· 40 40 #include <target/target_core_base.h> 41 41 #include <target/target_core_backend.h> 42 42 #include <target/target_core_fabric.h> 43 - #include <target/target_core_fabric_configfs.h> 44 - #include <target/configfs_macros.h> 45 43 46 44 #include "target_core_internal.h" 47 45 #include "target_core_alua.h" ··· 76 78 static LIST_HEAD(g_tf_list); 77 79 static DEFINE_MUTEX(g_tf_lock); 78 80 79 - struct target_core_configfs_attribute { 80 - struct configfs_attribute attr; 81 - ssize_t (*show)(void *, char *); 82 - ssize_t (*store)(void *, const char *, size_t); 83 - }; 84 - 85 81 static struct config_group target_core_hbagroup; 86 82 static struct config_group alua_group; 87 83 static struct config_group alua_lu_gps_group; ··· 89 97 /* 90 98 * Attributes for /sys/kernel/config/target/ 91 99 */ 92 - static ssize_t target_core_attr_show(struct config_item *item, 93 - struct configfs_attribute *attr, 94 - char *page) 100 + static ssize_t target_core_item_version_show(struct config_item *item, 101 + char *page) 95 102 { 96 103 return sprintf(page, "Target Engine Core ConfigFS Infrastructure %s" 97 104 " on %s/%s on "UTS_RELEASE"\n", TARGET_CORE_VERSION, 98 105 utsname()->sysname, utsname()->machine); 99 106 } 100 107 101 - static struct configfs_item_operations target_core_fabric_item_ops = { 102 - .show_attribute = target_core_attr_show, 103 - }; 104 - 105 - static struct configfs_attribute target_core_item_attr_version = { 106 - .ca_owner = THIS_MODULE, 107 - .ca_name = "version", 108 - .ca_mode = S_IRUGO, 109 - }; 108 + CONFIGFS_ATTR_RO(target_core_item_, version); 110 109 111 110 static struct target_fabric_configfs *target_core_get_fabric( 112 111 const char *name) ··· 256 273 * Provides Fabrics Groups and Item Attributes for /sys/kernel/config/target/ 257 274 */ 258 275 static struct config_item_type target_core_fabrics_item = { 259 - .ct_item_ops = &target_core_fabric_item_ops, 260 276 .ct_group_ops = &target_core_fabric_group_ops, 261 277 .ct_attrs = target_core_fabric_item_attrs, 262 278 .ct_owner = THIS_MODULE, ··· 458 476 // Stop functions called by external Target Fabrics Modules 459 477 //############################################################################*/ 460 478 461 - /* Start functions for struct config_item_type tb_dev_attrib_cit */ 462 - #define DEF_TB_DEV_ATTRIB_SHOW(_name) \ 463 - static ssize_t show_##_name(struct se_dev_attrib *da, char *page) \ 464 - { \ 465 - return snprintf(page, PAGE_SIZE, "%u\n", da->_name); \ 479 + static inline struct se_dev_attrib *to_attrib(struct config_item *item) 480 + { 481 + return container_of(to_config_group(item), struct se_dev_attrib, 482 + da_group); 466 483 } 467 484 468 - DEF_TB_DEV_ATTRIB_SHOW(emulate_model_alias); 469 - DEF_TB_DEV_ATTRIB_SHOW(emulate_dpo); 470 - DEF_TB_DEV_ATTRIB_SHOW(emulate_fua_write); 471 - DEF_TB_DEV_ATTRIB_SHOW(emulate_fua_read); 472 - DEF_TB_DEV_ATTRIB_SHOW(emulate_write_cache); 473 - DEF_TB_DEV_ATTRIB_SHOW(emulate_ua_intlck_ctrl); 474 - DEF_TB_DEV_ATTRIB_SHOW(emulate_tas); 475 - DEF_TB_DEV_ATTRIB_SHOW(emulate_tpu); 476 - DEF_TB_DEV_ATTRIB_SHOW(emulate_tpws); 477 - DEF_TB_DEV_ATTRIB_SHOW(emulate_caw); 478 - DEF_TB_DEV_ATTRIB_SHOW(emulate_3pc); 479 - DEF_TB_DEV_ATTRIB_SHOW(pi_prot_type); 480 - DEF_TB_DEV_ATTRIB_SHOW(hw_pi_prot_type); 481 - DEF_TB_DEV_ATTRIB_SHOW(pi_prot_format); 482 - DEF_TB_DEV_ATTRIB_SHOW(enforce_pr_isids); 483 - DEF_TB_DEV_ATTRIB_SHOW(is_nonrot); 484 - DEF_TB_DEV_ATTRIB_SHOW(emulate_rest_reord); 485 - DEF_TB_DEV_ATTRIB_SHOW(force_pr_aptpl); 486 - DEF_TB_DEV_ATTRIB_SHOW(hw_block_size); 487 - DEF_TB_DEV_ATTRIB_SHOW(block_size); 488 - DEF_TB_DEV_ATTRIB_SHOW(hw_max_sectors); 489 - DEF_TB_DEV_ATTRIB_SHOW(optimal_sectors); 490 - DEF_TB_DEV_ATTRIB_SHOW(hw_queue_depth); 491 - DEF_TB_DEV_ATTRIB_SHOW(queue_depth); 492 - DEF_TB_DEV_ATTRIB_SHOW(max_unmap_lba_count); 493 - DEF_TB_DEV_ATTRIB_SHOW(max_unmap_block_desc_count); 494 - DEF_TB_DEV_ATTRIB_SHOW(unmap_granularity); 495 - DEF_TB_DEV_ATTRIB_SHOW(unmap_granularity_alignment); 496 - DEF_TB_DEV_ATTRIB_SHOW(max_write_same_len); 485 + /* Start functions for struct config_item_type tb_dev_attrib_cit */ 486 + #define DEF_CONFIGFS_ATTRIB_SHOW(_name) \ 487 + static ssize_t _name##_show(struct config_item *item, char *page) \ 488 + { \ 489 + return snprintf(page, PAGE_SIZE, "%u\n", to_attrib(item)->_name); \ 490 + } 497 491 498 - #define DEF_TB_DEV_ATTRIB_STORE_U32(_name) \ 499 - static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ 492 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_model_alias); 493 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_dpo); 494 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_fua_write); 495 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_fua_read); 496 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_write_cache); 497 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_ua_intlck_ctrl); 498 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_tas); 499 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_tpu); 500 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_tpws); 501 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_caw); 502 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_3pc); 503 + DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_type); 504 + DEF_CONFIGFS_ATTRIB_SHOW(hw_pi_prot_type); 505 + DEF_CONFIGFS_ATTRIB_SHOW(pi_prot_format); 506 + DEF_CONFIGFS_ATTRIB_SHOW(enforce_pr_isids); 507 + DEF_CONFIGFS_ATTRIB_SHOW(is_nonrot); 508 + DEF_CONFIGFS_ATTRIB_SHOW(emulate_rest_reord); 509 + DEF_CONFIGFS_ATTRIB_SHOW(force_pr_aptpl); 510 + DEF_CONFIGFS_ATTRIB_SHOW(hw_block_size); 511 + DEF_CONFIGFS_ATTRIB_SHOW(block_size); 512 + DEF_CONFIGFS_ATTRIB_SHOW(hw_max_sectors); 513 + DEF_CONFIGFS_ATTRIB_SHOW(optimal_sectors); 514 + DEF_CONFIGFS_ATTRIB_SHOW(hw_queue_depth); 515 + DEF_CONFIGFS_ATTRIB_SHOW(queue_depth); 516 + DEF_CONFIGFS_ATTRIB_SHOW(max_unmap_lba_count); 517 + DEF_CONFIGFS_ATTRIB_SHOW(max_unmap_block_desc_count); 518 + DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity); 519 + DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment); 520 + DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len); 521 + 522 + #define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \ 523 + static ssize_t _name##_store(struct config_item *item, const char *page,\ 500 524 size_t count) \ 501 525 { \ 526 + struct se_dev_attrib *da = to_attrib(item); \ 502 527 u32 val; \ 503 528 int ret; \ 504 529 \ ··· 516 527 return count; \ 517 528 } 518 529 519 - DEF_TB_DEV_ATTRIB_STORE_U32(max_unmap_lba_count); 520 - DEF_TB_DEV_ATTRIB_STORE_U32(max_unmap_block_desc_count); 521 - DEF_TB_DEV_ATTRIB_STORE_U32(unmap_granularity); 522 - DEF_TB_DEV_ATTRIB_STORE_U32(unmap_granularity_alignment); 523 - DEF_TB_DEV_ATTRIB_STORE_U32(max_write_same_len); 530 + DEF_CONFIGFS_ATTRIB_STORE_U32(max_unmap_lba_count); 531 + DEF_CONFIGFS_ATTRIB_STORE_U32(max_unmap_block_desc_count); 532 + DEF_CONFIGFS_ATTRIB_STORE_U32(unmap_granularity); 533 + DEF_CONFIGFS_ATTRIB_STORE_U32(unmap_granularity_alignment); 534 + DEF_CONFIGFS_ATTRIB_STORE_U32(max_write_same_len); 524 535 525 - #define DEF_TB_DEV_ATTRIB_STORE_BOOL(_name) \ 526 - static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ 536 + #define DEF_CONFIGFS_ATTRIB_STORE_BOOL(_name) \ 537 + static ssize_t _name##_store(struct config_item *item, const char *page, \ 527 538 size_t count) \ 528 539 { \ 540 + struct se_dev_attrib *da = to_attrib(item); \ 529 541 bool flag; \ 530 542 int ret; \ 531 543 \ ··· 537 547 return count; \ 538 548 } 539 549 540 - DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_fua_write); 541 - DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_caw); 542 - DEF_TB_DEV_ATTRIB_STORE_BOOL(emulate_3pc); 543 - DEF_TB_DEV_ATTRIB_STORE_BOOL(enforce_pr_isids); 544 - DEF_TB_DEV_ATTRIB_STORE_BOOL(is_nonrot); 550 + DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_fua_write); 551 + DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_caw); 552 + DEF_CONFIGFS_ATTRIB_STORE_BOOL(emulate_3pc); 553 + DEF_CONFIGFS_ATTRIB_STORE_BOOL(enforce_pr_isids); 554 + DEF_CONFIGFS_ATTRIB_STORE_BOOL(is_nonrot); 545 555 546 - #define DEF_TB_DEV_ATTRIB_STORE_STUB(_name) \ 547 - static ssize_t store_##_name(struct se_dev_attrib *da, const char *page,\ 556 + #define DEF_CONFIGFS_ATTRIB_STORE_STUB(_name) \ 557 + static ssize_t _name##_store(struct config_item *item, const char *page,\ 548 558 size_t count) \ 549 559 { \ 550 560 printk_once(KERN_WARNING \ ··· 552 562 return count; \ 553 563 } 554 564 555 - DEF_TB_DEV_ATTRIB_STORE_STUB(emulate_dpo); 556 - DEF_TB_DEV_ATTRIB_STORE_STUB(emulate_fua_read); 565 + DEF_CONFIGFS_ATTRIB_STORE_STUB(emulate_dpo); 566 + DEF_CONFIGFS_ATTRIB_STORE_STUB(emulate_fua_read); 557 567 558 568 static void dev_set_t10_wwn_model_alias(struct se_device *dev) 559 569 { ··· 568 578 snprintf(&dev->t10_wwn.model[0], 16, "%s", configname); 569 579 } 570 580 571 - static ssize_t store_emulate_model_alias(struct se_dev_attrib *da, 581 + static ssize_t emulate_model_alias_store(struct config_item *item, 572 582 const char *page, size_t count) 573 583 { 584 + struct se_dev_attrib *da = to_attrib(item); 574 585 struct se_device *dev = da->da_dev; 575 586 bool flag; 576 587 int ret; ··· 597 606 return count; 598 607 } 599 608 600 - static ssize_t store_emulate_write_cache(struct se_dev_attrib *da, 609 + static ssize_t emulate_write_cache_store(struct config_item *item, 601 610 const char *page, size_t count) 602 611 { 612 + struct se_dev_attrib *da = to_attrib(item); 603 613 bool flag; 604 614 int ret; 605 615 ··· 619 627 return count; 620 628 } 621 629 622 - static ssize_t store_emulate_ua_intlck_ctrl(struct se_dev_attrib *da, 630 + static ssize_t emulate_ua_intlck_ctrl_store(struct config_item *item, 623 631 const char *page, size_t count) 624 632 { 633 + struct se_dev_attrib *da = to_attrib(item); 625 634 u32 val; 626 635 int ret; 627 636 ··· 647 654 return count; 648 655 } 649 656 650 - static ssize_t store_emulate_tas(struct se_dev_attrib *da, 657 + static ssize_t emulate_tas_store(struct config_item *item, 651 658 const char *page, size_t count) 652 659 { 660 + struct se_dev_attrib *da = to_attrib(item); 653 661 bool flag; 654 662 int ret; 655 663 ··· 671 677 return count; 672 678 } 673 679 674 - static ssize_t store_emulate_tpu(struct se_dev_attrib *da, 680 + static ssize_t emulate_tpu_store(struct config_item *item, 675 681 const char *page, size_t count) 676 682 { 683 + struct se_dev_attrib *da = to_attrib(item); 677 684 bool flag; 678 685 int ret; 679 686 ··· 697 702 return count; 698 703 } 699 704 700 - static ssize_t store_emulate_tpws(struct se_dev_attrib *da, 705 + static ssize_t emulate_tpws_store(struct config_item *item, 701 706 const char *page, size_t count) 702 707 { 708 + struct se_dev_attrib *da = to_attrib(item); 703 709 bool flag; 704 710 int ret; 705 711 ··· 723 727 return count; 724 728 } 725 729 726 - static ssize_t store_pi_prot_type(struct se_dev_attrib *da, 730 + static ssize_t pi_prot_type_store(struct config_item *item, 727 731 const char *page, size_t count) 728 732 { 733 + struct se_dev_attrib *da = to_attrib(item); 729 734 int old_prot = da->pi_prot_type, ret; 730 735 struct se_device *dev = da->da_dev; 731 736 u32 flag; ··· 784 787 return count; 785 788 } 786 789 787 - static ssize_t store_pi_prot_format(struct se_dev_attrib *da, 790 + static ssize_t pi_prot_format_store(struct config_item *item, 788 791 const char *page, size_t count) 789 792 { 793 + struct se_dev_attrib *da = to_attrib(item); 790 794 struct se_device *dev = da->da_dev; 791 795 bool flag; 792 796 int ret; ··· 822 824 return count; 823 825 } 824 826 825 - static ssize_t store_force_pr_aptpl(struct se_dev_attrib *da, 827 + static ssize_t force_pr_aptpl_store(struct config_item *item, 826 828 const char *page, size_t count) 827 829 { 830 + struct se_dev_attrib *da = to_attrib(item); 828 831 bool flag; 829 832 int ret; 830 833 ··· 844 845 return count; 845 846 } 846 847 847 - static ssize_t store_emulate_rest_reord(struct se_dev_attrib *da, 848 + static ssize_t emulate_rest_reord_store(struct config_item *item, 848 849 const char *page, size_t count) 849 850 { 851 + struct se_dev_attrib *da = to_attrib(item); 850 852 bool flag; 851 853 int ret; 852 854 ··· 869 869 /* 870 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 873 const char *page, size_t count) 874 874 { 875 + struct se_dev_attrib *da = to_attrib(item); 875 876 struct se_device *dev = da->da_dev; 876 877 u32 val; 877 878 int ret; ··· 906 905 return count; 907 906 } 908 907 909 - static ssize_t store_optimal_sectors(struct se_dev_attrib *da, 908 + static ssize_t optimal_sectors_store(struct config_item *item, 910 909 const char *page, size_t count) 911 910 { 911 + struct se_dev_attrib *da = to_attrib(item); 912 912 u32 val; 913 913 int ret; 914 914 ··· 936 934 return count; 937 935 } 938 936 939 - static ssize_t store_block_size(struct se_dev_attrib *da, 937 + static ssize_t block_size_store(struct config_item *item, 940 938 const char *page, size_t count) 941 939 { 940 + struct se_dev_attrib *da = to_attrib(item); 942 941 u32 val; 943 942 int ret; 944 943 ··· 970 967 return count; 971 968 } 972 969 973 - CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib); 974 - #define TB_DEV_ATTR(_backend, _name, _mode) \ 975 - static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ 976 - __CONFIGFS_EATTR(_name, _mode, \ 977 - show_##_name, \ 978 - store_##_name); 979 - 980 - #define TB_DEV_ATTR_RO(_backend, _name) \ 981 - static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ 982 - __CONFIGFS_EATTR_RO(_name, \ 983 - show_##_name); 984 - 985 - TB_DEV_ATTR(target_core, emulate_model_alias, S_IRUGO | S_IWUSR); 986 - TB_DEV_ATTR(target_core, emulate_dpo, S_IRUGO | S_IWUSR); 987 - TB_DEV_ATTR(target_core, emulate_fua_write, S_IRUGO | S_IWUSR); 988 - TB_DEV_ATTR(target_core, emulate_fua_read, S_IRUGO | S_IWUSR); 989 - TB_DEV_ATTR(target_core, emulate_write_cache, S_IRUGO | S_IWUSR); 990 - TB_DEV_ATTR(target_core, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); 991 - TB_DEV_ATTR(target_core, emulate_tas, S_IRUGO | S_IWUSR); 992 - TB_DEV_ATTR(target_core, emulate_tpu, S_IRUGO | S_IWUSR); 993 - TB_DEV_ATTR(target_core, emulate_tpws, S_IRUGO | S_IWUSR); 994 - TB_DEV_ATTR(target_core, emulate_caw, S_IRUGO | S_IWUSR); 995 - TB_DEV_ATTR(target_core, emulate_3pc, S_IRUGO | S_IWUSR); 996 - TB_DEV_ATTR(target_core, pi_prot_type, S_IRUGO | S_IWUSR); 997 - TB_DEV_ATTR_RO(target_core, hw_pi_prot_type); 998 - TB_DEV_ATTR(target_core, pi_prot_format, S_IRUGO | S_IWUSR); 999 - TB_DEV_ATTR(target_core, enforce_pr_isids, S_IRUGO | S_IWUSR); 1000 - TB_DEV_ATTR(target_core, is_nonrot, S_IRUGO | S_IWUSR); 1001 - TB_DEV_ATTR(target_core, emulate_rest_reord, S_IRUGO | S_IWUSR); 1002 - TB_DEV_ATTR(target_core, force_pr_aptpl, S_IRUGO | S_IWUSR) 1003 - TB_DEV_ATTR_RO(target_core, hw_block_size); 1004 - TB_DEV_ATTR(target_core, block_size, S_IRUGO | S_IWUSR) 1005 - TB_DEV_ATTR_RO(target_core, hw_max_sectors); 1006 - TB_DEV_ATTR(target_core, optimal_sectors, S_IRUGO | S_IWUSR); 1007 - TB_DEV_ATTR_RO(target_core, hw_queue_depth); 1008 - TB_DEV_ATTR(target_core, queue_depth, S_IRUGO | S_IWUSR); 1009 - TB_DEV_ATTR(target_core, max_unmap_lba_count, S_IRUGO | S_IWUSR); 1010 - TB_DEV_ATTR(target_core, max_unmap_block_desc_count, S_IRUGO | S_IWUSR); 1011 - TB_DEV_ATTR(target_core, unmap_granularity, S_IRUGO | S_IWUSR); 1012 - TB_DEV_ATTR(target_core, unmap_granularity_alignment, S_IRUGO | S_IWUSR); 1013 - TB_DEV_ATTR(target_core, max_write_same_len, S_IRUGO | S_IWUSR); 1014 - 1015 - CONFIGFS_EATTR_STRUCT(target_core_dev_attrib, se_dev_attrib); 1016 - CONFIGFS_EATTR_OPS(target_core_dev_attrib, se_dev_attrib, da_group); 970 + CONFIGFS_ATTR(, emulate_model_alias); 971 + CONFIGFS_ATTR(, emulate_dpo); 972 + CONFIGFS_ATTR(, emulate_fua_write); 973 + CONFIGFS_ATTR(, emulate_fua_read); 974 + CONFIGFS_ATTR(, emulate_write_cache); 975 + CONFIGFS_ATTR(, emulate_ua_intlck_ctrl); 976 + CONFIGFS_ATTR(, emulate_tas); 977 + CONFIGFS_ATTR(, emulate_tpu); 978 + CONFIGFS_ATTR(, emulate_tpws); 979 + CONFIGFS_ATTR(, emulate_caw); 980 + CONFIGFS_ATTR(, emulate_3pc); 981 + CONFIGFS_ATTR(, pi_prot_type); 982 + CONFIGFS_ATTR_RO(, hw_pi_prot_type); 983 + CONFIGFS_ATTR(, pi_prot_format); 984 + CONFIGFS_ATTR(, enforce_pr_isids); 985 + CONFIGFS_ATTR(, is_nonrot); 986 + CONFIGFS_ATTR(, emulate_rest_reord); 987 + CONFIGFS_ATTR(, force_pr_aptpl); 988 + CONFIGFS_ATTR_RO(, hw_block_size); 989 + CONFIGFS_ATTR(, block_size); 990 + CONFIGFS_ATTR_RO(, hw_max_sectors); 991 + CONFIGFS_ATTR(, optimal_sectors); 992 + CONFIGFS_ATTR_RO(, hw_queue_depth); 993 + CONFIGFS_ATTR(, queue_depth); 994 + CONFIGFS_ATTR(, max_unmap_lba_count); 995 + CONFIGFS_ATTR(, max_unmap_block_desc_count); 996 + CONFIGFS_ATTR(, unmap_granularity); 997 + CONFIGFS_ATTR(, unmap_granularity_alignment); 998 + CONFIGFS_ATTR(, max_write_same_len); 1017 999 1018 1000 /* 1019 1001 * dev_attrib attributes for devices using the target core SBC/SPC ··· 1006 1018 * these. 1007 1019 */ 1008 1020 struct configfs_attribute *sbc_attrib_attrs[] = { 1009 - &target_core_dev_attrib_emulate_model_alias.attr, 1010 - &target_core_dev_attrib_emulate_dpo.attr, 1011 - &target_core_dev_attrib_emulate_fua_write.attr, 1012 - &target_core_dev_attrib_emulate_fua_read.attr, 1013 - &target_core_dev_attrib_emulate_write_cache.attr, 1014 - &target_core_dev_attrib_emulate_ua_intlck_ctrl.attr, 1015 - &target_core_dev_attrib_emulate_tas.attr, 1016 - &target_core_dev_attrib_emulate_tpu.attr, 1017 - &target_core_dev_attrib_emulate_tpws.attr, 1018 - &target_core_dev_attrib_emulate_caw.attr, 1019 - &target_core_dev_attrib_emulate_3pc.attr, 1020 - &target_core_dev_attrib_pi_prot_type.attr, 1021 - &target_core_dev_attrib_hw_pi_prot_type.attr, 1022 - &target_core_dev_attrib_pi_prot_format.attr, 1023 - &target_core_dev_attrib_enforce_pr_isids.attr, 1024 - &target_core_dev_attrib_is_nonrot.attr, 1025 - &target_core_dev_attrib_emulate_rest_reord.attr, 1026 - &target_core_dev_attrib_force_pr_aptpl.attr, 1027 - &target_core_dev_attrib_hw_block_size.attr, 1028 - &target_core_dev_attrib_block_size.attr, 1029 - &target_core_dev_attrib_hw_max_sectors.attr, 1030 - &target_core_dev_attrib_optimal_sectors.attr, 1031 - &target_core_dev_attrib_hw_queue_depth.attr, 1032 - &target_core_dev_attrib_queue_depth.attr, 1033 - &target_core_dev_attrib_max_unmap_lba_count.attr, 1034 - &target_core_dev_attrib_max_unmap_block_desc_count.attr, 1035 - &target_core_dev_attrib_unmap_granularity.attr, 1036 - &target_core_dev_attrib_unmap_granularity_alignment.attr, 1037 - &target_core_dev_attrib_max_write_same_len.attr, 1021 + &attr_emulate_model_alias, 1022 + &attr_emulate_dpo, 1023 + &attr_emulate_fua_write, 1024 + &attr_emulate_fua_read, 1025 + &attr_emulate_write_cache, 1026 + &attr_emulate_ua_intlck_ctrl, 1027 + &attr_emulate_tas, 1028 + &attr_emulate_tpu, 1029 + &attr_emulate_tpws, 1030 + &attr_emulate_caw, 1031 + &attr_emulate_3pc, 1032 + &attr_pi_prot_type, 1033 + &attr_hw_pi_prot_type, 1034 + &attr_pi_prot_format, 1035 + &attr_enforce_pr_isids, 1036 + &attr_is_nonrot, 1037 + &attr_emulate_rest_reord, 1038 + &attr_force_pr_aptpl, 1039 + &attr_hw_block_size, 1040 + &attr_block_size, 1041 + &attr_hw_max_sectors, 1042 + &attr_optimal_sectors, 1043 + &attr_hw_queue_depth, 1044 + &attr_queue_depth, 1045 + &attr_max_unmap_lba_count, 1046 + &attr_max_unmap_block_desc_count, 1047 + &attr_unmap_granularity, 1048 + &attr_unmap_granularity_alignment, 1049 + &attr_max_write_same_len, 1038 1050 NULL, 1039 1051 }; 1040 1052 EXPORT_SYMBOL(sbc_attrib_attrs); 1041 - 1042 - TB_DEV_ATTR_RO(target_pt, hw_pi_prot_type); 1043 - TB_DEV_ATTR_RO(target_pt, hw_block_size); 1044 - TB_DEV_ATTR_RO(target_pt, hw_max_sectors); 1045 - TB_DEV_ATTR_RO(target_pt, hw_queue_depth); 1046 1053 1047 1054 /* 1048 1055 * Minimal dev_attrib attributes for devices passing through CDBs. ··· 1045 1062 * backwards compatibility. 1046 1063 */ 1047 1064 struct configfs_attribute *passthrough_attrib_attrs[] = { 1048 - &target_pt_dev_attrib_hw_pi_prot_type.attr, 1049 - &target_pt_dev_attrib_hw_block_size.attr, 1050 - &target_pt_dev_attrib_hw_max_sectors.attr, 1051 - &target_pt_dev_attrib_hw_queue_depth.attr, 1065 + &attr_hw_pi_prot_type, 1066 + &attr_hw_block_size, 1067 + &attr_hw_max_sectors, 1068 + &attr_hw_queue_depth, 1052 1069 NULL, 1053 1070 }; 1054 1071 EXPORT_SYMBOL(passthrough_attrib_attrs); 1055 1072 1056 - static struct configfs_item_operations target_core_dev_attrib_ops = { 1057 - .show_attribute = target_core_dev_attrib_attr_show, 1058 - .store_attribute = target_core_dev_attrib_attr_store, 1059 - }; 1060 - 1061 - TB_CIT_SETUP_DRV(dev_attrib, &target_core_dev_attrib_ops, NULL); 1073 + TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL); 1062 1074 1063 1075 /* End functions for struct config_item_type tb_dev_attrib_cit */ 1064 1076 1065 1077 /* Start functions for struct config_item_type tb_dev_wwn_cit */ 1066 1078 1067 - CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn); 1068 - #define SE_DEV_WWN_ATTR(_name, _mode) \ 1069 - static struct target_core_dev_wwn_attribute target_core_dev_wwn_##_name = \ 1070 - __CONFIGFS_EATTR(_name, _mode, \ 1071 - target_core_dev_wwn_show_attr_##_name, \ 1072 - target_core_dev_wwn_store_attr_##_name); 1073 - 1074 - #define SE_DEV_WWN_ATTR_RO(_name); \ 1075 - do { \ 1076 - static struct target_core_dev_wwn_attribute \ 1077 - target_core_dev_wwn_##_name = \ 1078 - __CONFIGFS_EATTR_RO(_name, \ 1079 - target_core_dev_wwn_show_attr_##_name); \ 1080 - } while (0); 1079 + static struct t10_wwn *to_t10_wwn(struct config_item *item) 1080 + { 1081 + return container_of(to_config_group(item), struct t10_wwn, t10_wwn_group); 1082 + } 1081 1083 1082 1084 /* 1083 1085 * VPD page 0x80 Unit serial 1084 1086 */ 1085 - static ssize_t target_core_dev_wwn_show_attr_vpd_unit_serial( 1086 - struct t10_wwn *t10_wwn, 1087 - char *page) 1087 + static ssize_t target_wwn_vpd_unit_serial_show(struct config_item *item, 1088 + char *page) 1088 1089 { 1089 1090 return sprintf(page, "T10 VPD Unit Serial Number: %s\n", 1090 - &t10_wwn->unit_serial[0]); 1091 + &to_t10_wwn(item)->unit_serial[0]); 1091 1092 } 1092 1093 1093 - static ssize_t target_core_dev_wwn_store_attr_vpd_unit_serial( 1094 - struct t10_wwn *t10_wwn, 1095 - const char *page, 1096 - size_t count) 1094 + static ssize_t target_wwn_vpd_unit_serial_store(struct config_item *item, 1095 + const char *page, size_t count) 1097 1096 { 1097 + struct t10_wwn *t10_wwn = to_t10_wwn(item); 1098 1098 struct se_device *dev = t10_wwn->t10_dev; 1099 1099 unsigned char buf[INQUIRY_VPD_SERIAL_LEN]; 1100 1100 ··· 1133 1167 return count; 1134 1168 } 1135 1169 1136 - SE_DEV_WWN_ATTR(vpd_unit_serial, S_IRUGO | S_IWUSR); 1137 - 1138 1170 /* 1139 1171 * VPD page 0x83 Protocol Identifier 1140 1172 */ 1141 - static ssize_t target_core_dev_wwn_show_attr_vpd_protocol_identifier( 1142 - struct t10_wwn *t10_wwn, 1143 - char *page) 1173 + static ssize_t target_wwn_vpd_protocol_identifier_show(struct config_item *item, 1174 + char *page) 1144 1175 { 1176 + struct t10_wwn *t10_wwn = to_t10_wwn(item); 1145 1177 struct t10_vpd *vpd; 1146 1178 unsigned char buf[VPD_TMP_BUF_SIZE]; 1147 1179 ssize_t len = 0; ··· 1163 1199 return len; 1164 1200 } 1165 1201 1166 - static ssize_t target_core_dev_wwn_store_attr_vpd_protocol_identifier( 1167 - struct t10_wwn *t10_wwn, 1168 - const char *page, 1169 - size_t count) 1170 - { 1171 - return -ENOSYS; 1172 - } 1173 - 1174 - SE_DEV_WWN_ATTR(vpd_protocol_identifier, S_IRUGO | S_IWUSR); 1175 - 1176 1202 /* 1177 1203 * Generic wrapper for dumping VPD identifiers by association. 1178 1204 */ 1179 1205 #define DEF_DEV_WWN_ASSOC_SHOW(_name, _assoc) \ 1180 - static ssize_t target_core_dev_wwn_show_attr_##_name( \ 1181 - struct t10_wwn *t10_wwn, \ 1182 - char *page) \ 1206 + static ssize_t target_wwn_##_name##_show(struct config_item *item, \ 1207 + char *page) \ 1183 1208 { \ 1184 - struct t10_vpd *vpd; \ 1209 + struct t10_wwn *t10_wwn = to_t10_wwn(item); \ 1210 + struct t10_vpd *vpd; \ 1185 1211 unsigned char buf[VPD_TMP_BUF_SIZE]; \ 1186 1212 ssize_t len = 0; \ 1187 1213 \ ··· 1203 1249 return len; \ 1204 1250 } 1205 1251 1206 - /* 1207 - * VPD page 0x83 Association: Logical Unit 1208 - */ 1252 + /* VPD page 0x83 Association: Logical Unit */ 1209 1253 DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_logical_unit, 0x00); 1210 - 1211 - static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_logical_unit( 1212 - struct t10_wwn *t10_wwn, 1213 - const char *page, 1214 - size_t count) 1215 - { 1216 - return -ENOSYS; 1217 - } 1218 - 1219 - SE_DEV_WWN_ATTR(vpd_assoc_logical_unit, S_IRUGO | S_IWUSR); 1220 - 1221 - /* 1222 - * VPD page 0x83 Association: Target Port 1223 - */ 1254 + /* VPD page 0x83 Association: Target Port */ 1224 1255 DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_target_port, 0x10); 1225 - 1226 - static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_target_port( 1227 - struct t10_wwn *t10_wwn, 1228 - const char *page, 1229 - size_t count) 1230 - { 1231 - return -ENOSYS; 1232 - } 1233 - 1234 - SE_DEV_WWN_ATTR(vpd_assoc_target_port, S_IRUGO | S_IWUSR); 1235 - 1236 - /* 1237 - * VPD page 0x83 Association: SCSI Target Device 1238 - */ 1256 + /* VPD page 0x83 Association: SCSI Target Device */ 1239 1257 DEF_DEV_WWN_ASSOC_SHOW(vpd_assoc_scsi_target_device, 0x20); 1240 1258 1241 - static ssize_t target_core_dev_wwn_store_attr_vpd_assoc_scsi_target_device( 1242 - struct t10_wwn *t10_wwn, 1243 - const char *page, 1244 - size_t count) 1245 - { 1246 - return -ENOSYS; 1247 - } 1248 - 1249 - SE_DEV_WWN_ATTR(vpd_assoc_scsi_target_device, S_IRUGO | S_IWUSR); 1250 - 1251 - CONFIGFS_EATTR_OPS(target_core_dev_wwn, t10_wwn, t10_wwn_group); 1259 + CONFIGFS_ATTR(target_wwn_, vpd_unit_serial); 1260 + CONFIGFS_ATTR_RO(target_wwn_, vpd_protocol_identifier); 1261 + CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_logical_unit); 1262 + CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_target_port); 1263 + CONFIGFS_ATTR_RO(target_wwn_, vpd_assoc_scsi_target_device); 1252 1264 1253 1265 static struct configfs_attribute *target_core_dev_wwn_attrs[] = { 1254 - &target_core_dev_wwn_vpd_unit_serial.attr, 1255 - &target_core_dev_wwn_vpd_protocol_identifier.attr, 1256 - &target_core_dev_wwn_vpd_assoc_logical_unit.attr, 1257 - &target_core_dev_wwn_vpd_assoc_target_port.attr, 1258 - &target_core_dev_wwn_vpd_assoc_scsi_target_device.attr, 1266 + &target_wwn_attr_vpd_unit_serial, 1267 + &target_wwn_attr_vpd_protocol_identifier, 1268 + &target_wwn_attr_vpd_assoc_logical_unit, 1269 + &target_wwn_attr_vpd_assoc_target_port, 1270 + &target_wwn_attr_vpd_assoc_scsi_target_device, 1259 1271 NULL, 1260 1272 }; 1261 1273 1262 - static struct configfs_item_operations target_core_dev_wwn_ops = { 1263 - .show_attribute = target_core_dev_wwn_attr_show, 1264 - .store_attribute = target_core_dev_wwn_attr_store, 1265 - }; 1266 - 1267 - TB_CIT_SETUP(dev_wwn, &target_core_dev_wwn_ops, NULL, target_core_dev_wwn_attrs); 1274 + TB_CIT_SETUP(dev_wwn, NULL, NULL, target_core_dev_wwn_attrs); 1268 1275 1269 1276 /* End functions for struct config_item_type tb_dev_wwn_cit */ 1270 1277 1271 1278 /* Start functions for struct config_item_type tb_dev_pr_cit */ 1272 1279 1273 - CONFIGFS_EATTR_STRUCT(target_core_dev_pr, se_device); 1274 - #define SE_DEV_PR_ATTR(_name, _mode) \ 1275 - static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ 1276 - __CONFIGFS_EATTR(_name, _mode, \ 1277 - target_core_dev_pr_show_attr_##_name, \ 1278 - target_core_dev_pr_store_attr_##_name); 1279 - 1280 - #define SE_DEV_PR_ATTR_RO(_name); \ 1281 - static struct target_core_dev_pr_attribute target_core_dev_pr_##_name = \ 1282 - __CONFIGFS_EATTR_RO(_name, \ 1283 - target_core_dev_pr_show_attr_##_name); 1280 + static struct se_device *pr_to_dev(struct config_item *item) 1281 + { 1282 + return container_of(to_config_group(item), struct se_device, 1283 + dev_pr_group); 1284 + } 1284 1285 1285 1286 static ssize_t target_core_dev_pr_show_spc3_res(struct se_device *dev, 1286 1287 char *page) ··· 1276 1367 return len; 1277 1368 } 1278 1369 1279 - static ssize_t target_core_dev_pr_show_attr_res_holder(struct se_device *dev, 1280 - char *page) 1370 + static ssize_t target_pr_res_holder_show(struct config_item *item, char *page) 1281 1371 { 1372 + struct se_device *dev = pr_to_dev(item); 1282 1373 int ret; 1283 1374 1284 1375 if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) ··· 1293 1384 return ret; 1294 1385 } 1295 1386 1296 - SE_DEV_PR_ATTR_RO(res_holder); 1297 - 1298 - static ssize_t target_core_dev_pr_show_attr_res_pr_all_tgt_pts( 1299 - struct se_device *dev, char *page) 1387 + static ssize_t target_pr_res_pr_all_tgt_pts_show(struct config_item *item, 1388 + char *page) 1300 1389 { 1390 + struct se_device *dev = pr_to_dev(item); 1301 1391 ssize_t len = 0; 1302 1392 1303 1393 spin_lock(&dev->dev_reservation_lock); ··· 1314 1406 return len; 1315 1407 } 1316 1408 1317 - SE_DEV_PR_ATTR_RO(res_pr_all_tgt_pts); 1318 - 1319 - static ssize_t target_core_dev_pr_show_attr_res_pr_generation( 1320 - struct se_device *dev, char *page) 1409 + static ssize_t target_pr_res_pr_generation_show(struct config_item *item, 1410 + char *page) 1321 1411 { 1322 - return sprintf(page, "0x%08x\n", dev->t10_pr.pr_generation); 1412 + return sprintf(page, "0x%08x\n", pr_to_dev(item)->t10_pr.pr_generation); 1323 1413 } 1324 1414 1325 - SE_DEV_PR_ATTR_RO(res_pr_generation); 1326 1415 1327 - /* 1328 - * res_pr_holder_tg_port 1329 - */ 1330 - static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port( 1331 - struct se_device *dev, char *page) 1416 + static ssize_t target_pr_res_pr_holder_tg_port_show(struct config_item *item, 1417 + char *page) 1332 1418 { 1419 + struct se_device *dev = pr_to_dev(item); 1333 1420 struct se_node_acl *se_nacl; 1334 1421 struct se_portal_group *se_tpg; 1335 1422 struct t10_pr_registration *pr_reg; ··· 1356 1453 return len; 1357 1454 } 1358 1455 1359 - SE_DEV_PR_ATTR_RO(res_pr_holder_tg_port); 1360 1456 1361 - static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts( 1362 - struct se_device *dev, char *page) 1457 + static ssize_t target_pr_res_pr_registered_i_pts_show(struct config_item *item, 1458 + char *page) 1363 1459 { 1460 + struct se_device *dev = pr_to_dev(item); 1364 1461 const struct target_core_fabric_ops *tfo; 1365 1462 struct t10_pr_registration *pr_reg; 1366 1463 unsigned char buf[384]; ··· 1398 1495 return len; 1399 1496 } 1400 1497 1401 - SE_DEV_PR_ATTR_RO(res_pr_registered_i_pts); 1402 - 1403 - static ssize_t target_core_dev_pr_show_attr_res_pr_type( 1404 - struct se_device *dev, char *page) 1498 + static ssize_t target_pr_res_pr_type_show(struct config_item *item, char *page) 1405 1499 { 1500 + struct se_device *dev = pr_to_dev(item); 1406 1501 struct t10_pr_registration *pr_reg; 1407 1502 ssize_t len = 0; 1408 1503 ··· 1417 1516 return len; 1418 1517 } 1419 1518 1420 - SE_DEV_PR_ATTR_RO(res_pr_type); 1421 - 1422 - static ssize_t target_core_dev_pr_show_attr_res_type( 1423 - struct se_device *dev, char *page) 1519 + static ssize_t target_pr_res_type_show(struct config_item *item, char *page) 1424 1520 { 1521 + struct se_device *dev = pr_to_dev(item); 1522 + 1425 1523 if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1426 1524 return sprintf(page, "SPC_PASSTHROUGH\n"); 1427 1525 else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS) ··· 1429 1529 return sprintf(page, "SPC3_PERSISTENT_RESERVATIONS\n"); 1430 1530 } 1431 1531 1432 - SE_DEV_PR_ATTR_RO(res_type); 1433 - 1434 - static ssize_t target_core_dev_pr_show_attr_res_aptpl_active( 1435 - struct se_device *dev, char *page) 1532 + static ssize_t target_pr_res_aptpl_active_show(struct config_item *item, 1533 + char *page) 1436 1534 { 1535 + struct se_device *dev = pr_to_dev(item); 1536 + 1437 1537 if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1438 1538 return 0; 1439 1539 ··· 1441 1541 (dev->t10_pr.pr_aptpl_active) ? "Activated" : "Disabled"); 1442 1542 } 1443 1543 1444 - SE_DEV_PR_ATTR_RO(res_aptpl_active); 1445 - 1446 - /* 1447 - * res_aptpl_metadata 1448 - */ 1449 - static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata( 1450 - struct se_device *dev, char *page) 1544 + static ssize_t target_pr_res_aptpl_metadata_show(struct config_item *item, 1545 + char *page) 1451 1546 { 1547 + struct se_device *dev = pr_to_dev(item); 1548 + 1452 1549 if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH) 1453 1550 return 0; 1454 1551 ··· 1477 1580 {Opt_err, NULL} 1478 1581 }; 1479 1582 1480 - static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata( 1481 - struct se_device *dev, 1482 - const char *page, 1483 - size_t count) 1583 + static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, 1584 + const char *page, size_t count) 1484 1585 { 1586 + struct se_device *dev = pr_to_dev(item); 1485 1587 unsigned char *i_fabric = NULL, *i_port = NULL, *isid = NULL; 1486 1588 unsigned char *t_fabric = NULL, *t_port = NULL; 1487 1589 char *orig, *ptr, *opts; ··· 1661 1765 return (ret == 0) ? count : ret; 1662 1766 } 1663 1767 1664 - SE_DEV_PR_ATTR(res_aptpl_metadata, S_IRUGO | S_IWUSR); 1665 1768 1666 - CONFIGFS_EATTR_OPS(target_core_dev_pr, se_device, dev_pr_group); 1769 + CONFIGFS_ATTR_RO(target_pr_, res_holder); 1770 + CONFIGFS_ATTR_RO(target_pr_, res_pr_all_tgt_pts); 1771 + CONFIGFS_ATTR_RO(target_pr_, res_pr_generation); 1772 + CONFIGFS_ATTR_RO(target_pr_, res_pr_holder_tg_port); 1773 + CONFIGFS_ATTR_RO(target_pr_, res_pr_registered_i_pts); 1774 + CONFIGFS_ATTR_RO(target_pr_, res_pr_type); 1775 + CONFIGFS_ATTR_RO(target_pr_, res_type); 1776 + CONFIGFS_ATTR_RO(target_pr_, res_aptpl_active); 1777 + CONFIGFS_ATTR(target_pr_, res_aptpl_metadata); 1667 1778 1668 1779 static struct configfs_attribute *target_core_dev_pr_attrs[] = { 1669 - &target_core_dev_pr_res_holder.attr, 1670 - &target_core_dev_pr_res_pr_all_tgt_pts.attr, 1671 - &target_core_dev_pr_res_pr_generation.attr, 1672 - &target_core_dev_pr_res_pr_holder_tg_port.attr, 1673 - &target_core_dev_pr_res_pr_registered_i_pts.attr, 1674 - &target_core_dev_pr_res_pr_type.attr, 1675 - &target_core_dev_pr_res_type.attr, 1676 - &target_core_dev_pr_res_aptpl_active.attr, 1677 - &target_core_dev_pr_res_aptpl_metadata.attr, 1780 + &target_pr_attr_res_holder, 1781 + &target_pr_attr_res_pr_all_tgt_pts, 1782 + &target_pr_attr_res_pr_generation, 1783 + &target_pr_attr_res_pr_holder_tg_port, 1784 + &target_pr_attr_res_pr_registered_i_pts, 1785 + &target_pr_attr_res_pr_type, 1786 + &target_pr_attr_res_type, 1787 + &target_pr_attr_res_aptpl_active, 1788 + &target_pr_attr_res_aptpl_metadata, 1678 1789 NULL, 1679 1790 }; 1680 1791 1681 - static struct configfs_item_operations target_core_dev_pr_ops = { 1682 - .show_attribute = target_core_dev_pr_attr_show, 1683 - .store_attribute = target_core_dev_pr_attr_store, 1684 - }; 1685 - 1686 - TB_CIT_SETUP(dev_pr, &target_core_dev_pr_ops, NULL, target_core_dev_pr_attrs); 1792 + TB_CIT_SETUP(dev_pr, NULL, NULL, target_core_dev_pr_attrs); 1687 1793 1688 1794 /* End functions for struct config_item_type tb_dev_pr_cit */ 1689 1795 1690 1796 /* Start functions for struct config_item_type tb_dev_cit */ 1691 1797 1692 - static ssize_t target_core_show_dev_info(void *p, char *page) 1798 + static inline struct se_device *to_device(struct config_item *item) 1693 1799 { 1694 - struct se_device *dev = p; 1800 + return container_of(to_config_group(item), struct se_device, dev_group); 1801 + } 1802 + 1803 + static ssize_t target_dev_info_show(struct config_item *item, char *page) 1804 + { 1805 + struct se_device *dev = to_device(item); 1695 1806 int bl = 0; 1696 1807 ssize_t read_bytes = 0; 1697 1808 ··· 1709 1806 return read_bytes; 1710 1807 } 1711 1808 1712 - static struct target_core_configfs_attribute target_core_attr_dev_info = { 1713 - .attr = { .ca_owner = THIS_MODULE, 1714 - .ca_name = "info", 1715 - .ca_mode = S_IRUGO }, 1716 - .show = target_core_show_dev_info, 1717 - .store = NULL, 1718 - }; 1719 - 1720 - static ssize_t target_core_store_dev_control( 1721 - void *p, 1722 - const char *page, 1723 - size_t count) 1809 + static ssize_t target_dev_control_store(struct config_item *item, 1810 + const char *page, size_t count) 1724 1811 { 1725 - struct se_device *dev = p; 1812 + struct se_device *dev = to_device(item); 1726 1813 1727 1814 return dev->transport->set_configfs_dev_params(dev, page, count); 1728 1815 } 1729 1816 1730 - static struct target_core_configfs_attribute target_core_attr_dev_control = { 1731 - .attr = { .ca_owner = THIS_MODULE, 1732 - .ca_name = "control", 1733 - .ca_mode = S_IWUSR }, 1734 - .show = NULL, 1735 - .store = target_core_store_dev_control, 1736 - }; 1737 - 1738 - static ssize_t target_core_show_dev_alias(void *p, char *page) 1817 + static ssize_t target_dev_alias_show(struct config_item *item, char *page) 1739 1818 { 1740 - struct se_device *dev = p; 1819 + struct se_device *dev = to_device(item); 1741 1820 1742 1821 if (!(dev->dev_flags & DF_USING_ALIAS)) 1743 1822 return 0; ··· 1727 1842 return snprintf(page, PAGE_SIZE, "%s\n", dev->dev_alias); 1728 1843 } 1729 1844 1730 - static ssize_t target_core_store_dev_alias( 1731 - void *p, 1732 - const char *page, 1733 - size_t count) 1845 + static ssize_t target_dev_alias_store(struct config_item *item, 1846 + const char *page, size_t count) 1734 1847 { 1735 - struct se_device *dev = p; 1848 + struct se_device *dev = to_device(item); 1736 1849 struct se_hba *hba = dev->se_hba; 1737 1850 ssize_t read_bytes; 1738 1851 ··· 1757 1874 return read_bytes; 1758 1875 } 1759 1876 1760 - static struct target_core_configfs_attribute target_core_attr_dev_alias = { 1761 - .attr = { .ca_owner = THIS_MODULE, 1762 - .ca_name = "alias", 1763 - .ca_mode = S_IRUGO | S_IWUSR }, 1764 - .show = target_core_show_dev_alias, 1765 - .store = target_core_store_dev_alias, 1766 - }; 1767 - 1768 - static ssize_t target_core_show_dev_udev_path(void *p, char *page) 1877 + static ssize_t target_dev_udev_path_show(struct config_item *item, char *page) 1769 1878 { 1770 - struct se_device *dev = p; 1879 + struct se_device *dev = to_device(item); 1771 1880 1772 1881 if (!(dev->dev_flags & DF_USING_UDEV_PATH)) 1773 1882 return 0; ··· 1767 1892 return snprintf(page, PAGE_SIZE, "%s\n", dev->udev_path); 1768 1893 } 1769 1894 1770 - static ssize_t target_core_store_dev_udev_path( 1771 - void *p, 1772 - const char *page, 1773 - size_t count) 1895 + static ssize_t target_dev_udev_path_store(struct config_item *item, 1896 + const char *page, size_t count) 1774 1897 { 1775 - struct se_device *dev = p; 1898 + struct se_device *dev = to_device(item); 1776 1899 struct se_hba *hba = dev->se_hba; 1777 1900 ssize_t read_bytes; 1778 1901 ··· 1798 1925 return read_bytes; 1799 1926 } 1800 1927 1801 - static struct target_core_configfs_attribute target_core_attr_dev_udev_path = { 1802 - .attr = { .ca_owner = THIS_MODULE, 1803 - .ca_name = "udev_path", 1804 - .ca_mode = S_IRUGO | S_IWUSR }, 1805 - .show = target_core_show_dev_udev_path, 1806 - .store = target_core_store_dev_udev_path, 1807 - }; 1808 - 1809 - static ssize_t target_core_show_dev_enable(void *p, char *page) 1928 + static ssize_t target_dev_enable_show(struct config_item *item, char *page) 1810 1929 { 1811 - struct se_device *dev = p; 1930 + struct se_device *dev = to_device(item); 1812 1931 1813 1932 return snprintf(page, PAGE_SIZE, "%d\n", !!(dev->dev_flags & DF_CONFIGURED)); 1814 1933 } 1815 1934 1816 - static ssize_t target_core_store_dev_enable( 1817 - void *p, 1818 - const char *page, 1819 - size_t count) 1935 + static ssize_t target_dev_enable_store(struct config_item *item, 1936 + const char *page, size_t count) 1820 1937 { 1821 - struct se_device *dev = p; 1938 + struct se_device *dev = to_device(item); 1822 1939 char *ptr; 1823 1940 int ret; 1824 1941 ··· 1825 1962 return count; 1826 1963 } 1827 1964 1828 - static struct target_core_configfs_attribute target_core_attr_dev_enable = { 1829 - .attr = { .ca_owner = THIS_MODULE, 1830 - .ca_name = "enable", 1831 - .ca_mode = S_IRUGO | S_IWUSR }, 1832 - .show = target_core_show_dev_enable, 1833 - .store = target_core_store_dev_enable, 1834 - }; 1835 - 1836 - static ssize_t target_core_show_alua_lu_gp(void *p, char *page) 1965 + static ssize_t target_dev_alua_lu_gp_show(struct config_item *item, char *page) 1837 1966 { 1838 - struct se_device *dev = p; 1967 + struct se_device *dev = to_device(item); 1839 1968 struct config_item *lu_ci; 1840 1969 struct t10_alua_lu_gp *lu_gp; 1841 1970 struct t10_alua_lu_gp_member *lu_gp_mem; ··· 1849 1994 return len; 1850 1995 } 1851 1996 1852 - static ssize_t target_core_store_alua_lu_gp( 1853 - void *p, 1854 - const char *page, 1855 - size_t count) 1997 + static ssize_t target_dev_alua_lu_gp_store(struct config_item *item, 1998 + const char *page, size_t count) 1856 1999 { 1857 - struct se_device *dev = p; 2000 + struct se_device *dev = to_device(item); 1858 2001 struct se_hba *hba = dev->se_hba; 1859 2002 struct t10_alua_lu_gp *lu_gp = NULL, *lu_gp_new = NULL; 1860 2003 struct t10_alua_lu_gp_member *lu_gp_mem; ··· 1929 2076 return count; 1930 2077 } 1931 2078 1932 - static struct target_core_configfs_attribute target_core_attr_dev_alua_lu_gp = { 1933 - .attr = { .ca_owner = THIS_MODULE, 1934 - .ca_name = "alua_lu_gp", 1935 - .ca_mode = S_IRUGO | S_IWUSR }, 1936 - .show = target_core_show_alua_lu_gp, 1937 - .store = target_core_store_alua_lu_gp, 1938 - }; 1939 - 1940 - static ssize_t target_core_show_dev_lba_map(void *p, char *page) 2079 + static ssize_t target_dev_lba_map_show(struct config_item *item, char *page) 1941 2080 { 1942 - struct se_device *dev = p; 2081 + struct se_device *dev = to_device(item); 1943 2082 struct t10_alua_lba_map *map; 1944 2083 struct t10_alua_lba_map_member *mem; 1945 2084 char *b = page; ··· 1974 2129 return bl; 1975 2130 } 1976 2131 1977 - static ssize_t target_core_store_dev_lba_map( 1978 - void *p, 1979 - const char *page, 1980 - size_t count) 2132 + static ssize_t target_dev_lba_map_store(struct config_item *item, 2133 + const char *page, size_t count) 1981 2134 { 1982 - struct se_device *dev = p; 2135 + struct se_device *dev = to_device(item); 1983 2136 struct t10_alua_lba_map *lba_map = NULL; 1984 2137 struct list_head lba_list; 1985 2138 char *map_entries, *ptr; ··· 2089 2246 return count; 2090 2247 } 2091 2248 2092 - static struct target_core_configfs_attribute target_core_attr_dev_lba_map = { 2093 - .attr = { .ca_owner = THIS_MODULE, 2094 - .ca_name = "lba_map", 2095 - .ca_mode = S_IRUGO | S_IWUSR }, 2096 - .show = target_core_show_dev_lba_map, 2097 - .store = target_core_store_dev_lba_map, 2098 - }; 2249 + CONFIGFS_ATTR_RO(target_dev_, info); 2250 + CONFIGFS_ATTR_WO(target_dev_, control); 2251 + CONFIGFS_ATTR(target_dev_, alias); 2252 + CONFIGFS_ATTR(target_dev_, udev_path); 2253 + CONFIGFS_ATTR(target_dev_, enable); 2254 + CONFIGFS_ATTR(target_dev_, alua_lu_gp); 2255 + CONFIGFS_ATTR(target_dev_, lba_map); 2099 2256 2100 2257 static struct configfs_attribute *target_core_dev_attrs[] = { 2101 - &target_core_attr_dev_info.attr, 2102 - &target_core_attr_dev_control.attr, 2103 - &target_core_attr_dev_alias.attr, 2104 - &target_core_attr_dev_udev_path.attr, 2105 - &target_core_attr_dev_enable.attr, 2106 - &target_core_attr_dev_alua_lu_gp.attr, 2107 - &target_core_attr_dev_lba_map.attr, 2258 + &target_dev_attr_info, 2259 + &target_dev_attr_control, 2260 + &target_dev_attr_alias, 2261 + &target_dev_attr_udev_path, 2262 + &target_dev_attr_enable, 2263 + &target_dev_attr_alua_lu_gp, 2264 + &target_dev_attr_lba_map, 2108 2265 NULL, 2109 2266 }; 2110 2267 ··· 2118 2275 target_free_device(dev); 2119 2276 } 2120 2277 2121 - static ssize_t target_core_dev_show(struct config_item *item, 2122 - struct configfs_attribute *attr, 2123 - char *page) 2124 - { 2125 - struct config_group *dev_cg = to_config_group(item); 2126 - struct se_device *dev = 2127 - container_of(dev_cg, struct se_device, dev_group); 2128 - struct target_core_configfs_attribute *tc_attr = container_of( 2129 - attr, struct target_core_configfs_attribute, attr); 2130 - 2131 - if (!tc_attr->show) 2132 - return -EINVAL; 2133 - 2134 - return tc_attr->show(dev, page); 2135 - } 2136 - 2137 - static ssize_t target_core_dev_store(struct config_item *item, 2138 - struct configfs_attribute *attr, 2139 - const char *page, size_t count) 2140 - { 2141 - struct config_group *dev_cg = to_config_group(item); 2142 - struct se_device *dev = 2143 - container_of(dev_cg, struct se_device, dev_group); 2144 - struct target_core_configfs_attribute *tc_attr = container_of( 2145 - attr, struct target_core_configfs_attribute, attr); 2146 - 2147 - if (!tc_attr->store) 2148 - return -EINVAL; 2149 - 2150 - return tc_attr->store(dev, page, count); 2151 - } 2152 - 2153 2278 static struct configfs_item_operations target_core_dev_item_ops = { 2154 2279 .release = target_core_dev_release, 2155 - .show_attribute = target_core_dev_show, 2156 - .store_attribute = target_core_dev_store, 2157 2280 }; 2158 2281 2159 2282 TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs); ··· 2128 2319 2129 2320 /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */ 2130 2321 2131 - CONFIGFS_EATTR_STRUCT(target_core_alua_lu_gp, t10_alua_lu_gp); 2132 - #define SE_DEV_ALUA_LU_ATTR(_name, _mode) \ 2133 - static struct target_core_alua_lu_gp_attribute \ 2134 - target_core_alua_lu_gp_##_name = \ 2135 - __CONFIGFS_EATTR(_name, _mode, \ 2136 - target_core_alua_lu_gp_show_attr_##_name, \ 2137 - target_core_alua_lu_gp_store_attr_##_name); 2138 - 2139 - #define SE_DEV_ALUA_LU_ATTR_RO(_name) \ 2140 - static struct target_core_alua_lu_gp_attribute \ 2141 - target_core_alua_lu_gp_##_name = \ 2142 - __CONFIGFS_EATTR_RO(_name, \ 2143 - target_core_alua_lu_gp_show_attr_##_name); 2144 - 2145 - /* 2146 - * lu_gp_id 2147 - */ 2148 - static ssize_t target_core_alua_lu_gp_show_attr_lu_gp_id( 2149 - struct t10_alua_lu_gp *lu_gp, 2150 - char *page) 2322 + static inline struct t10_alua_lu_gp *to_lu_gp(struct config_item *item) 2151 2323 { 2324 + return container_of(to_config_group(item), struct t10_alua_lu_gp, 2325 + lu_gp_group); 2326 + } 2327 + 2328 + static ssize_t target_lu_gp_lu_gp_id_show(struct config_item *item, char *page) 2329 + { 2330 + struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); 2331 + 2152 2332 if (!lu_gp->lu_gp_valid_id) 2153 2333 return 0; 2154 - 2155 2334 return sprintf(page, "%hu\n", lu_gp->lu_gp_id); 2156 2335 } 2157 2336 2158 - static ssize_t target_core_alua_lu_gp_store_attr_lu_gp_id( 2159 - struct t10_alua_lu_gp *lu_gp, 2160 - const char *page, 2161 - size_t count) 2337 + static ssize_t target_lu_gp_lu_gp_id_store(struct config_item *item, 2338 + const char *page, size_t count) 2162 2339 { 2340 + struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); 2163 2341 struct config_group *alua_lu_gp_cg = &lu_gp->lu_gp_group; 2164 2342 unsigned long lu_gp_id; 2165 2343 int ret; ··· 2175 2379 return count; 2176 2380 } 2177 2381 2178 - SE_DEV_ALUA_LU_ATTR(lu_gp_id, S_IRUGO | S_IWUSR); 2179 - 2180 - /* 2181 - * members 2182 - */ 2183 - static ssize_t target_core_alua_lu_gp_show_attr_members( 2184 - struct t10_alua_lu_gp *lu_gp, 2185 - char *page) 2382 + static ssize_t target_lu_gp_members_show(struct config_item *item, char *page) 2186 2383 { 2384 + struct t10_alua_lu_gp *lu_gp = to_lu_gp(item); 2187 2385 struct se_device *dev; 2188 2386 struct se_hba *hba; 2189 2387 struct t10_alua_lu_gp_member *lu_gp_mem; ··· 2209 2419 return len; 2210 2420 } 2211 2421 2212 - SE_DEV_ALUA_LU_ATTR_RO(members); 2213 - 2214 - CONFIGFS_EATTR_OPS(target_core_alua_lu_gp, t10_alua_lu_gp, lu_gp_group); 2422 + CONFIGFS_ATTR(target_lu_gp_, lu_gp_id); 2423 + CONFIGFS_ATTR_RO(target_lu_gp_, members); 2215 2424 2216 2425 static struct configfs_attribute *target_core_alua_lu_gp_attrs[] = { 2217 - &target_core_alua_lu_gp_lu_gp_id.attr, 2218 - &target_core_alua_lu_gp_members.attr, 2426 + &target_lu_gp_attr_lu_gp_id, 2427 + &target_lu_gp_attr_members, 2219 2428 NULL, 2220 2429 }; 2221 2430 ··· 2228 2439 2229 2440 static struct configfs_item_operations target_core_alua_lu_gp_ops = { 2230 2441 .release = target_core_alua_lu_gp_release, 2231 - .show_attribute = target_core_alua_lu_gp_attr_show, 2232 - .store_attribute = target_core_alua_lu_gp_attr_store, 2233 2442 }; 2234 2443 2235 2444 static struct config_item_type target_core_alua_lu_gp_cit = { ··· 2298 2511 2299 2512 /* Start functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ 2300 2513 2301 - CONFIGFS_EATTR_STRUCT(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp); 2302 - #define SE_DEV_ALUA_TG_PT_ATTR(_name, _mode) \ 2303 - static struct target_core_alua_tg_pt_gp_attribute \ 2304 - target_core_alua_tg_pt_gp_##_name = \ 2305 - __CONFIGFS_EATTR(_name, _mode, \ 2306 - target_core_alua_tg_pt_gp_show_attr_##_name, \ 2307 - target_core_alua_tg_pt_gp_store_attr_##_name); 2308 - 2309 - #define SE_DEV_ALUA_TG_PT_ATTR_RO(_name) \ 2310 - static struct target_core_alua_tg_pt_gp_attribute \ 2311 - target_core_alua_tg_pt_gp_##_name = \ 2312 - __CONFIGFS_EATTR_RO(_name, \ 2313 - target_core_alua_tg_pt_gp_show_attr_##_name); 2314 - 2315 - /* 2316 - * alua_access_state 2317 - */ 2318 - static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_state( 2319 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2320 - char *page) 2514 + static inline struct t10_alua_tg_pt_gp *to_tg_pt_gp(struct config_item *item) 2321 2515 { 2322 - return sprintf(page, "%d\n", 2323 - atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state)); 2516 + return container_of(to_config_group(item), struct t10_alua_tg_pt_gp, 2517 + tg_pt_gp_group); 2324 2518 } 2325 2519 2326 - static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state( 2327 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2328 - const char *page, 2329 - size_t count) 2520 + static ssize_t target_tg_pt_gp_alua_access_state_show(struct config_item *item, 2521 + char *page) 2330 2522 { 2523 + return sprintf(page, "%d\n", 2524 + atomic_read(&to_tg_pt_gp(item)->tg_pt_gp_alua_access_state)); 2525 + } 2526 + 2527 + static ssize_t target_tg_pt_gp_alua_access_state_store(struct config_item *item, 2528 + const char *page, size_t count) 2529 + { 2530 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2331 2531 struct se_device *dev = tg_pt_gp->tg_pt_gp_dev; 2332 2532 unsigned long tmp; 2333 2533 int new_state, ret; ··· 2356 2582 return (!ret) ? count : -EINVAL; 2357 2583 } 2358 2584 2359 - SE_DEV_ALUA_TG_PT_ATTR(alua_access_state, S_IRUGO | S_IWUSR); 2360 - 2361 - /* 2362 - * alua_access_status 2363 - */ 2364 - static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_status( 2365 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2366 - char *page) 2585 + static ssize_t target_tg_pt_gp_alua_access_status_show(struct config_item *item, 2586 + char *page) 2367 2587 { 2588 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2368 2589 return sprintf(page, "%s\n", 2369 2590 core_alua_dump_status(tg_pt_gp->tg_pt_gp_alua_access_status)); 2370 2591 } 2371 2592 2372 - static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_status( 2373 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2374 - const char *page, 2375 - size_t count) 2593 + static ssize_t target_tg_pt_gp_alua_access_status_store( 2594 + struct config_item *item, const char *page, size_t count) 2376 2595 { 2596 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2377 2597 unsigned long tmp; 2378 2598 int new_status, ret; 2379 2599 ··· 2398 2630 return count; 2399 2631 } 2400 2632 2401 - SE_DEV_ALUA_TG_PT_ATTR(alua_access_status, S_IRUGO | S_IWUSR); 2402 - 2403 - /* 2404 - * alua_access_type 2405 - */ 2406 - static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_access_type( 2407 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2408 - char *page) 2633 + static ssize_t target_tg_pt_gp_alua_access_type_show(struct config_item *item, 2634 + char *page) 2409 2635 { 2410 - return core_alua_show_access_type(tg_pt_gp, page); 2636 + return core_alua_show_access_type(to_tg_pt_gp(item), page); 2411 2637 } 2412 2638 2413 - static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_type( 2414 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2415 - const char *page, 2416 - size_t count) 2639 + static ssize_t target_tg_pt_gp_alua_access_type_store(struct config_item *item, 2640 + const char *page, size_t count) 2417 2641 { 2418 - return core_alua_store_access_type(tg_pt_gp, page, count); 2642 + return core_alua_store_access_type(to_tg_pt_gp(item), page, count); 2419 2643 } 2420 2644 2421 - SE_DEV_ALUA_TG_PT_ATTR(alua_access_type, S_IRUGO | S_IWUSR); 2422 - 2423 - /* 2424 - * alua_supported_states 2425 - */ 2426 - 2427 - #define SE_DEV_ALUA_SUPPORT_STATE_SHOW(_name, _var, _bit) \ 2428 - static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_support_##_name( \ 2429 - struct t10_alua_tg_pt_gp *t, char *p) \ 2645 + #define ALUA_SUPPORTED_STATE_ATTR(_name, _bit) \ 2646 + static ssize_t target_tg_pt_gp_alua_support_##_name##_show( \ 2647 + struct config_item *item, char *p) \ 2430 2648 { \ 2431 - return sprintf(p, "%d\n", !!(t->_var & _bit)); \ 2432 - } 2433 - 2434 - #define SE_DEV_ALUA_SUPPORT_STATE_STORE(_name, _var, _bit) \ 2435 - static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_support_##_name(\ 2436 - struct t10_alua_tg_pt_gp *t, const char *p, size_t c) \ 2649 + struct t10_alua_tg_pt_gp *t = to_tg_pt_gp(item); \ 2650 + return sprintf(p, "%d\n", \ 2651 + !!(t->tg_pt_gp_alua_supported_states & _bit)); \ 2652 + } \ 2653 + \ 2654 + static ssize_t target_tg_pt_gp_alua_support_##_name##_store( \ 2655 + struct config_item *item, const char *p, size_t c) \ 2437 2656 { \ 2657 + struct t10_alua_tg_pt_gp *t = to_tg_pt_gp(item); \ 2438 2658 unsigned long tmp; \ 2439 2659 int ret; \ 2440 2660 \ ··· 2443 2687 return -EINVAL; \ 2444 2688 } \ 2445 2689 if (tmp) \ 2446 - t->_var |= _bit; \ 2690 + t->tg_pt_gp_alua_supported_states |= _bit; \ 2447 2691 else \ 2448 - t->_var &= ~_bit; \ 2692 + t->tg_pt_gp_alua_supported_states &= ~_bit; \ 2449 2693 \ 2450 2694 return c; \ 2451 2695 } 2452 2696 2453 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(transitioning, 2454 - tg_pt_gp_alua_supported_states, ALUA_T_SUP); 2455 - SE_DEV_ALUA_SUPPORT_STATE_STORE(transitioning, 2456 - tg_pt_gp_alua_supported_states, ALUA_T_SUP); 2457 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_transitioning, S_IRUGO | S_IWUSR); 2697 + ALUA_SUPPORTED_STATE_ATTR(transitioning, ALUA_T_SUP); 2698 + ALUA_SUPPORTED_STATE_ATTR(offline, ALUA_O_SUP); 2699 + ALUA_SUPPORTED_STATE_ATTR(lba_dependent, ALUA_LBD_SUP); 2700 + ALUA_SUPPORTED_STATE_ATTR(unavailable, ALUA_U_SUP); 2701 + ALUA_SUPPORTED_STATE_ATTR(standby, ALUA_S_SUP); 2702 + ALUA_SUPPORTED_STATE_ATTR(active_optimized, ALUA_AO_SUP); 2703 + ALUA_SUPPORTED_STATE_ATTR(active_nonoptimized, ALUA_AN_SUP); 2458 2704 2459 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(offline, 2460 - tg_pt_gp_alua_supported_states, ALUA_O_SUP); 2461 - SE_DEV_ALUA_SUPPORT_STATE_STORE(offline, 2462 - tg_pt_gp_alua_supported_states, ALUA_O_SUP); 2463 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_offline, S_IRUGO | S_IWUSR); 2464 - 2465 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(lba_dependent, 2466 - tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); 2467 - SE_DEV_ALUA_SUPPORT_STATE_STORE(lba_dependent, 2468 - tg_pt_gp_alua_supported_states, ALUA_LBD_SUP); 2469 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_lba_dependent, S_IRUGO); 2470 - 2471 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(unavailable, 2472 - tg_pt_gp_alua_supported_states, ALUA_U_SUP); 2473 - SE_DEV_ALUA_SUPPORT_STATE_STORE(unavailable, 2474 - tg_pt_gp_alua_supported_states, ALUA_U_SUP); 2475 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_unavailable, S_IRUGO | S_IWUSR); 2476 - 2477 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(standby, 2478 - tg_pt_gp_alua_supported_states, ALUA_S_SUP); 2479 - SE_DEV_ALUA_SUPPORT_STATE_STORE(standby, 2480 - tg_pt_gp_alua_supported_states, ALUA_S_SUP); 2481 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_standby, S_IRUGO | S_IWUSR); 2482 - 2483 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_optimized, 2484 - tg_pt_gp_alua_supported_states, ALUA_AO_SUP); 2485 - SE_DEV_ALUA_SUPPORT_STATE_STORE(active_optimized, 2486 - tg_pt_gp_alua_supported_states, ALUA_AO_SUP); 2487 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_optimized, S_IRUGO | S_IWUSR); 2488 - 2489 - SE_DEV_ALUA_SUPPORT_STATE_SHOW(active_nonoptimized, 2490 - tg_pt_gp_alua_supported_states, ALUA_AN_SUP); 2491 - SE_DEV_ALUA_SUPPORT_STATE_STORE(active_nonoptimized, 2492 - tg_pt_gp_alua_supported_states, ALUA_AN_SUP); 2493 - SE_DEV_ALUA_TG_PT_ATTR(alua_support_active_nonoptimized, S_IRUGO | S_IWUSR); 2494 - 2495 - /* 2496 - * alua_write_metadata 2497 - */ 2498 - static ssize_t target_core_alua_tg_pt_gp_show_attr_alua_write_metadata( 2499 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2500 - char *page) 2705 + static ssize_t target_tg_pt_gp_alua_write_metadata_show( 2706 + struct config_item *item, char *page) 2501 2707 { 2502 - return sprintf(page, "%d\n", tg_pt_gp->tg_pt_gp_write_metadata); 2708 + return sprintf(page, "%d\n", 2709 + to_tg_pt_gp(item)->tg_pt_gp_write_metadata); 2503 2710 } 2504 2711 2505 - static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_write_metadata( 2506 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2507 - const char *page, 2508 - size_t count) 2712 + static ssize_t target_tg_pt_gp_alua_write_metadata_store( 2713 + struct config_item *item, const char *page, size_t count) 2509 2714 { 2715 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2510 2716 unsigned long tmp; 2511 2717 int ret; 2512 2718 ··· 2488 2770 return count; 2489 2771 } 2490 2772 2491 - SE_DEV_ALUA_TG_PT_ATTR(alua_write_metadata, S_IRUGO | S_IWUSR); 2492 - 2493 - 2494 - 2495 - /* 2496 - * nonop_delay_msecs 2497 - */ 2498 - static ssize_t target_core_alua_tg_pt_gp_show_attr_nonop_delay_msecs( 2499 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2500 - char *page) 2773 + static ssize_t target_tg_pt_gp_nonop_delay_msecs_show(struct config_item *item, 2774 + char *page) 2501 2775 { 2502 - return core_alua_show_nonop_delay_msecs(tg_pt_gp, page); 2503 - 2776 + return core_alua_show_nonop_delay_msecs(to_tg_pt_gp(item), page); 2504 2777 } 2505 2778 2506 - static ssize_t target_core_alua_tg_pt_gp_store_attr_nonop_delay_msecs( 2507 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2508 - const char *page, 2509 - size_t count) 2779 + static ssize_t target_tg_pt_gp_nonop_delay_msecs_store(struct config_item *item, 2780 + const char *page, size_t count) 2510 2781 { 2511 - return core_alua_store_nonop_delay_msecs(tg_pt_gp, page, count); 2782 + return core_alua_store_nonop_delay_msecs(to_tg_pt_gp(item), page, 2783 + count); 2512 2784 } 2513 2785 2514 - SE_DEV_ALUA_TG_PT_ATTR(nonop_delay_msecs, S_IRUGO | S_IWUSR); 2515 - 2516 - /* 2517 - * trans_delay_msecs 2518 - */ 2519 - static ssize_t target_core_alua_tg_pt_gp_show_attr_trans_delay_msecs( 2520 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2521 - char *page) 2786 + static ssize_t target_tg_pt_gp_trans_delay_msecs_show(struct config_item *item, 2787 + char *page) 2522 2788 { 2523 - return core_alua_show_trans_delay_msecs(tg_pt_gp, page); 2789 + return core_alua_show_trans_delay_msecs(to_tg_pt_gp(item), page); 2524 2790 } 2525 2791 2526 - static ssize_t target_core_alua_tg_pt_gp_store_attr_trans_delay_msecs( 2527 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2528 - const char *page, 2529 - size_t count) 2792 + static ssize_t target_tg_pt_gp_trans_delay_msecs_store(struct config_item *item, 2793 + const char *page, size_t count) 2530 2794 { 2531 - return core_alua_store_trans_delay_msecs(tg_pt_gp, page, count); 2795 + return core_alua_store_trans_delay_msecs(to_tg_pt_gp(item), page, 2796 + count); 2532 2797 } 2533 2798 2534 - SE_DEV_ALUA_TG_PT_ATTR(trans_delay_msecs, S_IRUGO | S_IWUSR); 2535 - 2536 - /* 2537 - * implicit_trans_secs 2538 - */ 2539 - static ssize_t target_core_alua_tg_pt_gp_show_attr_implicit_trans_secs( 2540 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2541 - char *page) 2799 + static ssize_t target_tg_pt_gp_implicit_trans_secs_show( 2800 + struct config_item *item, char *page) 2542 2801 { 2543 - return core_alua_show_implicit_trans_secs(tg_pt_gp, page); 2802 + return core_alua_show_implicit_trans_secs(to_tg_pt_gp(item), page); 2544 2803 } 2545 2804 2546 - static ssize_t target_core_alua_tg_pt_gp_store_attr_implicit_trans_secs( 2547 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2548 - const char *page, 2549 - size_t count) 2805 + static ssize_t target_tg_pt_gp_implicit_trans_secs_store( 2806 + struct config_item *item, const char *page, size_t count) 2550 2807 { 2551 - return core_alua_store_implicit_trans_secs(tg_pt_gp, page, count); 2808 + return core_alua_store_implicit_trans_secs(to_tg_pt_gp(item), page, 2809 + count); 2552 2810 } 2553 2811 2554 - SE_DEV_ALUA_TG_PT_ATTR(implicit_trans_secs, S_IRUGO | S_IWUSR); 2555 - 2556 - /* 2557 - * preferred 2558 - */ 2559 - 2560 - static ssize_t target_core_alua_tg_pt_gp_show_attr_preferred( 2561 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2562 - char *page) 2812 + static ssize_t target_tg_pt_gp_preferred_show(struct config_item *item, 2813 + char *page) 2563 2814 { 2564 - return core_alua_show_preferred_bit(tg_pt_gp, page); 2815 + return core_alua_show_preferred_bit(to_tg_pt_gp(item), page); 2565 2816 } 2566 2817 2567 - static ssize_t target_core_alua_tg_pt_gp_store_attr_preferred( 2568 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2569 - const char *page, 2570 - size_t count) 2818 + static ssize_t target_tg_pt_gp_preferred_store(struct config_item *item, 2819 + const char *page, size_t count) 2571 2820 { 2572 - return core_alua_store_preferred_bit(tg_pt_gp, page, count); 2821 + return core_alua_store_preferred_bit(to_tg_pt_gp(item), page, count); 2573 2822 } 2574 2823 2575 - SE_DEV_ALUA_TG_PT_ATTR(preferred, S_IRUGO | S_IWUSR); 2576 - 2577 - /* 2578 - * tg_pt_gp_id 2579 - */ 2580 - static ssize_t target_core_alua_tg_pt_gp_show_attr_tg_pt_gp_id( 2581 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2582 - char *page) 2824 + static ssize_t target_tg_pt_gp_tg_pt_gp_id_show(struct config_item *item, 2825 + char *page) 2583 2826 { 2827 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2828 + 2584 2829 if (!tg_pt_gp->tg_pt_gp_valid_id) 2585 2830 return 0; 2586 - 2587 2831 return sprintf(page, "%hu\n", tg_pt_gp->tg_pt_gp_id); 2588 2832 } 2589 2833 2590 - static ssize_t target_core_alua_tg_pt_gp_store_attr_tg_pt_gp_id( 2591 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2592 - const char *page, 2593 - size_t count) 2834 + static ssize_t target_tg_pt_gp_tg_pt_gp_id_store(struct config_item *item, 2835 + const char *page, size_t count) 2594 2836 { 2837 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2595 2838 struct config_group *alua_tg_pt_gp_cg = &tg_pt_gp->tg_pt_gp_group; 2596 2839 unsigned long tg_pt_gp_id; 2597 2840 int ret; ··· 2581 2902 return count; 2582 2903 } 2583 2904 2584 - SE_DEV_ALUA_TG_PT_ATTR(tg_pt_gp_id, S_IRUGO | S_IWUSR); 2585 - 2586 - /* 2587 - * members 2588 - */ 2589 - static ssize_t target_core_alua_tg_pt_gp_show_attr_members( 2590 - struct t10_alua_tg_pt_gp *tg_pt_gp, 2591 - char *page) 2905 + static ssize_t target_tg_pt_gp_members_show(struct config_item *item, 2906 + char *page) 2592 2907 { 2908 + struct t10_alua_tg_pt_gp *tg_pt_gp = to_tg_pt_gp(item); 2593 2909 struct se_lun *lun; 2594 2910 ssize_t len = 0, cur_len; 2595 2911 unsigned char buf[TG_PT_GROUP_NAME_BUF]; ··· 2616 2942 return len; 2617 2943 } 2618 2944 2619 - SE_DEV_ALUA_TG_PT_ATTR_RO(members); 2620 - 2621 - CONFIGFS_EATTR_OPS(target_core_alua_tg_pt_gp, t10_alua_tg_pt_gp, 2622 - tg_pt_gp_group); 2945 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_state); 2946 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_status); 2947 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_access_type); 2948 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_transitioning); 2949 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_offline); 2950 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_lba_dependent); 2951 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_unavailable); 2952 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_standby); 2953 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_active_optimized); 2954 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_support_active_nonoptimized); 2955 + CONFIGFS_ATTR(target_tg_pt_gp_, alua_write_metadata); 2956 + CONFIGFS_ATTR(target_tg_pt_gp_, nonop_delay_msecs); 2957 + CONFIGFS_ATTR(target_tg_pt_gp_, trans_delay_msecs); 2958 + CONFIGFS_ATTR(target_tg_pt_gp_, implicit_trans_secs); 2959 + CONFIGFS_ATTR(target_tg_pt_gp_, preferred); 2960 + CONFIGFS_ATTR(target_tg_pt_gp_, tg_pt_gp_id); 2961 + CONFIGFS_ATTR_RO(target_tg_pt_gp_, members); 2623 2962 2624 2963 static struct configfs_attribute *target_core_alua_tg_pt_gp_attrs[] = { 2625 - &target_core_alua_tg_pt_gp_alua_access_state.attr, 2626 - &target_core_alua_tg_pt_gp_alua_access_status.attr, 2627 - &target_core_alua_tg_pt_gp_alua_access_type.attr, 2628 - &target_core_alua_tg_pt_gp_alua_support_transitioning.attr, 2629 - &target_core_alua_tg_pt_gp_alua_support_offline.attr, 2630 - &target_core_alua_tg_pt_gp_alua_support_lba_dependent.attr, 2631 - &target_core_alua_tg_pt_gp_alua_support_unavailable.attr, 2632 - &target_core_alua_tg_pt_gp_alua_support_standby.attr, 2633 - &target_core_alua_tg_pt_gp_alua_support_active_nonoptimized.attr, 2634 - &target_core_alua_tg_pt_gp_alua_support_active_optimized.attr, 2635 - &target_core_alua_tg_pt_gp_alua_write_metadata.attr, 2636 - &target_core_alua_tg_pt_gp_nonop_delay_msecs.attr, 2637 - &target_core_alua_tg_pt_gp_trans_delay_msecs.attr, 2638 - &target_core_alua_tg_pt_gp_implicit_trans_secs.attr, 2639 - &target_core_alua_tg_pt_gp_preferred.attr, 2640 - &target_core_alua_tg_pt_gp_tg_pt_gp_id.attr, 2641 - &target_core_alua_tg_pt_gp_members.attr, 2964 + &target_tg_pt_gp_attr_alua_access_state, 2965 + &target_tg_pt_gp_attr_alua_access_status, 2966 + &target_tg_pt_gp_attr_alua_access_type, 2967 + &target_tg_pt_gp_attr_alua_support_transitioning, 2968 + &target_tg_pt_gp_attr_alua_support_offline, 2969 + &target_tg_pt_gp_attr_alua_support_lba_dependent, 2970 + &target_tg_pt_gp_attr_alua_support_unavailable, 2971 + &target_tg_pt_gp_attr_alua_support_standby, 2972 + &target_tg_pt_gp_attr_alua_support_active_nonoptimized, 2973 + &target_tg_pt_gp_attr_alua_support_active_optimized, 2974 + &target_tg_pt_gp_attr_alua_write_metadata, 2975 + &target_tg_pt_gp_attr_nonop_delay_msecs, 2976 + &target_tg_pt_gp_attr_trans_delay_msecs, 2977 + &target_tg_pt_gp_attr_implicit_trans_secs, 2978 + &target_tg_pt_gp_attr_preferred, 2979 + &target_tg_pt_gp_attr_tg_pt_gp_id, 2980 + &target_tg_pt_gp_attr_members, 2642 2981 NULL, 2643 2982 }; 2644 2983 ··· 2665 2978 2666 2979 static struct configfs_item_operations target_core_alua_tg_pt_gp_ops = { 2667 2980 .release = target_core_alua_tg_pt_gp_release, 2668 - .show_attribute = target_core_alua_tg_pt_gp_attr_show, 2669 - .store_attribute = target_core_alua_tg_pt_gp_attr_store, 2670 2981 }; 2671 2982 2672 2983 static struct config_item_type target_core_alua_tg_pt_gp_cit = { ··· 2922 3237 .drop_item = target_core_drop_subdev, 2923 3238 }; 2924 3239 2925 - CONFIGFS_EATTR_STRUCT(target_core_hba, se_hba); 2926 - #define SE_HBA_ATTR(_name, _mode) \ 2927 - static struct target_core_hba_attribute \ 2928 - target_core_hba_##_name = \ 2929 - __CONFIGFS_EATTR(_name, _mode, \ 2930 - target_core_hba_show_attr_##_name, \ 2931 - target_core_hba_store_attr_##_name); 2932 3240 2933 - #define SE_HBA_ATTR_RO(_name) \ 2934 - static struct target_core_hba_attribute \ 2935 - target_core_hba_##_name = \ 2936 - __CONFIGFS_EATTR_RO(_name, \ 2937 - target_core_hba_show_attr_##_name); 2938 - 2939 - static ssize_t target_core_hba_show_attr_hba_info( 2940 - struct se_hba *hba, 2941 - char *page) 3241 + static inline struct se_hba *to_hba(struct config_item *item) 2942 3242 { 3243 + return container_of(to_config_group(item), struct se_hba, hba_group); 3244 + } 3245 + 3246 + static ssize_t target_hba_info_show(struct config_item *item, char *page) 3247 + { 3248 + struct se_hba *hba = to_hba(item); 3249 + 2943 3250 return sprintf(page, "HBA Index: %d plugin: %s version: %s\n", 2944 3251 hba->hba_id, hba->backend->ops->name, 2945 3252 TARGET_CORE_VERSION); 2946 3253 } 2947 3254 2948 - SE_HBA_ATTR_RO(hba_info); 2949 - 2950 - static ssize_t target_core_hba_show_attr_hba_mode(struct se_hba *hba, 2951 - char *page) 3255 + static ssize_t target_hba_mode_show(struct config_item *item, char *page) 2952 3256 { 3257 + struct se_hba *hba = to_hba(item); 2953 3258 int hba_mode = 0; 2954 3259 2955 3260 if (hba->hba_flags & HBA_FLAGS_PSCSI_MODE) ··· 2948 3273 return sprintf(page, "%d\n", hba_mode); 2949 3274 } 2950 3275 2951 - static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba, 2952 - const char *page, size_t count) 3276 + static ssize_t target_hba_mode_store(struct config_item *item, 3277 + const char *page, size_t count) 2953 3278 { 3279 + struct se_hba *hba = to_hba(item); 2954 3280 unsigned long mode_flag; 2955 3281 int ret; 2956 3282 ··· 2980 3304 return count; 2981 3305 } 2982 3306 2983 - SE_HBA_ATTR(hba_mode, S_IRUGO | S_IWUSR); 2984 - 2985 - CONFIGFS_EATTR_OPS(target_core_hba, se_hba, hba_group); 3307 + CONFIGFS_ATTR_RO(target_, hba_info); 3308 + CONFIGFS_ATTR(target_, hba_mode); 2986 3309 2987 3310 static void target_core_hba_release(struct config_item *item) 2988 3311 { ··· 2991 3316 } 2992 3317 2993 3318 static struct configfs_attribute *target_core_hba_attrs[] = { 2994 - &target_core_hba_hba_info.attr, 2995 - &target_core_hba_hba_mode.attr, 3319 + &target_attr_hba_info, 3320 + &target_attr_hba_mode, 2996 3321 NULL, 2997 3322 }; 2998 3323 2999 3324 static struct configfs_item_operations target_core_hba_item_ops = { 3000 3325 .release = target_core_hba_release, 3001 - .show_attribute = target_core_hba_attr_show, 3002 - .store_attribute = target_core_hba_attr_store, 3003 3326 }; 3004 3327 3005 3328 static struct config_item_type target_core_hba_cit = {
+71 -208
drivers/target/target_core_fabric_configfs.c
··· 35 35 36 36 #include <target/target_core_base.h> 37 37 #include <target/target_core_fabric.h> 38 - #include <target/target_core_fabric_configfs.h> 39 - #include <target/configfs_macros.h> 40 38 41 39 #include "target_core_internal.h" 42 40 #include "target_core_alua.h" ··· 150 152 return core_dev_del_initiator_node_lun_acl(lun, lacl); 151 153 } 152 154 153 - CONFIGFS_EATTR_STRUCT(target_fabric_mappedlun, se_lun_acl); 154 - #define TCM_MAPPEDLUN_ATTR(_name, _mode) \ 155 - static struct target_fabric_mappedlun_attribute target_fabric_mappedlun_##_name = \ 156 - __CONFIGFS_EATTR(_name, _mode, \ 157 - target_fabric_mappedlun_show_##_name, \ 158 - target_fabric_mappedlun_store_##_name); 159 - 160 - static ssize_t target_fabric_mappedlun_show_write_protect( 161 - struct se_lun_acl *lacl, 162 - char *page) 155 + static struct se_lun_acl *item_to_lun_acl(struct config_item *item) 163 156 { 157 + return container_of(to_config_group(item), struct se_lun_acl, 158 + se_lun_group); 159 + } 160 + 161 + static ssize_t target_fabric_mappedlun_write_protect_show( 162 + struct config_item *item, char *page) 163 + { 164 + struct se_lun_acl *lacl = item_to_lun_acl(item); 164 165 struct se_node_acl *se_nacl = lacl->se_lun_nacl; 165 166 struct se_dev_entry *deve; 166 167 ssize_t len = 0; ··· 175 178 return len; 176 179 } 177 180 178 - static ssize_t target_fabric_mappedlun_store_write_protect( 179 - struct se_lun_acl *lacl, 180 - const char *page, 181 - size_t count) 181 + static ssize_t target_fabric_mappedlun_write_protect_store( 182 + struct config_item *item, const char *page, size_t count) 182 183 { 184 + struct se_lun_acl *lacl = item_to_lun_acl(item); 183 185 struct se_node_acl *se_nacl = lacl->se_lun_nacl; 184 186 struct se_portal_group *se_tpg = se_nacl->se_tpg; 185 187 unsigned long op; ··· 205 209 206 210 } 207 211 208 - TCM_MAPPEDLUN_ATTR(write_protect, S_IRUGO | S_IWUSR); 212 + CONFIGFS_ATTR(target_fabric_mappedlun_, write_protect); 209 213 210 - CONFIGFS_EATTR_OPS(target_fabric_mappedlun, se_lun_acl, se_lun_group); 214 + static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { 215 + &target_fabric_mappedlun_attr_write_protect, 216 + NULL, 217 + }; 211 218 212 219 static void target_fabric_mappedlun_release(struct config_item *item) 213 220 { ··· 221 222 core_dev_free_initiator_node_lun_acl(se_tpg, lacl); 222 223 } 223 224 224 - static struct configfs_attribute *target_fabric_mappedlun_attrs[] = { 225 - &target_fabric_mappedlun_write_protect.attr, 226 - NULL, 227 - }; 228 - 229 225 static struct configfs_item_operations target_fabric_mappedlun_item_ops = { 230 226 .release = target_fabric_mappedlun_release, 231 - .show_attribute = target_fabric_mappedlun_attr_show, 232 - .store_attribute = target_fabric_mappedlun_attr_store, 233 227 .allow_link = target_fabric_mappedlun_link, 234 228 .drop_link = target_fabric_mappedlun_unlink, 235 229 }; ··· 258 266 259 267 /* End of tfc_tpg_mappedlun_port_cit */ 260 268 261 - /* Start of tfc_tpg_nacl_attrib_cit */ 262 - 263 - CONFIGFS_EATTR_OPS(target_fabric_nacl_attrib, se_node_acl, acl_attrib_group); 264 - 265 - static struct configfs_item_operations target_fabric_nacl_attrib_item_ops = { 266 - .show_attribute = target_fabric_nacl_attrib_attr_show, 267 - .store_attribute = target_fabric_nacl_attrib_attr_store, 268 - }; 269 - 270 - TF_CIT_SETUP_DRV(tpg_nacl_attrib, &target_fabric_nacl_attrib_item_ops, NULL); 271 - 272 - /* End of tfc_tpg_nacl_attrib_cit */ 273 - 274 - /* Start of tfc_tpg_nacl_auth_cit */ 275 - 276 - CONFIGFS_EATTR_OPS(target_fabric_nacl_auth, se_node_acl, acl_auth_group); 277 - 278 - static struct configfs_item_operations target_fabric_nacl_auth_item_ops = { 279 - .show_attribute = target_fabric_nacl_auth_attr_show, 280 - .store_attribute = target_fabric_nacl_auth_attr_store, 281 - }; 282 - 283 - TF_CIT_SETUP_DRV(tpg_nacl_auth, &target_fabric_nacl_auth_item_ops, NULL); 284 - 285 - /* End of tfc_tpg_nacl_auth_cit */ 286 - 287 - /* Start of tfc_tpg_nacl_param_cit */ 288 - 289 - CONFIGFS_EATTR_OPS(target_fabric_nacl_param, se_node_acl, acl_param_group); 290 - 291 - static struct configfs_item_operations target_fabric_nacl_param_item_ops = { 292 - .show_attribute = target_fabric_nacl_param_attr_show, 293 - .store_attribute = target_fabric_nacl_param_attr_store, 294 - }; 295 - 296 - TF_CIT_SETUP_DRV(tpg_nacl_param, &target_fabric_nacl_param_item_ops, NULL); 297 - 298 - /* End of tfc_tpg_nacl_param_cit */ 269 + TF_CIT_SETUP_DRV(tpg_nacl_attrib, NULL, NULL); 270 + TF_CIT_SETUP_DRV(tpg_nacl_auth, NULL, NULL); 271 + TF_CIT_SETUP_DRV(tpg_nacl_param, NULL, NULL); 299 272 300 273 /* Start of tfc_tpg_nacl_base_cit */ 301 - 302 - CONFIGFS_EATTR_OPS(target_fabric_nacl_base, se_node_acl, acl_group); 303 274 304 275 static struct config_group *target_fabric_make_mappedlun( 305 276 struct config_group *group, ··· 393 438 394 439 static struct configfs_item_operations target_fabric_nacl_base_item_ops = { 395 440 .release = target_fabric_nacl_base_release, 396 - .show_attribute = target_fabric_nacl_base_attr_show, 397 - .store_attribute = target_fabric_nacl_base_attr_store, 398 441 }; 399 442 400 443 static struct configfs_group_operations target_fabric_nacl_base_group_ops = { ··· 493 540 494 541 /* Start of tfc_tpg_np_base_cit */ 495 542 496 - CONFIGFS_EATTR_OPS(target_fabric_np_base, se_tpg_np, tpg_np_group); 497 - 498 543 static void target_fabric_np_base_release(struct config_item *item) 499 544 { 500 545 struct se_tpg_np *se_tpg_np = container_of(to_config_group(item), ··· 505 554 506 555 static struct configfs_item_operations target_fabric_np_base_item_ops = { 507 556 .release = target_fabric_np_base_release, 508 - .show_attribute = target_fabric_np_base_attr_show, 509 - .store_attribute = target_fabric_np_base_attr_store, 510 557 }; 511 558 512 559 TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL); ··· 559 610 560 611 /* Start of tfc_tpg_port_cit */ 561 612 562 - CONFIGFS_EATTR_STRUCT(target_fabric_port, se_lun); 563 - #define TCM_PORT_ATTR(_name, _mode) \ 564 - static struct target_fabric_port_attribute target_fabric_port_##_name = \ 565 - __CONFIGFS_EATTR(_name, _mode, \ 566 - target_fabric_port_show_attr_##_name, \ 567 - target_fabric_port_store_attr_##_name); 568 - 569 - #define TCM_PORT_ATTOR_RO(_name) \ 570 - __CONFIGFS_EATTR_RO(_name, \ 571 - target_fabric_port_show_attr_##_name); 572 - 573 - /* 574 - * alua_tg_pt_gp 575 - */ 576 - static ssize_t target_fabric_port_show_attr_alua_tg_pt_gp( 577 - struct se_lun *lun, 578 - char *page) 613 + static struct se_lun *item_to_lun(struct config_item *item) 579 614 { 615 + return container_of(to_config_group(item), struct se_lun, 616 + lun_group); 617 + } 618 + 619 + static ssize_t target_fabric_port_alua_tg_pt_gp_show(struct config_item *item, 620 + char *page) 621 + { 622 + struct se_lun *lun = item_to_lun(item); 623 + 580 624 if (!lun || !lun->lun_se_dev) 581 625 return -ENODEV; 582 626 583 627 return core_alua_show_tg_pt_gp_info(lun, page); 584 628 } 585 629 586 - static ssize_t target_fabric_port_store_attr_alua_tg_pt_gp( 587 - struct se_lun *lun, 588 - const char *page, 589 - size_t count) 630 + static ssize_t target_fabric_port_alua_tg_pt_gp_store(struct config_item *item, 631 + const char *page, size_t count) 590 632 { 633 + struct se_lun *lun = item_to_lun(item); 634 + 591 635 if (!lun || !lun->lun_se_dev) 592 636 return -ENODEV; 593 637 594 638 return core_alua_store_tg_pt_gp_info(lun, page, count); 595 639 } 596 640 597 - TCM_PORT_ATTR(alua_tg_pt_gp, S_IRUGO | S_IWUSR); 598 - 599 - /* 600 - * alua_tg_pt_offline 601 - */ 602 - static ssize_t target_fabric_port_show_attr_alua_tg_pt_offline( 603 - struct se_lun *lun, 604 - char *page) 641 + static ssize_t target_fabric_port_alua_tg_pt_offline_show( 642 + struct config_item *item, char *page) 605 643 { 644 + struct se_lun *lun = item_to_lun(item); 645 + 606 646 if (!lun || !lun->lun_se_dev) 607 647 return -ENODEV; 608 648 609 649 return core_alua_show_offline_bit(lun, page); 610 650 } 611 651 612 - static ssize_t target_fabric_port_store_attr_alua_tg_pt_offline( 613 - struct se_lun *lun, 614 - const char *page, 615 - size_t count) 652 + static ssize_t target_fabric_port_alua_tg_pt_offline_store( 653 + struct config_item *item, const char *page, size_t count) 616 654 { 655 + struct se_lun *lun = item_to_lun(item); 656 + 617 657 if (!lun || !lun->lun_se_dev) 618 658 return -ENODEV; 619 659 620 660 return core_alua_store_offline_bit(lun, page, count); 621 661 } 622 662 623 - TCM_PORT_ATTR(alua_tg_pt_offline, S_IRUGO | S_IWUSR); 624 - 625 - /* 626 - * alua_tg_pt_status 627 - */ 628 - static ssize_t target_fabric_port_show_attr_alua_tg_pt_status( 629 - struct se_lun *lun, 630 - char *page) 663 + static ssize_t target_fabric_port_alua_tg_pt_status_show( 664 + struct config_item *item, char *page) 631 665 { 666 + struct se_lun *lun = item_to_lun(item); 667 + 632 668 if (!lun || !lun->lun_se_dev) 633 669 return -ENODEV; 634 670 635 671 return core_alua_show_secondary_status(lun, page); 636 672 } 637 673 638 - static ssize_t target_fabric_port_store_attr_alua_tg_pt_status( 639 - struct se_lun *lun, 640 - const char *page, 641 - size_t count) 674 + static ssize_t target_fabric_port_alua_tg_pt_status_store( 675 + struct config_item *item, const char *page, size_t count) 642 676 { 677 + struct se_lun *lun = item_to_lun(item); 678 + 643 679 if (!lun || !lun->lun_se_dev) 644 680 return -ENODEV; 645 681 646 682 return core_alua_store_secondary_status(lun, page, count); 647 683 } 648 684 649 - TCM_PORT_ATTR(alua_tg_pt_status, S_IRUGO | S_IWUSR); 650 - 651 - /* 652 - * alua_tg_pt_write_md 653 - */ 654 - static ssize_t target_fabric_port_show_attr_alua_tg_pt_write_md( 655 - struct se_lun *lun, 656 - char *page) 685 + static ssize_t target_fabric_port_alua_tg_pt_write_md_show( 686 + struct config_item *item, char *page) 657 687 { 688 + struct se_lun *lun = item_to_lun(item); 689 + 658 690 if (!lun || !lun->lun_se_dev) 659 691 return -ENODEV; 660 692 661 693 return core_alua_show_secondary_write_metadata(lun, page); 662 694 } 663 695 664 - static ssize_t target_fabric_port_store_attr_alua_tg_pt_write_md( 665 - struct se_lun *lun, 666 - const char *page, 667 - size_t count) 696 + static ssize_t target_fabric_port_alua_tg_pt_write_md_store( 697 + struct config_item *item, const char *page, size_t count) 668 698 { 699 + struct se_lun *lun = item_to_lun(item); 700 + 669 701 if (!lun || !lun->lun_se_dev) 670 702 return -ENODEV; 671 703 672 704 return core_alua_store_secondary_write_metadata(lun, page, count); 673 705 } 674 706 675 - TCM_PORT_ATTR(alua_tg_pt_write_md, S_IRUGO | S_IWUSR); 676 - 707 + CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_gp); 708 + CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_offline); 709 + CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_status); 710 + CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_write_md); 677 711 678 712 static struct configfs_attribute *target_fabric_port_attrs[] = { 679 - &target_fabric_port_alua_tg_pt_gp.attr, 680 - &target_fabric_port_alua_tg_pt_offline.attr, 681 - &target_fabric_port_alua_tg_pt_status.attr, 682 - &target_fabric_port_alua_tg_pt_write_md.attr, 713 + &target_fabric_port_attr_alua_tg_pt_gp, 714 + &target_fabric_port_attr_alua_tg_pt_offline, 715 + &target_fabric_port_attr_alua_tg_pt_status, 716 + &target_fabric_port_attr_alua_tg_pt_write_md, 683 717 NULL, 684 718 }; 685 - 686 - CONFIGFS_EATTR_OPS(target_fabric_port, se_lun, lun_group); 687 719 688 720 static int target_fabric_port_link( 689 721 struct config_item *lun_ci, ··· 751 821 } 752 822 753 823 static struct configfs_item_operations target_fabric_port_item_ops = { 754 - .show_attribute = target_fabric_port_attr_show, 755 - .store_attribute = target_fabric_port_attr_store, 756 824 .release = target_fabric_port_release, 757 825 .allow_link = target_fabric_port_link, 758 826 .drop_link = target_fabric_port_unlink, ··· 880 952 881 953 /* End of tfc_tpg_lun_cit */ 882 954 883 - /* Start of tfc_tpg_attrib_cit */ 884 - 885 - CONFIGFS_EATTR_OPS(target_fabric_tpg_attrib, se_portal_group, tpg_attrib_group); 886 - 887 - static struct configfs_item_operations target_fabric_tpg_attrib_item_ops = { 888 - .show_attribute = target_fabric_tpg_attrib_attr_show, 889 - .store_attribute = target_fabric_tpg_attrib_attr_store, 890 - }; 891 - 892 - TF_CIT_SETUP_DRV(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL); 893 - 894 - /* End of tfc_tpg_attrib_cit */ 895 - 896 - /* Start of tfc_tpg_auth_cit */ 897 - 898 - CONFIGFS_EATTR_OPS(target_fabric_tpg_auth, se_portal_group, tpg_auth_group); 899 - 900 - static struct configfs_item_operations target_fabric_tpg_auth_item_ops = { 901 - .show_attribute = target_fabric_tpg_auth_attr_show, 902 - .store_attribute = target_fabric_tpg_auth_attr_store, 903 - }; 904 - 905 - TF_CIT_SETUP_DRV(tpg_auth, &target_fabric_tpg_auth_item_ops, NULL); 906 - 907 - /* End of tfc_tpg_attrib_cit */ 908 - 909 - /* Start of tfc_tpg_param_cit */ 910 - 911 - CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group); 912 - 913 - static struct configfs_item_operations target_fabric_tpg_param_item_ops = { 914 - .show_attribute = target_fabric_tpg_param_attr_show, 915 - .store_attribute = target_fabric_tpg_param_attr_store, 916 - }; 917 - 918 - TF_CIT_SETUP_DRV(tpg_param, &target_fabric_tpg_param_item_ops, NULL); 919 - 920 - /* End of tfc_tpg_param_cit */ 955 + TF_CIT_SETUP_DRV(tpg_attrib, NULL, NULL); 956 + TF_CIT_SETUP_DRV(tpg_auth, NULL, NULL); 957 + TF_CIT_SETUP_DRV(tpg_param, NULL, NULL); 921 958 922 959 /* Start of tfc_tpg_base_cit */ 923 - /* 924 - * For use with TF_TPG_ATTR() and TF_TPG_ATTR_RO() 925 - */ 926 - CONFIGFS_EATTR_OPS(target_fabric_tpg, se_portal_group, tpg_group); 927 960 928 961 static void target_fabric_tpg_release(struct config_item *item) 929 962 { ··· 898 1009 899 1010 static struct configfs_item_operations target_fabric_tpg_base_item_ops = { 900 1011 .release = target_fabric_tpg_release, 901 - .show_attribute = target_fabric_tpg_attr_show, 902 - .store_attribute = target_fabric_tpg_attr_store, 903 1012 }; 904 1013 905 1014 TF_CIT_SETUP_DRV(tpg_base, &target_fabric_tpg_base_item_ops, NULL); ··· 1063 1176 .make_group = target_fabric_make_wwn, 1064 1177 .drop_item = target_fabric_drop_wwn, 1065 1178 }; 1066 - /* 1067 - * For use with TF_WWN_ATTR() and TF_WWN_ATTR_RO() 1068 - */ 1069 - CONFIGFS_EATTR_OPS(target_fabric_wwn, target_fabric_configfs, tf_group); 1070 1179 1071 - static struct configfs_item_operations target_fabric_wwn_item_ops = { 1072 - .show_attribute = target_fabric_wwn_attr_show, 1073 - .store_attribute = target_fabric_wwn_attr_store, 1074 - }; 1075 - 1076 - TF_CIT_SETUP_DRV(wwn, &target_fabric_wwn_item_ops, &target_fabric_wwn_group_ops); 1077 - 1078 - /* End of tfc_wwn_cit */ 1079 - 1080 - /* Start of tfc_discovery_cit */ 1081 - 1082 - CONFIGFS_EATTR_OPS(target_fabric_discovery, target_fabric_configfs, 1083 - tf_disc_group); 1084 - 1085 - static struct configfs_item_operations target_fabric_discovery_item_ops = { 1086 - .show_attribute = target_fabric_discovery_attr_show, 1087 - .store_attribute = target_fabric_discovery_attr_store, 1088 - }; 1089 - 1090 - TF_CIT_SETUP_DRV(discovery, &target_fabric_discovery_item_ops, NULL); 1091 - 1092 - /* End of tfc_discovery_cit */ 1180 + TF_CIT_SETUP_DRV(wwn, NULL, &target_fabric_wwn_group_ops); 1181 + TF_CIT_SETUP_DRV(discovery, NULL, NULL); 1093 1182 1094 1183 int target_fabric_setup_cits(struct target_fabric_configfs *tf) 1095 1184 {
+3
drivers/target/target_core_internal.h
··· 87 87 /* target_core_configfs.c */ 88 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 93 /* target_core_fabric_lib.c */ 91 94 int target_get_pr_transport_id_len(struct se_node_acl *nacl, 92 95 struct t10_pr_registration *pr_reg, int *format_code);
+362 -556
drivers/target/target_core_stat.c
··· 37 37 #include <target/target_core_base.h> 38 38 #include <target/target_core_backend.h> 39 39 #include <target/target_core_fabric.h> 40 - #include <target/configfs_macros.h> 41 40 42 41 #include "target_core_internal.h" 43 42 ··· 54 55 * SCSI Device Table 55 56 */ 56 57 57 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_dev, se_dev_stat_grps); 58 - #define DEV_STAT_SCSI_DEV_ATTR(_name, _mode) \ 59 - static struct target_stat_scsi_dev_attribute \ 60 - target_stat_scsi_dev_##_name = \ 61 - __CONFIGFS_EATTR(_name, _mode, \ 62 - target_stat_scsi_dev_show_attr_##_name, \ 63 - target_stat_scsi_dev_store_attr_##_name); 64 - 65 - #define DEV_STAT_SCSI_DEV_ATTR_RO(_name) \ 66 - static struct target_stat_scsi_dev_attribute \ 67 - target_stat_scsi_dev_##_name = \ 68 - __CONFIGFS_EATTR_RO(_name, \ 69 - target_stat_scsi_dev_show_attr_##_name); 70 - 71 - static ssize_t target_stat_scsi_dev_show_attr_inst( 72 - struct se_dev_stat_grps *sgrps, char *page) 58 + static struct se_device *to_stat_dev(struct config_item *item) 73 59 { 74 - struct se_device *dev = 75 - container_of(sgrps, struct se_device, dev_stat_grps); 76 - struct se_hba *hba = dev->se_hba; 60 + struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), 61 + struct se_dev_stat_grps, scsi_dev_group); 62 + return container_of(sgrps, struct se_device, dev_stat_grps); 63 + } 64 + 65 + static ssize_t target_stat_inst_show(struct config_item *item, char *page) 66 + { 67 + struct se_hba *hba = to_stat_dev(item)->se_hba; 77 68 78 69 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); 79 70 } 80 - DEV_STAT_SCSI_DEV_ATTR_RO(inst); 81 71 82 - static ssize_t target_stat_scsi_dev_show_attr_indx( 83 - struct se_dev_stat_grps *sgrps, char *page) 72 + static ssize_t target_stat_indx_show(struct config_item *item, char *page) 84 73 { 85 - struct se_device *dev = 86 - container_of(sgrps, struct se_device, dev_stat_grps); 87 - 88 - return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); 74 + return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->dev_index); 89 75 } 90 - DEV_STAT_SCSI_DEV_ATTR_RO(indx); 91 76 92 - static ssize_t target_stat_scsi_dev_show_attr_role( 93 - struct se_dev_stat_grps *sgrps, char *page) 77 + static ssize_t target_stat_role_show(struct config_item *item, char *page) 94 78 { 95 79 return snprintf(page, PAGE_SIZE, "Target\n"); 96 80 } 97 - DEV_STAT_SCSI_DEV_ATTR_RO(role); 98 81 99 - static ssize_t target_stat_scsi_dev_show_attr_ports( 100 - struct se_dev_stat_grps *sgrps, char *page) 82 + static ssize_t target_stat_ports_show(struct config_item *item, char *page) 101 83 { 102 - struct se_device *dev = 103 - container_of(sgrps, struct se_device, dev_stat_grps); 104 - 105 - return snprintf(page, PAGE_SIZE, "%u\n", dev->export_count); 84 + return snprintf(page, PAGE_SIZE, "%u\n", to_stat_dev(item)->export_count); 106 85 } 107 - DEV_STAT_SCSI_DEV_ATTR_RO(ports); 108 86 109 - CONFIGFS_EATTR_OPS(target_stat_scsi_dev, se_dev_stat_grps, scsi_dev_group); 87 + CONFIGFS_ATTR_RO(target_stat_, inst); 88 + CONFIGFS_ATTR_RO(target_stat_, indx); 89 + CONFIGFS_ATTR_RO(target_stat_, role); 90 + CONFIGFS_ATTR_RO(target_stat_, ports); 110 91 111 92 static struct configfs_attribute *target_stat_scsi_dev_attrs[] = { 112 - &target_stat_scsi_dev_inst.attr, 113 - &target_stat_scsi_dev_indx.attr, 114 - &target_stat_scsi_dev_role.attr, 115 - &target_stat_scsi_dev_ports.attr, 93 + &target_stat_attr_inst, 94 + &target_stat_attr_indx, 95 + &target_stat_attr_role, 96 + &target_stat_attr_ports, 116 97 NULL, 117 98 }; 118 99 119 - static struct configfs_item_operations target_stat_scsi_dev_attrib_ops = { 120 - .show_attribute = target_stat_scsi_dev_attr_show, 121 - .store_attribute = target_stat_scsi_dev_attr_store, 122 - }; 123 - 124 100 static struct config_item_type target_stat_scsi_dev_cit = { 125 - .ct_item_ops = &target_stat_scsi_dev_attrib_ops, 126 101 .ct_attrs = target_stat_scsi_dev_attrs, 127 102 .ct_owner = THIS_MODULE, 128 103 }; ··· 104 131 /* 105 132 * SCSI Target Device Table 106 133 */ 107 - 108 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_dev, se_dev_stat_grps); 109 - #define DEV_STAT_SCSI_TGT_DEV_ATTR(_name, _mode) \ 110 - static struct target_stat_scsi_tgt_dev_attribute \ 111 - target_stat_scsi_tgt_dev_##_name = \ 112 - __CONFIGFS_EATTR(_name, _mode, \ 113 - target_stat_scsi_tgt_dev_show_attr_##_name, \ 114 - target_stat_scsi_tgt_dev_store_attr_##_name); 115 - 116 - #define DEV_STAT_SCSI_TGT_DEV_ATTR_RO(_name) \ 117 - static struct target_stat_scsi_tgt_dev_attribute \ 118 - target_stat_scsi_tgt_dev_##_name = \ 119 - __CONFIGFS_EATTR_RO(_name, \ 120 - target_stat_scsi_tgt_dev_show_attr_##_name); 121 - 122 - static ssize_t target_stat_scsi_tgt_dev_show_attr_inst( 123 - struct se_dev_stat_grps *sgrps, char *page) 134 + static struct se_device *to_stat_tgt_dev(struct config_item *item) 124 135 { 125 - struct se_device *dev = 126 - container_of(sgrps, struct se_device, dev_stat_grps); 127 - struct se_hba *hba = dev->se_hba; 136 + struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), 137 + struct se_dev_stat_grps, scsi_tgt_dev_group); 138 + return container_of(sgrps, struct se_device, dev_stat_grps); 139 + } 140 + 141 + static ssize_t target_stat_tgt_inst_show(struct config_item *item, char *page) 142 + { 143 + struct se_hba *hba = to_stat_tgt_dev(item)->se_hba; 128 144 129 145 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); 130 146 } 131 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst); 132 147 133 - static ssize_t target_stat_scsi_tgt_dev_show_attr_indx( 134 - struct se_dev_stat_grps *sgrps, char *page) 148 + static ssize_t target_stat_tgt_indx_show(struct config_item *item, char *page) 135 149 { 136 - struct se_device *dev = 137 - container_of(sgrps, struct se_device, dev_stat_grps); 138 - 139 - return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); 150 + return snprintf(page, PAGE_SIZE, "%u\n", to_stat_tgt_dev(item)->dev_index); 140 151 } 141 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx); 142 152 143 - static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus( 144 - struct se_dev_stat_grps *sgrps, char *page) 153 + static ssize_t target_stat_tgt_num_lus_show(struct config_item *item, 154 + char *page) 145 155 { 146 156 return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT); 147 157 } 148 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus); 149 158 150 - static ssize_t target_stat_scsi_tgt_dev_show_attr_status( 151 - struct se_dev_stat_grps *sgrps, char *page) 159 + static ssize_t target_stat_tgt_status_show(struct config_item *item, 160 + char *page) 152 161 { 153 - struct se_device *dev = 154 - container_of(sgrps, struct se_device, dev_stat_grps); 155 - 156 - if (dev->export_count) 162 + if (to_stat_tgt_dev(item)->export_count) 157 163 return snprintf(page, PAGE_SIZE, "activated"); 158 164 else 159 165 return snprintf(page, PAGE_SIZE, "deactivated"); 160 166 } 161 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status); 162 167 163 - static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus( 164 - struct se_dev_stat_grps *sgrps, char *page) 168 + static ssize_t target_stat_tgt_non_access_lus_show(struct config_item *item, 169 + char *page) 165 170 { 166 - struct se_device *dev = 167 - container_of(sgrps, struct se_device, dev_stat_grps); 168 171 int non_accessible_lus; 169 172 170 - if (dev->export_count) 173 + if (to_stat_tgt_dev(item)->export_count) 171 174 non_accessible_lus = 0; 172 175 else 173 176 non_accessible_lus = 1; 174 177 175 178 return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus); 176 179 } 177 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus); 178 180 179 - static ssize_t target_stat_scsi_tgt_dev_show_attr_resets( 180 - struct se_dev_stat_grps *sgrps, char *page) 181 + static ssize_t target_stat_tgt_resets_show(struct config_item *item, 182 + char *page) 181 183 { 182 - struct se_device *dev = 183 - container_of(sgrps, struct se_device, dev_stat_grps); 184 - 185 184 return snprintf(page, PAGE_SIZE, "%lu\n", 186 - atomic_long_read(&dev->num_resets)); 185 + atomic_long_read(&to_stat_tgt_dev(item)->num_resets)); 187 186 } 188 - DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets); 189 187 190 - 191 - CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_dev, se_dev_stat_grps, scsi_tgt_dev_group); 188 + CONFIGFS_ATTR_RO(target_stat_tgt_, inst); 189 + CONFIGFS_ATTR_RO(target_stat_tgt_, indx); 190 + CONFIGFS_ATTR_RO(target_stat_tgt_, num_lus); 191 + CONFIGFS_ATTR_RO(target_stat_tgt_, status); 192 + CONFIGFS_ATTR_RO(target_stat_tgt_, non_access_lus); 193 + CONFIGFS_ATTR_RO(target_stat_tgt_, resets); 192 194 193 195 static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = { 194 - &target_stat_scsi_tgt_dev_inst.attr, 195 - &target_stat_scsi_tgt_dev_indx.attr, 196 - &target_stat_scsi_tgt_dev_num_lus.attr, 197 - &target_stat_scsi_tgt_dev_status.attr, 198 - &target_stat_scsi_tgt_dev_non_access_lus.attr, 199 - &target_stat_scsi_tgt_dev_resets.attr, 196 + &target_stat_tgt_attr_inst, 197 + &target_stat_tgt_attr_indx, 198 + &target_stat_tgt_attr_num_lus, 199 + &target_stat_tgt_attr_status, 200 + &target_stat_tgt_attr_non_access_lus, 201 + &target_stat_tgt_attr_resets, 200 202 NULL, 201 203 }; 202 204 203 - static struct configfs_item_operations target_stat_scsi_tgt_dev_attrib_ops = { 204 - .show_attribute = target_stat_scsi_tgt_dev_attr_show, 205 - .store_attribute = target_stat_scsi_tgt_dev_attr_store, 206 - }; 207 - 208 205 static struct config_item_type target_stat_scsi_tgt_dev_cit = { 209 - .ct_item_ops = &target_stat_scsi_tgt_dev_attrib_ops, 210 206 .ct_attrs = target_stat_scsi_tgt_dev_attrs, 211 207 .ct_owner = THIS_MODULE, 212 208 }; ··· 184 242 * SCSI Logical Unit Table 185 243 */ 186 244 187 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_lu, se_dev_stat_grps); 188 - #define DEV_STAT_SCSI_LU_ATTR(_name, _mode) \ 189 - static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \ 190 - __CONFIGFS_EATTR(_name, _mode, \ 191 - target_stat_scsi_lu_show_attr_##_name, \ 192 - target_stat_scsi_lu_store_attr_##_name); 193 - 194 - #define DEV_STAT_SCSI_LU_ATTR_RO(_name) \ 195 - static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \ 196 - __CONFIGFS_EATTR_RO(_name, \ 197 - target_stat_scsi_lu_show_attr_##_name); 198 - 199 - static ssize_t target_stat_scsi_lu_show_attr_inst( 200 - struct se_dev_stat_grps *sgrps, char *page) 245 + static struct se_device *to_stat_lu_dev(struct config_item *item) 201 246 { 202 - struct se_device *dev = 203 - container_of(sgrps, struct se_device, dev_stat_grps); 204 - struct se_hba *hba = dev->se_hba; 247 + struct se_dev_stat_grps *sgrps = container_of(to_config_group(item), 248 + struct se_dev_stat_grps, scsi_lu_group); 249 + return container_of(sgrps, struct se_device, dev_stat_grps); 250 + } 251 + 252 + static ssize_t target_stat_lu_inst_show(struct config_item *item, char *page) 253 + { 254 + struct se_hba *hba = to_stat_lu_dev(item)->se_hba; 205 255 206 256 return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index); 207 257 } 208 - DEV_STAT_SCSI_LU_ATTR_RO(inst); 209 258 210 - static ssize_t target_stat_scsi_lu_show_attr_dev( 211 - struct se_dev_stat_grps *sgrps, char *page) 259 + static ssize_t target_stat_lu_dev_show(struct config_item *item, char *page) 212 260 { 213 - struct se_device *dev = 214 - container_of(sgrps, struct se_device, dev_stat_grps); 215 - 216 - return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index); 261 + return snprintf(page, PAGE_SIZE, "%u\n", 262 + to_stat_lu_dev(item)->dev_index); 217 263 } 218 - DEV_STAT_SCSI_LU_ATTR_RO(dev); 219 264 220 - static ssize_t target_stat_scsi_lu_show_attr_indx( 221 - struct se_dev_stat_grps *sgrps, char *page) 265 + static ssize_t target_stat_lu_indx_show(struct config_item *item, char *page) 222 266 { 223 267 return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX); 224 268 } 225 - DEV_STAT_SCSI_LU_ATTR_RO(indx); 226 269 227 - static ssize_t target_stat_scsi_lu_show_attr_lun( 228 - struct se_dev_stat_grps *sgrps, char *page) 270 + static ssize_t target_stat_lu_lun_show(struct config_item *item, char *page) 229 271 { 230 272 /* FIXME: scsiLuDefaultLun */ 231 273 return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0); 232 274 } 233 - DEV_STAT_SCSI_LU_ATTR_RO(lun); 234 275 235 - static ssize_t target_stat_scsi_lu_show_attr_lu_name( 236 - struct se_dev_stat_grps *sgrps, char *page) 276 + static ssize_t target_stat_lu_lu_name_show(struct config_item *item, char *page) 237 277 { 238 - struct se_device *dev = 239 - container_of(sgrps, struct se_device, dev_stat_grps); 278 + struct se_device *dev = to_stat_lu_dev(item); 240 279 241 280 /* scsiLuWwnName */ 242 281 return snprintf(page, PAGE_SIZE, "%s\n", 243 282 (strlen(dev->t10_wwn.unit_serial)) ? 244 283 dev->t10_wwn.unit_serial : "None"); 245 284 } 246 - DEV_STAT_SCSI_LU_ATTR_RO(lu_name); 247 285 248 - static ssize_t target_stat_scsi_lu_show_attr_vend( 249 - struct se_dev_stat_grps *sgrps, char *page) 286 + static ssize_t target_stat_lu_vend_show(struct config_item *item, char *page) 250 287 { 251 - struct se_device *dev = 252 - container_of(sgrps, struct se_device, dev_stat_grps); 288 + struct se_device *dev = to_stat_lu_dev(item); 253 289 int i; 254 290 char str[sizeof(dev->t10_wwn.vendor)+1]; 255 291 ··· 238 318 str[i] = '\0'; 239 319 return snprintf(page, PAGE_SIZE, "%s\n", str); 240 320 } 241 - DEV_STAT_SCSI_LU_ATTR_RO(vend); 242 321 243 - static ssize_t target_stat_scsi_lu_show_attr_prod( 244 - struct se_dev_stat_grps *sgrps, char *page) 322 + static ssize_t target_stat_lu_prod_show(struct config_item *item, char *page) 245 323 { 246 - struct se_device *dev = 247 - container_of(sgrps, struct se_device, dev_stat_grps); 324 + struct se_device *dev = to_stat_lu_dev(item); 248 325 int i; 249 326 char str[sizeof(dev->t10_wwn.model)+1]; 250 327 ··· 252 335 str[i] = '\0'; 253 336 return snprintf(page, PAGE_SIZE, "%s\n", str); 254 337 } 255 - DEV_STAT_SCSI_LU_ATTR_RO(prod); 256 338 257 - static ssize_t target_stat_scsi_lu_show_attr_rev( 258 - struct se_dev_stat_grps *sgrps, char *page) 339 + static ssize_t target_stat_lu_rev_show(struct config_item *item, char *page) 259 340 { 260 - struct se_device *dev = 261 - container_of(sgrps, struct se_device, dev_stat_grps); 341 + struct se_device *dev = to_stat_lu_dev(item); 262 342 int i; 263 343 char str[sizeof(dev->t10_wwn.revision)+1]; 264 344 ··· 266 352 str[i] = '\0'; 267 353 return snprintf(page, PAGE_SIZE, "%s\n", str); 268 354 } 269 - DEV_STAT_SCSI_LU_ATTR_RO(rev); 270 355 271 - static ssize_t target_stat_scsi_lu_show_attr_dev_type( 272 - struct se_dev_stat_grps *sgrps, char *page) 356 + static ssize_t target_stat_lu_dev_type_show(struct config_item *item, char *page) 273 357 { 274 - struct se_device *dev = 275 - container_of(sgrps, struct se_device, dev_stat_grps); 358 + struct se_device *dev = to_stat_lu_dev(item); 276 359 277 360 /* scsiLuPeripheralType */ 278 361 return snprintf(page, PAGE_SIZE, "%u\n", 279 362 dev->transport->get_device_type(dev)); 280 363 } 281 - DEV_STAT_SCSI_LU_ATTR_RO(dev_type); 282 364 283 - static ssize_t target_stat_scsi_lu_show_attr_status( 284 - struct se_dev_stat_grps *sgrps, char *page) 365 + static ssize_t target_stat_lu_status_show(struct config_item *item, char *page) 285 366 { 286 - struct se_device *dev = 287 - container_of(sgrps, struct se_device, dev_stat_grps); 367 + struct se_device *dev = to_stat_lu_dev(item); 288 368 289 369 /* scsiLuStatus */ 290 370 return snprintf(page, PAGE_SIZE, "%s\n", 291 371 (dev->export_count) ? "available" : "notavailable"); 292 372 } 293 - DEV_STAT_SCSI_LU_ATTR_RO(status); 294 373 295 - static ssize_t target_stat_scsi_lu_show_attr_state_bit( 296 - struct se_dev_stat_grps *sgrps, char *page) 374 + static ssize_t target_stat_lu_state_bit_show(struct config_item *item, 375 + char *page) 297 376 { 298 377 /* scsiLuState */ 299 378 return snprintf(page, PAGE_SIZE, "exposed\n"); 300 379 } 301 - DEV_STAT_SCSI_LU_ATTR_RO(state_bit); 302 380 303 - static ssize_t target_stat_scsi_lu_show_attr_num_cmds( 304 - struct se_dev_stat_grps *sgrps, char *page) 381 + static ssize_t target_stat_lu_num_cmds_show(struct config_item *item, 382 + char *page) 305 383 { 306 - struct se_device *dev = 307 - container_of(sgrps, struct se_device, dev_stat_grps); 384 + struct se_device *dev = to_stat_lu_dev(item); 308 385 309 386 /* scsiLuNumCommands */ 310 387 return snprintf(page, PAGE_SIZE, "%lu\n", 311 388 atomic_long_read(&dev->num_cmds)); 312 389 } 313 - DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); 314 390 315 - static ssize_t target_stat_scsi_lu_show_attr_read_mbytes( 316 - struct se_dev_stat_grps *sgrps, char *page) 391 + static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item, 392 + char *page) 317 393 { 318 - struct se_device *dev = 319 - container_of(sgrps, struct se_device, dev_stat_grps); 394 + struct se_device *dev = to_stat_lu_dev(item); 320 395 321 396 /* scsiLuReadMegaBytes */ 322 397 return snprintf(page, PAGE_SIZE, "%lu\n", 323 398 atomic_long_read(&dev->read_bytes) >> 20); 324 399 } 325 - DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); 326 400 327 - static ssize_t target_stat_scsi_lu_show_attr_write_mbytes( 328 - struct se_dev_stat_grps *sgrps, char *page) 401 + static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item, 402 + char *page) 329 403 { 330 - struct se_device *dev = 331 - container_of(sgrps, struct se_device, dev_stat_grps); 404 + struct se_device *dev = to_stat_lu_dev(item); 332 405 333 406 /* scsiLuWrittenMegaBytes */ 334 407 return snprintf(page, PAGE_SIZE, "%lu\n", 335 408 atomic_long_read(&dev->write_bytes) >> 20); 336 409 } 337 - DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); 338 410 339 - static ssize_t target_stat_scsi_lu_show_attr_resets( 340 - struct se_dev_stat_grps *sgrps, char *page) 411 + static ssize_t target_stat_lu_resets_show(struct config_item *item, char *page) 341 412 { 342 - struct se_device *dev = 343 - container_of(sgrps, struct se_device, dev_stat_grps); 413 + struct se_device *dev = to_stat_lu_dev(item); 344 414 345 415 /* scsiLuInResets */ 346 - return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets)); 416 + return snprintf(page, PAGE_SIZE, "%lu\n", 417 + atomic_long_read(&dev->num_resets)); 347 418 } 348 - DEV_STAT_SCSI_LU_ATTR_RO(resets); 349 419 350 - static ssize_t target_stat_scsi_lu_show_attr_full_stat( 351 - struct se_dev_stat_grps *sgrps, char *page) 420 + static ssize_t target_stat_lu_full_stat_show(struct config_item *item, 421 + char *page) 352 422 { 353 423 /* FIXME: scsiLuOutTaskSetFullStatus */ 354 424 return snprintf(page, PAGE_SIZE, "%u\n", 0); 355 425 } 356 - DEV_STAT_SCSI_LU_ATTR_RO(full_stat); 357 426 358 - static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds( 359 - struct se_dev_stat_grps *sgrps, char *page) 427 + static ssize_t target_stat_lu_hs_num_cmds_show(struct config_item *item, 428 + char *page) 360 429 { 361 430 /* FIXME: scsiLuHSInCommands */ 362 431 return snprintf(page, PAGE_SIZE, "%u\n", 0); 363 432 } 364 - DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds); 365 433 366 - static ssize_t target_stat_scsi_lu_show_attr_creation_time( 367 - struct se_dev_stat_grps *sgrps, char *page) 434 + static ssize_t target_stat_lu_creation_time_show(struct config_item *item, 435 + char *page) 368 436 { 369 - struct se_device *dev = 370 - container_of(sgrps, struct se_device, dev_stat_grps); 437 + struct se_device *dev = to_stat_lu_dev(item); 371 438 372 439 /* scsiLuCreationTime */ 373 440 return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time - 374 441 INITIAL_JIFFIES) * 100 / HZ)); 375 442 } 376 - DEV_STAT_SCSI_LU_ATTR_RO(creation_time); 377 443 378 - CONFIGFS_EATTR_OPS(target_stat_scsi_lu, se_dev_stat_grps, scsi_lu_group); 444 + CONFIGFS_ATTR_RO(target_stat_lu_, inst); 445 + CONFIGFS_ATTR_RO(target_stat_lu_, dev); 446 + CONFIGFS_ATTR_RO(target_stat_lu_, indx); 447 + CONFIGFS_ATTR_RO(target_stat_lu_, lun); 448 + CONFIGFS_ATTR_RO(target_stat_lu_, lu_name); 449 + CONFIGFS_ATTR_RO(target_stat_lu_, vend); 450 + CONFIGFS_ATTR_RO(target_stat_lu_, prod); 451 + CONFIGFS_ATTR_RO(target_stat_lu_, rev); 452 + CONFIGFS_ATTR_RO(target_stat_lu_, dev_type); 453 + CONFIGFS_ATTR_RO(target_stat_lu_, status); 454 + CONFIGFS_ATTR_RO(target_stat_lu_, state_bit); 455 + CONFIGFS_ATTR_RO(target_stat_lu_, num_cmds); 456 + CONFIGFS_ATTR_RO(target_stat_lu_, read_mbytes); 457 + CONFIGFS_ATTR_RO(target_stat_lu_, write_mbytes); 458 + CONFIGFS_ATTR_RO(target_stat_lu_, resets); 459 + CONFIGFS_ATTR_RO(target_stat_lu_, full_stat); 460 + CONFIGFS_ATTR_RO(target_stat_lu_, hs_num_cmds); 461 + CONFIGFS_ATTR_RO(target_stat_lu_, creation_time); 379 462 380 463 static struct configfs_attribute *target_stat_scsi_lu_attrs[] = { 381 - &target_stat_scsi_lu_inst.attr, 382 - &target_stat_scsi_lu_dev.attr, 383 - &target_stat_scsi_lu_indx.attr, 384 - &target_stat_scsi_lu_lun.attr, 385 - &target_stat_scsi_lu_lu_name.attr, 386 - &target_stat_scsi_lu_vend.attr, 387 - &target_stat_scsi_lu_prod.attr, 388 - &target_stat_scsi_lu_rev.attr, 389 - &target_stat_scsi_lu_dev_type.attr, 390 - &target_stat_scsi_lu_status.attr, 391 - &target_stat_scsi_lu_state_bit.attr, 392 - &target_stat_scsi_lu_num_cmds.attr, 393 - &target_stat_scsi_lu_read_mbytes.attr, 394 - &target_stat_scsi_lu_write_mbytes.attr, 395 - &target_stat_scsi_lu_resets.attr, 396 - &target_stat_scsi_lu_full_stat.attr, 397 - &target_stat_scsi_lu_hs_num_cmds.attr, 398 - &target_stat_scsi_lu_creation_time.attr, 464 + &target_stat_lu_attr_inst, 465 + &target_stat_lu_attr_dev, 466 + &target_stat_lu_attr_indx, 467 + &target_stat_lu_attr_lun, 468 + &target_stat_lu_attr_lu_name, 469 + &target_stat_lu_attr_vend, 470 + &target_stat_lu_attr_prod, 471 + &target_stat_lu_attr_rev, 472 + &target_stat_lu_attr_dev_type, 473 + &target_stat_lu_attr_status, 474 + &target_stat_lu_attr_state_bit, 475 + &target_stat_lu_attr_num_cmds, 476 + &target_stat_lu_attr_read_mbytes, 477 + &target_stat_lu_attr_write_mbytes, 478 + &target_stat_lu_attr_resets, 479 + &target_stat_lu_attr_full_stat, 480 + &target_stat_lu_attr_hs_num_cmds, 481 + &target_stat_lu_attr_creation_time, 399 482 NULL, 400 483 }; 401 484 402 - static struct configfs_item_operations target_stat_scsi_lu_attrib_ops = { 403 - .show_attribute = target_stat_scsi_lu_attr_show, 404 - .store_attribute = target_stat_scsi_lu_attr_store, 405 - }; 406 - 407 485 static struct config_item_type target_stat_scsi_lu_cit = { 408 - .ct_item_ops = &target_stat_scsi_lu_attrib_ops, 409 486 .ct_attrs = target_stat_scsi_lu_attrs, 410 487 .ct_owner = THIS_MODULE, 411 488 }; ··· 426 521 * SCSI Port Table 427 522 */ 428 523 429 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_port, se_port_stat_grps); 430 - #define DEV_STAT_SCSI_PORT_ATTR(_name, _mode) \ 431 - static struct target_stat_scsi_port_attribute \ 432 - target_stat_scsi_port_##_name = \ 433 - __CONFIGFS_EATTR(_name, _mode, \ 434 - target_stat_scsi_port_show_attr_##_name, \ 435 - target_stat_scsi_port_store_attr_##_name); 436 - 437 - #define DEV_STAT_SCSI_PORT_ATTR_RO(_name) \ 438 - static struct target_stat_scsi_port_attribute \ 439 - target_stat_scsi_port_##_name = \ 440 - __CONFIGFS_EATTR_RO(_name, \ 441 - target_stat_scsi_port_show_attr_##_name); 442 - 443 - static ssize_t target_stat_scsi_port_show_attr_inst( 444 - struct se_port_stat_grps *pgrps, char *page) 524 + static struct se_lun *to_stat_port(struct config_item *item) 445 525 { 446 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 526 + struct se_port_stat_grps *pgrps = container_of(to_config_group(item), 527 + struct se_port_stat_grps, scsi_port_group); 528 + return container_of(pgrps, struct se_lun, port_stat_grps); 529 + } 530 + 531 + static ssize_t target_stat_port_inst_show(struct config_item *item, char *page) 532 + { 533 + struct se_lun *lun = to_stat_port(item); 447 534 struct se_device *dev; 448 535 ssize_t ret = -ENODEV; 449 536 ··· 446 549 rcu_read_unlock(); 447 550 return ret; 448 551 } 449 - DEV_STAT_SCSI_PORT_ATTR_RO(inst); 450 552 451 - static ssize_t target_stat_scsi_port_show_attr_dev( 452 - struct se_port_stat_grps *pgrps, char *page) 553 + static ssize_t target_stat_port_dev_show(struct config_item *item, char *page) 453 554 { 454 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 555 + struct se_lun *lun = to_stat_port(item); 455 556 struct se_device *dev; 456 557 ssize_t ret = -ENODEV; 457 558 ··· 460 565 rcu_read_unlock(); 461 566 return ret; 462 567 } 463 - DEV_STAT_SCSI_PORT_ATTR_RO(dev); 464 568 465 - static ssize_t target_stat_scsi_port_show_attr_indx( 466 - struct se_port_stat_grps *pgrps, char *page) 569 + static ssize_t target_stat_port_indx_show(struct config_item *item, char *page) 467 570 { 468 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 571 + struct se_lun *lun = to_stat_port(item); 469 572 struct se_device *dev; 470 573 ssize_t ret = -ENODEV; 471 574 ··· 474 581 rcu_read_unlock(); 475 582 return ret; 476 583 } 477 - DEV_STAT_SCSI_PORT_ATTR_RO(indx); 478 584 479 - static ssize_t target_stat_scsi_port_show_attr_role( 480 - struct se_port_stat_grps *pgrps, char *page) 585 + static ssize_t target_stat_port_role_show(struct config_item *item, char *page) 481 586 { 482 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 587 + struct se_lun *lun = to_stat_port(item); 483 588 struct se_device *dev; 484 589 ssize_t ret = -ENODEV; 485 590 ··· 488 597 rcu_read_unlock(); 489 598 return ret; 490 599 } 491 - DEV_STAT_SCSI_PORT_ATTR_RO(role); 492 600 493 - static ssize_t target_stat_scsi_port_show_attr_busy_count( 494 - struct se_port_stat_grps *pgrps, char *page) 601 + static ssize_t target_stat_port_busy_count_show(struct config_item *item, 602 + char *page) 495 603 { 496 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 604 + struct se_lun *lun = to_stat_port(item); 497 605 struct se_device *dev; 498 606 ssize_t ret = -ENODEV; 499 607 ··· 505 615 rcu_read_unlock(); 506 616 return ret; 507 617 } 508 - DEV_STAT_SCSI_PORT_ATTR_RO(busy_count); 509 618 510 - CONFIGFS_EATTR_OPS(target_stat_scsi_port, se_port_stat_grps, scsi_port_group); 619 + CONFIGFS_ATTR_RO(target_stat_port_, inst); 620 + CONFIGFS_ATTR_RO(target_stat_port_, dev); 621 + CONFIGFS_ATTR_RO(target_stat_port_, indx); 622 + CONFIGFS_ATTR_RO(target_stat_port_, role); 623 + CONFIGFS_ATTR_RO(target_stat_port_, busy_count); 511 624 512 625 static struct configfs_attribute *target_stat_scsi_port_attrs[] = { 513 - &target_stat_scsi_port_inst.attr, 514 - &target_stat_scsi_port_dev.attr, 515 - &target_stat_scsi_port_indx.attr, 516 - &target_stat_scsi_port_role.attr, 517 - &target_stat_scsi_port_busy_count.attr, 626 + &target_stat_port_attr_inst, 627 + &target_stat_port_attr_dev, 628 + &target_stat_port_attr_indx, 629 + &target_stat_port_attr_role, 630 + &target_stat_port_attr_busy_count, 518 631 NULL, 519 632 }; 520 633 521 - static struct configfs_item_operations target_stat_scsi_port_attrib_ops = { 522 - .show_attribute = target_stat_scsi_port_attr_show, 523 - .store_attribute = target_stat_scsi_port_attr_store, 524 - }; 525 - 526 634 static struct config_item_type target_stat_scsi_port_cit = { 527 - .ct_item_ops = &target_stat_scsi_port_attrib_ops, 528 635 .ct_attrs = target_stat_scsi_port_attrs, 529 636 .ct_owner = THIS_MODULE, 530 637 }; ··· 529 642 /* 530 643 * SCSI Target Port Table 531 644 */ 532 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_port, se_port_stat_grps); 533 - #define DEV_STAT_SCSI_TGT_PORT_ATTR(_name, _mode) \ 534 - static struct target_stat_scsi_tgt_port_attribute \ 535 - target_stat_scsi_tgt_port_##_name = \ 536 - __CONFIGFS_EATTR(_name, _mode, \ 537 - target_stat_scsi_tgt_port_show_attr_##_name, \ 538 - target_stat_scsi_tgt_port_store_attr_##_name); 539 - 540 - #define DEV_STAT_SCSI_TGT_PORT_ATTR_RO(_name) \ 541 - static struct target_stat_scsi_tgt_port_attribute \ 542 - target_stat_scsi_tgt_port_##_name = \ 543 - __CONFIGFS_EATTR_RO(_name, \ 544 - target_stat_scsi_tgt_port_show_attr_##_name); 545 - 546 - static ssize_t target_stat_scsi_tgt_port_show_attr_inst( 547 - struct se_port_stat_grps *pgrps, char *page) 645 + static struct se_lun *to_stat_tgt_port(struct config_item *item) 548 646 { 549 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 647 + struct se_port_stat_grps *pgrps = container_of(to_config_group(item), 648 + struct se_port_stat_grps, scsi_tgt_port_group); 649 + return container_of(pgrps, struct se_lun, port_stat_grps); 650 + } 651 + 652 + static ssize_t target_stat_tgt_port_inst_show(struct config_item *item, 653 + char *page) 654 + { 655 + struct se_lun *lun = to_stat_tgt_port(item); 550 656 struct se_device *dev; 551 657 ssize_t ret = -ENODEV; 552 658 ··· 550 670 rcu_read_unlock(); 551 671 return ret; 552 672 } 553 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst); 554 673 555 - static ssize_t target_stat_scsi_tgt_port_show_attr_dev( 556 - struct se_port_stat_grps *pgrps, char *page) 674 + static ssize_t target_stat_tgt_port_dev_show(struct config_item *item, 675 + char *page) 557 676 { 558 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 677 + struct se_lun *lun = to_stat_tgt_port(item); 559 678 struct se_device *dev; 560 679 ssize_t ret = -ENODEV; 561 680 ··· 565 686 rcu_read_unlock(); 566 687 return ret; 567 688 } 568 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev); 569 689 570 - static ssize_t target_stat_scsi_tgt_port_show_attr_indx( 571 - struct se_port_stat_grps *pgrps, char *page) 690 + static ssize_t target_stat_tgt_port_indx_show(struct config_item *item, 691 + char *page) 572 692 { 573 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 693 + struct se_lun *lun = to_stat_tgt_port(item); 574 694 struct se_device *dev; 575 695 ssize_t ret = -ENODEV; 576 696 ··· 580 702 rcu_read_unlock(); 581 703 return ret; 582 704 } 583 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx); 584 705 585 - static ssize_t target_stat_scsi_tgt_port_show_attr_name( 586 - struct se_port_stat_grps *pgrps, char *page) 706 + static ssize_t target_stat_tgt_port_name_show(struct config_item *item, 707 + char *page) 587 708 { 588 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 709 + struct se_lun *lun = to_stat_tgt_port(item); 589 710 struct se_portal_group *tpg = lun->lun_tpg; 590 711 struct se_device *dev; 591 712 ssize_t ret = -ENODEV; ··· 598 721 rcu_read_unlock(); 599 722 return ret; 600 723 } 601 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name); 602 724 603 - static ssize_t target_stat_scsi_tgt_port_show_attr_port_index( 604 - struct se_port_stat_grps *pgrps, char *page) 725 + static ssize_t target_stat_tgt_port_port_index_show(struct config_item *item, 726 + char *page) 605 727 { 606 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 728 + struct se_lun *lun = to_stat_tgt_port(item); 607 729 struct se_portal_group *tpg = lun->lun_tpg; 608 730 struct se_device *dev; 609 731 ssize_t ret = -ENODEV; ··· 616 740 rcu_read_unlock(); 617 741 return ret; 618 742 } 619 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index); 620 743 621 - static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds( 622 - struct se_port_stat_grps *pgrps, char *page) 744 + static ssize_t target_stat_tgt_port_in_cmds_show(struct config_item *item, 745 + char *page) 623 746 { 624 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 747 + struct se_lun *lun = to_stat_tgt_port(item); 625 748 struct se_device *dev; 626 749 ssize_t ret = -ENODEV; 627 750 ··· 632 757 rcu_read_unlock(); 633 758 return ret; 634 759 } 635 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds); 636 760 637 - static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes( 638 - struct se_port_stat_grps *pgrps, char *page) 761 + static ssize_t target_stat_tgt_port_write_mbytes_show(struct config_item *item, 762 + char *page) 639 763 { 640 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 764 + struct se_lun *lun = to_stat_tgt_port(item); 641 765 struct se_device *dev; 642 766 ssize_t ret = -ENODEV; 643 767 ··· 648 774 rcu_read_unlock(); 649 775 return ret; 650 776 } 651 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes); 652 777 653 - static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes( 654 - struct se_port_stat_grps *pgrps, char *page) 778 + static ssize_t target_stat_tgt_port_read_mbytes_show(struct config_item *item, 779 + char *page) 655 780 { 656 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 781 + struct se_lun *lun = to_stat_tgt_port(item); 657 782 struct se_device *dev; 658 783 ssize_t ret = -ENODEV; 659 784 ··· 664 791 rcu_read_unlock(); 665 792 return ret; 666 793 } 667 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes); 668 794 669 - static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds( 670 - struct se_port_stat_grps *pgrps, char *page) 795 + static ssize_t target_stat_tgt_port_hs_in_cmds_show(struct config_item *item, 796 + char *page) 671 797 { 672 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 798 + struct se_lun *lun = to_stat_tgt_port(item); 673 799 struct se_device *dev; 674 800 ssize_t ret = -ENODEV; 675 801 ··· 681 809 rcu_read_unlock(); 682 810 return ret; 683 811 } 684 - DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds); 685 812 686 - CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port, se_port_stat_grps, 687 - scsi_tgt_port_group); 813 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, inst); 814 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, dev); 815 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, indx); 816 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, name); 817 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, port_index); 818 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, in_cmds); 819 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, write_mbytes); 820 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, read_mbytes); 821 + CONFIGFS_ATTR_RO(target_stat_tgt_port_, hs_in_cmds); 688 822 689 823 static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = { 690 - &target_stat_scsi_tgt_port_inst.attr, 691 - &target_stat_scsi_tgt_port_dev.attr, 692 - &target_stat_scsi_tgt_port_indx.attr, 693 - &target_stat_scsi_tgt_port_name.attr, 694 - &target_stat_scsi_tgt_port_port_index.attr, 695 - &target_stat_scsi_tgt_port_in_cmds.attr, 696 - &target_stat_scsi_tgt_port_write_mbytes.attr, 697 - &target_stat_scsi_tgt_port_read_mbytes.attr, 698 - &target_stat_scsi_tgt_port_hs_in_cmds.attr, 824 + &target_stat_tgt_port_attr_inst, 825 + &target_stat_tgt_port_attr_dev, 826 + &target_stat_tgt_port_attr_indx, 827 + &target_stat_tgt_port_attr_name, 828 + &target_stat_tgt_port_attr_port_index, 829 + &target_stat_tgt_port_attr_in_cmds, 830 + &target_stat_tgt_port_attr_write_mbytes, 831 + &target_stat_tgt_port_attr_read_mbytes, 832 + &target_stat_tgt_port_attr_hs_in_cmds, 699 833 NULL, 700 834 }; 701 835 702 - static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops = { 703 - .show_attribute = target_stat_scsi_tgt_port_attr_show, 704 - .store_attribute = target_stat_scsi_tgt_port_attr_store, 705 - }; 706 - 707 836 static struct config_item_type target_stat_scsi_tgt_port_cit = { 708 - .ct_item_ops = &target_stat_scsi_tgt_port_attrib_ops, 709 837 .ct_attrs = target_stat_scsi_tgt_port_attrs, 710 838 .ct_owner = THIS_MODULE, 711 839 }; 712 840 713 841 /* 714 842 * SCSI Transport Table 715 - o */ 716 - 717 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport, se_port_stat_grps); 718 - #define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \ 719 - static struct target_stat_scsi_transport_attribute \ 720 - target_stat_scsi_transport_##_name = \ 721 - __CONFIGFS_EATTR(_name, _mode, \ 722 - target_stat_scsi_transport_show_attr_##_name, \ 723 - target_stat_scsi_transport_store_attr_##_name); 724 - 725 - #define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \ 726 - static struct target_stat_scsi_transport_attribute \ 727 - target_stat_scsi_transport_##_name = \ 728 - __CONFIGFS_EATTR_RO(_name, \ 729 - target_stat_scsi_transport_show_attr_##_name); 730 - 731 - static ssize_t target_stat_scsi_transport_show_attr_inst( 732 - struct se_port_stat_grps *pgrps, char *page) 843 + */ 844 + static struct se_lun *to_transport_stat(struct config_item *item) 733 845 { 734 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 846 + struct se_port_stat_grps *pgrps = container_of(to_config_group(item), 847 + struct se_port_stat_grps, scsi_transport_group); 848 + return container_of(pgrps, struct se_lun, port_stat_grps); 849 + } 850 + 851 + static ssize_t target_stat_transport_inst_show(struct config_item *item, 852 + char *page) 853 + { 854 + struct se_lun *lun = to_transport_stat(item); 735 855 struct se_device *dev; 736 856 ssize_t ret = -ENODEV; 737 857 ··· 734 870 rcu_read_unlock(); 735 871 return ret; 736 872 } 737 - DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst); 738 873 739 - static ssize_t target_stat_scsi_transport_show_attr_device( 740 - struct se_port_stat_grps *pgrps, char *page) 874 + static ssize_t target_stat_transport_device_show(struct config_item *item, 875 + char *page) 741 876 { 742 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 877 + struct se_lun *lun = to_transport_stat(item); 743 878 struct se_device *dev; 744 879 struct se_portal_group *tpg = lun->lun_tpg; 745 880 ssize_t ret = -ENODEV; ··· 753 890 rcu_read_unlock(); 754 891 return ret; 755 892 } 756 - DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device); 757 893 758 - static ssize_t target_stat_scsi_transport_show_attr_indx( 759 - struct se_port_stat_grps *pgrps, char *page) 894 + static ssize_t target_stat_transport_indx_show(struct config_item *item, 895 + char *page) 760 896 { 761 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 897 + struct se_lun *lun = to_transport_stat(item); 762 898 struct se_device *dev; 763 899 struct se_portal_group *tpg = lun->lun_tpg; 764 900 ssize_t ret = -ENODEV; ··· 770 908 rcu_read_unlock(); 771 909 return ret; 772 910 } 773 - DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx); 774 911 775 - static ssize_t target_stat_scsi_transport_show_attr_dev_name( 776 - struct se_port_stat_grps *pgrps, char *page) 912 + static ssize_t target_stat_transport_dev_name_show(struct config_item *item, 913 + char *page) 777 914 { 778 - struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps); 915 + struct se_lun *lun = to_transport_stat(item); 779 916 struct se_device *dev; 780 917 struct se_portal_group *tpg = lun->lun_tpg; 781 918 struct t10_wwn *wwn; ··· 793 932 rcu_read_unlock(); 794 933 return ret; 795 934 } 796 - DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name); 797 935 798 - CONFIGFS_EATTR_OPS(target_stat_scsi_transport, se_port_stat_grps, 799 - scsi_transport_group); 936 + CONFIGFS_ATTR_RO(target_stat_transport_, inst); 937 + CONFIGFS_ATTR_RO(target_stat_transport_, device); 938 + CONFIGFS_ATTR_RO(target_stat_transport_, indx); 939 + CONFIGFS_ATTR_RO(target_stat_transport_, dev_name); 800 940 801 941 static struct configfs_attribute *target_stat_scsi_transport_attrs[] = { 802 - &target_stat_scsi_transport_inst.attr, 803 - &target_stat_scsi_transport_device.attr, 804 - &target_stat_scsi_transport_indx.attr, 805 - &target_stat_scsi_transport_dev_name.attr, 942 + &target_stat_transport_attr_inst, 943 + &target_stat_transport_attr_device, 944 + &target_stat_transport_attr_indx, 945 + &target_stat_transport_attr_dev_name, 806 946 NULL, 807 947 }; 808 948 809 - static struct configfs_item_operations target_stat_scsi_transport_attrib_ops = { 810 - .show_attribute = target_stat_scsi_transport_attr_show, 811 - .store_attribute = target_stat_scsi_transport_attr_store, 812 - }; 813 - 814 949 static struct config_item_type target_stat_scsi_transport_cit = { 815 - .ct_item_ops = &target_stat_scsi_transport_attrib_ops, 816 950 .ct_attrs = target_stat_scsi_transport_attrs, 817 951 .ct_owner = THIS_MODULE, 818 952 }; ··· 837 981 * SCSI Authorized Initiator Table 838 982 */ 839 983 840 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr, se_ml_stat_grps); 841 - #define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \ 842 - static struct target_stat_scsi_auth_intr_attribute \ 843 - target_stat_scsi_auth_intr_##_name = \ 844 - __CONFIGFS_EATTR(_name, _mode, \ 845 - target_stat_scsi_auth_intr_show_attr_##_name, \ 846 - target_stat_scsi_auth_intr_store_attr_##_name); 847 - 848 - #define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \ 849 - static struct target_stat_scsi_auth_intr_attribute \ 850 - target_stat_scsi_auth_intr_##_name = \ 851 - __CONFIGFS_EATTR_RO(_name, \ 852 - target_stat_scsi_auth_intr_show_attr_##_name); 853 - 854 - static ssize_t target_stat_scsi_auth_intr_show_attr_inst( 855 - struct se_ml_stat_grps *lgrps, char *page) 984 + static struct se_lun_acl *auth_to_lacl(struct config_item *item) 856 985 { 857 - struct se_lun_acl *lacl = container_of(lgrps, 858 - struct se_lun_acl, ml_stat_grps); 986 + struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), 987 + struct se_ml_stat_grps, scsi_auth_intr_group); 988 + return container_of(lgrps, struct se_lun_acl, ml_stat_grps); 989 + } 990 + 991 + static ssize_t target_stat_auth_inst_show(struct config_item *item, 992 + char *page) 993 + { 994 + struct se_lun_acl *lacl = auth_to_lacl(item); 859 995 struct se_node_acl *nacl = lacl->se_lun_nacl; 860 996 struct se_dev_entry *deve; 861 997 struct se_portal_group *tpg; ··· 866 1018 rcu_read_unlock(); 867 1019 return ret; 868 1020 } 869 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst); 870 1021 871 - static ssize_t target_stat_scsi_auth_intr_show_attr_dev( 872 - struct se_ml_stat_grps *lgrps, char *page) 1022 + static ssize_t target_stat_auth_dev_show(struct config_item *item, 1023 + char *page) 873 1024 { 874 - struct se_lun_acl *lacl = container_of(lgrps, 875 - struct se_lun_acl, ml_stat_grps); 1025 + struct se_lun_acl *lacl = auth_to_lacl(item); 876 1026 struct se_node_acl *nacl = lacl->se_lun_nacl; 877 1027 struct se_dev_entry *deve; 878 1028 struct se_lun *lun; ··· 888 1042 rcu_read_unlock(); 889 1043 return ret; 890 1044 } 891 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev); 892 1045 893 - static ssize_t target_stat_scsi_auth_intr_show_attr_port( 894 - struct se_ml_stat_grps *lgrps, char *page) 1046 + static ssize_t target_stat_auth_port_show(struct config_item *item, 1047 + char *page) 895 1048 { 896 - struct se_lun_acl *lacl = container_of(lgrps, 897 - struct se_lun_acl, ml_stat_grps); 1049 + struct se_lun_acl *lacl = auth_to_lacl(item); 898 1050 struct se_node_acl *nacl = lacl->se_lun_nacl; 899 1051 struct se_dev_entry *deve; 900 1052 struct se_portal_group *tpg; ··· 910 1066 rcu_read_unlock(); 911 1067 return ret; 912 1068 } 913 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port); 914 1069 915 - static ssize_t target_stat_scsi_auth_intr_show_attr_indx( 916 - struct se_ml_stat_grps *lgrps, char *page) 1070 + static ssize_t target_stat_auth_indx_show(struct config_item *item, 1071 + char *page) 917 1072 { 918 - struct se_lun_acl *lacl = container_of(lgrps, 919 - struct se_lun_acl, ml_stat_grps); 1073 + struct se_lun_acl *lacl = auth_to_lacl(item); 920 1074 struct se_node_acl *nacl = lacl->se_lun_nacl; 921 1075 struct se_dev_entry *deve; 922 1076 ssize_t ret; ··· 930 1088 rcu_read_unlock(); 931 1089 return ret; 932 1090 } 933 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx); 934 1091 935 - static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port( 936 - struct se_ml_stat_grps *lgrps, char *page) 1092 + static ssize_t target_stat_auth_dev_or_port_show(struct config_item *item, 1093 + char *page) 937 1094 { 938 - struct se_lun_acl *lacl = container_of(lgrps, 939 - struct se_lun_acl, ml_stat_grps); 1095 + struct se_lun_acl *lacl = auth_to_lacl(item); 940 1096 struct se_node_acl *nacl = lacl->se_lun_nacl; 941 1097 struct se_dev_entry *deve; 942 1098 ssize_t ret; ··· 950 1110 rcu_read_unlock(); 951 1111 return ret; 952 1112 } 953 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port); 954 1113 955 - static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name( 956 - struct se_ml_stat_grps *lgrps, char *page) 1114 + static ssize_t target_stat_auth_intr_name_show(struct config_item *item, 1115 + char *page) 957 1116 { 958 - struct se_lun_acl *lacl = container_of(lgrps, 959 - struct se_lun_acl, ml_stat_grps); 1117 + struct se_lun_acl *lacl = auth_to_lacl(item); 960 1118 struct se_node_acl *nacl = lacl->se_lun_nacl; 961 1119 struct se_dev_entry *deve; 962 1120 ssize_t ret; ··· 970 1132 rcu_read_unlock(); 971 1133 return ret; 972 1134 } 973 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name); 974 1135 975 - static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx( 976 - struct se_ml_stat_grps *lgrps, char *page) 1136 + static ssize_t target_stat_auth_map_indx_show(struct config_item *item, 1137 + char *page) 977 1138 { 978 - struct se_lun_acl *lacl = container_of(lgrps, 979 - struct se_lun_acl, ml_stat_grps); 1139 + struct se_lun_acl *lacl = auth_to_lacl(item); 980 1140 struct se_node_acl *nacl = lacl->se_lun_nacl; 981 1141 struct se_dev_entry *deve; 982 1142 ssize_t ret; ··· 990 1154 rcu_read_unlock(); 991 1155 return ret; 992 1156 } 993 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx); 994 1157 995 - static ssize_t target_stat_scsi_auth_intr_show_attr_att_count( 996 - struct se_ml_stat_grps *lgrps, char *page) 1158 + static ssize_t target_stat_auth_att_count_show(struct config_item *item, 1159 + char *page) 997 1160 { 998 - struct se_lun_acl *lacl = container_of(lgrps, 999 - struct se_lun_acl, ml_stat_grps); 1161 + struct se_lun_acl *lacl = auth_to_lacl(item); 1000 1162 struct se_node_acl *nacl = lacl->se_lun_nacl; 1001 1163 struct se_dev_entry *deve; 1002 1164 ssize_t ret; ··· 1010 1176 rcu_read_unlock(); 1011 1177 return ret; 1012 1178 } 1013 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count); 1014 1179 1015 - static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds( 1016 - struct se_ml_stat_grps *lgrps, char *page) 1180 + static ssize_t target_stat_auth_num_cmds_show(struct config_item *item, 1181 + char *page) 1017 1182 { 1018 - struct se_lun_acl *lacl = container_of(lgrps, 1019 - struct se_lun_acl, ml_stat_grps); 1183 + struct se_lun_acl *lacl = auth_to_lacl(item); 1020 1184 struct se_node_acl *nacl = lacl->se_lun_nacl; 1021 1185 struct se_dev_entry *deve; 1022 1186 ssize_t ret; ··· 1031 1199 rcu_read_unlock(); 1032 1200 return ret; 1033 1201 } 1034 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds); 1035 1202 1036 - static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes( 1037 - struct se_ml_stat_grps *lgrps, char *page) 1203 + static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item, 1204 + char *page) 1038 1205 { 1039 - struct se_lun_acl *lacl = container_of(lgrps, 1040 - struct se_lun_acl, ml_stat_grps); 1206 + struct se_lun_acl *lacl = auth_to_lacl(item); 1041 1207 struct se_node_acl *nacl = lacl->se_lun_nacl; 1042 1208 struct se_dev_entry *deve; 1043 1209 ssize_t ret; ··· 1052 1222 rcu_read_unlock(); 1053 1223 return ret; 1054 1224 } 1055 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes); 1056 1225 1057 - static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes( 1058 - struct se_ml_stat_grps *lgrps, char *page) 1226 + static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item, 1227 + char *page) 1059 1228 { 1060 - struct se_lun_acl *lacl = container_of(lgrps, 1061 - struct se_lun_acl, ml_stat_grps); 1229 + struct se_lun_acl *lacl = auth_to_lacl(item); 1062 1230 struct se_node_acl *nacl = lacl->se_lun_nacl; 1063 1231 struct se_dev_entry *deve; 1064 1232 ssize_t ret; ··· 1073 1245 rcu_read_unlock(); 1074 1246 return ret; 1075 1247 } 1076 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes); 1077 1248 1078 - static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds( 1079 - struct se_ml_stat_grps *lgrps, char *page) 1249 + static ssize_t target_stat_auth_hs_num_cmds_show(struct config_item *item, 1250 + char *page) 1080 1251 { 1081 - struct se_lun_acl *lacl = container_of(lgrps, 1082 - struct se_lun_acl, ml_stat_grps); 1252 + struct se_lun_acl *lacl = auth_to_lacl(item); 1083 1253 struct se_node_acl *nacl = lacl->se_lun_nacl; 1084 1254 struct se_dev_entry *deve; 1085 1255 ssize_t ret; ··· 1093 1267 rcu_read_unlock(); 1094 1268 return ret; 1095 1269 } 1096 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds); 1097 1270 1098 - static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time( 1099 - struct se_ml_stat_grps *lgrps, char *page) 1271 + static ssize_t target_stat_auth_creation_time_show(struct config_item *item, 1272 + char *page) 1100 1273 { 1101 - struct se_lun_acl *lacl = container_of(lgrps, 1102 - struct se_lun_acl, ml_stat_grps); 1274 + struct se_lun_acl *lacl = auth_to_lacl(item); 1103 1275 struct se_node_acl *nacl = lacl->se_lun_nacl; 1104 1276 struct se_dev_entry *deve; 1105 1277 ssize_t ret; ··· 1114 1290 rcu_read_unlock(); 1115 1291 return ret; 1116 1292 } 1117 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time); 1118 1293 1119 - static ssize_t target_stat_scsi_auth_intr_show_attr_row_status( 1120 - struct se_ml_stat_grps *lgrps, char *page) 1294 + static ssize_t target_stat_auth_row_status_show(struct config_item *item, 1295 + char *page) 1121 1296 { 1122 - struct se_lun_acl *lacl = container_of(lgrps, 1123 - struct se_lun_acl, ml_stat_grps); 1297 + struct se_lun_acl *lacl = auth_to_lacl(item); 1124 1298 struct se_node_acl *nacl = lacl->se_lun_nacl; 1125 1299 struct se_dev_entry *deve; 1126 1300 ssize_t ret; ··· 1134 1312 rcu_read_unlock(); 1135 1313 return ret; 1136 1314 } 1137 - DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status); 1138 1315 1139 - CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr, se_ml_stat_grps, 1140 - scsi_auth_intr_group); 1316 + CONFIGFS_ATTR_RO(target_stat_auth_, inst); 1317 + CONFIGFS_ATTR_RO(target_stat_auth_, dev); 1318 + CONFIGFS_ATTR_RO(target_stat_auth_, port); 1319 + CONFIGFS_ATTR_RO(target_stat_auth_, indx); 1320 + CONFIGFS_ATTR_RO(target_stat_auth_, dev_or_port); 1321 + CONFIGFS_ATTR_RO(target_stat_auth_, intr_name); 1322 + CONFIGFS_ATTR_RO(target_stat_auth_, map_indx); 1323 + CONFIGFS_ATTR_RO(target_stat_auth_, att_count); 1324 + CONFIGFS_ATTR_RO(target_stat_auth_, num_cmds); 1325 + CONFIGFS_ATTR_RO(target_stat_auth_, read_mbytes); 1326 + CONFIGFS_ATTR_RO(target_stat_auth_, write_mbytes); 1327 + CONFIGFS_ATTR_RO(target_stat_auth_, hs_num_cmds); 1328 + CONFIGFS_ATTR_RO(target_stat_auth_, creation_time); 1329 + CONFIGFS_ATTR_RO(target_stat_auth_, row_status); 1141 1330 1142 1331 static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = { 1143 - &target_stat_scsi_auth_intr_inst.attr, 1144 - &target_stat_scsi_auth_intr_dev.attr, 1145 - &target_stat_scsi_auth_intr_port.attr, 1146 - &target_stat_scsi_auth_intr_indx.attr, 1147 - &target_stat_scsi_auth_intr_dev_or_port.attr, 1148 - &target_stat_scsi_auth_intr_intr_name.attr, 1149 - &target_stat_scsi_auth_intr_map_indx.attr, 1150 - &target_stat_scsi_auth_intr_att_count.attr, 1151 - &target_stat_scsi_auth_intr_num_cmds.attr, 1152 - &target_stat_scsi_auth_intr_read_mbytes.attr, 1153 - &target_stat_scsi_auth_intr_write_mbytes.attr, 1154 - &target_stat_scsi_auth_intr_hs_num_cmds.attr, 1155 - &target_stat_scsi_auth_intr_creation_time.attr, 1156 - &target_stat_scsi_auth_intr_row_status.attr, 1332 + &target_stat_auth_attr_inst, 1333 + &target_stat_auth_attr_dev, 1334 + &target_stat_auth_attr_port, 1335 + &target_stat_auth_attr_indx, 1336 + &target_stat_auth_attr_dev_or_port, 1337 + &target_stat_auth_attr_intr_name, 1338 + &target_stat_auth_attr_map_indx, 1339 + &target_stat_auth_attr_att_count, 1340 + &target_stat_auth_attr_num_cmds, 1341 + &target_stat_auth_attr_read_mbytes, 1342 + &target_stat_auth_attr_write_mbytes, 1343 + &target_stat_auth_attr_hs_num_cmds, 1344 + &target_stat_auth_attr_creation_time, 1345 + &target_stat_auth_attr_row_status, 1157 1346 NULL, 1158 1347 }; 1159 1348 1160 - static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops = { 1161 - .show_attribute = target_stat_scsi_auth_intr_attr_show, 1162 - .store_attribute = target_stat_scsi_auth_intr_attr_store, 1163 - }; 1164 - 1165 1349 static struct config_item_type target_stat_scsi_auth_intr_cit = { 1166 - .ct_item_ops = &target_stat_scsi_auth_intr_attrib_ops, 1167 1350 .ct_attrs = target_stat_scsi_auth_intr_attrs, 1168 1351 .ct_owner = THIS_MODULE, 1169 1352 }; ··· 1177 1350 * SCSI Attached Initiator Port Table 1178 1351 */ 1179 1352 1180 - CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port, se_ml_stat_grps); 1181 - #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \ 1182 - static struct target_stat_scsi_att_intr_port_attribute \ 1183 - target_stat_scsi_att_intr_port_##_name = \ 1184 - __CONFIGFS_EATTR(_name, _mode, \ 1185 - target_stat_scsi_att_intr_port_show_attr_##_name, \ 1186 - target_stat_scsi_att_intr_port_store_attr_##_name); 1187 - 1188 - #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \ 1189 - static struct target_stat_scsi_att_intr_port_attribute \ 1190 - target_stat_scsi_att_intr_port_##_name = \ 1191 - __CONFIGFS_EATTR_RO(_name, \ 1192 - target_stat_scsi_att_intr_port_show_attr_##_name); 1193 - 1194 - static ssize_t target_stat_scsi_att_intr_port_show_attr_inst( 1195 - struct se_ml_stat_grps *lgrps, char *page) 1353 + static struct se_lun_acl *iport_to_lacl(struct config_item *item) 1196 1354 { 1197 - struct se_lun_acl *lacl = container_of(lgrps, 1198 - struct se_lun_acl, ml_stat_grps); 1355 + struct se_ml_stat_grps *lgrps = container_of(to_config_group(item), 1356 + struct se_ml_stat_grps, scsi_att_intr_port_group); 1357 + return container_of(lgrps, struct se_lun_acl, ml_stat_grps); 1358 + } 1359 + 1360 + static ssize_t target_stat_iport_inst_show(struct config_item *item, 1361 + char *page) 1362 + { 1363 + struct se_lun_acl *lacl = iport_to_lacl(item); 1199 1364 struct se_node_acl *nacl = lacl->se_lun_nacl; 1200 1365 struct se_dev_entry *deve; 1201 1366 struct se_portal_group *tpg; ··· 1206 1387 rcu_read_unlock(); 1207 1388 return ret; 1208 1389 } 1209 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst); 1210 1390 1211 - static ssize_t target_stat_scsi_att_intr_port_show_attr_dev( 1212 - struct se_ml_stat_grps *lgrps, char *page) 1391 + static ssize_t target_stat_iport_dev_show(struct config_item *item, 1392 + char *page) 1213 1393 { 1214 - struct se_lun_acl *lacl = container_of(lgrps, 1215 - struct se_lun_acl, ml_stat_grps); 1394 + struct se_lun_acl *lacl = iport_to_lacl(item); 1216 1395 struct se_node_acl *nacl = lacl->se_lun_nacl; 1217 1396 struct se_dev_entry *deve; 1218 1397 struct se_lun *lun; ··· 1228 1411 rcu_read_unlock(); 1229 1412 return ret; 1230 1413 } 1231 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev); 1232 1414 1233 - static ssize_t target_stat_scsi_att_intr_port_show_attr_port( 1234 - struct se_ml_stat_grps *lgrps, char *page) 1415 + static ssize_t target_stat_iport_port_show(struct config_item *item, 1416 + char *page) 1235 1417 { 1236 - struct se_lun_acl *lacl = container_of(lgrps, 1237 - struct se_lun_acl, ml_stat_grps); 1418 + struct se_lun_acl *lacl = iport_to_lacl(item); 1238 1419 struct se_node_acl *nacl = lacl->se_lun_nacl; 1239 1420 struct se_dev_entry *deve; 1240 1421 struct se_portal_group *tpg; ··· 1250 1435 rcu_read_unlock(); 1251 1436 return ret; 1252 1437 } 1253 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port); 1254 1438 1255 - static ssize_t target_stat_scsi_att_intr_port_show_attr_indx( 1256 - struct se_ml_stat_grps *lgrps, char *page) 1439 + static ssize_t target_stat_iport_indx_show(struct config_item *item, 1440 + char *page) 1257 1441 { 1258 - struct se_lun_acl *lacl = container_of(lgrps, 1259 - struct se_lun_acl, ml_stat_grps); 1442 + struct se_lun_acl *lacl = iport_to_lacl(item); 1260 1443 struct se_node_acl *nacl = lacl->se_lun_nacl; 1261 1444 struct se_session *se_sess; 1262 1445 struct se_portal_group *tpg; ··· 1274 1461 spin_unlock_irq(&nacl->nacl_sess_lock); 1275 1462 return ret; 1276 1463 } 1277 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx); 1278 1464 1279 - static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx( 1280 - struct se_ml_stat_grps *lgrps, char *page) 1465 + static ssize_t target_stat_iport_port_auth_indx_show(struct config_item *item, 1466 + char *page) 1281 1467 { 1282 - struct se_lun_acl *lacl = container_of(lgrps, 1283 - struct se_lun_acl, ml_stat_grps); 1468 + struct se_lun_acl *lacl = iport_to_lacl(item); 1284 1469 struct se_node_acl *nacl = lacl->se_lun_nacl; 1285 1470 struct se_dev_entry *deve; 1286 1471 ssize_t ret; ··· 1294 1483 rcu_read_unlock(); 1295 1484 return ret; 1296 1485 } 1297 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx); 1298 1486 1299 - static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident( 1300 - struct se_ml_stat_grps *lgrps, char *page) 1487 + static ssize_t target_stat_iport_port_ident_show(struct config_item *item, 1488 + char *page) 1301 1489 { 1302 - struct se_lun_acl *lacl = container_of(lgrps, 1303 - struct se_lun_acl, ml_stat_grps); 1490 + struct se_lun_acl *lacl = iport_to_lacl(item); 1304 1491 struct se_node_acl *nacl = lacl->se_lun_nacl; 1305 1492 struct se_session *se_sess; 1306 1493 struct se_portal_group *tpg; ··· 1322 1513 spin_unlock_irq(&nacl->nacl_sess_lock); 1323 1514 return ret; 1324 1515 } 1325 - DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident); 1326 1516 1327 - CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port, se_ml_stat_grps, 1328 - scsi_att_intr_port_group); 1517 + CONFIGFS_ATTR_RO(target_stat_iport_, inst); 1518 + CONFIGFS_ATTR_RO(target_stat_iport_, dev); 1519 + CONFIGFS_ATTR_RO(target_stat_iport_, port); 1520 + CONFIGFS_ATTR_RO(target_stat_iport_, indx); 1521 + CONFIGFS_ATTR_RO(target_stat_iport_, port_auth_indx); 1522 + CONFIGFS_ATTR_RO(target_stat_iport_, port_ident); 1329 1523 1330 1524 static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = { 1331 - &target_stat_scsi_att_intr_port_inst.attr, 1332 - &target_stat_scsi_att_intr_port_dev.attr, 1333 - &target_stat_scsi_att_intr_port_port.attr, 1334 - &target_stat_scsi_att_intr_port_indx.attr, 1335 - &target_stat_scsi_att_intr_port_port_auth_indx.attr, 1336 - &target_stat_scsi_att_intr_port_port_ident.attr, 1525 + &target_stat_iport_attr_inst, 1526 + &target_stat_iport_attr_dev, 1527 + &target_stat_iport_attr_port, 1528 + &target_stat_iport_attr_indx, 1529 + &target_stat_iport_attr_port_auth_indx, 1530 + &target_stat_iport_attr_port_ident, 1337 1531 NULL, 1338 1532 }; 1339 1533 1340 - static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops = { 1341 - .show_attribute = target_stat_scsi_att_intr_port_attr_show, 1342 - .store_attribute = target_stat_scsi_att_intr_port_attr_store, 1343 - }; 1344 - 1345 1534 static struct config_item_type target_stat_scsi_att_intr_port_cit = { 1346 - .ct_item_ops = &target_stat_scsi_att_intr_port_attrib_ops, 1347 1535 .ct_attrs = target_stat_scsi_ath_intr_port_attrs, 1348 1536 .ct_owner = THIS_MODULE, 1349 1537 };
-1
drivers/target/tcm_fc/tfc_cmd.c
··· 36 36 37 37 #include <target/target_core_base.h> 38 38 #include <target/target_core_fabric.h> 39 - #include <target/configfs_macros.h> 40 39 41 40 #include "tcm_fc.h" 42 41
+18 -26
drivers/target/tcm_fc/tfc_conf.c
··· 38 38 39 39 #include <target/target_core_base.h> 40 40 #include <target/target_core_fabric.h> 41 - #include <target/target_core_fabric_configfs.h> 42 - #include <target/configfs_macros.h> 43 41 44 42 #include "tcm_fc.h" 45 43 ··· 129 131 * ACL auth ops. 130 132 */ 131 133 132 - static ssize_t ft_nacl_show_port_name( 133 - struct se_node_acl *se_nacl, 134 - char *page) 134 + static ssize_t ft_nacl_port_name_show(struct config_item *item, char *page) 135 135 { 136 + struct se_node_acl *se_nacl = acl_to_nacl(item); 136 137 struct ft_node_acl *acl = container_of(se_nacl, 137 138 struct ft_node_acl, se_node_acl); 138 139 139 140 return ft_wwn_show(&acl->node_auth.port_name, page); 140 141 } 141 142 142 - static ssize_t ft_nacl_store_port_name( 143 - struct se_node_acl *se_nacl, 144 - const char *page, 145 - size_t count) 143 + static ssize_t ft_nacl_port_name_store(struct config_item *item, 144 + const char *page, size_t count) 146 145 { 146 + struct se_node_acl *se_nacl = acl_to_nacl(item); 147 147 struct ft_node_acl *acl = container_of(se_nacl, 148 148 struct ft_node_acl, se_node_acl); 149 149 150 150 return ft_wwn_store(&acl->node_auth.port_name, page, count); 151 151 } 152 152 153 - TF_NACL_BASE_ATTR(ft, port_name, S_IRUGO | S_IWUSR); 154 - 155 - static ssize_t ft_nacl_show_node_name( 156 - struct se_node_acl *se_nacl, 157 - char *page) 153 + static ssize_t ft_nacl_node_name_show(struct config_item *item, 154 + char *page) 158 155 { 156 + struct se_node_acl *se_nacl = acl_to_nacl(item); 159 157 struct ft_node_acl *acl = container_of(se_nacl, 160 158 struct ft_node_acl, se_node_acl); 161 159 162 160 return ft_wwn_show(&acl->node_auth.node_name, page); 163 161 } 164 162 165 - static ssize_t ft_nacl_store_node_name( 166 - struct se_node_acl *se_nacl, 167 - const char *page, 168 - size_t count) 163 + static ssize_t ft_nacl_node_name_store(struct config_item *item, 164 + const char *page, size_t count) 169 165 { 166 + struct se_node_acl *se_nacl = acl_to_nacl(item); 170 167 struct ft_node_acl *acl = container_of(se_nacl, 171 168 struct ft_node_acl, se_node_acl); 172 169 173 170 return ft_wwn_store(&acl->node_auth.node_name, page, count); 174 171 } 175 172 176 - TF_NACL_BASE_ATTR(ft, node_name, S_IRUGO | S_IWUSR); 173 + CONFIGFS_ATTR(ft_nacl_, node_name); 174 + CONFIGFS_ATTR(ft_nacl_, port_name); 177 175 178 176 static struct configfs_attribute *ft_nacl_base_attrs[] = { 179 - &ft_nacl_port_name.attr, 180 - &ft_nacl_node_name.attr, 177 + &ft_nacl_attr_port_name, 178 + &ft_nacl_attr_node_name, 181 179 NULL, 182 180 }; 183 181 ··· 380 386 kfree(ft_wwn); 381 387 } 382 388 383 - static ssize_t ft_wwn_show_attr_version( 384 - struct target_fabric_configfs *tf, 385 - char *page) 389 + static ssize_t ft_wwn_version_show(struct config_item *item, char *page) 386 390 { 387 391 return sprintf(page, "TCM FC " FT_VERSION " on %s/%s on " 388 392 ""UTS_RELEASE"\n", utsname()->sysname, utsname()->machine); 389 393 } 390 394 391 - TF_WWN_ATTR_RO(ft, version); 395 + CONFIGFS_ATTR_RO(ft_wwn_, version); 392 396 393 397 static struct configfs_attribute *ft_wwn_attrs[] = { 394 - &ft_wwn_version.attr, 398 + &ft_wwn_attr_version, 395 399 NULL, 396 400 }; 397 401
-1
drivers/target/tcm_fc/tfc_io.c
··· 44 44 45 45 #include <target/target_core_base.h> 46 46 #include <target/target_core_fabric.h> 47 - #include <target/configfs_macros.h> 48 47 49 48 #include "tcm_fc.h" 50 49
-1
drivers/target/tcm_fc/tfc_sess.c
··· 36 36 37 37 #include <target/target_core_base.h> 38 38 #include <target/target_core_fabric.h> 39 - #include <target/configfs_macros.h> 40 39 41 40 #include "tcm_fc.h" 42 41
+114 -183
drivers/usb/gadget/configfs.c
··· 64 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 72 struct config_usb_cfg { 68 73 struct config_group group; 69 74 struct config_group strings_group; ··· 78 73 struct list_head func_list; 79 74 struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1]; 80 75 }; 76 + 77 + static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item) 78 + { 79 + return container_of(to_config_group(item), struct config_usb_cfg, 80 + group); 81 + } 81 82 82 83 struct gadget_strings { 83 84 struct usb_gadget_strings stringtab_dev; ··· 128 117 return 0; 129 118 } 130 119 131 - CONFIGFS_ATTR_STRUCT(gadget_info); 132 - CONFIGFS_ATTR_STRUCT(config_usb_cfg); 133 - 134 - #define GI_DEVICE_DESC_ITEM_ATTR(name) \ 135 - static struct gadget_info_attribute gadget_cdev_desc_##name = \ 136 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 137 - gadget_dev_desc_##name##_show, \ 138 - gadget_dev_desc_##name##_store) 139 - 140 120 #define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \ 141 - static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \ 121 + static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \ 142 122 char *page) \ 143 123 { \ 144 - return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \ 124 + return sprintf(page, "0x%02x\n", \ 125 + to_gadget_info(item)->cdev.desc.__name); \ 145 126 } 146 127 147 128 #define GI_DEVICE_DESC_SIMPLE_R_u16(__name) \ 148 - static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \ 129 + static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \ 149 130 char *page) \ 150 131 { \ 151 - return sprintf(page, "0x%04x\n", le16_to_cpup(&gi->cdev.desc.__name)); \ 132 + return sprintf(page, "0x%04x\n", \ 133 + le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \ 152 134 } 153 135 154 136 155 137 #define GI_DEVICE_DESC_SIMPLE_W_u8(_name) \ 156 - static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \ 138 + static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \ 157 139 const char *page, size_t len) \ 158 140 { \ 159 141 u8 val; \ ··· 154 150 ret = kstrtou8(page, 0, &val); \ 155 151 if (ret) \ 156 152 return ret; \ 157 - gi->cdev.desc._name = val; \ 153 + to_gadget_info(item)->cdev.desc._name = val; \ 158 154 return len; \ 159 155 } 160 156 161 157 #define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \ 162 - static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \ 158 + static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \ 163 159 const char *page, size_t len) \ 164 160 { \ 165 161 u16 val; \ ··· 167 163 ret = kstrtou16(page, 0, &val); \ 168 164 if (ret) \ 169 165 return ret; \ 170 - gi->cdev.desc._name = cpu_to_le16p(&val); \ 166 + to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \ 171 167 return len; \ 172 168 } 173 169 ··· 197 193 return 0; 198 194 } 199 195 200 - static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi, 196 + static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item, 201 197 const char *page, size_t len) 202 198 { 203 199 u16 bcdDevice; ··· 210 206 if (ret) 211 207 return ret; 212 208 213 - gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice); 209 + to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice); 214 210 return len; 215 211 } 216 212 217 - static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi, 213 + static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item, 218 214 const char *page, size_t len) 219 215 { 220 216 u16 bcdUSB; ··· 227 223 if (ret) 228 224 return ret; 229 225 230 - gi->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB); 226 + to_gadget_info(item)->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB); 231 227 return len; 232 228 } 233 229 234 - static ssize_t gadget_dev_desc_UDC_show(struct gadget_info *gi, char *page) 230 + static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page) 235 231 { 236 - return sprintf(page, "%s\n", gi->udc_name ?: ""); 232 + return sprintf(page, "%s\n", to_gadget_info(item)->udc_name ?: ""); 237 233 } 238 234 239 235 static int unregister_gadget(struct gadget_info *gi) ··· 251 247 return 0; 252 248 } 253 249 254 - static ssize_t gadget_dev_desc_UDC_store(struct gadget_info *gi, 250 + static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, 255 251 const char *page, size_t len) 256 252 { 253 + struct gadget_info *gi = to_gadget_info(item); 257 254 char *name; 258 255 int ret; 259 256 ··· 288 283 return ret; 289 284 } 290 285 291 - GI_DEVICE_DESC_ITEM_ATTR(bDeviceClass); 292 - GI_DEVICE_DESC_ITEM_ATTR(bDeviceSubClass); 293 - GI_DEVICE_DESC_ITEM_ATTR(bDeviceProtocol); 294 - GI_DEVICE_DESC_ITEM_ATTR(bMaxPacketSize0); 295 - GI_DEVICE_DESC_ITEM_ATTR(idVendor); 296 - GI_DEVICE_DESC_ITEM_ATTR(idProduct); 297 - GI_DEVICE_DESC_ITEM_ATTR(bcdDevice); 298 - GI_DEVICE_DESC_ITEM_ATTR(bcdUSB); 299 - GI_DEVICE_DESC_ITEM_ATTR(UDC); 286 + CONFIGFS_ATTR(gadget_dev_desc_, bDeviceClass); 287 + CONFIGFS_ATTR(gadget_dev_desc_, bDeviceSubClass); 288 + CONFIGFS_ATTR(gadget_dev_desc_, bDeviceProtocol); 289 + CONFIGFS_ATTR(gadget_dev_desc_, bMaxPacketSize0); 290 + CONFIGFS_ATTR(gadget_dev_desc_, idVendor); 291 + CONFIGFS_ATTR(gadget_dev_desc_, idProduct); 292 + CONFIGFS_ATTR(gadget_dev_desc_, bcdDevice); 293 + CONFIGFS_ATTR(gadget_dev_desc_, bcdUSB); 294 + CONFIGFS_ATTR(gadget_dev_desc_, UDC); 300 295 301 296 static struct configfs_attribute *gadget_root_attrs[] = { 302 - &gadget_cdev_desc_bDeviceClass.attr, 303 - &gadget_cdev_desc_bDeviceSubClass.attr, 304 - &gadget_cdev_desc_bDeviceProtocol.attr, 305 - &gadget_cdev_desc_bMaxPacketSize0.attr, 306 - &gadget_cdev_desc_idVendor.attr, 307 - &gadget_cdev_desc_idProduct.attr, 308 - &gadget_cdev_desc_bcdDevice.attr, 309 - &gadget_cdev_desc_bcdUSB.attr, 310 - &gadget_cdev_desc_UDC.attr, 297 + &gadget_dev_desc_attr_bDeviceClass, 298 + &gadget_dev_desc_attr_bDeviceSubClass, 299 + &gadget_dev_desc_attr_bDeviceProtocol, 300 + &gadget_dev_desc_attr_bMaxPacketSize0, 301 + &gadget_dev_desc_attr_idVendor, 302 + &gadget_dev_desc_attr_idProduct, 303 + &gadget_dev_desc_attr_bcdDevice, 304 + &gadget_dev_desc_attr_bcdUSB, 305 + &gadget_dev_desc_attr_UDC, 311 306 NULL, 312 307 }; 313 - 314 - static inline struct gadget_info *to_gadget_info(struct config_item *item) 315 - { 316 - return container_of(to_config_group(item), struct gadget_info, group); 317 - } 318 308 319 309 static inline struct gadget_strings *to_gadget_strings(struct config_item *item) 320 310 { ··· 322 322 { 323 323 return container_of(to_config_group(item), struct gadget_config_name, 324 324 group); 325 - } 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 325 } 332 326 333 327 static inline struct usb_function_instance *to_usb_function_instance( ··· 342 348 kfree(gi); 343 349 } 344 350 345 - CONFIGFS_ATTR_OPS(gadget_info); 346 - 347 351 static struct configfs_item_operations gadget_root_item_ops = { 348 352 .release = gadget_info_attr_release, 349 - .show_attribute = gadget_info_attr_show, 350 - .store_attribute = gadget_info_attr_store, 351 353 }; 352 354 353 355 static void gadget_config_attr_release(struct config_item *item) ··· 444 454 return 0; 445 455 } 446 456 447 - CONFIGFS_ATTR_OPS(config_usb_cfg); 448 - 449 457 static struct configfs_item_operations gadget_config_item_ops = { 450 458 .release = gadget_config_attr_release, 451 - .show_attribute = config_usb_cfg_attr_show, 452 - .store_attribute = config_usb_cfg_attr_store, 453 459 .allow_link = config_usb_cfg_link, 454 460 .drop_link = config_usb_cfg_unlink, 455 461 }; 456 462 457 463 458 - static ssize_t gadget_config_desc_MaxPower_show(struct config_usb_cfg *cfg, 464 + static ssize_t gadget_config_desc_MaxPower_show(struct config_item *item, 459 465 char *page) 460 466 { 461 - return sprintf(page, "%u\n", cfg->c.MaxPower); 467 + return sprintf(page, "%u\n", to_config_usb_cfg(item)->c.MaxPower); 462 468 } 463 469 464 - static ssize_t gadget_config_desc_MaxPower_store(struct config_usb_cfg *cfg, 470 + static ssize_t gadget_config_desc_MaxPower_store(struct config_item *item, 465 471 const char *page, size_t len) 466 472 { 467 473 u16 val; ··· 467 481 return ret; 468 482 if (DIV_ROUND_UP(val, 8) > 0xff) 469 483 return -ERANGE; 470 - cfg->c.MaxPower = val; 484 + to_config_usb_cfg(item)->c.MaxPower = val; 471 485 return len; 472 486 } 473 487 474 - static ssize_t gadget_config_desc_bmAttributes_show(struct config_usb_cfg *cfg, 488 + static ssize_t gadget_config_desc_bmAttributes_show(struct config_item *item, 475 489 char *page) 476 490 { 477 - return sprintf(page, "0x%02x\n", cfg->c.bmAttributes); 491 + return sprintf(page, "0x%02x\n", 492 + to_config_usb_cfg(item)->c.bmAttributes); 478 493 } 479 494 480 - static ssize_t gadget_config_desc_bmAttributes_store(struct config_usb_cfg *cfg, 495 + static ssize_t gadget_config_desc_bmAttributes_store(struct config_item *item, 481 496 const char *page, size_t len) 482 497 { 483 498 u8 val; ··· 491 504 if (val & ~(USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER | 492 505 USB_CONFIG_ATT_WAKEUP)) 493 506 return -EINVAL; 494 - cfg->c.bmAttributes = val; 507 + to_config_usb_cfg(item)->c.bmAttributes = val; 495 508 return len; 496 509 } 497 510 498 - #define CFG_CONFIG_DESC_ITEM_ATTR(name) \ 499 - static struct config_usb_cfg_attribute gadget_usb_cfg_##name = \ 500 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 501 - gadget_config_desc_##name##_show, \ 502 - gadget_config_desc_##name##_store) 503 - 504 - CFG_CONFIG_DESC_ITEM_ATTR(MaxPower); 505 - CFG_CONFIG_DESC_ITEM_ATTR(bmAttributes); 511 + CONFIGFS_ATTR(gadget_config_desc_, MaxPower); 512 + CONFIGFS_ATTR(gadget_config_desc_, bmAttributes); 506 513 507 514 static struct configfs_attribute *gadget_config_attrs[] = { 508 - &gadget_usb_cfg_MaxPower.attr, 509 - &gadget_usb_cfg_bmAttributes.attr, 515 + &gadget_config_desc_attr_MaxPower, 516 + &gadget_config_desc_attr_bmAttributes, 510 517 NULL, 511 518 }; 512 519 ··· 597 616 .ct_owner = THIS_MODULE, 598 617 }; 599 618 600 - CONFIGFS_ATTR_STRUCT(gadget_config_name); 601 619 GS_STRINGS_RW(gadget_config_name, configuration); 602 620 603 621 static struct configfs_attribute *gadget_config_name_langid_attrs[] = { 604 - &gadget_config_name_configuration.attr, 622 + &gadget_config_name_attr_configuration, 605 623 NULL, 606 624 }; 607 625 ··· 699 719 .ct_owner = THIS_MODULE, 700 720 }; 701 721 702 - CONFIGFS_ATTR_STRUCT(gadget_strings); 703 722 GS_STRINGS_RW(gadget_strings, manufacturer); 704 723 GS_STRINGS_RW(gadget_strings, product); 705 724 GS_STRINGS_RW(gadget_strings, serialnumber); 706 725 707 726 static struct configfs_attribute *gadget_strings_langid_attrs[] = { 708 - &gadget_strings_manufacturer.attr, 709 - &gadget_strings_product.attr, 710 - &gadget_strings_serialnumber.attr, 727 + &gadget_strings_attr_manufacturer, 728 + &gadget_strings_attr_product, 729 + &gadget_strings_attr_serialnumber, 711 730 NULL, 712 731 }; 713 732 ··· 730 751 return container_of(to_config_group(item), struct os_desc, group); 731 752 } 732 753 733 - CONFIGFS_ATTR_STRUCT(os_desc); 734 - CONFIGFS_ATTR_OPS(os_desc); 735 - 736 - static ssize_t os_desc_use_show(struct os_desc *os_desc, char *page) 754 + static inline struct gadget_info *os_desc_item_to_gadget_info( 755 + struct config_item *item) 737 756 { 738 - struct gadget_info *gi; 739 - 740 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 741 - 742 - return sprintf(page, "%d", gi->use_os_desc); 757 + return to_gadget_info(to_os_desc(item)->group.cg_item.ci_parent); 743 758 } 744 759 745 - static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page, 760 + static ssize_t os_desc_use_show(struct config_item *item, char *page) 761 + { 762 + return sprintf(page, "%d", 763 + os_desc_item_to_gadget_info(item)->use_os_desc); 764 + } 765 + 766 + static ssize_t os_desc_use_store(struct config_item *item, const char *page, 746 767 size_t len) 747 768 { 748 - struct gadget_info *gi; 769 + struct gadget_info *gi = os_desc_item_to_gadget_info(item); 749 770 int ret; 750 771 bool use; 751 - 752 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 753 772 754 773 mutex_lock(&gi->lock); 755 774 ret = strtobool(page, &use); ··· 760 783 return ret; 761 784 } 762 785 763 - static struct os_desc_attribute os_desc_use = 764 - __CONFIGFS_ATTR(use, S_IRUGO | S_IWUSR, 765 - os_desc_use_show, 766 - os_desc_use_store); 767 - 768 - static ssize_t os_desc_b_vendor_code_show(struct os_desc *os_desc, char *page) 786 + static ssize_t os_desc_b_vendor_code_show(struct config_item *item, char *page) 769 787 { 770 - struct gadget_info *gi; 771 - 772 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 773 - 774 - return sprintf(page, "%d", gi->b_vendor_code); 788 + return sprintf(page, "%d", 789 + os_desc_item_to_gadget_info(item)->b_vendor_code); 775 790 } 776 791 777 - static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc, 792 + static ssize_t os_desc_b_vendor_code_store(struct config_item *item, 778 793 const char *page, size_t len) 779 794 { 780 - struct gadget_info *gi; 795 + struct gadget_info *gi = os_desc_item_to_gadget_info(item); 781 796 int ret; 782 797 u8 b_vendor_code; 783 - 784 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 785 798 786 799 mutex_lock(&gi->lock); 787 800 ret = kstrtou8(page, 0, &b_vendor_code); ··· 784 817 return ret; 785 818 } 786 819 787 - static struct os_desc_attribute os_desc_b_vendor_code = 788 - __CONFIGFS_ATTR(b_vendor_code, S_IRUGO | S_IWUSR, 789 - os_desc_b_vendor_code_show, 790 - os_desc_b_vendor_code_store); 791 - 792 - static ssize_t os_desc_qw_sign_show(struct os_desc *os_desc, char *page) 820 + static ssize_t os_desc_qw_sign_show(struct config_item *item, char *page) 793 821 { 794 - struct gadget_info *gi; 795 - 796 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 822 + struct gadget_info *gi = os_desc_item_to_gadget_info(item); 797 823 798 824 memcpy(page, gi->qw_sign, OS_STRING_QW_SIGN_LEN); 799 - 800 825 return OS_STRING_QW_SIGN_LEN; 801 826 } 802 827 803 - static ssize_t os_desc_qw_sign_store(struct os_desc *os_desc, const char *page, 828 + static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page, 804 829 size_t len) 805 830 { 806 - struct gadget_info *gi; 831 + struct gadget_info *gi = os_desc_item_to_gadget_info(item); 807 832 int res, l; 808 833 809 - gi = to_gadget_info(os_desc->group.cg_item.ci_parent); 810 834 l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1); 811 835 if (page[l - 1] == '\n') 812 836 --l; ··· 813 855 return res; 814 856 } 815 857 816 - static struct os_desc_attribute os_desc_qw_sign = 817 - __CONFIGFS_ATTR(qw_sign, S_IRUGO | S_IWUSR, 818 - os_desc_qw_sign_show, 819 - os_desc_qw_sign_store); 858 + CONFIGFS_ATTR(os_desc_, use); 859 + CONFIGFS_ATTR(os_desc_, b_vendor_code); 860 + CONFIGFS_ATTR(os_desc_, qw_sign); 820 861 821 862 static struct configfs_attribute *os_desc_attrs[] = { 822 - &os_desc_use.attr, 823 - &os_desc_b_vendor_code.attr, 824 - &os_desc_qw_sign.attr, 863 + &os_desc_attr_use, 864 + &os_desc_attr_b_vendor_code, 865 + &os_desc_attr_qw_sign, 825 866 NULL, 826 867 }; 827 868 ··· 883 926 884 927 static struct configfs_item_operations os_desc_ops = { 885 928 .release = os_desc_attr_release, 886 - .show_attribute = os_desc_attr_show, 887 - .store_attribute = os_desc_attr_store, 888 929 .allow_link = os_desc_link, 889 930 .drop_link = os_desc_unlink, 890 931 }; ··· 893 938 .ct_owner = THIS_MODULE, 894 939 }; 895 940 896 - CONFIGFS_ATTR_STRUCT(usb_os_desc); 897 - CONFIGFS_ATTR_OPS(usb_os_desc); 898 - 899 - 900 941 static inline struct usb_os_desc_ext_prop 901 942 *to_usb_os_desc_ext_prop(struct config_item *item) 902 943 { 903 944 return container_of(item, struct usb_os_desc_ext_prop, item); 904 945 } 905 946 906 - CONFIGFS_ATTR_STRUCT(usb_os_desc_ext_prop); 907 - CONFIGFS_ATTR_OPS(usb_os_desc_ext_prop); 908 - 909 - static ssize_t ext_prop_type_show(struct usb_os_desc_ext_prop *ext_prop, 910 - char *page) 947 + static ssize_t ext_prop_type_show(struct config_item *item, char *page) 911 948 { 912 - return sprintf(page, "%d", ext_prop->type); 949 + return sprintf(page, "%d", to_usb_os_desc_ext_prop(item)->type); 913 950 } 914 951 915 - static ssize_t ext_prop_type_store(struct usb_os_desc_ext_prop *ext_prop, 952 + static ssize_t ext_prop_type_store(struct config_item *item, 916 953 const char *page, size_t len) 917 954 { 955 + struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); 918 956 struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); 919 957 u8 type; 920 958 int ret; ··· 945 997 return ret; 946 998 } 947 999 948 - static ssize_t ext_prop_data_show(struct usb_os_desc_ext_prop *ext_prop, 949 - char *page) 1000 + static ssize_t ext_prop_data_show(struct config_item *item, char *page) 950 1001 { 1002 + struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); 951 1003 int len = ext_prop->data_len; 952 1004 953 1005 if (ext_prop->type == USB_EXT_PROP_UNICODE || ··· 959 1011 return len; 960 1012 } 961 1013 962 - static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop, 1014 + static ssize_t ext_prop_data_store(struct config_item *item, 963 1015 const char *page, size_t len) 964 1016 { 1017 + struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item); 965 1018 struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent); 966 1019 char *new_data; 967 1020 size_t ret_len = len; ··· 993 1044 return ret_len; 994 1045 } 995 1046 996 - static struct usb_os_desc_ext_prop_attribute ext_prop_type = 997 - __CONFIGFS_ATTR(type, S_IRUGO | S_IWUSR, 998 - ext_prop_type_show, ext_prop_type_store); 999 - 1000 - static struct usb_os_desc_ext_prop_attribute ext_prop_data = 1001 - __CONFIGFS_ATTR(data, S_IRUGO | S_IWUSR, 1002 - ext_prop_data_show, ext_prop_data_store); 1047 + CONFIGFS_ATTR(ext_prop_, type); 1048 + CONFIGFS_ATTR(ext_prop_, data); 1003 1049 1004 1050 static struct configfs_attribute *ext_prop_attrs[] = { 1005 - &ext_prop_type.attr, 1006 - &ext_prop_data.attr, 1051 + &ext_prop_attr_type, 1052 + &ext_prop_attr_data, 1007 1053 NULL, 1008 1054 }; 1009 1055 ··· 1011 1067 1012 1068 static struct configfs_item_operations ext_prop_ops = { 1013 1069 .release = usb_os_desc_ext_prop_release, 1014 - .show_attribute = usb_os_desc_ext_prop_attr_show, 1015 - .store_attribute = usb_os_desc_ext_prop_attr_store, 1016 1070 }; 1017 1071 1018 1072 static struct config_item *ext_prop_make( ··· 1079 1137 .drop_item = &ext_prop_drop, 1080 1138 }; 1081 1139 1082 - static struct configfs_item_operations interf_item_ops = { 1083 - .show_attribute = usb_os_desc_attr_show, 1084 - .store_attribute = usb_os_desc_attr_store, 1085 - }; 1086 - 1087 - static ssize_t interf_grp_compatible_id_show(struct usb_os_desc *desc, 1140 + static ssize_t interf_grp_compatible_id_show(struct config_item *item, 1088 1141 char *page) 1089 1142 { 1090 - memcpy(page, desc->ext_compat_id, 8); 1143 + memcpy(page, to_usb_os_desc(item)->ext_compat_id, 8); 1091 1144 return 8; 1092 1145 } 1093 1146 1094 - static ssize_t interf_grp_compatible_id_store(struct usb_os_desc *desc, 1147 + static ssize_t interf_grp_compatible_id_store(struct config_item *item, 1095 1148 const char *page, size_t len) 1096 1149 { 1150 + struct usb_os_desc *desc = to_usb_os_desc(item); 1097 1151 int l; 1098 1152 1099 1153 l = min_t(int, 8, len); ··· 1105 1167 return len; 1106 1168 } 1107 1169 1108 - static struct usb_os_desc_attribute interf_grp_attr_compatible_id = 1109 - __CONFIGFS_ATTR(compatible_id, S_IRUGO | S_IWUSR, 1110 - interf_grp_compatible_id_show, 1111 - interf_grp_compatible_id_store); 1112 - 1113 - static ssize_t interf_grp_sub_compatible_id_show(struct usb_os_desc *desc, 1170 + static ssize_t interf_grp_sub_compatible_id_show(struct config_item *item, 1114 1171 char *page) 1115 1172 { 1116 - memcpy(page, desc->ext_compat_id + 8, 8); 1173 + memcpy(page, to_usb_os_desc(item)->ext_compat_id + 8, 8); 1117 1174 return 8; 1118 1175 } 1119 1176 1120 - static ssize_t interf_grp_sub_compatible_id_store(struct usb_os_desc *desc, 1177 + static ssize_t interf_grp_sub_compatible_id_store(struct config_item *item, 1121 1178 const char *page, size_t len) 1122 1179 { 1180 + struct usb_os_desc *desc = to_usb_os_desc(item); 1123 1181 int l; 1124 1182 1125 1183 l = min_t(int, 8, len); ··· 1131 1197 return len; 1132 1198 } 1133 1199 1134 - static struct usb_os_desc_attribute interf_grp_attr_sub_compatible_id = 1135 - __CONFIGFS_ATTR(sub_compatible_id, S_IRUGO | S_IWUSR, 1136 - interf_grp_sub_compatible_id_show, 1137 - interf_grp_sub_compatible_id_store); 1200 + CONFIGFS_ATTR(interf_grp_, compatible_id); 1201 + CONFIGFS_ATTR(interf_grp_, sub_compatible_id); 1138 1202 1139 1203 static struct configfs_attribute *interf_grp_attrs[] = { 1140 - &interf_grp_attr_compatible_id.attr, 1141 - &interf_grp_attr_sub_compatible_id.attr, 1204 + &interf_grp_attr_compatible_id, 1205 + &interf_grp_attr_sub_compatible_id, 1142 1206 NULL 1143 1207 }; 1144 1208 ··· 1174 1242 f_default_groups[0] = os_desc_group; 1175 1243 1176 1244 os_desc_group->default_groups = interface_groups; 1177 - interface_type->ct_item_ops = &interf_item_ops; 1178 1245 interface_type->ct_group_ops = &interf_grp_ops; 1179 1246 interface_type->ct_attrs = interf_grp_attrs; 1180 1247 interface_type->ct_owner = owner;
+4 -22
drivers/usb/gadget/function/f_acm.c
··· 761 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 764 static void acm_attr_release(struct config_item *item) 780 765 { 781 766 struct f_serial_opts *opts = to_f_serial_opts(item); ··· 770 785 771 786 static struct configfs_item_operations acm_item_ops = { 772 787 .release = acm_attr_release, 773 - .show_attribute = f_acm_attr_show, 774 788 }; 775 789 776 - static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page) 790 + static ssize_t f_acm_port_num_show(struct config_item *item, char *page) 777 791 { 778 - return sprintf(page, "%u\n", opts->port_num); 792 + return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); 779 793 } 780 794 781 - static struct f_serial_opts_attribute f_acm_port_num = 782 - __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show); 783 - 795 + CONFIGFS_ATTR_RO(f_acm_port_, num); 784 796 785 797 static struct configfs_attribute *acm_attrs[] = { 786 - &f_acm_port_num.attr, 798 + &f_acm_port_attr_num, 787 799 NULL, 788 800 }; 789 801
+4 -4
drivers/usb/gadget/function/f_ecm.c
··· 838 838 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm); 839 839 840 840 static struct configfs_attribute *ecm_attrs[] = { 841 - &f_ecm_opts_dev_addr.attr, 842 - &f_ecm_opts_host_addr.attr, 843 - &f_ecm_opts_qmult.attr, 844 - &f_ecm_opts_ifname.attr, 841 + &ecm_opts_attr_dev_addr, 842 + &ecm_opts_attr_host_addr, 843 + &ecm_opts_attr_qmult, 844 + &ecm_opts_attr_ifname, 845 845 NULL, 846 846 }; 847 847
+4 -4
drivers/usb/gadget/function/f_eem.c
··· 545 545 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem); 546 546 547 547 static struct configfs_attribute *eem_attrs[] = { 548 - &f_eem_opts_dev_addr.attr, 549 - &f_eem_opts_host_addr.attr, 550 - &f_eem_opts_qmult.attr, 551 - &f_eem_opts_ifname.attr, 548 + &eem_opts_attr_dev_addr, 549 + &eem_opts_attr_host_addr, 550 + &eem_opts_attr_qmult, 551 + &eem_opts_attr_ifname, 552 552 NULL, 553 553 }; 554 554
+14 -20
drivers/usb/gadget/function/f_hid.c
··· 705 705 func_inst.group); 706 706 } 707 707 708 - CONFIGFS_ATTR_STRUCT(f_hid_opts); 709 - CONFIGFS_ATTR_OPS(f_hid_opts); 710 - 711 708 static void hid_attr_release(struct config_item *item) 712 709 { 713 710 struct f_hid_opts *opts = to_f_hid_opts(item); ··· 714 717 715 718 static struct configfs_item_operations hidg_item_ops = { 716 719 .release = hid_attr_release, 717 - .show_attribute = f_hid_opts_attr_show, 718 - .store_attribute = f_hid_opts_attr_store, 719 720 }; 720 721 721 722 #define F_HID_OPT(name, prec, limit) \ 722 - static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\ 723 + static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\ 723 724 { \ 725 + struct f_hid_opts *opts = to_f_hid_opts(item); \ 724 726 int result; \ 725 727 \ 726 728 mutex_lock(&opts->lock); \ ··· 729 733 return result; \ 730 734 } \ 731 735 \ 732 - static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts, \ 736 + static ssize_t f_hid_opts_##name##_store(struct config_item *item, \ 733 737 const char *page, size_t len) \ 734 738 { \ 739 + struct f_hid_opts *opts = to_f_hid_opts(item); \ 735 740 int ret; \ 736 741 u##prec num; \ 737 742 \ ··· 758 761 return ret; \ 759 762 } \ 760 763 \ 761 - static struct f_hid_opts_attribute f_hid_opts_##name = \ 762 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\ 763 - f_hid_opts_##name##_store) 764 + CONFIGFS_ATTR(f_hid_opts_, name) 764 765 765 766 F_HID_OPT(subclass, 8, 255); 766 767 F_HID_OPT(protocol, 8, 255); 767 768 F_HID_OPT(report_length, 16, 65535); 768 769 769 - static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page) 770 + static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char *page) 770 771 { 772 + struct f_hid_opts *opts = to_f_hid_opts(item); 771 773 int result; 772 774 773 775 mutex_lock(&opts->lock); ··· 777 781 return result; 778 782 } 779 783 780 - static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts, 784 + static ssize_t f_hid_opts_report_desc_store(struct config_item *item, 781 785 const char *page, size_t len) 782 786 { 787 + struct f_hid_opts *opts = to_f_hid_opts(item); 783 788 int ret = -EBUSY; 784 789 char *d; 785 790 ··· 807 810 return ret; 808 811 } 809 812 810 - static struct f_hid_opts_attribute f_hid_opts_report_desc = 811 - __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR, 812 - f_hid_opts_report_desc_show, 813 - f_hid_opts_report_desc_store); 813 + CONFIGFS_ATTR(f_hid_opts_, report_desc); 814 814 815 815 static struct configfs_attribute *hid_attrs[] = { 816 - &f_hid_opts_subclass.attr, 817 - &f_hid_opts_protocol.attr, 818 - &f_hid_opts_report_length.attr, 819 - &f_hid_opts_report_desc.attr, 816 + &f_hid_opts_attr_subclass, 817 + &f_hid_opts_attr_protocol, 818 + &f_hid_opts_attr_report_length, 819 + &f_hid_opts_attr_report_desc, 820 820 NULL, 821 821 }; 822 822
+12 -19
drivers/usb/gadget/function/f_loopback.c
··· 465 465 func_inst.group); 466 466 } 467 467 468 - CONFIGFS_ATTR_STRUCT(f_lb_opts); 469 - CONFIGFS_ATTR_OPS(f_lb_opts); 470 - 471 468 static void lb_attr_release(struct config_item *item) 472 469 { 473 470 struct f_lb_opts *lb_opts = to_f_lb_opts(item); ··· 474 477 475 478 static struct configfs_item_operations lb_item_ops = { 476 479 .release = lb_attr_release, 477 - .show_attribute = f_lb_opts_attr_show, 478 - .store_attribute = f_lb_opts_attr_store, 479 480 }; 480 481 481 - static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page) 482 + static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page) 482 483 { 484 + struct f_lb_opts *opts = to_f_lb_opts(item); 483 485 int result; 484 486 485 487 mutex_lock(&opts->lock); ··· 488 492 return result; 489 493 } 490 494 491 - static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts, 495 + static ssize_t f_lb_opts_qlen_store(struct config_item *item, 492 496 const char *page, size_t len) 493 497 { 498 + struct f_lb_opts *opts = to_f_lb_opts(item); 494 499 int ret; 495 500 u32 num; 496 501 ··· 512 515 return ret; 513 516 } 514 517 515 - static struct f_lb_opts_attribute f_lb_opts_qlen = 516 - __CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR, 517 - f_lb_opts_qlen_show, 518 - f_lb_opts_qlen_store); 518 + CONFIGFS_ATTR(f_lb_opts_, qlen); 519 519 520 - static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page) 520 + static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page) 521 521 { 522 + struct f_lb_opts *opts = to_f_lb_opts(item); 522 523 int result; 523 524 524 525 mutex_lock(&opts->lock); ··· 526 531 return result; 527 532 } 528 533 529 - static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts, 534 + static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item, 530 535 const char *page, size_t len) 531 536 { 537 + struct f_lb_opts *opts = to_f_lb_opts(item); 532 538 int ret; 533 539 u32 num; 534 540 ··· 550 554 return ret; 551 555 } 552 556 553 - static struct f_lb_opts_attribute f_lb_opts_bulk_buflen = 554 - __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR, 555 - f_lb_opts_bulk_buflen_show, 556 - f_lb_opts_bulk_buflen_store); 557 + CONFIGFS_ATTR(f_lb_opts_, bulk_buflen); 557 558 558 559 static struct configfs_attribute *lb_attrs[] = { 559 - &f_lb_opts_qlen.attr, 560 - &f_lb_opts_bulk_buflen.attr, 560 + &f_lb_opts_attr_qlen, 561 + &f_lb_opts_attr_bulk_buflen, 561 562 NULL, 562 563 }; 563 564
+46 -73
drivers/usb/gadget/function/f_mass_storage.c
··· 3140 3140 func_inst.group); 3141 3141 } 3142 3142 3143 - CONFIGFS_ATTR_STRUCT(fsg_lun_opts); 3144 - CONFIGFS_ATTR_OPS(fsg_lun_opts); 3145 - 3146 3143 static void fsg_lun_attr_release(struct config_item *item) 3147 3144 { 3148 3145 struct fsg_lun_opts *lun_opts; ··· 3150 3153 3151 3154 static struct configfs_item_operations fsg_lun_item_ops = { 3152 3155 .release = fsg_lun_attr_release, 3153 - .show_attribute = fsg_lun_opts_attr_show, 3154 - .store_attribute = fsg_lun_opts_attr_store, 3155 3156 }; 3156 3157 3157 - static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page) 3158 + static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page) 3158 3159 { 3159 - struct fsg_opts *fsg_opts; 3160 - 3161 - fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3160 + struct fsg_lun_opts *opts = to_fsg_lun_opts(item); 3161 + struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3162 3162 3163 3163 return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page); 3164 3164 } 3165 3165 3166 - static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts, 3166 + static ssize_t fsg_lun_opts_file_store(struct config_item *item, 3167 3167 const char *page, size_t len) 3168 3168 { 3169 - struct fsg_opts *fsg_opts; 3170 - 3171 - fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3169 + struct fsg_lun_opts *opts = to_fsg_lun_opts(item); 3170 + struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3172 3171 3173 3172 return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len); 3174 3173 } 3175 3174 3176 - static struct fsg_lun_opts_attribute fsg_lun_opts_file = 3177 - __CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show, 3178 - fsg_lun_opts_file_store); 3175 + CONFIGFS_ATTR(fsg_lun_opts_, file); 3179 3176 3180 - static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page) 3177 + static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page) 3181 3178 { 3182 - return fsg_show_ro(opts->lun, page); 3179 + return fsg_show_ro(to_fsg_lun_opts(item)->lun, page); 3183 3180 } 3184 3181 3185 - static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts, 3182 + static ssize_t fsg_lun_opts_ro_store(struct config_item *item, 3186 3183 const char *page, size_t len) 3187 3184 { 3188 - struct fsg_opts *fsg_opts; 3189 - 3190 - fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3185 + struct fsg_lun_opts *opts = to_fsg_lun_opts(item); 3186 + struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3191 3187 3192 3188 return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len); 3193 3189 } 3194 3190 3195 - static struct fsg_lun_opts_attribute fsg_lun_opts_ro = 3196 - __CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show, 3197 - fsg_lun_opts_ro_store); 3191 + CONFIGFS_ATTR(fsg_lun_opts_, ro); 3198 3192 3199 - static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts, 3193 + static ssize_t fsg_lun_opts_removable_show(struct config_item *item, 3200 3194 char *page) 3201 3195 { 3202 - return fsg_show_removable(opts->lun, page); 3196 + return fsg_show_removable(to_fsg_lun_opts(item)->lun, page); 3203 3197 } 3204 3198 3205 - static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts, 3199 + static ssize_t fsg_lun_opts_removable_store(struct config_item *item, 3206 3200 const char *page, size_t len) 3207 3201 { 3208 - return fsg_store_removable(opts->lun, page, len); 3202 + return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len); 3209 3203 } 3210 3204 3211 - static struct fsg_lun_opts_attribute fsg_lun_opts_removable = 3212 - __CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR, 3213 - fsg_lun_opts_removable_show, 3214 - fsg_lun_opts_removable_store); 3205 + CONFIGFS_ATTR(fsg_lun_opts_, removable); 3215 3206 3216 - static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page) 3207 + static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page) 3217 3208 { 3218 - return fsg_show_cdrom(opts->lun, page); 3209 + return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page); 3219 3210 } 3220 3211 3221 - static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts, 3212 + static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item, 3222 3213 const char *page, size_t len) 3223 3214 { 3224 - struct fsg_opts *fsg_opts; 3225 - 3226 - fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3215 + struct fsg_lun_opts *opts = to_fsg_lun_opts(item); 3216 + struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); 3227 3217 3228 3218 return fsg_store_cdrom(opts->lun, &fsg_opts->common->filesem, page, 3229 3219 len); 3230 3220 } 3231 3221 3232 - static struct fsg_lun_opts_attribute fsg_lun_opts_cdrom = 3233 - __CONFIGFS_ATTR(cdrom, S_IRUGO | S_IWUSR, fsg_lun_opts_cdrom_show, 3234 - fsg_lun_opts_cdrom_store); 3222 + CONFIGFS_ATTR(fsg_lun_opts_, cdrom); 3235 3223 3236 - static ssize_t fsg_lun_opts_nofua_show(struct fsg_lun_opts *opts, char *page) 3224 + static ssize_t fsg_lun_opts_nofua_show(struct config_item *item, char *page) 3237 3225 { 3238 - return fsg_show_nofua(opts->lun, page); 3226 + return fsg_show_nofua(to_fsg_lun_opts(item)->lun, page); 3239 3227 } 3240 3228 3241 - static ssize_t fsg_lun_opts_nofua_store(struct fsg_lun_opts *opts, 3229 + static ssize_t fsg_lun_opts_nofua_store(struct config_item *item, 3242 3230 const char *page, size_t len) 3243 3231 { 3244 - return fsg_store_nofua(opts->lun, page, len); 3232 + return fsg_store_nofua(to_fsg_lun_opts(item)->lun, page, len); 3245 3233 } 3246 3234 3247 - static struct fsg_lun_opts_attribute fsg_lun_opts_nofua = 3248 - __CONFIGFS_ATTR(nofua, S_IRUGO | S_IWUSR, fsg_lun_opts_nofua_show, 3249 - fsg_lun_opts_nofua_store); 3235 + CONFIGFS_ATTR(fsg_lun_opts_, nofua); 3250 3236 3251 3237 static struct configfs_attribute *fsg_lun_attrs[] = { 3252 - &fsg_lun_opts_file.attr, 3253 - &fsg_lun_opts_ro.attr, 3254 - &fsg_lun_opts_removable.attr, 3255 - &fsg_lun_opts_cdrom.attr, 3256 - &fsg_lun_opts_nofua.attr, 3238 + &fsg_lun_opts_attr_file, 3239 + &fsg_lun_opts_attr_ro, 3240 + &fsg_lun_opts_attr_removable, 3241 + &fsg_lun_opts_attr_cdrom, 3242 + &fsg_lun_opts_attr_nofua, 3257 3243 NULL, 3258 3244 }; 3259 3245 ··· 3328 3348 config_item_put(item); 3329 3349 } 3330 3350 3331 - CONFIGFS_ATTR_STRUCT(fsg_opts); 3332 - CONFIGFS_ATTR_OPS(fsg_opts); 3333 - 3334 3351 static void fsg_attr_release(struct config_item *item) 3335 3352 { 3336 3353 struct fsg_opts *opts = to_fsg_opts(item); ··· 3337 3360 3338 3361 static struct configfs_item_operations fsg_item_ops = { 3339 3362 .release = fsg_attr_release, 3340 - .show_attribute = fsg_opts_attr_show, 3341 - .store_attribute = fsg_opts_attr_store, 3342 3363 }; 3343 3364 3344 - static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page) 3365 + static ssize_t fsg_opts_stall_show(struct config_item *item, char *page) 3345 3366 { 3367 + struct fsg_opts *opts = to_fsg_opts(item); 3346 3368 int result; 3347 3369 3348 3370 mutex_lock(&opts->lock); ··· 3351 3375 return result; 3352 3376 } 3353 3377 3354 - static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page, 3378 + static ssize_t fsg_opts_stall_store(struct config_item *item, const char *page, 3355 3379 size_t len) 3356 3380 { 3381 + struct fsg_opts *opts = to_fsg_opts(item); 3357 3382 int ret; 3358 3383 bool stall; 3359 3384 ··· 3376 3399 return ret; 3377 3400 } 3378 3401 3379 - static struct fsg_opts_attribute fsg_opts_stall = 3380 - __CONFIGFS_ATTR(stall, S_IRUGO | S_IWUSR, fsg_opts_stall_show, 3381 - fsg_opts_stall_store); 3402 + CONFIGFS_ATTR(fsg_opts_, stall); 3382 3403 3383 3404 #ifdef CONFIG_USB_GADGET_DEBUG_FILES 3384 - static ssize_t fsg_opts_num_buffers_show(struct fsg_opts *opts, char *page) 3405 + static ssize_t fsg_opts_num_buffers_show(struct config_item *item, char *page) 3385 3406 { 3407 + struct fsg_opts *opts = to_fsg_opts(item); 3386 3408 int result; 3387 3409 3388 3410 mutex_lock(&opts->lock); ··· 3391 3415 return result; 3392 3416 } 3393 3417 3394 - static ssize_t fsg_opts_num_buffers_store(struct fsg_opts *opts, 3418 + static ssize_t fsg_opts_num_buffers_store(struct config_item *item, 3395 3419 const char *page, size_t len) 3396 3420 { 3421 + struct fsg_opts *opts = to_fsg_opts(item); 3397 3422 int ret; 3398 3423 u8 num; 3399 3424 ··· 3419 3442 return ret; 3420 3443 } 3421 3444 3422 - static struct fsg_opts_attribute fsg_opts_num_buffers = 3423 - __CONFIGFS_ATTR(num_buffers, S_IRUGO | S_IWUSR, 3424 - fsg_opts_num_buffers_show, 3425 - fsg_opts_num_buffers_store); 3426 - 3445 + CONFIGFS_ATTR(fsg_opts_, num_buffers); 3427 3446 #endif 3428 3447 3429 3448 static struct configfs_attribute *fsg_attrs[] = { 3430 - &fsg_opts_stall.attr, 3449 + &fsg_opts_attr_stall, 3431 3450 #ifdef CONFIG_USB_GADGET_DEBUG_FILES 3432 - &fsg_opts_num_buffers.attr, 3451 + &fsg_opts_attr_num_buffers, 3433 3452 #endif 3434 3453 NULL, 3435 3454 };
+16 -21
drivers/usb/gadget/function/f_midi.c
··· 902 902 func_inst.group); 903 903 } 904 904 905 - CONFIGFS_ATTR_STRUCT(f_midi_opts); 906 - CONFIGFS_ATTR_OPS(f_midi_opts); 907 - 908 905 static void midi_attr_release(struct config_item *item) 909 906 { 910 907 struct f_midi_opts *opts = to_f_midi_opts(item); ··· 911 914 912 915 static struct configfs_item_operations midi_item_ops = { 913 916 .release = midi_attr_release, 914 - .show_attribute = f_midi_opts_attr_show, 915 - .store_attribute = f_midi_opts_attr_store, 916 917 }; 917 918 918 919 #define F_MIDI_OPT(name, test_limit, limit) \ 919 - static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) \ 920 + static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) \ 920 921 { \ 922 + struct f_midi_opts *opts = to_f_midi_opts(item); \ 921 923 int result; \ 922 924 \ 923 925 mutex_lock(&opts->lock); \ ··· 926 930 return result; \ 927 931 } \ 928 932 \ 929 - static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts, \ 933 + static ssize_t f_midi_opts_##name##_store(struct config_item *item, \ 930 934 const char *page, size_t len) \ 931 935 { \ 936 + struct f_midi_opts *opts = to_f_midi_opts(item); \ 932 937 int ret; \ 933 938 u32 num; \ 934 939 \ ··· 955 958 return ret; \ 956 959 } \ 957 960 \ 958 - static struct f_midi_opts_attribute f_midi_opts_##name = \ 959 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \ 960 - f_midi_opts_##name##_store) 961 + CONFIGFS_ATTR(f_midi_opts_, name); 961 962 962 963 F_MIDI_OPT(index, true, SNDRV_CARDS); 963 964 F_MIDI_OPT(buflen, false, 0); ··· 963 968 F_MIDI_OPT(in_ports, true, MAX_PORTS); 964 969 F_MIDI_OPT(out_ports, true, MAX_PORTS); 965 970 966 - static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page) 971 + static ssize_t f_midi_opts_id_show(struct config_item *item, char *page) 967 972 { 973 + struct f_midi_opts *opts = to_f_midi_opts(item); 968 974 int result; 969 975 970 976 mutex_lock(&opts->lock); ··· 981 985 return result; 982 986 } 983 987 984 - static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts, 988 + static ssize_t f_midi_opts_id_store(struct config_item *item, 985 989 const char *page, size_t len) 986 990 { 991 + struct f_midi_opts *opts = to_f_midi_opts(item); 987 992 int ret; 988 993 char *c; 989 994 ··· 1009 1012 return ret; 1010 1013 } 1011 1014 1012 - static struct f_midi_opts_attribute f_midi_opts_id = 1013 - __CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show, 1014 - f_midi_opts_id_store); 1015 + CONFIGFS_ATTR(f_midi_opts_, id); 1015 1016 1016 1017 static struct configfs_attribute *midi_attrs[] = { 1017 - &f_midi_opts_index.attr, 1018 - &f_midi_opts_buflen.attr, 1019 - &f_midi_opts_qlen.attr, 1020 - &f_midi_opts_in_ports.attr, 1021 - &f_midi_opts_out_ports.attr, 1022 - &f_midi_opts_id.attr, 1018 + &f_midi_opts_attr_index, 1019 + &f_midi_opts_attr_buflen, 1020 + &f_midi_opts_attr_qlen, 1021 + &f_midi_opts_attr_in_ports, 1022 + &f_midi_opts_attr_out_ports, 1023 + &f_midi_opts_attr_id, 1023 1024 NULL, 1024 1025 }; 1025 1026
+4 -4
drivers/usb/gadget/function/f_ncm.c
··· 1488 1488 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); 1489 1489 1490 1490 static struct configfs_attribute *ncm_attrs[] = { 1491 - &f_ncm_opts_dev_addr.attr, 1492 - &f_ncm_opts_host_addr.attr, 1493 - &f_ncm_opts_qmult.attr, 1494 - &f_ncm_opts_ifname.attr, 1491 + &ncm_opts_attr_dev_addr, 1492 + &ncm_opts_attr_host_addr, 1493 + &ncm_opts_attr_qmult, 1494 + &ncm_opts_attr_ifname, 1495 1495 NULL, 1496 1496 }; 1497 1497
+4 -22
drivers/usb/gadget/function/f_obex.c
··· 387 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 390 static void obex_attr_release(struct config_item *item) 407 391 { 408 392 struct f_serial_opts *opts = to_f_serial_opts(item); ··· 396 412 397 413 static struct configfs_item_operations obex_item_ops = { 398 414 .release = obex_attr_release, 399 - .show_attribute = f_obex_attr_show, 400 415 }; 401 416 402 - static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page) 417 + static ssize_t f_obex_port_num_show(struct config_item *item, char *page) 403 418 { 404 - return sprintf(page, "%u\n", opts->port_num); 419 + return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); 405 420 } 406 421 407 - static struct f_serial_opts_attribute f_obex_port_num = 408 - __CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show); 422 + CONFIGFS_ATTR_RO(f_obex_, port_num); 409 423 410 424 static struct configfs_attribute *acm_attrs[] = { 411 - &f_obex_port_num.attr, 425 + &f_obex_attr_port_num, 412 426 NULL, 413 427 }; 414 428
+4 -21
drivers/usb/gadget/function/f_phonet.c
··· 583 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 586 static void phonet_attr_release(struct config_item *item) 602 587 { 603 588 struct f_phonet_opts *opts = to_f_phonet_opts(item); ··· 592 607 593 608 static struct configfs_item_operations phonet_item_ops = { 594 609 .release = phonet_attr_release, 595 - .show_attribute = f_phonet_attr_show, 596 610 }; 597 611 598 - static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page) 612 + static ssize_t f_phonet_ifname_show(struct config_item *item, char *page) 599 613 { 600 - return gether_get_ifname(opts->net, page, PAGE_SIZE); 614 + return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE); 601 615 } 602 616 603 - static struct f_phonet_opts_attribute f_phonet_ifname = 604 - __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show); 617 + CONFIGFS_ATTR_RO(f_phonet_, ifname); 605 618 606 619 static struct configfs_attribute *phonet_attrs[] = { 607 - &f_phonet_ifname.attr, 620 + &f_phonet_attr_ifname, 608 621 NULL, 609 622 }; 610 623
+12 -18
drivers/usb/gadget/function/f_printer.c
··· 1146 1146 func_inst.group); 1147 1147 } 1148 1148 1149 - CONFIGFS_ATTR_STRUCT(f_printer_opts); 1150 - CONFIGFS_ATTR_OPS(f_printer_opts); 1151 - 1152 1149 static void printer_attr_release(struct config_item *item) 1153 1150 { 1154 1151 struct f_printer_opts *opts = to_f_printer_opts(item); ··· 1155 1158 1156 1159 static struct configfs_item_operations printer_item_ops = { 1157 1160 .release = printer_attr_release, 1158 - .show_attribute = f_printer_opts_attr_show, 1159 - .store_attribute = f_printer_opts_attr_store, 1160 1161 }; 1161 1162 1162 - static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, 1163 + static ssize_t f_printer_opts_pnp_string_show(struct config_item *item, 1163 1164 char *page) 1164 1165 { 1166 + struct f_printer_opts *opts = to_f_printer_opts(item); 1165 1167 int result; 1166 1168 1167 1169 mutex_lock(&opts->lock); ··· 1170 1174 return result; 1171 1175 } 1172 1176 1173 - static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, 1177 + static ssize_t f_printer_opts_pnp_string_store(struct config_item *item, 1174 1178 const char *page, size_t len) 1175 1179 { 1180 + struct f_printer_opts *opts = to_f_printer_opts(item); 1176 1181 int result, l; 1177 1182 1178 1183 mutex_lock(&opts->lock); ··· 1186 1189 return result; 1187 1190 } 1188 1191 1189 - static struct f_printer_opts_attribute f_printer_opts_pnp_string = 1190 - __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR, 1191 - f_printer_opts_pnp_string_show, 1192 - f_printer_opts_pnp_string_store); 1192 + CONFIGFS_ATTR(f_printer_opts_, pnp_string); 1193 1193 1194 - static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, 1194 + static ssize_t f_printer_opts_q_len_show(struct config_item *item, 1195 1195 char *page) 1196 1196 { 1197 + struct f_printer_opts *opts = to_f_printer_opts(item); 1197 1198 int result; 1198 1199 1199 1200 mutex_lock(&opts->lock); ··· 1201 1206 return result; 1202 1207 } 1203 1208 1204 - static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts, 1209 + static ssize_t f_printer_opts_q_len_store(struct config_item *item, 1205 1210 const char *page, size_t len) 1206 1211 { 1212 + struct f_printer_opts *opts = to_f_printer_opts(item); 1207 1213 int ret; 1208 1214 u16 num; 1209 1215 ··· 1225 1229 return ret; 1226 1230 } 1227 1231 1228 - static struct f_printer_opts_attribute f_printer_opts_q_len = 1229 - __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show, 1230 - f_printer_opts_q_len_store); 1232 + CONFIGFS_ATTR(f_printer_opts_, q_len); 1231 1233 1232 1234 static struct configfs_attribute *printer_attrs[] = { 1233 - &f_printer_opts_pnp_string.attr, 1234 - &f_printer_opts_q_len.attr, 1235 + &f_printer_opts_attr_pnp_string, 1236 + &f_printer_opts_attr_q_len, 1235 1237 NULL, 1236 1238 }; 1237 1239
+4 -4
drivers/usb/gadget/function/f_rndis.c
··· 864 864 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis); 865 865 866 866 static struct configfs_attribute *rndis_attrs[] = { 867 - &f_rndis_opts_dev_addr.attr, 868 - &f_rndis_opts_host_addr.attr, 869 - &f_rndis_opts_qmult.attr, 870 - &f_rndis_opts_ifname.attr, 867 + &rndis_opts_attr_dev_addr, 868 + &rndis_opts_attr_host_addr, 869 + &rndis_opts_attr_qmult, 870 + &rndis_opts_attr_ifname, 871 871 NULL, 872 872 }; 873 873
+4 -22
drivers/usb/gadget/function/f_serial.c
··· 258 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 261 static void serial_attr_release(struct config_item *item) 278 262 { 279 263 struct f_serial_opts *opts = to_f_serial_opts(item); ··· 267 283 268 284 static struct configfs_item_operations serial_item_ops = { 269 285 .release = serial_attr_release, 270 - .show_attribute = f_serial_attr_show, 271 286 }; 272 287 273 - static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page) 288 + static ssize_t f_serial_port_num_show(struct config_item *item, char *page) 274 289 { 275 - return sprintf(page, "%u\n", opts->port_num); 290 + return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); 276 291 } 277 292 278 - static struct f_serial_opts_attribute f_serial_port_num = 279 - __CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show); 293 + CONFIGFS_ATTR_RO(f_serial_, port_num); 280 294 281 295 static struct configfs_attribute *acm_attrs[] = { 282 - &f_serial_port_num.attr, 296 + &f_serial_attr_port_num, 283 297 NULL, 284 298 }; 285 299
+36 -47
drivers/usb/gadget/function/f_sourcesink.c
··· 889 889 func_inst.group); 890 890 } 891 891 892 - CONFIGFS_ATTR_STRUCT(f_ss_opts); 893 - CONFIGFS_ATTR_OPS(f_ss_opts); 894 - 895 892 static void ss_attr_release(struct config_item *item) 896 893 { 897 894 struct f_ss_opts *ss_opts = to_f_ss_opts(item); ··· 898 901 899 902 static struct configfs_item_operations ss_item_ops = { 900 903 .release = ss_attr_release, 901 - .show_attribute = f_ss_opts_attr_show, 902 - .store_attribute = f_ss_opts_attr_store, 903 904 }; 904 905 905 - static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page) 906 + static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page) 906 907 { 908 + struct f_ss_opts *opts = to_f_ss_opts(item); 907 909 int result; 908 910 909 911 mutex_lock(&opts->lock); ··· 912 916 return result; 913 917 } 914 918 915 - static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts, 919 + static ssize_t f_ss_opts_pattern_store(struct config_item *item, 916 920 const char *page, size_t len) 917 921 { 922 + struct f_ss_opts *opts = to_f_ss_opts(item); 918 923 int ret; 919 924 u8 num; 920 925 ··· 941 944 return ret; 942 945 } 943 946 944 - static struct f_ss_opts_attribute f_ss_opts_pattern = 945 - __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR, 946 - f_ss_opts_pattern_show, 947 - f_ss_opts_pattern_store); 947 + CONFIGFS_ATTR(f_ss_opts_, pattern); 948 948 949 - static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page) 949 + static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char *page) 950 950 { 951 + struct f_ss_opts *opts = to_f_ss_opts(item); 951 952 int result; 952 953 953 954 mutex_lock(&opts->lock); ··· 955 960 return result; 956 961 } 957 962 958 - static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts, 963 + static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item, 959 964 const char *page, size_t len) 960 965 { 966 + struct f_ss_opts *opts = to_f_ss_opts(item); 961 967 int ret; 962 968 u8 num; 963 969 ··· 984 988 return ret; 985 989 } 986 990 987 - static struct f_ss_opts_attribute f_ss_opts_isoc_interval = 988 - __CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR, 989 - f_ss_opts_isoc_interval_show, 990 - f_ss_opts_isoc_interval_store); 991 + CONFIGFS_ATTR(f_ss_opts_, isoc_interval); 991 992 992 - static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char *page) 993 + static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char *page) 993 994 { 995 + struct f_ss_opts *opts = to_f_ss_opts(item); 994 996 int result; 995 997 996 998 mutex_lock(&opts->lock); ··· 998 1004 return result; 999 1005 } 1000 1006 1001 - static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts, 1007 + static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item, 1002 1008 const char *page, size_t len) 1003 1009 { 1010 + struct f_ss_opts *opts = to_f_ss_opts(item); 1004 1011 int ret; 1005 1012 u16 num; 1006 1013 ··· 1027 1032 return ret; 1028 1033 } 1029 1034 1030 - static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket = 1031 - __CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR, 1032 - f_ss_opts_isoc_maxpacket_show, 1033 - f_ss_opts_isoc_maxpacket_store); 1035 + CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket); 1034 1036 1035 - static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page) 1037 + static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page) 1036 1038 { 1039 + struct f_ss_opts *opts = to_f_ss_opts(item); 1037 1040 int result; 1038 1041 1039 1042 mutex_lock(&opts->lock); ··· 1041 1048 return result; 1042 1049 } 1043 1050 1044 - static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts, 1051 + static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item, 1045 1052 const char *page, size_t len) 1046 1053 { 1054 + struct f_ss_opts *opts = to_f_ss_opts(item); 1047 1055 int ret; 1048 1056 u8 num; 1049 1057 ··· 1070 1076 return ret; 1071 1077 } 1072 1078 1073 - static struct f_ss_opts_attribute f_ss_opts_isoc_mult = 1074 - __CONFIGFS_ATTR(isoc_mult, S_IRUGO | S_IWUSR, 1075 - f_ss_opts_isoc_mult_show, 1076 - f_ss_opts_isoc_mult_store); 1079 + CONFIGFS_ATTR(f_ss_opts_, isoc_mult); 1077 1080 1078 - static ssize_t f_ss_opts_isoc_maxburst_show(struct f_ss_opts *opts, char *page) 1081 + static ssize_t f_ss_opts_isoc_maxburst_show(struct config_item *item, char *page) 1079 1082 { 1083 + struct f_ss_opts *opts = to_f_ss_opts(item); 1080 1084 int result; 1081 1085 1082 1086 mutex_lock(&opts->lock); ··· 1084 1092 return result; 1085 1093 } 1086 1094 1087 - static ssize_t f_ss_opts_isoc_maxburst_store(struct f_ss_opts *opts, 1095 + static ssize_t f_ss_opts_isoc_maxburst_store(struct config_item *item, 1088 1096 const char *page, size_t len) 1089 1097 { 1098 + struct f_ss_opts *opts = to_f_ss_opts(item); 1090 1099 int ret; 1091 1100 u8 num; 1092 1101 ··· 1113 1120 return ret; 1114 1121 } 1115 1122 1116 - static struct f_ss_opts_attribute f_ss_opts_isoc_maxburst = 1117 - __CONFIGFS_ATTR(isoc_maxburst, S_IRUGO | S_IWUSR, 1118 - f_ss_opts_isoc_maxburst_show, 1119 - f_ss_opts_isoc_maxburst_store); 1123 + CONFIGFS_ATTR(f_ss_opts_, isoc_maxburst); 1120 1124 1121 - static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page) 1125 + static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *page) 1122 1126 { 1127 + struct f_ss_opts *opts = to_f_ss_opts(item); 1123 1128 int result; 1124 1129 1125 1130 mutex_lock(&opts->lock); ··· 1127 1136 return result; 1128 1137 } 1129 1138 1130 - static ssize_t f_ss_opts_bulk_buflen_store(struct f_ss_opts *opts, 1139 + static ssize_t f_ss_opts_bulk_buflen_store(struct config_item *item, 1131 1140 const char *page, size_t len) 1132 1141 { 1142 + struct f_ss_opts *opts = to_f_ss_opts(item); 1133 1143 int ret; 1134 1144 u32 num; 1135 1145 ··· 1151 1159 return ret; 1152 1160 } 1153 1161 1154 - static struct f_ss_opts_attribute f_ss_opts_bulk_buflen = 1155 - __CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR, 1156 - f_ss_opts_bulk_buflen_show, 1157 - f_ss_opts_bulk_buflen_store); 1162 + CONFIGFS_ATTR(f_ss_opts_, bulk_buflen); 1158 1163 1159 1164 static struct configfs_attribute *ss_attrs[] = { 1160 - &f_ss_opts_pattern.attr, 1161 - &f_ss_opts_isoc_interval.attr, 1162 - &f_ss_opts_isoc_maxpacket.attr, 1163 - &f_ss_opts_isoc_mult.attr, 1164 - &f_ss_opts_isoc_maxburst.attr, 1165 - &f_ss_opts_bulk_buflen.attr, 1165 + &f_ss_opts_attr_pattern, 1166 + &f_ss_opts_attr_isoc_interval, 1167 + &f_ss_opts_attr_isoc_maxpacket, 1168 + &f_ss_opts_attr_isoc_mult, 1169 + &f_ss_opts_attr_isoc_maxburst, 1170 + &f_ss_opts_attr_bulk_buflen, 1166 1171 NULL, 1167 1172 }; 1168 1173
+4 -4
drivers/usb/gadget/function/f_subset.c
··· 405 405 USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether); 406 406 407 407 static struct configfs_attribute *gether_attrs[] = { 408 - &f_gether_opts_dev_addr.attr, 409 - &f_gether_opts_host_addr.attr, 410 - &f_gether_opts_qmult.attr, 411 - &f_gether_opts_ifname.attr, 408 + &gether_opts_attr_dev_addr, 409 + &gether_opts_attr_host_addr, 410 + &gether_opts_attr_qmult, 411 + &gether_opts_attr_ifname, 412 412 NULL, 413 413 }; 414 414
+16 -23
drivers/usb/gadget/function/f_uac1.c
··· 769 769 func_inst.group); 770 770 } 771 771 772 - CONFIGFS_ATTR_STRUCT(f_uac1_opts); 773 - CONFIGFS_ATTR_OPS(f_uac1_opts); 774 - 775 772 static void f_uac1_attr_release(struct config_item *item) 776 773 { 777 774 struct f_uac1_opts *opts = to_f_uac1_opts(item); ··· 778 781 779 782 static struct configfs_item_operations f_uac1_item_ops = { 780 783 .release = f_uac1_attr_release, 781 - .show_attribute = f_uac1_opts_attr_show, 782 - .store_attribute = f_uac1_opts_attr_store, 783 784 }; 784 785 785 786 #define UAC1_INT_ATTRIBUTE(name) \ 786 - static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ 787 + static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ 787 788 char *page) \ 788 789 { \ 790 + struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 789 791 int result; \ 790 792 \ 791 793 mutex_lock(&opts->lock); \ ··· 794 798 return result; \ 795 799 } \ 796 800 \ 797 - static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \ 801 + static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ 798 802 const char *page, size_t len) \ 799 803 { \ 804 + struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 800 805 int ret; \ 801 806 u32 num; \ 802 807 \ ··· 819 822 return ret; \ 820 823 } \ 821 824 \ 822 - static struct f_uac1_opts_attribute f_uac1_opts_##name = \ 823 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 824 - f_uac1_opts_##name##_show, \ 825 - f_uac1_opts_##name##_store) 825 + CONFIGFS_ATTR(f_uac1_opts_, name) 826 826 827 827 UAC1_INT_ATTRIBUTE(req_buf_size); 828 828 UAC1_INT_ATTRIBUTE(req_count); 829 829 UAC1_INT_ATTRIBUTE(audio_buf_size); 830 830 831 831 #define UAC1_STR_ATTRIBUTE(name) \ 832 - static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \ 832 + static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \ 833 833 char *page) \ 834 834 { \ 835 + struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 835 836 int result; \ 836 837 \ 837 838 mutex_lock(&opts->lock); \ ··· 839 844 return result; \ 840 845 } \ 841 846 \ 842 - static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \ 847 + static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \ 843 848 const char *page, size_t len) \ 844 849 { \ 850 + struct f_uac1_opts *opts = to_f_uac1_opts(item); \ 845 851 int ret = -EBUSY; \ 846 852 char *tmp; \ 847 853 \ ··· 866 870 return ret; \ 867 871 } \ 868 872 \ 869 - static struct f_uac1_opts_attribute f_uac1_opts_##name = \ 870 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 871 - f_uac1_opts_##name##_show, \ 872 - f_uac1_opts_##name##_store) 873 + CONFIGFS_ATTR(f_uac1_opts_, name) 873 874 874 875 UAC1_STR_ATTRIBUTE(fn_play); 875 876 UAC1_STR_ATTRIBUTE(fn_cap); 876 877 UAC1_STR_ATTRIBUTE(fn_cntl); 877 878 878 879 static struct configfs_attribute *f_uac1_attrs[] = { 879 - &f_uac1_opts_req_buf_size.attr, 880 - &f_uac1_opts_req_count.attr, 881 - &f_uac1_opts_audio_buf_size.attr, 882 - &f_uac1_opts_fn_play.attr, 883 - &f_uac1_opts_fn_cap.attr, 884 - &f_uac1_opts_fn_cntl.attr, 880 + &f_uac1_opts_attr_req_buf_size, 881 + &f_uac1_opts_attr_req_count, 882 + &f_uac1_opts_attr_audio_buf_size, 883 + &f_uac1_opts_attr_fn_play, 884 + &f_uac1_opts_attr_fn_cap, 885 + &f_uac1_opts_attr_fn_cntl, 885 886 NULL, 886 887 }; 887 888
+11 -17
drivers/usb/gadget/function/f_uac2.c
··· 1439 1439 func_inst.group); 1440 1440 } 1441 1441 1442 - CONFIGFS_ATTR_STRUCT(f_uac2_opts); 1443 - CONFIGFS_ATTR_OPS(f_uac2_opts); 1444 - 1445 1442 static void f_uac2_attr_release(struct config_item *item) 1446 1443 { 1447 1444 struct f_uac2_opts *opts = to_f_uac2_opts(item); ··· 1448 1451 1449 1452 static struct configfs_item_operations f_uac2_item_ops = { 1450 1453 .release = f_uac2_attr_release, 1451 - .show_attribute = f_uac2_opts_attr_show, 1452 - .store_attribute = f_uac2_opts_attr_store, 1453 1454 }; 1454 1455 1455 1456 #define UAC2_ATTRIBUTE(name) \ 1456 - static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \ 1457 + static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \ 1457 1458 char *page) \ 1458 1459 { \ 1460 + struct f_uac2_opts *opts = to_f_uac2_opts(item); \ 1459 1461 int result; \ 1460 1462 \ 1461 1463 mutex_lock(&opts->lock); \ ··· 1464 1468 return result; \ 1465 1469 } \ 1466 1470 \ 1467 - static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts, \ 1471 + static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \ 1468 1472 const char *page, size_t len) \ 1469 1473 { \ 1474 + struct f_uac2_opts *opts = to_f_uac2_opts(item); \ 1470 1475 int ret; \ 1471 1476 u32 num; \ 1472 1477 \ ··· 1489 1492 return ret; \ 1490 1493 } \ 1491 1494 \ 1492 - static struct f_uac2_opts_attribute f_uac2_opts_##name = \ 1493 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 1494 - f_uac2_opts_##name##_show, \ 1495 - f_uac2_opts_##name##_store) 1495 + CONFIGFS_ATTR(f_uac2_opts_, name) 1496 1496 1497 1497 UAC2_ATTRIBUTE(p_chmask); 1498 1498 UAC2_ATTRIBUTE(p_srate); ··· 1499 1505 UAC2_ATTRIBUTE(c_ssize); 1500 1506 1501 1507 static struct configfs_attribute *f_uac2_attrs[] = { 1502 - &f_uac2_opts_p_chmask.attr, 1503 - &f_uac2_opts_p_srate.attr, 1504 - &f_uac2_opts_p_ssize.attr, 1505 - &f_uac2_opts_c_chmask.attr, 1506 - &f_uac2_opts_c_srate.attr, 1507 - &f_uac2_opts_c_ssize.attr, 1508 + &f_uac2_opts_attr_p_chmask, 1509 + &f_uac2_opts_attr_p_srate, 1510 + &f_uac2_opts_attr_p_ssize, 1511 + &f_uac2_opts_attr_c_chmask, 1512 + &f_uac2_opts_attr_c_srate, 1513 + &f_uac2_opts_attr_c_ssize, 1508 1514 NULL, 1509 1515 }; 1510 1516
+18 -26
drivers/usb/gadget/function/u_ether_configfs.h
··· 17 17 #define __U_ETHER_CONFIGFS_H 18 18 19 19 #define USB_ETHERNET_CONFIGFS_ITEM(_f_) \ 20 - CONFIGFS_ATTR_STRUCT(f_##_f_##_opts); \ 21 - CONFIGFS_ATTR_OPS(f_##_f_##_opts); \ 22 - \ 23 20 static void _f_##_attr_release(struct config_item *item) \ 24 21 { \ 25 22 struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ ··· 26 29 \ 27 30 static struct configfs_item_operations _f_##_item_ops = { \ 28 31 .release = _f_##_attr_release, \ 29 - .show_attribute = f_##_f_##_opts_attr_show, \ 30 - .store_attribute = f_##_f_##_opts_attr_store, \ 31 32 } 32 33 33 34 #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \ 34 - static ssize_t _f_##_opts_dev_addr_show(struct f_##_f_##_opts *opts, \ 35 + static ssize_t _f_##_opts_dev_addr_show(struct config_item *item, \ 35 36 char *page) \ 36 37 { \ 38 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 37 39 int result; \ 38 40 \ 39 41 mutex_lock(&opts->lock); \ ··· 42 46 return result; \ 43 47 } \ 44 48 \ 45 - static ssize_t _f_##_opts_dev_addr_store(struct f_##_f_##_opts *opts, \ 49 + static ssize_t _f_##_opts_dev_addr_store(struct config_item *item, \ 46 50 const char *page, size_t len)\ 47 51 { \ 52 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 48 53 int ret; \ 49 54 \ 50 55 mutex_lock(&opts->lock); \ ··· 61 64 return ret; \ 62 65 } \ 63 66 \ 64 - static struct f_##_f_##_opts_attribute f_##_f_##_opts_dev_addr = \ 65 - __CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, \ 66 - _f_##_opts_dev_addr_show, \ 67 - _f_##_opts_dev_addr_store) 67 + CONFIGFS_ATTR(_f_##_opts_, dev_addr) 68 68 69 69 #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \ 70 - static ssize_t _f_##_opts_host_addr_show(struct f_##_f_##_opts *opts, \ 70 + static ssize_t _f_##_opts_host_addr_show(struct config_item *item, \ 71 71 char *page) \ 72 72 { \ 73 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 73 74 int result; \ 74 75 \ 75 76 mutex_lock(&opts->lock); \ ··· 77 82 return result; \ 78 83 } \ 79 84 \ 80 - static ssize_t _f_##_opts_host_addr_store(struct f_##_f_##_opts *opts, \ 85 + static ssize_t _f_##_opts_host_addr_store(struct config_item *item, \ 81 86 const char *page, size_t len)\ 82 87 { \ 88 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 83 89 int ret; \ 84 90 \ 85 91 mutex_lock(&opts->lock); \ ··· 96 100 return ret; \ 97 101 } \ 98 102 \ 99 - static struct f_##_f_##_opts_attribute f_##_f_##_opts_host_addr = \ 100 - __CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, \ 101 - _f_##_opts_host_addr_show, \ 102 - _f_##_opts_host_addr_store) 103 + CONFIGFS_ATTR(_f_##_opts_, host_addr) 103 104 104 105 #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \ 105 - static ssize_t _f_##_opts_qmult_show(struct f_##_f_##_opts *opts, \ 106 + static ssize_t _f_##_opts_qmult_show(struct config_item *item, \ 106 107 char *page) \ 107 108 { \ 109 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 108 110 unsigned qmult; \ 109 111 \ 110 112 mutex_lock(&opts->lock); \ ··· 111 117 return sprintf(page, "%d", qmult); \ 112 118 } \ 113 119 \ 114 - static ssize_t _f_##_opts_qmult_store(struct f_##_f_##_opts *opts, \ 120 + static ssize_t _f_##_opts_qmult_store(struct config_item *item, \ 115 121 const char *page, size_t len)\ 116 122 { \ 123 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 117 124 u8 val; \ 118 125 int ret; \ 119 126 \ ··· 135 140 return ret; \ 136 141 } \ 137 142 \ 138 - static struct f_##_f_##_opts_attribute f_##_f_##_opts_qmult = \ 139 - __CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, \ 140 - _f_##_opts_qmult_show, \ 141 - _f_##_opts_qmult_store) 143 + CONFIGFS_ATTR(_f_##_opts_, qmult) 142 144 143 145 #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \ 144 - static ssize_t _f_##_opts_ifname_show(struct f_##_f_##_opts *opts, \ 146 + static ssize_t _f_##_opts_ifname_show(struct config_item *item, \ 145 147 char *page) \ 146 148 { \ 149 + struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ 147 150 int ret; \ 148 151 \ 149 152 mutex_lock(&opts->lock); \ ··· 151 158 return ret; \ 152 159 } \ 153 160 \ 154 - static struct f_##_f_##_opts_attribute f_##_f_##_opts_ifname = \ 155 - __CONFIGFS_ATTR_RO(ifname, _f_##_opts_ifname_show) 161 + CONFIGFS_ATTR_RO(_f_##_opts_, ifname) 156 162 157 163 #endif /* __U_ETHER_CONFIGFS_H */
+143 -244
drivers/usb/gadget/function/uvc_configfs.c
··· 17 17 18 18 #define UVCG_STREAMING_CONTROL_SIZE 1 19 19 20 - #define CONFIGFS_ATTR_OPS_RO(_item) \ 21 - static ssize_t _item##_attr_show(struct config_item *item, \ 22 - struct configfs_attribute *attr, \ 23 - char *page) \ 24 - { \ 25 - struct _item *_item = to_##_item(item); \ 26 - struct _item##_attribute *_item##_attr = \ 27 - container_of(attr, struct _item##_attribute, attr); \ 28 - ssize_t ret = 0; \ 29 - \ 30 - if (_item##_attr->show) \ 31 - ret = _item##_attr->show(_item, page); \ 32 - return ret; \ 20 + #define UVC_ATTR(prefix, cname, aname) \ 21 + static struct configfs_attribute prefix##attr_##cname = { \ 22 + .ca_name = __stringify(aname), \ 23 + .ca_mode = S_IRUGO, \ 24 + .ca_owner = THIS_MODULE, \ 25 + .show = prefix##cname##_show, \ 26 + .store = prefix##cname##_store, \ 27 + } 28 + 29 + #define UVC_ATTR_RO(prefix, cname, aname) \ 30 + static struct configfs_attribute prefix##attr_##cname = { \ 31 + .ca_name = __stringify(aname), \ 32 + .ca_mode = S_IRUGO, \ 33 + .ca_owner = THIS_MODULE, \ 34 + .show = prefix##cname##_show, \ 33 35 } 34 36 35 37 static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item); ··· 50 48 return container_of(item, struct uvcg_control_header, item); 51 49 } 52 50 53 - CONFIGFS_ATTR_STRUCT(uvcg_control_header); 54 - CONFIGFS_ATTR_OPS(uvcg_control_header); 55 - 56 - static struct configfs_item_operations uvcg_control_header_item_ops = { 57 - .show_attribute = uvcg_control_header_attr_show, 58 - .store_attribute = uvcg_control_header_attr_store, 59 - }; 60 - 61 51 #define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \ 62 52 static ssize_t uvcg_control_header_##cname##_show( \ 63 - struct uvcg_control_header *ch, char *page) \ 53 + struct config_item *item, char *page) \ 64 54 { \ 55 + struct uvcg_control_header *ch = to_uvcg_control_header(item); \ 65 56 struct f_uvc_opts *opts; \ 66 57 struct config_item *opts_item; \ 67 58 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ ··· 74 79 } \ 75 80 \ 76 81 static ssize_t \ 77 - uvcg_control_header_##cname##_store(struct uvcg_control_header *ch, \ 82 + uvcg_control_header_##cname##_store(struct config_item *item, \ 78 83 const char *page, size_t len) \ 79 84 { \ 85 + struct uvcg_control_header *ch = to_uvcg_control_header(item); \ 80 86 struct f_uvc_opts *opts; \ 81 87 struct config_item *opts_item; \ 82 88 struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\ ··· 111 115 return ret; \ 112 116 } \ 113 117 \ 114 - static struct uvcg_control_header_attribute \ 115 - uvcg_control_header_##cname = \ 116 - __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ 117 - uvcg_control_header_##cname##_show, \ 118 - uvcg_control_header_##cname##_store) 118 + UVC_ATTR(uvcg_control_header_, cname, aname) 119 119 120 120 UVCG_CTRL_HDR_ATTR(bcd_uvc, bcdUVC, le16_to_cpu, kstrtou16, u16, cpu_to_le16, 121 121 0xffff); ··· 122 130 #undef UVCG_CTRL_HDR_ATTR 123 131 124 132 static struct configfs_attribute *uvcg_control_header_attrs[] = { 125 - &uvcg_control_header_bcd_uvc.attr, 126 - &uvcg_control_header_dw_clock_frequency.attr, 133 + &uvcg_control_header_attr_bcd_uvc, 134 + &uvcg_control_header_attr_dw_clock_frequency, 127 135 NULL, 128 136 }; 129 137 130 138 static struct config_item_type uvcg_control_header_type = { 131 - .ct_item_ops = &uvcg_control_header_item_ops, 132 139 .ct_attrs = uvcg_control_header_attrs, 133 140 .ct_owner = THIS_MODULE, 134 141 }; ··· 187 196 struct uvcg_default_processing, group); 188 197 } 189 198 190 - CONFIGFS_ATTR_STRUCT(uvcg_default_processing); 191 - CONFIGFS_ATTR_OPS_RO(uvcg_default_processing); 192 - 193 - static struct configfs_item_operations uvcg_default_processing_item_ops = { 194 - .show_attribute = uvcg_default_processing_attr_show, 195 - }; 196 - 197 199 #define UVCG_DEFAULT_PROCESSING_ATTR(cname, aname, conv) \ 198 200 static ssize_t uvcg_default_processing_##cname##_show( \ 199 - struct uvcg_default_processing *dp, char *page) \ 201 + struct config_item *item, char *page) \ 200 202 { \ 203 + struct uvcg_default_processing *dp = to_uvcg_default_processing(item); \ 201 204 struct f_uvc_opts *opts; \ 202 205 struct config_item *opts_item; \ 203 206 struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; \ ··· 212 227 return result; \ 213 228 } \ 214 229 \ 215 - static struct uvcg_default_processing_attribute \ 216 - uvcg_default_processing_##cname = \ 217 - __CONFIGFS_ATTR_RO(aname, uvcg_default_processing_##cname##_show) 230 + UVC_ATTR_RO(uvcg_default_processing_, cname, aname) 218 231 219 232 #define identity_conv(x) (x) 220 233 ··· 226 243 #undef UVCG_DEFAULT_PROCESSING_ATTR 227 244 228 245 static ssize_t uvcg_default_processing_bm_controls_show( 229 - struct uvcg_default_processing *dp, char *page) 246 + struct config_item *item, char *page) 230 247 { 248 + struct uvcg_default_processing *dp = to_uvcg_default_processing(item); 231 249 struct f_uvc_opts *opts; 232 250 struct config_item *opts_item; 233 251 struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; ··· 254 270 return result; 255 271 } 256 272 257 - static struct uvcg_default_processing_attribute 258 - uvcg_default_processing_bm_controls = 259 - __CONFIGFS_ATTR_RO(bmControls, 260 - uvcg_default_processing_bm_controls_show); 273 + UVC_ATTR_RO(uvcg_default_processing_, bm_controls, bmControls); 261 274 262 275 static struct configfs_attribute *uvcg_default_processing_attrs[] = { 263 - &uvcg_default_processing_b_unit_id.attr, 264 - &uvcg_default_processing_b_source_id.attr, 265 - &uvcg_default_processing_w_max_multiplier.attr, 266 - &uvcg_default_processing_bm_controls.attr, 267 - &uvcg_default_processing_i_processing.attr, 276 + &uvcg_default_processing_attr_b_unit_id, 277 + &uvcg_default_processing_attr_b_source_id, 278 + &uvcg_default_processing_attr_w_max_multiplier, 279 + &uvcg_default_processing_attr_bm_controls, 280 + &uvcg_default_processing_attr_i_processing, 268 281 NULL, 269 282 }; 270 283 271 284 static struct config_item_type uvcg_default_processing_type = { 272 - .ct_item_ops = &uvcg_default_processing_item_ops, 273 285 .ct_attrs = uvcg_default_processing_attrs, 274 286 .ct_owner = THIS_MODULE, 275 287 }; ··· 298 318 struct uvcg_default_camera, group); 299 319 } 300 320 301 - CONFIGFS_ATTR_STRUCT(uvcg_default_camera); 302 - CONFIGFS_ATTR_OPS_RO(uvcg_default_camera); 303 - 304 - static struct configfs_item_operations uvcg_default_camera_item_ops = { 305 - .show_attribute = uvcg_default_camera_attr_show, 306 - }; 307 - 308 321 #define UVCG_DEFAULT_CAMERA_ATTR(cname, aname, conv) \ 309 322 static ssize_t uvcg_default_camera_##cname##_show( \ 310 - struct uvcg_default_camera *dc, char *page) \ 323 + struct config_item *item, char *page) \ 311 324 { \ 325 + struct uvcg_default_camera *dc = to_uvcg_default_camera(item); \ 312 326 struct f_uvc_opts *opts; \ 313 327 struct config_item *opts_item; \ 314 328 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ ··· 325 351 return result; \ 326 352 } \ 327 353 \ 328 - static struct uvcg_default_camera_attribute \ 329 - uvcg_default_camera_##cname = \ 330 - __CONFIGFS_ATTR_RO(aname, uvcg_default_camera_##cname##_show) 354 + UVC_ATTR_RO(uvcg_default_camera_, cname, aname) 331 355 332 356 #define identity_conv(x) (x) 333 357 ··· 345 373 #undef UVCG_DEFAULT_CAMERA_ATTR 346 374 347 375 static ssize_t uvcg_default_camera_bm_controls_show( 348 - struct uvcg_default_camera *dc, char *page) 376 + struct config_item *item, char *page) 349 377 { 378 + struct uvcg_default_camera *dc = to_uvcg_default_camera(item); 350 379 struct f_uvc_opts *opts; 351 380 struct config_item *opts_item; 352 381 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; ··· 373 400 return result; 374 401 } 375 402 376 - static struct uvcg_default_camera_attribute 377 - uvcg_default_camera_bm_controls = 378 - __CONFIGFS_ATTR_RO(bmControls, uvcg_default_camera_bm_controls_show); 403 + UVC_ATTR_RO(uvcg_default_camera_, bm_controls, bmControls); 379 404 380 405 static struct configfs_attribute *uvcg_default_camera_attrs[] = { 381 - &uvcg_default_camera_b_terminal_id.attr, 382 - &uvcg_default_camera_w_terminal_type.attr, 383 - &uvcg_default_camera_b_assoc_terminal.attr, 384 - &uvcg_default_camera_i_terminal.attr, 385 - &uvcg_default_camera_w_objective_focal_length_min.attr, 386 - &uvcg_default_camera_w_objective_focal_length_max.attr, 387 - &uvcg_default_camera_w_ocular_focal_length.attr, 388 - &uvcg_default_camera_bm_controls.attr, 406 + &uvcg_default_camera_attr_b_terminal_id, 407 + &uvcg_default_camera_attr_w_terminal_type, 408 + &uvcg_default_camera_attr_b_assoc_terminal, 409 + &uvcg_default_camera_attr_i_terminal, 410 + &uvcg_default_camera_attr_w_objective_focal_length_min, 411 + &uvcg_default_camera_attr_w_objective_focal_length_max, 412 + &uvcg_default_camera_attr_w_ocular_focal_length, 413 + &uvcg_default_camera_attr_bm_controls, 389 414 NULL, 390 415 }; 391 416 392 417 static struct config_item_type uvcg_default_camera_type = { 393 - .ct_item_ops = &uvcg_default_camera_item_ops, 394 418 .ct_attrs = uvcg_default_camera_attrs, 395 419 .ct_owner = THIS_MODULE, 396 420 }; ··· 420 450 struct uvcg_default_output, group); 421 451 } 422 452 423 - CONFIGFS_ATTR_STRUCT(uvcg_default_output); 424 - CONFIGFS_ATTR_OPS_RO(uvcg_default_output); 425 - 426 - static struct configfs_item_operations uvcg_default_output_item_ops = { 427 - .show_attribute = uvcg_default_output_attr_show, 428 - }; 429 - 430 453 #define UVCG_DEFAULT_OUTPUT_ATTR(cname, aname, conv) \ 431 454 static ssize_t uvcg_default_output_##cname##_show( \ 432 - struct uvcg_default_output *dout, char *page) \ 455 + struct config_item *item, char *page) \ 433 456 { \ 457 + struct uvcg_default_output *dout = to_uvcg_default_output(item); \ 434 458 struct f_uvc_opts *opts; \ 435 459 struct config_item *opts_item; \ 436 460 struct mutex *su_mutex = &dout->group.cg_subsys->su_mutex; \ ··· 447 483 return result; \ 448 484 } \ 449 485 \ 450 - static struct uvcg_default_output_attribute \ 451 - uvcg_default_output_##cname = \ 452 - __CONFIGFS_ATTR_RO(aname, uvcg_default_output_##cname##_show) 486 + UVC_ATTR_RO(uvcg_default_output_, cname, aname) 453 487 454 488 #define identity_conv(x) (x) 455 489 ··· 462 500 #undef UVCG_DEFAULT_OUTPUT_ATTR 463 501 464 502 static struct configfs_attribute *uvcg_default_output_attrs[] = { 465 - &uvcg_default_output_b_terminal_id.attr, 466 - &uvcg_default_output_w_terminal_type.attr, 467 - &uvcg_default_output_b_assoc_terminal.attr, 468 - &uvcg_default_output_b_source_id.attr, 469 - &uvcg_default_output_i_terminal.attr, 503 + &uvcg_default_output_attr_b_terminal_id, 504 + &uvcg_default_output_attr_w_terminal_type, 505 + &uvcg_default_output_attr_b_assoc_terminal, 506 + &uvcg_default_output_attr_b_source_id, 507 + &uvcg_default_output_attr_i_terminal, 470 508 NULL, 471 509 }; 472 510 473 511 static struct config_item_type uvcg_default_output_type = { 474 - .ct_item_ops = &uvcg_default_output_item_ops, 475 512 .ct_attrs = uvcg_default_output_attrs, 476 513 .ct_owner = THIS_MODULE, 477 514 }; ··· 761 800 return container_of(item, struct uvcg_streaming_header, item); 762 801 } 763 802 764 - CONFIGFS_ATTR_STRUCT(uvcg_streaming_header); 765 - CONFIGFS_ATTR_OPS(uvcg_streaming_header); 766 - 767 803 static int uvcg_streaming_header_allow_link(struct config_item *src, 768 804 struct config_item *target) 769 805 { ··· 851 893 } 852 894 853 895 static struct configfs_item_operations uvcg_streaming_header_item_ops = { 854 - .show_attribute = uvcg_streaming_header_attr_show, 855 - .store_attribute = uvcg_streaming_header_attr_store, 856 896 .allow_link = uvcg_streaming_header_allow_link, 857 897 .drop_link = uvcg_streaming_header_drop_link, 858 898 }; 859 899 860 900 #define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \ 861 901 static ssize_t uvcg_streaming_header_##cname##_show( \ 862 - struct uvcg_streaming_header *sh, char *page) \ 902 + struct config_item *item, char *page) \ 863 903 { \ 904 + struct uvcg_streaming_header *sh = to_uvcg_streaming_header(item); \ 864 905 struct f_uvc_opts *opts; \ 865 906 struct config_item *opts_item; \ 866 907 struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\ ··· 878 921 return result; \ 879 922 } \ 880 923 \ 881 - static struct uvcg_streaming_header_attribute \ 882 - uvcg_streaming_header_##cname = \ 883 - __CONFIGFS_ATTR_RO(aname, uvcg_streaming_header_##cname##_show) 924 + UVC_ATTR_RO(uvcg_streaming_header_, cname, aname) 884 925 885 926 #define identity_conv(x) (x) 886 927 ··· 894 939 #undef UVCG_STREAMING_HEADER_ATTR 895 940 896 941 static struct configfs_attribute *uvcg_streaming_header_attrs[] = { 897 - &uvcg_streaming_header_bm_info.attr, 898 - &uvcg_streaming_header_b_terminal_link.attr, 899 - &uvcg_streaming_header_b_still_capture_method.attr, 900 - &uvcg_streaming_header_b_trigger_support.attr, 901 - &uvcg_streaming_header_b_trigger_usage.attr, 942 + &uvcg_streaming_header_attr_bm_info, 943 + &uvcg_streaming_header_attr_b_terminal_link, 944 + &uvcg_streaming_header_attr_b_still_capture_method, 945 + &uvcg_streaming_header_attr_b_trigger_support, 946 + &uvcg_streaming_header_attr_b_trigger_usage, 902 947 NULL, 903 948 }; 904 949 ··· 977 1022 return container_of(item, struct uvcg_frame, item); 978 1023 } 979 1024 980 - CONFIGFS_ATTR_STRUCT(uvcg_frame); 981 - CONFIGFS_ATTR_OPS(uvcg_frame); 982 - 983 - static struct configfs_item_operations uvcg_frame_item_ops = { 984 - .show_attribute = uvcg_frame_attr_show, 985 - .store_attribute = uvcg_frame_attr_store, 986 - }; 987 - 988 1025 #define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \ 989 - static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\ 1026 + static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\ 990 1027 { \ 1028 + struct uvcg_frame *f = to_uvcg_frame(item); \ 991 1029 struct f_uvc_opts *opts; \ 992 1030 struct config_item *opts_item; \ 993 1031 struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\ ··· 999 1051 return result; \ 1000 1052 } \ 1001 1053 \ 1002 - static ssize_t uvcg_frame_##cname##_store(struct uvcg_frame *f, \ 1054 + static ssize_t uvcg_frame_##cname##_store(struct config_item *item, \ 1003 1055 const char *page, size_t len)\ 1004 1056 { \ 1057 + struct uvcg_frame *f = to_uvcg_frame(item); \ 1005 1058 struct f_uvc_opts *opts; \ 1006 1059 struct config_item *opts_item; \ 1007 1060 struct uvcg_format *fmt; \ ··· 1034 1085 return ret; \ 1035 1086 } \ 1036 1087 \ 1037 - static struct uvcg_frame_attribute \ 1038 - uvcg_frame_##cname = \ 1039 - __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ 1040 - uvcg_frame_##cname##_show, \ 1041 - uvcg_frame_##cname##_store) 1088 + UVC_ATTR(uvcg_frame_, cname, aname); 1042 1089 1043 1090 #define noop_conversion(x) (x) 1044 1091 ··· 1053 1108 1054 1109 #undef UVCG_FRAME_ATTR 1055 1110 1056 - static ssize_t uvcg_frame_dw_frame_interval_show(struct uvcg_frame *frm, 1111 + static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item, 1057 1112 char *page) 1058 1113 { 1114 + struct uvcg_frame *frm = to_uvcg_frame(item); 1059 1115 struct f_uvc_opts *opts; 1060 1116 struct config_item *opts_item; 1061 1117 struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex; ··· 1131 1185 return 0; 1132 1186 } 1133 1187 1134 - static ssize_t uvcg_frame_dw_frame_interval_store(struct uvcg_frame *ch, 1188 + static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item, 1135 1189 const char *page, size_t len) 1136 1190 { 1191 + struct uvcg_frame *ch = to_uvcg_frame(item); 1137 1192 struct f_uvc_opts *opts; 1138 1193 struct config_item *opts_item; 1139 1194 struct uvcg_format *fmt; ··· 1181 1234 return ret; 1182 1235 } 1183 1236 1184 - static struct uvcg_frame_attribute 1185 - uvcg_frame_dw_frame_interval = 1186 - __CONFIGFS_ATTR(dwFrameInterval, S_IRUGO | S_IWUSR, 1187 - uvcg_frame_dw_frame_interval_show, 1188 - uvcg_frame_dw_frame_interval_store); 1237 + UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval); 1189 1238 1190 1239 static struct configfs_attribute *uvcg_frame_attrs[] = { 1191 - &uvcg_frame_bm_capabilities.attr, 1192 - &uvcg_frame_w_width.attr, 1193 - &uvcg_frame_w_height.attr, 1194 - &uvcg_frame_dw_min_bit_rate.attr, 1195 - &uvcg_frame_dw_max_bit_rate.attr, 1196 - &uvcg_frame_dw_max_video_frame_buffer_size.attr, 1197 - &uvcg_frame_dw_default_frame_interval.attr, 1198 - &uvcg_frame_dw_frame_interval.attr, 1240 + &uvcg_frame_attr_bm_capabilities, 1241 + &uvcg_frame_attr_w_width, 1242 + &uvcg_frame_attr_w_height, 1243 + &uvcg_frame_attr_dw_min_bit_rate, 1244 + &uvcg_frame_attr_dw_max_bit_rate, 1245 + &uvcg_frame_attr_dw_max_video_frame_buffer_size, 1246 + &uvcg_frame_attr_dw_default_frame_interval, 1247 + &uvcg_frame_attr_dw_frame_interval, 1199 1248 NULL, 1200 1249 }; 1201 1250 1202 1251 static struct config_item_type uvcg_frame_type = { 1203 - .ct_item_ops = &uvcg_frame_item_ops, 1204 1252 .ct_attrs = uvcg_frame_attrs, 1205 1253 .ct_owner = THIS_MODULE, 1206 1254 }; ··· 1275 1333 struct uvcg_uncompressed, fmt); 1276 1334 } 1277 1335 1278 - CONFIGFS_ATTR_STRUCT(uvcg_uncompressed); 1279 - CONFIGFS_ATTR_OPS(uvcg_uncompressed); 1280 - 1281 - static struct configfs_item_operations uvcg_uncompressed_item_ops = { 1282 - .show_attribute = uvcg_uncompressed_attr_show, 1283 - .store_attribute = uvcg_uncompressed_attr_store, 1284 - }; 1285 - 1286 1336 static struct configfs_group_operations uvcg_uncompressed_group_ops = { 1287 1337 .make_item = uvcg_frame_make, 1288 1338 .drop_item = uvcg_frame_drop, 1289 1339 }; 1290 1340 1291 - static ssize_t uvcg_uncompressed_guid_format_show(struct uvcg_uncompressed *ch, 1341 + static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item, 1292 1342 char *page) 1293 1343 { 1344 + struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item); 1294 1345 struct f_uvc_opts *opts; 1295 1346 struct config_item *opts_item; 1296 1347 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; ··· 1302 1367 return sizeof(ch->desc.guidFormat); 1303 1368 } 1304 1369 1305 - static ssize_t uvcg_uncompressed_guid_format_store(struct uvcg_uncompressed *ch, 1370 + static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item, 1306 1371 const char *page, size_t len) 1307 1372 { 1373 + struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item); 1308 1374 struct f_uvc_opts *opts; 1309 1375 struct config_item *opts_item; 1310 1376 struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex; ··· 1332 1396 return ret; 1333 1397 } 1334 1398 1335 - static struct uvcg_uncompressed_attribute uvcg_uncompressed_guid_format = 1336 - __CONFIGFS_ATTR(guidFormat, S_IRUGO | S_IWUSR, 1337 - uvcg_uncompressed_guid_format_show, 1338 - uvcg_uncompressed_guid_format_store); 1339 - 1399 + UVC_ATTR(uvcg_uncompressed_, guid_format, guidFormat); 1340 1400 1341 1401 #define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \ 1342 1402 static ssize_t uvcg_uncompressed_##cname##_show( \ 1343 - struct uvcg_uncompressed *u, char *page) \ 1403 + struct config_item *item, char *page) \ 1344 1404 { \ 1405 + struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ 1345 1406 struct f_uvc_opts *opts; \ 1346 1407 struct config_item *opts_item; \ 1347 1408 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1357 1424 return result; \ 1358 1425 } \ 1359 1426 \ 1360 - static struct uvcg_uncompressed_attribute \ 1361 - uvcg_uncompressed_##cname = \ 1362 - __CONFIGFS_ATTR_RO(aname, uvcg_uncompressed_##cname##_show) 1427 + UVC_ATTR_RO(uvcg_uncompressed_, cname, aname); 1363 1428 1364 1429 #define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \ 1365 1430 static ssize_t uvcg_uncompressed_##cname##_show( \ 1366 - struct uvcg_uncompressed *u, char *page) \ 1431 + struct config_item *item, char *page) \ 1367 1432 { \ 1433 + struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ 1368 1434 struct f_uvc_opts *opts; \ 1369 1435 struct config_item *opts_item; \ 1370 1436 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1383 1451 } \ 1384 1452 \ 1385 1453 static ssize_t \ 1386 - uvcg_uncompressed_##cname##_store(struct uvcg_uncompressed *u, \ 1454 + uvcg_uncompressed_##cname##_store(struct config_item *item, \ 1387 1455 const char *page, size_t len) \ 1388 1456 { \ 1457 + struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \ 1389 1458 struct f_uvc_opts *opts; \ 1390 1459 struct config_item *opts_item; \ 1391 1460 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1420 1487 return ret; \ 1421 1488 } \ 1422 1489 \ 1423 - static struct uvcg_uncompressed_attribute \ 1424 - uvcg_uncompressed_##cname = \ 1425 - __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ 1426 - uvcg_uncompressed_##cname##_show, \ 1427 - uvcg_uncompressed_##cname##_store) 1490 + UVC_ATTR(uvcg_uncompressed_, cname, aname); 1428 1491 1429 1492 #define identity_conv(x) (x) 1430 1493 ··· 1437 1508 #undef UVCG_UNCOMPRESSED_ATTR_RO 1438 1509 1439 1510 static inline ssize_t 1440 - uvcg_uncompressed_bma_controls_show(struct uvcg_uncompressed *unc, char *page) 1511 + uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page) 1441 1512 { 1513 + struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item); 1442 1514 return uvcg_format_bma_controls_show(&unc->fmt, page); 1443 1515 } 1444 1516 1445 1517 static inline ssize_t 1446 - uvcg_uncompressed_bma_controls_store(struct uvcg_uncompressed *ch, 1518 + uvcg_uncompressed_bma_controls_store(struct config_item *item, 1447 1519 const char *page, size_t len) 1448 1520 { 1449 - return uvcg_format_bma_controls_store(&ch->fmt, page, len); 1521 + struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item); 1522 + return uvcg_format_bma_controls_store(&unc->fmt, page, len); 1450 1523 } 1451 1524 1452 - static struct uvcg_uncompressed_attribute uvcg_uncompressed_bma_controls = 1453 - __CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR, 1454 - uvcg_uncompressed_bma_controls_show, 1455 - uvcg_uncompressed_bma_controls_store); 1525 + UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls); 1456 1526 1457 1527 static struct configfs_attribute *uvcg_uncompressed_attrs[] = { 1458 - &uvcg_uncompressed_guid_format.attr, 1459 - &uvcg_uncompressed_b_bits_per_pixel.attr, 1460 - &uvcg_uncompressed_b_default_frame_index.attr, 1461 - &uvcg_uncompressed_b_aspect_ratio_x.attr, 1462 - &uvcg_uncompressed_b_aspect_ratio_y.attr, 1463 - &uvcg_uncompressed_bm_interface_flags.attr, 1464 - &uvcg_uncompressed_bma_controls.attr, 1528 + &uvcg_uncompressed_attr_guid_format, 1529 + &uvcg_uncompressed_attr_b_bits_per_pixel, 1530 + &uvcg_uncompressed_attr_b_default_frame_index, 1531 + &uvcg_uncompressed_attr_b_aspect_ratio_x, 1532 + &uvcg_uncompressed_attr_b_aspect_ratio_y, 1533 + &uvcg_uncompressed_attr_bm_interface_flags, 1534 + &uvcg_uncompressed_attr_bma_controls, 1465 1535 NULL, 1466 1536 }; 1467 1537 1468 1538 static struct config_item_type uvcg_uncompressed_type = { 1469 - .ct_item_ops = &uvcg_uncompressed_item_ops, 1470 1539 .ct_group_ops = &uvcg_uncompressed_group_ops, 1471 1540 .ct_attrs = uvcg_uncompressed_attrs, 1472 1541 .ct_owner = THIS_MODULE, ··· 1532 1605 struct uvcg_mjpeg, fmt); 1533 1606 } 1534 1607 1535 - CONFIGFS_ATTR_STRUCT(uvcg_mjpeg); 1536 - CONFIGFS_ATTR_OPS(uvcg_mjpeg); 1537 - 1538 - static struct configfs_item_operations uvcg_mjpeg_item_ops = { 1539 - .show_attribute = uvcg_mjpeg_attr_show, 1540 - .store_attribute = uvcg_mjpeg_attr_store, 1541 - }; 1542 - 1543 1608 static struct configfs_group_operations uvcg_mjpeg_group_ops = { 1544 1609 .make_item = uvcg_frame_make, 1545 1610 .drop_item = uvcg_frame_drop, 1546 1611 }; 1547 1612 1548 1613 #define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \ 1549 - static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ 1614 + static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\ 1550 1615 { \ 1616 + struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ 1551 1617 struct f_uvc_opts *opts; \ 1552 1618 struct config_item *opts_item; \ 1553 1619 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1559 1639 return result; \ 1560 1640 } \ 1561 1641 \ 1562 - static struct uvcg_mjpeg_attribute \ 1563 - uvcg_mjpeg_##cname = \ 1564 - __CONFIGFS_ATTR_RO(aname, uvcg_mjpeg_##cname##_show) 1642 + UVC_ATTR_RO(uvcg_mjpeg_, cname, aname) 1565 1643 1566 1644 #define UVCG_MJPEG_ATTR(cname, aname, conv) \ 1567 - static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\ 1645 + static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\ 1568 1646 { \ 1647 + struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ 1569 1648 struct f_uvc_opts *opts; \ 1570 1649 struct config_item *opts_item; \ 1571 1650 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1584 1665 } \ 1585 1666 \ 1586 1667 static ssize_t \ 1587 - uvcg_mjpeg_##cname##_store(struct uvcg_mjpeg *u, \ 1668 + uvcg_mjpeg_##cname##_store(struct config_item *item, \ 1588 1669 const char *page, size_t len) \ 1589 1670 { \ 1671 + struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \ 1590 1672 struct f_uvc_opts *opts; \ 1591 1673 struct config_item *opts_item; \ 1592 1674 struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \ ··· 1621 1701 return ret; \ 1622 1702 } \ 1623 1703 \ 1624 - static struct uvcg_mjpeg_attribute \ 1625 - uvcg_mjpeg_##cname = \ 1626 - __CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \ 1627 - uvcg_mjpeg_##cname##_show, \ 1628 - uvcg_mjpeg_##cname##_store) 1704 + UVC_ATTR(uvcg_mjpeg_, cname, aname) 1629 1705 1630 1706 #define identity_conv(x) (x) 1631 1707 ··· 1638 1722 #undef UVCG_MJPEG_ATTR_RO 1639 1723 1640 1724 static inline ssize_t 1641 - uvcg_mjpeg_bma_controls_show(struct uvcg_mjpeg *unc, char *page) 1725 + uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page) 1642 1726 { 1643 - return uvcg_format_bma_controls_show(&unc->fmt, page); 1727 + struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); 1728 + return uvcg_format_bma_controls_show(&u->fmt, page); 1644 1729 } 1645 1730 1646 1731 static inline ssize_t 1647 - uvcg_mjpeg_bma_controls_store(struct uvcg_mjpeg *ch, 1732 + uvcg_mjpeg_bma_controls_store(struct config_item *item, 1648 1733 const char *page, size_t len) 1649 1734 { 1650 - return uvcg_format_bma_controls_store(&ch->fmt, page, len); 1735 + struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); 1736 + return uvcg_format_bma_controls_store(&u->fmt, page, len); 1651 1737 } 1652 1738 1653 - static struct uvcg_mjpeg_attribute uvcg_mjpeg_bma_controls = 1654 - __CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR, 1655 - uvcg_mjpeg_bma_controls_show, 1656 - uvcg_mjpeg_bma_controls_store); 1739 + UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls); 1657 1740 1658 1741 static struct configfs_attribute *uvcg_mjpeg_attrs[] = { 1659 - &uvcg_mjpeg_b_default_frame_index.attr, 1660 - &uvcg_mjpeg_bm_flags.attr, 1661 - &uvcg_mjpeg_b_aspect_ratio_x.attr, 1662 - &uvcg_mjpeg_b_aspect_ratio_y.attr, 1663 - &uvcg_mjpeg_bm_interface_flags.attr, 1664 - &uvcg_mjpeg_bma_controls.attr, 1742 + &uvcg_mjpeg_attr_b_default_frame_index, 1743 + &uvcg_mjpeg_attr_bm_flags, 1744 + &uvcg_mjpeg_attr_b_aspect_ratio_x, 1745 + &uvcg_mjpeg_attr_b_aspect_ratio_y, 1746 + &uvcg_mjpeg_attr_bm_interface_flags, 1747 + &uvcg_mjpeg_attr_bma_controls, 1665 1748 NULL, 1666 1749 }; 1667 1750 1668 1751 static struct config_item_type uvcg_mjpeg_type = { 1669 - .ct_item_ops = &uvcg_mjpeg_item_ops, 1670 1752 .ct_group_ops = &uvcg_mjpeg_group_ops, 1671 1753 .ct_attrs = uvcg_mjpeg_attrs, 1672 1754 .ct_owner = THIS_MODULE, ··· 1725 1811 struct uvcg_default_color_matching, group); 1726 1812 } 1727 1813 1728 - CONFIGFS_ATTR_STRUCT(uvcg_default_color_matching); 1729 - CONFIGFS_ATTR_OPS_RO(uvcg_default_color_matching); 1730 - 1731 - static struct configfs_item_operations uvcg_default_color_matching_item_ops = { 1732 - .show_attribute = uvcg_default_color_matching_attr_show, 1733 - }; 1734 - 1735 1814 #define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \ 1736 1815 static ssize_t uvcg_default_color_matching_##cname##_show( \ 1737 - struct uvcg_default_color_matching *dc, char *page) \ 1816 + struct config_item *item, char *page) \ 1738 1817 { \ 1818 + struct uvcg_default_color_matching *dc = \ 1819 + to_uvcg_default_color_matching(item); \ 1739 1820 struct f_uvc_opts *opts; \ 1740 1821 struct config_item *opts_item; \ 1741 1822 struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \ ··· 1751 1842 return result; \ 1752 1843 } \ 1753 1844 \ 1754 - static struct uvcg_default_color_matching_attribute \ 1755 - uvcg_default_color_matching_##cname = \ 1756 - __CONFIGFS_ATTR_RO(aname, uvcg_default_color_matching_##cname##_show) 1845 + UVC_ATTR_RO(uvcg_default_color_matching_, cname, aname) 1757 1846 1758 1847 #define identity_conv(x) (x) 1759 1848 ··· 1767 1860 #undef UVCG_DEFAULT_COLOR_MATCHING_ATTR 1768 1861 1769 1862 static struct configfs_attribute *uvcg_default_color_matching_attrs[] = { 1770 - &uvcg_default_color_matching_b_color_primaries.attr, 1771 - &uvcg_default_color_matching_b_transfer_characteristics.attr, 1772 - &uvcg_default_color_matching_b_matrix_coefficients.attr, 1863 + &uvcg_default_color_matching_attr_b_color_primaries, 1864 + &uvcg_default_color_matching_attr_b_transfer_characteristics, 1865 + &uvcg_default_color_matching_attr_b_matrix_coefficients, 1773 1866 NULL, 1774 1867 }; 1775 1868 1776 1869 static struct config_item_type uvcg_default_color_matching_type = { 1777 - .ct_item_ops = &uvcg_default_color_matching_item_ops, 1778 1870 .ct_attrs = uvcg_default_color_matching_attrs, 1779 1871 .ct_owner = THIS_MODULE, 1780 1872 }; ··· 2191 2285 func_inst.group); 2192 2286 } 2193 2287 2194 - CONFIGFS_ATTR_STRUCT(f_uvc_opts); 2195 - CONFIGFS_ATTR_OPS(f_uvc_opts); 2196 - 2197 2288 static void uvc_attr_release(struct config_item *item) 2198 2289 { 2199 2290 struct f_uvc_opts *opts = to_f_uvc_opts(item); ··· 2200 2297 2201 2298 static struct configfs_item_operations uvc_item_ops = { 2202 2299 .release = uvc_attr_release, 2203 - .show_attribute = f_uvc_opts_attr_show, 2204 - .store_attribute = f_uvc_opts_attr_store, 2205 2300 }; 2206 2301 2207 2302 #define UVCG_OPTS_ATTR(cname, conv, str2u, uxx, vnoc, limit) \ 2208 2303 static ssize_t f_uvc_opts_##cname##_show( \ 2209 - struct f_uvc_opts *opts, char *page) \ 2304 + struct config_item *item, char *page) \ 2210 2305 { \ 2306 + struct f_uvc_opts *opts = to_f_uvc_opts(item); \ 2211 2307 int result; \ 2212 2308 \ 2213 2309 mutex_lock(&opts->lock); \ ··· 2217 2315 } \ 2218 2316 \ 2219 2317 static ssize_t \ 2220 - f_uvc_opts_##cname##_store(struct f_uvc_opts *opts, \ 2318 + f_uvc_opts_##cname##_store(struct config_item *item, \ 2221 2319 const char *page, size_t len) \ 2222 2320 { \ 2321 + struct f_uvc_opts *opts = to_f_uvc_opts(item); \ 2223 2322 int ret; \ 2224 2323 uxx num; \ 2225 2324 \ ··· 2245 2342 return ret; \ 2246 2343 } \ 2247 2344 \ 2248 - static struct f_uvc_opts_attribute \ 2249 - f_uvc_opts_attribute_##cname = \ 2250 - __CONFIGFS_ATTR(cname, S_IRUGO | S_IWUSR, \ 2251 - f_uvc_opts_##cname##_show, \ 2252 - f_uvc_opts_##cname##_store) 2345 + UVC_ATTR(f_uvc_opts_, cname, aname) 2253 2346 2254 2347 #define identity_conv(x) (x) 2255 2348 ··· 2261 2362 #undef UVCG_OPTS_ATTR 2262 2363 2263 2364 static struct configfs_attribute *uvc_attrs[] = { 2264 - &f_uvc_opts_attribute_streaming_interval.attr, 2265 - &f_uvc_opts_attribute_streaming_maxpacket.attr, 2266 - &f_uvc_opts_attribute_streaming_maxburst.attr, 2365 + &f_uvc_opts_attr_streaming_interval, 2366 + &f_uvc_opts_attr_streaming_maxpacket, 2367 + &f_uvc_opts_attr_streaming_maxburst, 2267 2368 NULL, 2268 2369 }; 2269 2370
+19 -25
drivers/usb/gadget/legacy/tcm_usb_gadget.c
··· 19 19 #include <scsi/scsi_tcq.h> 20 20 #include <target/target_core_base.h> 21 21 #include <target/target_core_fabric.h> 22 - #include <target/target_core_fabric_configfs.h> 23 - #include <target/configfs_macros.h> 24 22 #include <asm/unaligned.h> 25 23 26 24 #include "tcm_usb_gadget.h" ··· 1465 1467 /* 1466 1468 * If somebody feels like dropping the version property, go ahead. 1467 1469 */ 1468 - static ssize_t usbg_wwn_show_attr_version( 1469 - struct target_fabric_configfs *tf, 1470 - char *page) 1470 + static ssize_t usbg_wwn_version_show(struct config_item *item, char *page) 1471 1471 { 1472 1472 return sprintf(page, "usb-gadget fabric module\n"); 1473 1473 } 1474 - TF_WWN_ATTR_RO(usbg, version); 1474 + 1475 + CONFIGFS_ATTR_RO(usbg_wwn_, version); 1475 1476 1476 1477 static struct configfs_attribute *usbg_wwn_attrs[] = { 1477 - &usbg_wwn_version.attr, 1478 + &usbg_wwn_attr_version, 1478 1479 NULL, 1479 1480 }; 1480 1481 1481 - static ssize_t tcm_usbg_tpg_show_enable( 1482 - struct se_portal_group *se_tpg, 1483 - char *page) 1482 + static ssize_t tcm_usbg_tpg_enable_show(struct config_item *item, char *page) 1484 1483 { 1484 + struct se_portal_group *se_tpg = to_tpg(item); 1485 1485 struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); 1486 1486 1487 1487 return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect); ··· 1488 1492 static int usbg_attach(struct usbg_tpg *); 1489 1493 static void usbg_detach(struct usbg_tpg *); 1490 1494 1491 - static ssize_t tcm_usbg_tpg_store_enable( 1492 - struct se_portal_group *se_tpg, 1493 - const char *page, 1494 - size_t count) 1495 + static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item, 1496 + const char *page, size_t count) 1495 1497 { 1498 + struct se_portal_group *se_tpg = to_tpg(item); 1496 1499 struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); 1497 1500 unsigned long op; 1498 1501 ssize_t ret; ··· 1518 1523 out: 1519 1524 return count; 1520 1525 } 1521 - TF_TPG_BASE_ATTR(tcm_usbg, enable, S_IRUGO | S_IWUSR); 1522 1526 1523 - static ssize_t tcm_usbg_tpg_show_nexus( 1524 - struct se_portal_group *se_tpg, 1525 - char *page) 1527 + static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page) 1526 1528 { 1529 + struct se_portal_group *se_tpg = to_tpg(item); 1527 1530 struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); 1528 1531 struct tcm_usbg_nexus *tv_nexus; 1529 1532 ssize_t ret; ··· 1629 1636 return ret; 1630 1637 } 1631 1638 1632 - static ssize_t tcm_usbg_tpg_store_nexus( 1633 - struct se_portal_group *se_tpg, 1634 - const char *page, 1635 - size_t count) 1639 + static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item, 1640 + const char *page, size_t count) 1636 1641 { 1642 + struct se_portal_group *se_tpg = to_tpg(item); 1637 1643 struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); 1638 1644 unsigned char i_port[USBG_NAMELEN], *ptr; 1639 1645 int ret; ··· 1662 1670 return ret; 1663 1671 return count; 1664 1672 } 1665 - TF_TPG_BASE_ATTR(tcm_usbg, nexus, S_IRUGO | S_IWUSR); 1673 + 1674 + CONFIGFS_ATTR(tcm_usbg_tpg_, enable); 1675 + CONFIGFS_ATTR(tcm_usbg_tpg_, nexus); 1666 1676 1667 1677 static struct configfs_attribute *usbg_base_attrs[] = { 1668 - &tcm_usbg_tpg_enable.attr, 1669 - &tcm_usbg_tpg_nexus.attr, 1678 + &tcm_usbg_tpg_attr_enable, 1679 + &tcm_usbg_tpg_attr_nexus, 1670 1680 NULL, 1671 1681 }; 1672 1682
+19 -22
drivers/vhost/scsi.c
··· 42 42 #include <scsi/scsi_proto.h> 43 43 #include <target/target_core_base.h> 44 44 #include <target/target_core_fabric.h> 45 - #include <target/target_core_fabric_configfs.h> 46 - #include <target/configfs_macros.h> 47 45 #include <linux/vhost.h> 48 46 #include <linux/virtio_scsi.h> 49 47 #include <linux/llist.h> ··· 1682 1684 } 1683 1685 } 1684 1686 1685 - static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type( 1686 - struct se_portal_group *se_tpg, 1687 - const char *page, 1688 - size_t count) 1687 + static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_store( 1688 + struct config_item *item, const char *page, size_t count) 1689 1689 { 1690 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 1690 1691 struct vhost_scsi_tpg *tpg = container_of(se_tpg, 1691 1692 struct vhost_scsi_tpg, se_tpg); 1692 1693 unsigned long val; ··· 1704 1707 return count; 1705 1708 } 1706 1709 1707 - static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type( 1708 - struct se_portal_group *se_tpg, 1709 - char *page) 1710 + static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_show( 1711 + struct config_item *item, char *page) 1710 1712 { 1713 + struct se_portal_group *se_tpg = attrib_to_tpg(item); 1711 1714 struct vhost_scsi_tpg *tpg = container_of(se_tpg, 1712 1715 struct vhost_scsi_tpg, se_tpg); 1713 1716 1714 1717 return sprintf(page, "%d\n", tpg->tv_fabric_prot_type); 1715 1718 } 1716 - TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR); 1719 + 1720 + CONFIGFS_ATTR(vhost_scsi_tpg_attrib_, fabric_prot_type); 1717 1721 1718 1722 static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = { 1719 - &vhost_scsi_tpg_attrib_fabric_prot_type.attr, 1723 + &vhost_scsi_tpg_attrib_attr_fabric_prot_type, 1720 1724 NULL, 1721 1725 }; 1722 1726 ··· 1865 1867 return 0; 1866 1868 } 1867 1869 1868 - static ssize_t vhost_scsi_tpg_show_nexus(struct se_portal_group *se_tpg, 1869 - char *page) 1870 + static ssize_t vhost_scsi_tpg_nexus_show(struct config_item *item, char *page) 1870 1871 { 1872 + struct se_portal_group *se_tpg = to_tpg(item); 1871 1873 struct vhost_scsi_tpg *tpg = container_of(se_tpg, 1872 1874 struct vhost_scsi_tpg, se_tpg); 1873 1875 struct vhost_scsi_nexus *tv_nexus; ··· 1886 1888 return ret; 1887 1889 } 1888 1890 1889 - static ssize_t vhost_scsi_tpg_store_nexus(struct se_portal_group *se_tpg, 1890 - const char *page, 1891 - size_t count) 1891 + static ssize_t vhost_scsi_tpg_nexus_store(struct config_item *item, 1892 + const char *page, size_t count) 1892 1893 { 1894 + struct se_portal_group *se_tpg = to_tpg(item); 1893 1895 struct vhost_scsi_tpg *tpg = container_of(se_tpg, 1894 1896 struct vhost_scsi_tpg, se_tpg); 1895 1897 struct vhost_scsi_tport *tport_wwn = tpg->tport; ··· 1964 1966 return count; 1965 1967 } 1966 1968 1967 - TF_TPG_BASE_ATTR(vhost_scsi, nexus, S_IRUGO | S_IWUSR); 1969 + CONFIGFS_ATTR(vhost_scsi_tpg_, nexus); 1968 1970 1969 1971 static struct configfs_attribute *vhost_scsi_tpg_attrs[] = { 1970 - &vhost_scsi_tpg_nexus.attr, 1972 + &vhost_scsi_tpg_attr_nexus, 1971 1973 NULL, 1972 1974 }; 1973 1975 ··· 2103 2105 } 2104 2106 2105 2107 static ssize_t 2106 - vhost_scsi_wwn_show_attr_version(struct target_fabric_configfs *tf, 2107 - char *page) 2108 + vhost_scsi_wwn_version_show(struct config_item *item, char *page) 2108 2109 { 2109 2110 return sprintf(page, "TCM_VHOST fabric module %s on %s/%s" 2110 2111 "on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname, 2111 2112 utsname()->machine); 2112 2113 } 2113 2114 2114 - TF_WWN_ATTR_RO(vhost_scsi, version); 2115 + CONFIGFS_ATTR_RO(vhost_scsi_wwn_, version); 2115 2116 2116 2117 static struct configfs_attribute *vhost_scsi_wwn_attrs[] = { 2117 - &vhost_scsi_wwn_version.attr, 2118 + &vhost_scsi_wwn_attr_version, 2118 2119 NULL, 2119 2120 }; 2120 2121
+16 -16
drivers/xen/xen-scsiback.c
··· 53 53 54 54 #include <target/target_core_base.h> 55 55 #include <target/target_core_fabric.h> 56 - #include <target/target_core_fabric_configfs.h> 57 56 58 57 #include <asm/hypervisor.h> 59 58 ··· 1437 1438 { 1438 1439 } 1439 1440 1440 - static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg, 1441 + static ssize_t scsiback_tpg_param_alias_show(struct config_item *item, 1441 1442 char *page) 1442 1443 { 1444 + struct se_portal_group *se_tpg = param_to_tpg(item); 1443 1445 struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, 1444 1446 se_tpg); 1445 1447 ssize_t rb; ··· 1452 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 1456 const char *page, size_t count) 1457 1457 { 1458 + struct se_portal_group *se_tpg = param_to_tpg(item); 1458 1459 struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg, 1459 1460 se_tpg); 1460 1461 int len; ··· 1475 1474 return count; 1476 1475 } 1477 1476 1478 - TF_TPG_PARAM_ATTR(scsiback, alias, S_IRUGO | S_IWUSR); 1477 + CONFIGFS_ATTR(scsiback_tpg_param_, alias); 1479 1478 1480 1479 static struct configfs_attribute *scsiback_param_attrs[] = { 1481 - &scsiback_tpg_param_alias.attr, 1480 + &scsiback_tpg_param_attr_alias, 1482 1481 NULL, 1483 1482 }; 1484 1483 ··· 1586 1585 return 0; 1587 1586 } 1588 1587 1589 - static ssize_t scsiback_tpg_show_nexus(struct se_portal_group *se_tpg, 1590 - char *page) 1588 + static ssize_t scsiback_tpg_nexus_show(struct config_item *item, char *page) 1591 1589 { 1590 + struct se_portal_group *se_tpg = to_tpg(item); 1592 1591 struct scsiback_tpg *tpg = container_of(se_tpg, 1593 1592 struct scsiback_tpg, se_tpg); 1594 1593 struct scsiback_nexus *tv_nexus; ··· 1607 1606 return ret; 1608 1607 } 1609 1608 1610 - static ssize_t scsiback_tpg_store_nexus(struct se_portal_group *se_tpg, 1611 - const char *page, 1612 - size_t count) 1609 + static ssize_t scsiback_tpg_nexus_store(struct config_item *item, 1610 + const char *page, size_t count) 1613 1611 { 1612 + struct se_portal_group *se_tpg = to_tpg(item); 1614 1613 struct scsiback_tpg *tpg = container_of(se_tpg, 1615 1614 struct scsiback_tpg, se_tpg); 1616 1615 struct scsiback_tport *tport_wwn = tpg->tport; ··· 1682 1681 return count; 1683 1682 } 1684 1683 1685 - TF_TPG_BASE_ATTR(scsiback, nexus, S_IRUGO | S_IWUSR); 1684 + CONFIGFS_ATTR(scsiback_tpg_, nexus); 1686 1685 1687 1686 static struct configfs_attribute *scsiback_tpg_attrs[] = { 1688 - &scsiback_tpg_nexus.attr, 1687 + &scsiback_tpg_attr_nexus, 1689 1688 NULL, 1690 1689 }; 1691 1690 1692 1691 static ssize_t 1693 - scsiback_wwn_show_attr_version(struct target_fabric_configfs *tf, 1694 - char *page) 1692 + scsiback_wwn_version_show(struct config_item *item, char *page) 1695 1693 { 1696 1694 return sprintf(page, "xen-pvscsi fabric module %s on %s/%s on " 1697 1695 UTS_RELEASE"\n", 1698 1696 VSCSI_VERSION, utsname()->sysname, utsname()->machine); 1699 1697 } 1700 1698 1701 - TF_WWN_ATTR_RO(scsiback, version); 1699 + CONFIGFS_ATTR_RO(scsiback_wwn_, version); 1702 1700 1703 1701 static struct configfs_attribute *scsiback_wwn_attrs[] = { 1704 - &scsiback_wwn_version.attr, 1702 + &scsiback_wwn_attr_version, 1705 1703 NULL, 1706 1704 }; 1707 1705
+5 -7
fs/configfs/file.c
··· 65 65 { 66 66 struct configfs_attribute * attr = to_attr(dentry); 67 67 struct config_item * item = to_item(dentry->d_parent); 68 - struct configfs_item_operations * ops = buffer->ops; 69 68 int ret = 0; 70 69 ssize_t count; 71 70 ··· 73 74 if (!buffer->page) 74 75 return -ENOMEM; 75 76 76 - count = ops->show_attribute(item,attr,buffer->page); 77 + count = attr->show(item, buffer->page); 78 + 77 79 buffer->needs_read_fill = 0; 78 80 BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE); 79 81 if (count >= 0) ··· 171 171 { 172 172 struct configfs_attribute * attr = to_attr(dentry); 173 173 struct config_item * item = to_item(dentry->d_parent); 174 - struct configfs_item_operations * ops = buffer->ops; 175 174 176 - return ops->store_attribute(item,attr,buffer->page,count); 175 + return attr->store(item, buffer->page, count); 177 176 } 178 177 179 178 ··· 236 237 * and we must have a store method. 237 238 */ 238 239 if (file->f_mode & FMODE_WRITE) { 239 - 240 - if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute) 240 + if (!(inode->i_mode & S_IWUGO) || !attr->store) 241 241 goto Eaccess; 242 242 243 243 } ··· 246 248 * must be a show method for it. 247 249 */ 248 250 if (file->f_mode & FMODE_READ) { 249 - if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute) 251 + if (!(inode->i_mode & S_IRUGO) || !attr->show) 250 252 goto Eaccess; 251 253 } 252 254
+76 -216
fs/dlm/config.c
··· 61 61 static void drop_node(struct config_group *, struct config_item *); 62 62 static void release_node(struct config_item *); 63 63 64 - static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a, 65 - char *buf); 66 - static ssize_t store_cluster(struct config_item *i, 67 - struct configfs_attribute *a, 68 - const char *buf, size_t len); 69 - static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a, 70 - char *buf); 71 - static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a, 72 - const char *buf, size_t len); 73 - static ssize_t show_node(struct config_item *i, struct configfs_attribute *a, 74 - char *buf); 75 - static ssize_t store_node(struct config_item *i, struct configfs_attribute *a, 76 - const char *buf, size_t len); 77 - 78 - static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf); 79 - static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf, 80 - size_t len); 81 - static ssize_t comm_local_read(struct dlm_comm *cm, char *buf); 82 - static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf, 83 - size_t len); 84 - static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, 85 - size_t len); 86 - static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf); 87 - static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf); 88 - static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, 89 - size_t len); 90 - static ssize_t node_weight_read(struct dlm_node *nd, char *buf); 91 - static ssize_t node_weight_write(struct dlm_node *nd, const char *buf, 92 - size_t len); 64 + static struct configfs_attribute *comm_attrs[]; 65 + static struct configfs_attribute *node_attrs[]; 93 66 94 67 struct dlm_cluster { 95 68 struct config_group group; ··· 81 108 char cl_cluster_name[DLM_LOCKSPACE_LEN]; 82 109 }; 83 110 111 + static struct dlm_cluster *config_item_to_cluster(struct config_item *i) 112 + { 113 + return i ? container_of(to_config_group(i), struct dlm_cluster, group) : 114 + NULL; 115 + } 116 + 84 117 enum { 85 118 CLUSTER_ATTR_TCP_PORT = 0, 86 119 CLUSTER_ATTR_BUFFER_SIZE, ··· 103 124 CLUSTER_ATTR_CLUSTER_NAME, 104 125 }; 105 126 106 - struct cluster_attribute { 107 - struct configfs_attribute attr; 108 - ssize_t (*show)(struct dlm_cluster *, char *); 109 - ssize_t (*store)(struct dlm_cluster *, const char *, size_t); 110 - }; 111 - 112 - static ssize_t cluster_cluster_name_read(struct dlm_cluster *cl, char *buf) 127 + static ssize_t cluster_cluster_name_show(struct config_item *item, char *buf) 113 128 { 129 + struct dlm_cluster *cl = config_item_to_cluster(item); 114 130 return sprintf(buf, "%s\n", cl->cl_cluster_name); 115 131 } 116 132 117 - static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl, 133 + static ssize_t cluster_cluster_name_store(struct config_item *item, 118 134 const char *buf, size_t len) 119 135 { 136 + struct dlm_cluster *cl = config_item_to_cluster(item); 137 + 120 138 strlcpy(dlm_config.ci_cluster_name, buf, 121 139 sizeof(dlm_config.ci_cluster_name)); 122 140 strlcpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name)); 123 141 return len; 124 142 } 125 143 126 - static struct cluster_attribute cluster_attr_cluster_name = { 127 - .attr = { .ca_owner = THIS_MODULE, 128 - .ca_name = "cluster_name", 129 - .ca_mode = S_IRUGO | S_IWUSR }, 130 - .show = cluster_cluster_name_read, 131 - .store = cluster_cluster_name_write, 132 - }; 144 + CONFIGFS_ATTR(cluster_, cluster_name); 133 145 134 146 static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field, 135 147 int *info_field, int check_zero, ··· 145 175 } 146 176 147 177 #define CLUSTER_ATTR(name, check_zero) \ 148 - static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t len) \ 178 + static ssize_t cluster_##name##_store(struct config_item *item, \ 179 + const char *buf, size_t len) \ 149 180 { \ 181 + struct dlm_cluster *cl = config_item_to_cluster(item); \ 150 182 return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name, \ 151 183 check_zero, buf, len); \ 152 184 } \ 153 - static ssize_t name##_read(struct dlm_cluster *cl, char *buf) \ 185 + static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \ 154 186 { \ 187 + struct dlm_cluster *cl = config_item_to_cluster(item); \ 155 188 return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name); \ 156 189 } \ 157 - static struct cluster_attribute cluster_attr_##name = \ 158 - __CONFIGFS_ATTR(name, 0644, name##_read, name##_write) 190 + CONFIGFS_ATTR(cluster_, name); 159 191 160 192 CLUSTER_ATTR(tcp_port, 1); 161 193 CLUSTER_ATTR(buffer_size, 1); ··· 173 201 CLUSTER_ATTR(recover_callbacks, 0); 174 202 175 203 static struct configfs_attribute *cluster_attrs[] = { 176 - [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr, 177 - [CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size.attr, 178 - [CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size.attr, 179 - [CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer.attr, 180 - [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr, 181 - [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr, 182 - [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr, 183 - [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol.attr, 184 - [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr, 185 - [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us.attr, 186 - [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count.attr, 187 - [CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks.attr, 188 - [CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name.attr, 204 + [CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port, 205 + [CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size, 206 + [CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size, 207 + [CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer, 208 + [CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs, 209 + [CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs, 210 + [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug, 211 + [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol, 212 + [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs, 213 + [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us, 214 + [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count, 215 + [CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks, 216 + [CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name, 189 217 NULL, 190 218 }; 191 219 ··· 196 224 COMM_ATTR_ADDR_LIST, 197 225 }; 198 226 199 - struct comm_attribute { 200 - struct configfs_attribute attr; 201 - ssize_t (*show)(struct dlm_comm *, char *); 202 - ssize_t (*store)(struct dlm_comm *, const char *, size_t); 203 - }; 204 - 205 - static struct comm_attribute comm_attr_nodeid = { 206 - .attr = { .ca_owner = THIS_MODULE, 207 - .ca_name = "nodeid", 208 - .ca_mode = S_IRUGO | S_IWUSR }, 209 - .show = comm_nodeid_read, 210 - .store = comm_nodeid_write, 211 - }; 212 - 213 - static struct comm_attribute comm_attr_local = { 214 - .attr = { .ca_owner = THIS_MODULE, 215 - .ca_name = "local", 216 - .ca_mode = S_IRUGO | S_IWUSR }, 217 - .show = comm_local_read, 218 - .store = comm_local_write, 219 - }; 220 - 221 - static struct comm_attribute comm_attr_addr = { 222 - .attr = { .ca_owner = THIS_MODULE, 223 - .ca_name = "addr", 224 - .ca_mode = S_IWUSR }, 225 - .store = comm_addr_write, 226 - }; 227 - 228 - static struct comm_attribute comm_attr_addr_list = { 229 - .attr = { .ca_owner = THIS_MODULE, 230 - .ca_name = "addr_list", 231 - .ca_mode = S_IRUGO }, 232 - .show = comm_addr_list_read, 233 - }; 234 - 235 - static struct configfs_attribute *comm_attrs[] = { 236 - [COMM_ATTR_NODEID] = &comm_attr_nodeid.attr, 237 - [COMM_ATTR_LOCAL] = &comm_attr_local.attr, 238 - [COMM_ATTR_ADDR] = &comm_attr_addr.attr, 239 - [COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list.attr, 240 - NULL, 241 - }; 242 - 243 227 enum { 244 228 NODE_ATTR_NODEID = 0, 245 229 NODE_ATTR_WEIGHT, 246 - }; 247 - 248 - struct node_attribute { 249 - struct configfs_attribute attr; 250 - ssize_t (*show)(struct dlm_node *, char *); 251 - ssize_t (*store)(struct dlm_node *, const char *, size_t); 252 - }; 253 - 254 - static struct node_attribute node_attr_nodeid = { 255 - .attr = { .ca_owner = THIS_MODULE, 256 - .ca_name = "nodeid", 257 - .ca_mode = S_IRUGO | S_IWUSR }, 258 - .show = node_nodeid_read, 259 - .store = node_nodeid_write, 260 - }; 261 - 262 - static struct node_attribute node_attr_weight = { 263 - .attr = { .ca_owner = THIS_MODULE, 264 - .ca_name = "weight", 265 - .ca_mode = S_IRUGO | S_IWUSR }, 266 - .show = node_weight_read, 267 - .store = node_weight_write, 268 - }; 269 - 270 - static struct configfs_attribute *node_attrs[] = { 271 - [NODE_ATTR_NODEID] = &node_attr_nodeid.attr, 272 - [NODE_ATTR_WEIGHT] = &node_attr_weight.attr, 273 - NULL, 274 230 }; 275 231 276 232 struct dlm_clusters { ··· 249 349 250 350 static struct configfs_item_operations cluster_ops = { 251 351 .release = release_cluster, 252 - .show_attribute = show_cluster, 253 - .store_attribute = store_cluster, 254 352 }; 255 353 256 354 static struct configfs_group_operations spaces_ops = { ··· 267 369 268 370 static struct configfs_item_operations comm_ops = { 269 371 .release = release_comm, 270 - .show_attribute = show_comm, 271 - .store_attribute = store_comm, 272 372 }; 273 373 274 374 static struct configfs_group_operations nodes_ops = { ··· 276 380 277 381 static struct configfs_item_operations node_ops = { 278 382 .release = release_node, 279 - .show_attribute = show_node, 280 - .store_attribute = store_node, 281 383 }; 282 384 283 385 static struct config_item_type clusters_type = { ··· 320 426 .ct_attrs = node_attrs, 321 427 .ct_owner = THIS_MODULE, 322 428 }; 323 - 324 - static struct dlm_cluster *config_item_to_cluster(struct config_item *i) 325 - { 326 - return i ? container_of(to_config_group(i), struct dlm_cluster, group) : 327 - NULL; 328 - } 329 429 330 430 static struct dlm_space *config_item_to_space(struct config_item *i) 331 431 { ··· 575 687 * Functions for user space to read/write attributes 576 688 */ 577 689 578 - static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a, 579 - char *buf) 690 + static ssize_t comm_nodeid_show(struct config_item *item, char *buf) 580 691 { 581 - struct dlm_cluster *cl = config_item_to_cluster(i); 582 - struct cluster_attribute *cla = 583 - container_of(a, struct cluster_attribute, attr); 584 - return cla->show ? cla->show(cl, buf) : 0; 692 + return sprintf(buf, "%d\n", config_item_to_comm(item)->nodeid); 585 693 } 586 694 587 - static ssize_t store_cluster(struct config_item *i, 588 - struct configfs_attribute *a, 589 - const char *buf, size_t len) 590 - { 591 - struct dlm_cluster *cl = config_item_to_cluster(i); 592 - struct cluster_attribute *cla = 593 - container_of(a, struct cluster_attribute, attr); 594 - return cla->store ? cla->store(cl, buf, len) : -EINVAL; 595 - } 596 - 597 - static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a, 598 - char *buf) 599 - { 600 - struct dlm_comm *cm = config_item_to_comm(i); 601 - struct comm_attribute *cma = 602 - container_of(a, struct comm_attribute, attr); 603 - return cma->show ? cma->show(cm, buf) : 0; 604 - } 605 - 606 - static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a, 607 - const char *buf, size_t len) 608 - { 609 - struct dlm_comm *cm = config_item_to_comm(i); 610 - struct comm_attribute *cma = 611 - container_of(a, struct comm_attribute, attr); 612 - return cma->store ? cma->store(cm, buf, len) : -EINVAL; 613 - } 614 - 615 - static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf) 616 - { 617 - return sprintf(buf, "%d\n", cm->nodeid); 618 - } 619 - 620 - static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf, 695 + static ssize_t comm_nodeid_store(struct config_item *item, const char *buf, 621 696 size_t len) 622 697 { 623 - int rc = kstrtoint(buf, 0, &cm->nodeid); 698 + int rc = kstrtoint(buf, 0, &config_item_to_comm(item)->nodeid); 624 699 625 700 if (rc) 626 701 return rc; 627 702 return len; 628 703 } 629 704 630 - static ssize_t comm_local_read(struct dlm_comm *cm, char *buf) 705 + static ssize_t comm_local_show(struct config_item *item, char *buf) 631 706 { 632 - return sprintf(buf, "%d\n", cm->local); 707 + return sprintf(buf, "%d\n", config_item_to_comm(item)->local); 633 708 } 634 709 635 - static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf, 710 + static ssize_t comm_local_store(struct config_item *item, const char *buf, 636 711 size_t len) 637 712 { 713 + struct dlm_comm *cm = config_item_to_comm(item); 638 714 int rc = kstrtoint(buf, 0, &cm->local); 639 715 640 716 if (rc) ··· 608 756 return len; 609 757 } 610 758 611 - static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len) 759 + static ssize_t comm_addr_store(struct config_item *item, const char *buf, 760 + size_t len) 612 761 { 762 + struct dlm_comm *cm = config_item_to_comm(item); 613 763 struct sockaddr_storage *addr; 614 764 int rv; 615 765 ··· 637 783 return len; 638 784 } 639 785 640 - static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf) 786 + static ssize_t comm_addr_list_show(struct config_item *item, char *buf) 641 787 { 788 + struct dlm_comm *cm = config_item_to_comm(item); 642 789 ssize_t s; 643 790 ssize_t allowance; 644 791 int i; ··· 682 827 return 4096 - allowance; 683 828 } 684 829 685 - static ssize_t show_node(struct config_item *i, struct configfs_attribute *a, 686 - char *buf) 830 + CONFIGFS_ATTR(comm_, nodeid); 831 + CONFIGFS_ATTR(comm_, local); 832 + CONFIGFS_ATTR_WO(comm_, addr); 833 + CONFIGFS_ATTR_RO(comm_, addr_list); 834 + 835 + static struct configfs_attribute *comm_attrs[] = { 836 + [COMM_ATTR_NODEID] = &comm_attr_nodeid, 837 + [COMM_ATTR_LOCAL] = &comm_attr_local, 838 + [COMM_ATTR_ADDR] = &comm_attr_addr, 839 + [COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list, 840 + NULL, 841 + }; 842 + 843 + static ssize_t node_nodeid_show(struct config_item *item, char *buf) 687 844 { 688 - struct dlm_node *nd = config_item_to_node(i); 689 - struct node_attribute *nda = 690 - container_of(a, struct node_attribute, attr); 691 - return nda->show ? nda->show(nd, buf) : 0; 845 + return sprintf(buf, "%d\n", config_item_to_node(item)->nodeid); 692 846 } 693 847 694 - static ssize_t store_node(struct config_item *i, struct configfs_attribute *a, 695 - const char *buf, size_t len) 696 - { 697 - struct dlm_node *nd = config_item_to_node(i); 698 - struct node_attribute *nda = 699 - container_of(a, struct node_attribute, attr); 700 - return nda->store ? nda->store(nd, buf, len) : -EINVAL; 701 - } 702 - 703 - static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf) 704 - { 705 - return sprintf(buf, "%d\n", nd->nodeid); 706 - } 707 - 708 - static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf, 848 + static ssize_t node_nodeid_store(struct config_item *item, const char *buf, 709 849 size_t len) 710 850 { 851 + struct dlm_node *nd = config_item_to_node(item); 711 852 uint32_t seq = 0; 712 853 int rc = kstrtoint(buf, 0, &nd->nodeid); 713 854 ··· 714 863 return len; 715 864 } 716 865 717 - static ssize_t node_weight_read(struct dlm_node *nd, char *buf) 866 + static ssize_t node_weight_show(struct config_item *item, char *buf) 718 867 { 719 - return sprintf(buf, "%d\n", nd->weight); 868 + return sprintf(buf, "%d\n", config_item_to_node(item)->weight); 720 869 } 721 870 722 - static ssize_t node_weight_write(struct dlm_node *nd, const char *buf, 871 + static ssize_t node_weight_store(struct config_item *item, const char *buf, 723 872 size_t len) 724 873 { 725 - int rc = kstrtoint(buf, 0, &nd->weight); 874 + int rc = kstrtoint(buf, 0, &config_item_to_node(item)->weight); 726 875 727 876 if (rc) 728 877 return rc; 729 878 return len; 730 879 } 880 + 881 + CONFIGFS_ATTR(node_, nodeid); 882 + CONFIGFS_ATTR(node_, weight); 883 + 884 + static struct configfs_attribute *node_attrs[] = { 885 + [NODE_ATTR_NODEID] = &node_attr_nodeid, 886 + [NODE_ATTR_WEIGHT] = &node_attr_weight, 887 + NULL, 888 + }; 731 889 732 890 /* 733 891 * Functions for the dlm to get the info that's been configured
+41 -164
fs/ocfs2/cluster/heartbeat.c
··· 1480 1480 return 0; 1481 1481 } 1482 1482 1483 - static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg, 1483 + static ssize_t o2hb_region_block_bytes_show(struct config_item *item, 1484 1484 char *page) 1485 1485 { 1486 - return sprintf(page, "%u\n", reg->hr_block_bytes); 1486 + return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes); 1487 1487 } 1488 1488 1489 - static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg, 1489 + static ssize_t o2hb_region_block_bytes_store(struct config_item *item, 1490 1490 const char *page, 1491 1491 size_t count) 1492 1492 { 1493 + struct o2hb_region *reg = to_o2hb_region(item); 1493 1494 int status; 1494 1495 unsigned long block_bytes; 1495 1496 unsigned int block_bits; ··· 1509 1508 return count; 1510 1509 } 1511 1510 1512 - static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg, 1511 + static ssize_t o2hb_region_start_block_show(struct config_item *item, 1513 1512 char *page) 1514 1513 { 1515 - return sprintf(page, "%llu\n", reg->hr_start_block); 1514 + return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block); 1516 1515 } 1517 1516 1518 - static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg, 1517 + static ssize_t o2hb_region_start_block_store(struct config_item *item, 1519 1518 const char *page, 1520 1519 size_t count) 1521 1520 { 1521 + struct o2hb_region *reg = to_o2hb_region(item); 1522 1522 unsigned long long tmp; 1523 1523 char *p = (char *)page; 1524 1524 ··· 1535 1533 return count; 1536 1534 } 1537 1535 1538 - static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg, 1539 - char *page) 1536 + static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page) 1540 1537 { 1541 - return sprintf(page, "%d\n", reg->hr_blocks); 1538 + return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks); 1542 1539 } 1543 1540 1544 - static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg, 1541 + static ssize_t o2hb_region_blocks_store(struct config_item *item, 1545 1542 const char *page, 1546 1543 size_t count) 1547 1544 { 1545 + struct o2hb_region *reg = to_o2hb_region(item); 1548 1546 unsigned long tmp; 1549 1547 char *p = (char *)page; 1550 1548 ··· 1563 1561 return count; 1564 1562 } 1565 1563 1566 - static ssize_t o2hb_region_dev_read(struct o2hb_region *reg, 1567 - char *page) 1564 + static ssize_t o2hb_region_dev_show(struct config_item *item, char *page) 1568 1565 { 1569 1566 unsigned int ret = 0; 1570 1567 1571 - if (reg->hr_bdev) 1572 - ret = sprintf(page, "%s\n", reg->hr_dev_name); 1568 + if (to_o2hb_region(item)->hr_bdev) 1569 + ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name); 1573 1570 1574 1571 return ret; 1575 1572 } ··· 1678 1677 } 1679 1678 1680 1679 /* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */ 1681 - static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, 1680 + static ssize_t o2hb_region_dev_store(struct config_item *item, 1682 1681 const char *page, 1683 1682 size_t count) 1684 1683 { 1684 + struct o2hb_region *reg = to_o2hb_region(item); 1685 1685 struct task_struct *hb_task; 1686 1686 long fd; 1687 1687 int sectsize; ··· 1843 1841 return ret; 1844 1842 } 1845 1843 1846 - static ssize_t o2hb_region_pid_read(struct o2hb_region *reg, 1847 - char *page) 1844 + static ssize_t o2hb_region_pid_show(struct config_item *item, char *page) 1848 1845 { 1846 + struct o2hb_region *reg = to_o2hb_region(item); 1849 1847 pid_t pid = 0; 1850 1848 1851 1849 spin_lock(&o2hb_live_lock); ··· 1859 1857 return sprintf(page, "%u\n", pid); 1860 1858 } 1861 1859 1862 - struct o2hb_region_attribute { 1863 - struct configfs_attribute attr; 1864 - ssize_t (*show)(struct o2hb_region *, char *); 1865 - ssize_t (*store)(struct o2hb_region *, const char *, size_t); 1866 - }; 1867 - 1868 - static struct o2hb_region_attribute o2hb_region_attr_block_bytes = { 1869 - .attr = { .ca_owner = THIS_MODULE, 1870 - .ca_name = "block_bytes", 1871 - .ca_mode = S_IRUGO | S_IWUSR }, 1872 - .show = o2hb_region_block_bytes_read, 1873 - .store = o2hb_region_block_bytes_write, 1874 - }; 1875 - 1876 - static struct o2hb_region_attribute o2hb_region_attr_start_block = { 1877 - .attr = { .ca_owner = THIS_MODULE, 1878 - .ca_name = "start_block", 1879 - .ca_mode = S_IRUGO | S_IWUSR }, 1880 - .show = o2hb_region_start_block_read, 1881 - .store = o2hb_region_start_block_write, 1882 - }; 1883 - 1884 - static struct o2hb_region_attribute o2hb_region_attr_blocks = { 1885 - .attr = { .ca_owner = THIS_MODULE, 1886 - .ca_name = "blocks", 1887 - .ca_mode = S_IRUGO | S_IWUSR }, 1888 - .show = o2hb_region_blocks_read, 1889 - .store = o2hb_region_blocks_write, 1890 - }; 1891 - 1892 - static struct o2hb_region_attribute o2hb_region_attr_dev = { 1893 - .attr = { .ca_owner = THIS_MODULE, 1894 - .ca_name = "dev", 1895 - .ca_mode = S_IRUGO | S_IWUSR }, 1896 - .show = o2hb_region_dev_read, 1897 - .store = o2hb_region_dev_write, 1898 - }; 1899 - 1900 - static struct o2hb_region_attribute o2hb_region_attr_pid = { 1901 - .attr = { .ca_owner = THIS_MODULE, 1902 - .ca_name = "pid", 1903 - .ca_mode = S_IRUGO | S_IRUSR }, 1904 - .show = o2hb_region_pid_read, 1905 - }; 1860 + CONFIGFS_ATTR(o2hb_region_, block_bytes); 1861 + CONFIGFS_ATTR(o2hb_region_, start_block); 1862 + CONFIGFS_ATTR(o2hb_region_, blocks); 1863 + CONFIGFS_ATTR(o2hb_region_, dev); 1864 + CONFIGFS_ATTR_RO(o2hb_region_, pid); 1906 1865 1907 1866 static struct configfs_attribute *o2hb_region_attrs[] = { 1908 - &o2hb_region_attr_block_bytes.attr, 1909 - &o2hb_region_attr_start_block.attr, 1910 - &o2hb_region_attr_blocks.attr, 1911 - &o2hb_region_attr_dev.attr, 1912 - &o2hb_region_attr_pid.attr, 1867 + &o2hb_region_attr_block_bytes, 1868 + &o2hb_region_attr_start_block, 1869 + &o2hb_region_attr_blocks, 1870 + &o2hb_region_attr_dev, 1871 + &o2hb_region_attr_pid, 1913 1872 NULL, 1914 1873 }; 1915 1874 1916 - static ssize_t o2hb_region_show(struct config_item *item, 1917 - struct configfs_attribute *attr, 1918 - char *page) 1919 - { 1920 - struct o2hb_region *reg = to_o2hb_region(item); 1921 - struct o2hb_region_attribute *o2hb_region_attr = 1922 - container_of(attr, struct o2hb_region_attribute, attr); 1923 - ssize_t ret = 0; 1924 - 1925 - if (o2hb_region_attr->show) 1926 - ret = o2hb_region_attr->show(reg, page); 1927 - return ret; 1928 - } 1929 - 1930 - static ssize_t o2hb_region_store(struct config_item *item, 1931 - struct configfs_attribute *attr, 1932 - const char *page, size_t count) 1933 - { 1934 - struct o2hb_region *reg = to_o2hb_region(item); 1935 - struct o2hb_region_attribute *o2hb_region_attr = 1936 - container_of(attr, struct o2hb_region_attribute, attr); 1937 - ssize_t ret = -EINVAL; 1938 - 1939 - if (o2hb_region_attr->store) 1940 - ret = o2hb_region_attr->store(reg, page, count); 1941 - return ret; 1942 - } 1943 - 1944 1875 static struct configfs_item_operations o2hb_region_item_ops = { 1945 1876 .release = o2hb_region_release, 1946 - .show_attribute = o2hb_region_show, 1947 - .store_attribute = o2hb_region_store, 1948 1877 }; 1949 1878 1950 1879 static struct config_item_type o2hb_region_type = { ··· 2070 2137 spin_unlock(&o2hb_live_lock); 2071 2138 } 2072 2139 2073 - struct o2hb_heartbeat_group_attribute { 2074 - struct configfs_attribute attr; 2075 - ssize_t (*show)(struct o2hb_heartbeat_group *, char *); 2076 - ssize_t (*store)(struct o2hb_heartbeat_group *, const char *, size_t); 2077 - }; 2078 - 2079 - static ssize_t o2hb_heartbeat_group_show(struct config_item *item, 2080 - struct configfs_attribute *attr, 2081 - char *page) 2082 - { 2083 - struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); 2084 - struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = 2085 - container_of(attr, struct o2hb_heartbeat_group_attribute, attr); 2086 - ssize_t ret = 0; 2087 - 2088 - if (o2hb_heartbeat_group_attr->show) 2089 - ret = o2hb_heartbeat_group_attr->show(reg, page); 2090 - return ret; 2091 - } 2092 - 2093 - static ssize_t o2hb_heartbeat_group_store(struct config_item *item, 2094 - struct configfs_attribute *attr, 2095 - const char *page, size_t count) 2096 - { 2097 - struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); 2098 - struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = 2099 - container_of(attr, struct o2hb_heartbeat_group_attribute, attr); 2100 - ssize_t ret = -EINVAL; 2101 - 2102 - if (o2hb_heartbeat_group_attr->store) 2103 - ret = o2hb_heartbeat_group_attr->store(reg, page, count); 2104 - return ret; 2105 - } 2106 - 2107 - static ssize_t o2hb_heartbeat_group_threshold_show(struct o2hb_heartbeat_group *group, 2108 - char *page) 2140 + static ssize_t o2hb_heartbeat_group_threshold_show(struct config_item *item, 2141 + char *page) 2109 2142 { 2110 2143 return sprintf(page, "%u\n", o2hb_dead_threshold); 2111 2144 } 2112 2145 2113 - static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group *group, 2114 - const char *page, 2115 - size_t count) 2146 + static ssize_t o2hb_heartbeat_group_threshold_store(struct config_item *item, 2147 + const char *page, size_t count) 2116 2148 { 2117 2149 unsigned long tmp; 2118 2150 char *p = (char *)page; ··· 2092 2194 return count; 2093 2195 } 2094 2196 2095 - static 2096 - ssize_t o2hb_heartbeat_group_mode_show(struct o2hb_heartbeat_group *group, 2097 - char *page) 2197 + static ssize_t o2hb_heartbeat_group_mode_show(struct config_item *item, 2198 + char *page) 2098 2199 { 2099 2200 return sprintf(page, "%s\n", 2100 2201 o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]); 2101 2202 } 2102 2203 2103 - static 2104 - ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group, 2105 - const char *page, size_t count) 2204 + static ssize_t o2hb_heartbeat_group_mode_store(struct config_item *item, 2205 + const char *page, size_t count) 2106 2206 { 2107 2207 unsigned int i; 2108 2208 int ret; ··· 2125 2229 2126 2230 } 2127 2231 2128 - static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = { 2129 - .attr = { .ca_owner = THIS_MODULE, 2130 - .ca_name = "dead_threshold", 2131 - .ca_mode = S_IRUGO | S_IWUSR }, 2132 - .show = o2hb_heartbeat_group_threshold_show, 2133 - .store = o2hb_heartbeat_group_threshold_store, 2134 - }; 2135 - 2136 - static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_mode = { 2137 - .attr = { .ca_owner = THIS_MODULE, 2138 - .ca_name = "mode", 2139 - .ca_mode = S_IRUGO | S_IWUSR }, 2140 - .show = o2hb_heartbeat_group_mode_show, 2141 - .store = o2hb_heartbeat_group_mode_store, 2142 - }; 2232 + CONFIGFS_ATTR(o2hb_heartbeat_group_, threshold); 2233 + CONFIGFS_ATTR(o2hb_heartbeat_group_, mode); 2143 2234 2144 2235 static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { 2145 - &o2hb_heartbeat_group_attr_threshold.attr, 2146 - &o2hb_heartbeat_group_attr_mode.attr, 2236 + &o2hb_heartbeat_group_attr_threshold, 2237 + &o2hb_heartbeat_group_attr_mode, 2147 2238 NULL, 2148 - }; 2149 - 2150 - static struct configfs_item_operations o2hb_heartbeat_group_item_ops = { 2151 - .show_attribute = o2hb_heartbeat_group_show, 2152 - .store_attribute = o2hb_heartbeat_group_store, 2153 2239 }; 2154 2240 2155 2241 static struct configfs_group_operations o2hb_heartbeat_group_group_ops = { ··· 2141 2263 2142 2264 static struct config_item_type o2hb_heartbeat_group_type = { 2143 2265 .ct_group_ops = &o2hb_heartbeat_group_group_ops, 2144 - .ct_item_ops = &o2hb_heartbeat_group_item_ops, 2145 2266 .ct_attrs = o2hb_heartbeat_group_attrs, 2146 2267 .ct_owner = THIS_MODULE, 2147 2268 };
+71 -210
fs/ocfs2/cluster/nodemanager.c
··· 172 172 kfree(node); 173 173 } 174 174 175 - static ssize_t o2nm_node_num_read(struct o2nm_node *node, char *page) 175 + static ssize_t o2nm_node_num_show(struct config_item *item, char *page) 176 176 { 177 - return sprintf(page, "%d\n", node->nd_num); 177 + return sprintf(page, "%d\n", to_o2nm_node(item)->nd_num); 178 178 } 179 179 180 180 static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node) ··· 188 188 O2NM_NODE_ATTR_NUM = 0, 189 189 O2NM_NODE_ATTR_PORT, 190 190 O2NM_NODE_ATTR_ADDRESS, 191 - O2NM_NODE_ATTR_LOCAL, 192 191 }; 193 192 194 - static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page, 193 + static ssize_t o2nm_node_num_store(struct config_item *item, const char *page, 195 194 size_t count) 196 195 { 196 + struct o2nm_node *node = to_o2nm_node(item); 197 197 struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); 198 198 unsigned long tmp; 199 199 char *p = (char *)page; 200 + int ret = 0; 200 201 201 202 tmp = simple_strtoul(p, &p, 0); 202 203 if (!p || (*p && (*p != '\n'))) ··· 216 215 217 216 write_lock(&cluster->cl_nodes_lock); 218 217 if (cluster->cl_nodes[tmp]) 219 - p = NULL; 218 + ret = -EEXIST; 219 + else if (test_and_set_bit(O2NM_NODE_ATTR_NUM, 220 + &node->nd_set_attributes)) 221 + ret = -EBUSY; 220 222 else { 221 223 cluster->cl_nodes[tmp] = node; 222 224 node->nd_num = tmp; 223 225 set_bit(tmp, cluster->cl_nodes_bitmap); 224 226 } 225 227 write_unlock(&cluster->cl_nodes_lock); 226 - if (p == NULL) 227 - return -EEXIST; 228 + if (ret) 229 + return ret; 228 230 229 231 return count; 230 232 } 231 - static ssize_t o2nm_node_ipv4_port_read(struct o2nm_node *node, char *page) 233 + static ssize_t o2nm_node_ipv4_port_show(struct config_item *item, char *page) 232 234 { 233 - return sprintf(page, "%u\n", ntohs(node->nd_ipv4_port)); 235 + return sprintf(page, "%u\n", ntohs(to_o2nm_node(item)->nd_ipv4_port)); 234 236 } 235 237 236 - static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node, 238 + static ssize_t o2nm_node_ipv4_port_store(struct config_item *item, 237 239 const char *page, size_t count) 238 240 { 241 + struct o2nm_node *node = to_o2nm_node(item); 239 242 unsigned long tmp; 240 243 char *p = (char *)page; 241 244 ··· 252 247 if (tmp >= (u16)-1) 253 248 return -ERANGE; 254 249 250 + if (test_and_set_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) 251 + return -EBUSY; 255 252 node->nd_ipv4_port = htons(tmp); 256 253 257 254 return count; 258 255 } 259 256 260 - static ssize_t o2nm_node_ipv4_address_read(struct o2nm_node *node, char *page) 257 + static ssize_t o2nm_node_ipv4_address_show(struct config_item *item, char *page) 261 258 { 262 - return sprintf(page, "%pI4\n", &node->nd_ipv4_address); 259 + return sprintf(page, "%pI4\n", &to_o2nm_node(item)->nd_ipv4_address); 263 260 } 264 261 265 - static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node, 262 + static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, 266 263 const char *page, 267 264 size_t count) 268 265 { 266 + struct o2nm_node *node = to_o2nm_node(item); 269 267 struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); 270 268 int ret, i; 271 269 struct rb_node **p, *parent; ··· 290 282 write_lock(&cluster->cl_nodes_lock); 291 283 if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent)) 292 284 ret = -EEXIST; 285 + else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS, 286 + &node->nd_set_attributes)) 287 + ret = -EBUSY; 293 288 else { 294 289 rb_link_node(&node->nd_ip_node, parent, p); 295 290 rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree); ··· 306 295 return count; 307 296 } 308 297 309 - static ssize_t o2nm_node_local_read(struct o2nm_node *node, char *page) 298 + static ssize_t o2nm_node_local_show(struct config_item *item, char *page) 310 299 { 311 - return sprintf(page, "%d\n", node->nd_local); 300 + return sprintf(page, "%d\n", to_o2nm_node(item)->nd_local); 312 301 } 313 302 314 - static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page, 303 + static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, 315 304 size_t count) 316 305 { 306 + struct o2nm_node *node = to_o2nm_node(item); 317 307 struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); 318 308 unsigned long tmp; 319 309 char *p = (char *)page; ··· 361 349 return count; 362 350 } 363 351 364 - struct o2nm_node_attribute { 365 - struct configfs_attribute attr; 366 - ssize_t (*show)(struct o2nm_node *, char *); 367 - ssize_t (*store)(struct o2nm_node *, const char *, size_t); 368 - }; 369 - 370 - static struct o2nm_node_attribute o2nm_node_attr_num = { 371 - .attr = { .ca_owner = THIS_MODULE, 372 - .ca_name = "num", 373 - .ca_mode = S_IRUGO | S_IWUSR }, 374 - .show = o2nm_node_num_read, 375 - .store = o2nm_node_num_write, 376 - }; 377 - 378 - static struct o2nm_node_attribute o2nm_node_attr_ipv4_port = { 379 - .attr = { .ca_owner = THIS_MODULE, 380 - .ca_name = "ipv4_port", 381 - .ca_mode = S_IRUGO | S_IWUSR }, 382 - .show = o2nm_node_ipv4_port_read, 383 - .store = o2nm_node_ipv4_port_write, 384 - }; 385 - 386 - static struct o2nm_node_attribute o2nm_node_attr_ipv4_address = { 387 - .attr = { .ca_owner = THIS_MODULE, 388 - .ca_name = "ipv4_address", 389 - .ca_mode = S_IRUGO | S_IWUSR }, 390 - .show = o2nm_node_ipv4_address_read, 391 - .store = o2nm_node_ipv4_address_write, 392 - }; 393 - 394 - static struct o2nm_node_attribute o2nm_node_attr_local = { 395 - .attr = { .ca_owner = THIS_MODULE, 396 - .ca_name = "local", 397 - .ca_mode = S_IRUGO | S_IWUSR }, 398 - .show = o2nm_node_local_read, 399 - .store = o2nm_node_local_write, 400 - }; 352 + CONFIGFS_ATTR(o2nm_node_, num); 353 + CONFIGFS_ATTR(o2nm_node_, ipv4_port); 354 + CONFIGFS_ATTR(o2nm_node_, ipv4_address); 355 + CONFIGFS_ATTR(o2nm_node_, local); 401 356 402 357 static struct configfs_attribute *o2nm_node_attrs[] = { 403 - [O2NM_NODE_ATTR_NUM] = &o2nm_node_attr_num.attr, 404 - [O2NM_NODE_ATTR_PORT] = &o2nm_node_attr_ipv4_port.attr, 405 - [O2NM_NODE_ATTR_ADDRESS] = &o2nm_node_attr_ipv4_address.attr, 406 - [O2NM_NODE_ATTR_LOCAL] = &o2nm_node_attr_local.attr, 358 + &o2nm_node_attr_num, 359 + &o2nm_node_attr_ipv4_port, 360 + &o2nm_node_attr_ipv4_address, 361 + &o2nm_node_attr_local, 407 362 NULL, 408 363 }; 409 364 410 - static int o2nm_attr_index(struct configfs_attribute *attr) 411 - { 412 - int i; 413 - for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) { 414 - if (attr == o2nm_node_attrs[i]) 415 - return i; 416 - } 417 - BUG(); 418 - return 0; 419 - } 420 - 421 - static ssize_t o2nm_node_show(struct config_item *item, 422 - struct configfs_attribute *attr, 423 - char *page) 424 - { 425 - struct o2nm_node *node = to_o2nm_node(item); 426 - struct o2nm_node_attribute *o2nm_node_attr = 427 - container_of(attr, struct o2nm_node_attribute, attr); 428 - ssize_t ret = 0; 429 - 430 - if (o2nm_node_attr->show) 431 - ret = o2nm_node_attr->show(node, page); 432 - return ret; 433 - } 434 - 435 - static ssize_t o2nm_node_store(struct config_item *item, 436 - struct configfs_attribute *attr, 437 - const char *page, size_t count) 438 - { 439 - struct o2nm_node *node = to_o2nm_node(item); 440 - struct o2nm_node_attribute *o2nm_node_attr = 441 - container_of(attr, struct o2nm_node_attribute, attr); 442 - ssize_t ret; 443 - int attr_index = o2nm_attr_index(attr); 444 - 445 - if (o2nm_node_attr->store == NULL) { 446 - ret = -EINVAL; 447 - goto out; 448 - } 449 - 450 - if (test_bit(attr_index, &node->nd_set_attributes)) 451 - return -EBUSY; 452 - 453 - ret = o2nm_node_attr->store(node, page, count); 454 - if (ret < count) 455 - goto out; 456 - 457 - set_bit(attr_index, &node->nd_set_attributes); 458 - out: 459 - return ret; 460 - } 461 - 462 365 static struct configfs_item_operations o2nm_node_item_ops = { 463 366 .release = o2nm_node_release, 464 - .show_attribute = o2nm_node_show, 465 - .store_attribute = o2nm_node_store, 466 367 }; 467 368 468 369 static struct config_item_type o2nm_node_type = { ··· 400 475 } 401 476 #endif 402 477 403 - struct o2nm_cluster_attribute { 404 - struct configfs_attribute attr; 405 - ssize_t (*show)(struct o2nm_cluster *, char *); 406 - ssize_t (*store)(struct o2nm_cluster *, const char *, size_t); 407 - }; 408 - 409 478 static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count, 410 479 unsigned int *val) 411 480 { ··· 420 501 return count; 421 502 } 422 503 423 - static ssize_t o2nm_cluster_attr_idle_timeout_ms_read( 424 - struct o2nm_cluster *cluster, char *page) 504 + static ssize_t o2nm_cluster_idle_timeout_ms_show(struct config_item *item, 505 + char *page) 425 506 { 426 - return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms); 507 + return sprintf(page, "%u\n", to_o2nm_cluster(item)->cl_idle_timeout_ms); 427 508 } 428 509 429 - static ssize_t o2nm_cluster_attr_idle_timeout_ms_write( 430 - struct o2nm_cluster *cluster, const char *page, size_t count) 510 + static ssize_t o2nm_cluster_idle_timeout_ms_store(struct config_item *item, 511 + const char *page, size_t count) 431 512 { 513 + struct o2nm_cluster *cluster = to_o2nm_cluster(item); 432 514 ssize_t ret; 433 515 unsigned int val; 434 516 ··· 456 536 return ret; 457 537 } 458 538 459 - static ssize_t o2nm_cluster_attr_keepalive_delay_ms_read( 460 - struct o2nm_cluster *cluster, char *page) 539 + static ssize_t o2nm_cluster_keepalive_delay_ms_show( 540 + struct config_item *item, char *page) 461 541 { 462 - return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms); 542 + return sprintf(page, "%u\n", 543 + to_o2nm_cluster(item)->cl_keepalive_delay_ms); 463 544 } 464 545 465 - static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write( 466 - struct o2nm_cluster *cluster, const char *page, size_t count) 546 + static ssize_t o2nm_cluster_keepalive_delay_ms_store( 547 + struct config_item *item, const char *page, size_t count) 467 548 { 549 + struct o2nm_cluster *cluster = to_o2nm_cluster(item); 468 550 ssize_t ret; 469 551 unsigned int val; 470 552 ··· 493 571 return ret; 494 572 } 495 573 496 - static ssize_t o2nm_cluster_attr_reconnect_delay_ms_read( 497 - struct o2nm_cluster *cluster, char *page) 574 + static ssize_t o2nm_cluster_reconnect_delay_ms_show( 575 + struct config_item *item, char *page) 498 576 { 499 - return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms); 577 + return sprintf(page, "%u\n", 578 + to_o2nm_cluster(item)->cl_reconnect_delay_ms); 500 579 } 501 580 502 - static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write( 503 - struct o2nm_cluster *cluster, const char *page, size_t count) 581 + static ssize_t o2nm_cluster_reconnect_delay_ms_store( 582 + struct config_item *item, const char *page, size_t count) 504 583 { 505 584 return o2nm_cluster_attr_write(page, count, 506 - &cluster->cl_reconnect_delay_ms); 585 + &to_o2nm_cluster(item)->cl_reconnect_delay_ms); 507 586 } 508 587 509 - static ssize_t o2nm_cluster_attr_fence_method_read( 510 - struct o2nm_cluster *cluster, char *page) 588 + static ssize_t o2nm_cluster_fence_method_show( 589 + struct config_item *item, char *page) 511 590 { 591 + struct o2nm_cluster *cluster = to_o2nm_cluster(item); 512 592 ssize_t ret = 0; 513 593 514 594 if (cluster) ··· 519 595 return ret; 520 596 } 521 597 522 - static ssize_t o2nm_cluster_attr_fence_method_write( 523 - struct o2nm_cluster *cluster, const char *page, size_t count) 598 + static ssize_t o2nm_cluster_fence_method_store( 599 + struct config_item *item, const char *page, size_t count) 524 600 { 525 601 unsigned int i; 526 602 ··· 532 608 continue; 533 609 if (strncasecmp(page, o2nm_fence_method_desc[i], count - 1)) 534 610 continue; 535 - if (cluster->cl_fence_method != i) { 611 + if (to_o2nm_cluster(item)->cl_fence_method != i) { 536 612 printk(KERN_INFO "ocfs2: Changing fence method to %s\n", 537 613 o2nm_fence_method_desc[i]); 538 - cluster->cl_fence_method = i; 614 + to_o2nm_cluster(item)->cl_fence_method = i; 539 615 } 540 616 return count; 541 617 } ··· 544 620 return -EINVAL; 545 621 } 546 622 547 - static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = { 548 - .attr = { .ca_owner = THIS_MODULE, 549 - .ca_name = "idle_timeout_ms", 550 - .ca_mode = S_IRUGO | S_IWUSR }, 551 - .show = o2nm_cluster_attr_idle_timeout_ms_read, 552 - .store = o2nm_cluster_attr_idle_timeout_ms_write, 553 - }; 554 - 555 - static struct o2nm_cluster_attribute o2nm_cluster_attr_keepalive_delay_ms = { 556 - .attr = { .ca_owner = THIS_MODULE, 557 - .ca_name = "keepalive_delay_ms", 558 - .ca_mode = S_IRUGO | S_IWUSR }, 559 - .show = o2nm_cluster_attr_keepalive_delay_ms_read, 560 - .store = o2nm_cluster_attr_keepalive_delay_ms_write, 561 - }; 562 - 563 - static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = { 564 - .attr = { .ca_owner = THIS_MODULE, 565 - .ca_name = "reconnect_delay_ms", 566 - .ca_mode = S_IRUGO | S_IWUSR }, 567 - .show = o2nm_cluster_attr_reconnect_delay_ms_read, 568 - .store = o2nm_cluster_attr_reconnect_delay_ms_write, 569 - }; 570 - 571 - static struct o2nm_cluster_attribute o2nm_cluster_attr_fence_method = { 572 - .attr = { .ca_owner = THIS_MODULE, 573 - .ca_name = "fence_method", 574 - .ca_mode = S_IRUGO | S_IWUSR }, 575 - .show = o2nm_cluster_attr_fence_method_read, 576 - .store = o2nm_cluster_attr_fence_method_write, 577 - }; 623 + CONFIGFS_ATTR(o2nm_cluster_, idle_timeout_ms); 624 + CONFIGFS_ATTR(o2nm_cluster_, keepalive_delay_ms); 625 + CONFIGFS_ATTR(o2nm_cluster_, reconnect_delay_ms); 626 + CONFIGFS_ATTR(o2nm_cluster_, fence_method); 578 627 579 628 static struct configfs_attribute *o2nm_cluster_attrs[] = { 580 - &o2nm_cluster_attr_idle_timeout_ms.attr, 581 - &o2nm_cluster_attr_keepalive_delay_ms.attr, 582 - &o2nm_cluster_attr_reconnect_delay_ms.attr, 583 - &o2nm_cluster_attr_fence_method.attr, 629 + &o2nm_cluster_attr_idle_timeout_ms, 630 + &o2nm_cluster_attr_keepalive_delay_ms, 631 + &o2nm_cluster_attr_reconnect_delay_ms, 632 + &o2nm_cluster_attr_fence_method, 584 633 NULL, 585 634 }; 586 - static ssize_t o2nm_cluster_show(struct config_item *item, 587 - struct configfs_attribute *attr, 588 - char *page) 589 - { 590 - struct o2nm_cluster *cluster = to_o2nm_cluster(item); 591 - struct o2nm_cluster_attribute *o2nm_cluster_attr = 592 - container_of(attr, struct o2nm_cluster_attribute, attr); 593 - ssize_t ret = 0; 594 - 595 - if (o2nm_cluster_attr->show) 596 - ret = o2nm_cluster_attr->show(cluster, page); 597 - return ret; 598 - } 599 - 600 - static ssize_t o2nm_cluster_store(struct config_item *item, 601 - struct configfs_attribute *attr, 602 - const char *page, size_t count) 603 - { 604 - struct o2nm_cluster *cluster = to_o2nm_cluster(item); 605 - struct o2nm_cluster_attribute *o2nm_cluster_attr = 606 - container_of(attr, struct o2nm_cluster_attribute, attr); 607 - ssize_t ret; 608 - 609 - if (o2nm_cluster_attr->store == NULL) { 610 - ret = -EINVAL; 611 - goto out; 612 - } 613 - 614 - ret = o2nm_cluster_attr->store(cluster, page, count); 615 - if (ret < count) 616 - goto out; 617 - out: 618 - return ret; 619 - } 620 635 621 636 static struct config_item *o2nm_node_group_make_item(struct config_group *group, 622 637 const char *name) ··· 636 773 637 774 static struct configfs_item_operations o2nm_cluster_item_ops = { 638 775 .release = o2nm_cluster_release, 639 - .show_attribute = o2nm_cluster_show, 640 - .store_attribute = o2nm_cluster_store, 641 776 }; 642 777 643 778 static struct config_item_type o2nm_cluster_type = {
+21 -76
include/linux/configfs.h
··· 125 125 const char *ca_name; 126 126 struct module *ca_owner; 127 127 umode_t ca_mode; 128 + ssize_t (*show)(struct config_item *, char *); 129 + ssize_t (*store)(struct config_item *, const char *, size_t); 128 130 }; 129 131 130 - /* 131 - * Users often need to create attribute structures for their configurable 132 - * attributes, containing a configfs_attribute member and function pointers 133 - * for the show() and store() operations on that attribute. If they don't 134 - * need anything else on the extended attribute structure, they can use 135 - * this macro to define it The argument _item is the name of the 136 - * config_item structure. 137 - */ 138 - #define CONFIGFS_ATTR_STRUCT(_item) \ 139 - struct _item##_attribute { \ 140 - struct configfs_attribute attr; \ 141 - ssize_t (*show)(struct _item *, char *); \ 142 - ssize_t (*store)(struct _item *, const char *, size_t); \ 132 + #define CONFIGFS_ATTR(_pfx, _name) \ 133 + static struct configfs_attribute _pfx##attr_##_name = { \ 134 + .ca_name = __stringify(_name), \ 135 + .ca_mode = S_IRUGO | S_IWUSR, \ 136 + .ca_owner = THIS_MODULE, \ 137 + .show = _pfx##_name##_show, \ 138 + .store = _pfx##_name##_store, \ 143 139 } 144 140 145 - /* 146 - * With the extended attribute structure, users can use this macro 147 - * (similar to sysfs' __ATTR) to make defining attributes easier. 148 - * An example: 149 - * #define MYITEM_ATTR(_name, _mode, _show, _store) \ 150 - * struct myitem_attribute childless_attr_##_name = \ 151 - * __CONFIGFS_ATTR(_name, _mode, _show, _store) 152 - */ 153 - #define __CONFIGFS_ATTR(_name, _mode, _show, _store) \ 154 - { \ 155 - .attr = { \ 156 - .ca_name = __stringify(_name), \ 157 - .ca_mode = _mode, \ 158 - .ca_owner = THIS_MODULE, \ 159 - }, \ 160 - .show = _show, \ 161 - .store = _store, \ 162 - } 163 - /* Here is a readonly version, only requiring a show() operation */ 164 - #define __CONFIGFS_ATTR_RO(_name, _show) \ 165 - { \ 166 - .attr = { \ 167 - .ca_name = __stringify(_name), \ 168 - .ca_mode = 0444, \ 169 - .ca_owner = THIS_MODULE, \ 170 - }, \ 171 - .show = _show, \ 141 + #define CONFIGFS_ATTR_RO(_pfx, _name) \ 142 + static struct configfs_attribute _pfx##attr_##_name = { \ 143 + .ca_name = __stringify(_name), \ 144 + .ca_mode = S_IRUGO, \ 145 + .ca_owner = THIS_MODULE, \ 146 + .show = _pfx##_name##_show, \ 172 147 } 173 148 174 - /* 175 - * With these extended attributes, the simple show_attribute() and 176 - * store_attribute() operations need to call the show() and store() of the 177 - * attributes. This is a common pattern, so we provide a macro to define 178 - * them. The argument _item is the name of the config_item structure. 179 - * This macro expects the attributes to be named "struct <name>_attribute" 180 - * and the function to_<name>() to exist; 181 - */ 182 - #define CONFIGFS_ATTR_OPS(_item) \ 183 - static ssize_t _item##_attr_show(struct config_item *item, \ 184 - struct configfs_attribute *attr, \ 185 - char *page) \ 186 - { \ 187 - struct _item *_item = to_##_item(item); \ 188 - struct _item##_attribute *_item##_attr = \ 189 - container_of(attr, struct _item##_attribute, attr); \ 190 - ssize_t ret = 0; \ 191 - \ 192 - if (_item##_attr->show) \ 193 - ret = _item##_attr->show(_item, page); \ 194 - return ret; \ 195 - } \ 196 - static ssize_t _item##_attr_store(struct config_item *item, \ 197 - struct configfs_attribute *attr, \ 198 - const char *page, size_t count) \ 199 - { \ 200 - struct _item *_item = to_##_item(item); \ 201 - struct _item##_attribute *_item##_attr = \ 202 - container_of(attr, struct _item##_attribute, attr); \ 203 - ssize_t ret = -EINVAL; \ 204 - \ 205 - if (_item##_attr->store) \ 206 - ret = _item##_attr->store(_item, page, count); \ 207 - return ret; \ 149 + #define CONFIGFS_ATTR_WO(_pfx, _name) \ 150 + static struct configfs_attribute _pfx##attr_##_name = { \ 151 + .ca_name = __stringify(_name), \ 152 + .ca_mode = S_IWUSR, \ 153 + .ca_owner = THIS_MODULE, \ 154 + .store = _pfx##_name##_store, \ 208 155 } 209 156 210 157 /* ··· 170 223 */ 171 224 struct configfs_item_operations { 172 225 void (*release)(struct config_item *); 173 - ssize_t (*show_attribute)(struct config_item *, struct configfs_attribute *,char *); 174 - ssize_t (*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t); 175 226 int (*allow_link)(struct config_item *src, struct config_item *target); 176 227 int (*drop_link)(struct config_item *src, struct config_item *target); 177 228 };
+5 -14
include/linux/usb/gadget_configfs.h
··· 7 7 struct usb_gadget_strings *stringtab_dev); 8 8 9 9 #define GS_STRINGS_W(__struct, __name) \ 10 - static ssize_t __struct##_##__name##_store(struct __struct *gs, \ 10 + static ssize_t __struct##_##__name##_store(struct config_item *item, \ 11 11 const char *page, size_t len) \ 12 12 { \ 13 + struct __struct *gs = to_##__struct(item); \ 13 14 int ret; \ 14 15 \ 15 16 ret = usb_string_copy(page, &gs->__name); \ ··· 20 19 } 21 20 22 21 #define GS_STRINGS_R(__struct, __name) \ 23 - static ssize_t __struct##_##__name##_show(struct __struct *gs, \ 24 - char *page) \ 22 + static ssize_t __struct##_##__name##_show(struct config_item *item, char *page) \ 25 23 { \ 24 + struct __struct *gs = to_##__struct(item); \ 26 25 return sprintf(page, "%s\n", gs->__name ?: ""); \ 27 26 } 28 - 29 - #define GS_STRING_ITEM_ATTR(struct_name, name) \ 30 - static struct struct_name##_attribute struct_name##_##name = \ 31 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ 32 - struct_name##_##name##_show, \ 33 - struct_name##_##name##_store) 34 27 35 28 #define GS_STRINGS_RW(struct_name, _name) \ 36 29 GS_STRINGS_R(struct_name, _name) \ 37 30 GS_STRINGS_W(struct_name, _name) \ 38 - GS_STRING_ITEM_ATTR(struct_name, _name) 31 + CONFIGFS_ATTR(struct_name##_, _name) 39 32 40 33 #define USB_CONFIG_STRING_RW_OPS(struct_in) \ 41 - CONFIGFS_ATTR_OPS(struct_in); \ 42 - \ 43 34 static struct configfs_item_operations struct_in##_langid_item_ops = { \ 44 35 .release = struct_in##_attr_release, \ 45 - .show_attribute = struct_in##_attr_show, \ 46 - .store_attribute = struct_in##_attr_store, \ 47 36 }; \ 48 37 \ 49 38 static struct config_item_type struct_in##_langid_type = { \
-147
include/target/configfs_macros.h
··· 1 - /* -*- mode: c; c-basic-offset: 8; -*- 2 - * vim: noexpandtab sw=8 ts=8 sts=0: 3 - * 4 - * configfs_macros.h - extends macros for configfs 5 - * 6 - * This program is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU General Public 8 - * License as published by the Free Software Foundation; either 9 - * version 2 of the License, or (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 - * General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public 17 - * License along with this program; if not, write to the 18 - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 - * Boston, MA 021110-1307, USA. 20 - * 21 - * Based on sysfs: 22 - * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel 23 - * 24 - * Based on kobject.h: 25 - * Copyright (c) 2002-2003 Patrick Mochel 26 - * Copyright (c) 2002-2003 Open Source Development Labs 27 - * 28 - * configfs Copyright (C) 2005 Oracle. All rights reserved. 29 - * 30 - * Added CONFIGFS_EATTR() macros from original configfs.h macros 31 - * Copright (C) 2008-2009 Nicholas A. Bellinger <nab@linux-iscsi.org> 32 - * 33 - * Please read Documentation/filesystems/configfs/configfs.txt before using 34 - * the configfs interface, ESPECIALLY the parts about reference counts and 35 - * item destructors. 36 - */ 37 - 38 - #ifndef _CONFIGFS_MACROS_H_ 39 - #define _CONFIGFS_MACROS_H_ 40 - 41 - #include <linux/configfs.h> 42 - 43 - /* 44 - * Users often need to create attribute structures for their configurable 45 - * attributes, containing a configfs_attribute member and function pointers 46 - * for the show() and store() operations on that attribute. If they don't 47 - * need anything else on the extended attribute structure, they can use 48 - * this macro to define it. The argument _name isends up as 49 - * 'struct _name_attribute, as well as names of to CONFIGFS_ATTR_OPS() below. 50 - * The argument _item is the name of the structure containing the 51 - * struct config_item or struct config_group structure members 52 - */ 53 - #define CONFIGFS_EATTR_STRUCT(_name, _item) \ 54 - struct _name##_attribute { \ 55 - struct configfs_attribute attr; \ 56 - ssize_t (*show)(struct _item *, char *); \ 57 - ssize_t (*store)(struct _item *, const char *, size_t); \ 58 - } 59 - 60 - /* 61 - * With the extended attribute structure, users can use this macro 62 - * (similar to sysfs' __ATTR) to make defining attributes easier. 63 - * An example: 64 - * #define MYITEM_EATTR(_name, _mode, _show, _store) \ 65 - * struct myitem_attribute childless_attr_##_name = \ 66 - * __CONFIGFS_EATTR(_name, _mode, _show, _store) 67 - */ 68 - #define __CONFIGFS_EATTR(_name, _mode, _show, _store) \ 69 - { \ 70 - .attr = { \ 71 - .ca_name = __stringify(_name), \ 72 - .ca_mode = _mode, \ 73 - .ca_owner = THIS_MODULE, \ 74 - }, \ 75 - .show = _show, \ 76 - .store = _store, \ 77 - } 78 - /* Here is a readonly version, only requiring a show() operation */ 79 - #define __CONFIGFS_EATTR_RO(_name, _show) \ 80 - { \ 81 - .attr = { \ 82 - .ca_name = __stringify(_name), \ 83 - .ca_mode = 0444, \ 84 - .ca_owner = THIS_MODULE, \ 85 - }, \ 86 - .show = _show, \ 87 - } 88 - 89 - /* 90 - * With these extended attributes, the simple show_attribute() and 91 - * store_attribute() operations need to call the show() and store() of the 92 - * attributes. This is a common pattern, so we provide a macro to define 93 - * them. The argument _name is the name of the attribute defined by 94 - * CONFIGFS_ATTR_STRUCT(). The argument _item is the name of the structure 95 - * containing the struct config_item or struct config_group structure member. 96 - * The argument _item_member is the actual name of the struct config_* struct 97 - * in your _item structure. Meaning my_structure->some_config_group. 98 - * ^^_item^^^^^ ^^_item_member^^^ 99 - * This macro expects the attributes to be named "struct <name>_attribute". 100 - */ 101 - #define CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member) \ 102 - static struct _item *to_##_name(struct config_item *ci) \ 103 - { \ 104 - return (ci) ? container_of(to_config_group(ci), struct _item, \ 105 - _item_member) : NULL; \ 106 - } 107 - 108 - #define CONFIGFS_EATTR_OPS_SHOW(_name, _item) \ 109 - static ssize_t _name##_attr_show(struct config_item *item, \ 110 - struct configfs_attribute *attr, \ 111 - char *page) \ 112 - { \ 113 - struct _item *_item = to_##_name(item); \ 114 - struct _name##_attribute * _name##_attr = \ 115 - container_of(attr, struct _name##_attribute, attr); \ 116 - ssize_t ret = 0; \ 117 - \ 118 - if (_name##_attr->show) \ 119 - ret = _name##_attr->show(_item, page); \ 120 - return ret; \ 121 - } 122 - 123 - #define CONFIGFS_EATTR_OPS_STORE(_name, _item) \ 124 - static ssize_t _name##_attr_store(struct config_item *item, \ 125 - struct configfs_attribute *attr, \ 126 - const char *page, size_t count) \ 127 - { \ 128 - struct _item *_item = to_##_name(item); \ 129 - struct _name##_attribute * _name##_attr = \ 130 - container_of(attr, struct _name##_attribute, attr); \ 131 - ssize_t ret = -EINVAL; \ 132 - \ 133 - if (_name##_attr->store) \ 134 - ret = _name##_attr->store(_item, page, count); \ 135 - return ret; \ 136 - } 137 - 138 - #define CONFIGFS_EATTR_OPS(_name, _item, _item_member) \ 139 - CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \ 140 - CONFIGFS_EATTR_OPS_SHOW(_name, _item); \ 141 - CONFIGFS_EATTR_OPS_STORE(_name, _item); 142 - 143 - #define CONFIGFS_EATTR_OPS_RO(_name, _item, _item_member) \ 144 - CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \ 145 - CONFIGFS_EATTR_OPS_SHOW(_name, _item); 146 - 147 - #endif /* _CONFIGFS_MACROS_H_ */
+60
include/target/target_core_base.h
··· 563 563 struct kref acl_kref; 564 564 }; 565 565 566 + static inline struct se_node_acl *acl_to_nacl(struct config_item *item) 567 + { 568 + return container_of(to_config_group(item), struct se_node_acl, 569 + acl_group); 570 + } 571 + 572 + static inline struct se_node_acl *attrib_to_nacl(struct config_item *item) 573 + { 574 + return container_of(to_config_group(item), struct se_node_acl, 575 + acl_attrib_group); 576 + } 577 + 578 + static inline struct se_node_acl *auth_to_nacl(struct config_item *item) 579 + { 580 + return container_of(to_config_group(item), struct se_node_acl, 581 + acl_auth_group); 582 + } 583 + 584 + static inline struct se_node_acl *param_to_nacl(struct config_item *item) 585 + { 586 + return container_of(to_config_group(item), struct se_node_acl, 587 + acl_param_group); 588 + } 589 + 590 + static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item) 591 + { 592 + return container_of(to_config_group(item), struct se_node_acl, 593 + acl_fabric_stat_group); 594 + } 595 + 566 596 struct se_session { 567 597 unsigned sess_tearing_down:1; 568 598 u64 sess_bin_isid; ··· 851 821 struct config_group tpg_np_group; 852 822 }; 853 823 824 + static inline struct se_tpg_np *to_tpg_np(struct config_item *item) 825 + { 826 + return container_of(to_config_group(item), struct se_tpg_np, 827 + tpg_np_group); 828 + } 829 + 854 830 struct se_portal_group { 855 831 /* 856 832 * PROTOCOL IDENTIFIER value per SPC4, 7.5.1. ··· 892 856 struct config_group tpg_auth_group; 893 857 struct config_group tpg_param_group; 894 858 }; 859 + 860 + static inline struct se_portal_group *to_tpg(struct config_item *item) 861 + { 862 + return container_of(to_config_group(item), struct se_portal_group, 863 + tpg_group); 864 + } 865 + 866 + static inline struct se_portal_group *attrib_to_tpg(struct config_item *item) 867 + { 868 + return container_of(to_config_group(item), struct se_portal_group, 869 + tpg_attrib_group); 870 + } 871 + 872 + static inline struct se_portal_group *auth_to_tpg(struct config_item *item) 873 + { 874 + return container_of(to_config_group(item), struct se_portal_group, 875 + tpg_auth_group); 876 + } 877 + 878 + static inline struct se_portal_group *param_to_tpg(struct config_item *item) 879 + { 880 + return container_of(to_config_group(item), struct se_portal_group, 881 + tpg_param_group); 882 + } 895 883 896 884 struct se_wwn { 897 885 struct target_fabric_configfs *wwn_tf;
-122
include/target/target_core_fabric_configfs.h
··· 1 - /* 2 - * Used for tfc_wwn_cit attributes 3 - */ 4 - 5 - #include <target/configfs_macros.h> 6 - 7 - CONFIGFS_EATTR_STRUCT(target_fabric_nacl_attrib, se_node_acl); 8 - #define TF_NACL_ATTRIB_ATTR(_fabric, _name, _mode) \ 9 - static struct target_fabric_nacl_attrib_attribute _fabric##_nacl_attrib_##_name = \ 10 - __CONFIGFS_EATTR(_name, _mode, \ 11 - _fabric##_nacl_attrib_show_##_name, \ 12 - _fabric##_nacl_attrib_store_##_name); 13 - 14 - CONFIGFS_EATTR_STRUCT(target_fabric_nacl_auth, se_node_acl); 15 - #define TF_NACL_AUTH_ATTR(_fabric, _name, _mode) \ 16 - static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \ 17 - __CONFIGFS_EATTR(_name, _mode, \ 18 - _fabric##_nacl_auth_show_##_name, \ 19 - _fabric##_nacl_auth_store_##_name); 20 - 21 - #define TF_NACL_AUTH_ATTR_RO(_fabric, _name) \ 22 - static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \ 23 - __CONFIGFS_EATTR_RO(_name, \ 24 - _fabric##_nacl_auth_show_##_name); 25 - 26 - CONFIGFS_EATTR_STRUCT(target_fabric_nacl_param, se_node_acl); 27 - #define TF_NACL_PARAM_ATTR(_fabric, _name, _mode) \ 28 - static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \ 29 - __CONFIGFS_EATTR(_name, _mode, \ 30 - _fabric##_nacl_param_show_##_name, \ 31 - _fabric##_nacl_param_store_##_name); 32 - 33 - #define TF_NACL_PARAM_ATTR_RO(_fabric, _name) \ 34 - static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \ 35 - __CONFIGFS_EATTR_RO(_name, \ 36 - _fabric##_nacl_param_show_##_name); 37 - 38 - 39 - CONFIGFS_EATTR_STRUCT(target_fabric_nacl_base, se_node_acl); 40 - #define TF_NACL_BASE_ATTR(_fabric, _name, _mode) \ 41 - static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \ 42 - __CONFIGFS_EATTR(_name, _mode, \ 43 - _fabric##_nacl_show_##_name, \ 44 - _fabric##_nacl_store_##_name); 45 - 46 - #define TF_NACL_BASE_ATTR_RO(_fabric, _name) \ 47 - static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \ 48 - __CONFIGFS_EATTR_RO(_name, \ 49 - _fabric##_nacl_show_##_name); 50 - 51 - CONFIGFS_EATTR_STRUCT(target_fabric_np_base, se_tpg_np); 52 - #define TF_NP_BASE_ATTR(_fabric, _name, _mode) \ 53 - static struct target_fabric_np_base_attribute _fabric##_np_##_name = \ 54 - __CONFIGFS_EATTR(_name, _mode, \ 55 - _fabric##_np_show_##_name, \ 56 - _fabric##_np_store_##_name); 57 - 58 - CONFIGFS_EATTR_STRUCT(target_fabric_tpg_attrib, se_portal_group); 59 - #define TF_TPG_ATTRIB_ATTR(_fabric, _name, _mode) \ 60 - static struct target_fabric_tpg_attrib_attribute _fabric##_tpg_attrib_##_name = \ 61 - __CONFIGFS_EATTR(_name, _mode, \ 62 - _fabric##_tpg_attrib_show_##_name, \ 63 - _fabric##_tpg_attrib_store_##_name); 64 - 65 - CONFIGFS_EATTR_STRUCT(target_fabric_tpg_auth, se_portal_group); 66 - #define TF_TPG_AUTH_ATTR(_fabric, _name, _mode) \ 67 - static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \ 68 - __CONFIGFS_EATTR(_name, _mode, \ 69 - _fabric##_tpg_auth_show_##_name, \ 70 - _fabric##_tpg_auth_store_##_name); 71 - 72 - #define TF_TPG_AUTH_ATTR_RO(_fabric, _name) \ 73 - static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \ 74 - __CONFIGFS_EATTR_RO(_name, \ 75 - _fabric##_tpg_auth_show_##_name); 76 - 77 - CONFIGFS_EATTR_STRUCT(target_fabric_tpg_param, se_portal_group); 78 - #define TF_TPG_PARAM_ATTR(_fabric, _name, _mode) \ 79 - static struct target_fabric_tpg_param_attribute _fabric##_tpg_param_##_name = \ 80 - __CONFIGFS_EATTR(_name, _mode, \ 81 - _fabric##_tpg_param_show_##_name, \ 82 - _fabric##_tpg_param_store_##_name); 83 - 84 - 85 - CONFIGFS_EATTR_STRUCT(target_fabric_tpg, se_portal_group); 86 - #define TF_TPG_BASE_ATTR(_fabric, _name, _mode) \ 87 - static struct target_fabric_tpg_attribute _fabric##_tpg_##_name = \ 88 - __CONFIGFS_EATTR(_name, _mode, \ 89 - _fabric##_tpg_show_##_name, \ 90 - _fabric##_tpg_store_##_name); 91 - 92 - 93 - #define TF_TPG_BASE_ATTR_RO(_fabric, _name) \ 94 - static struct target_fabric_tpg_attribute _fabric##_tpg_##_name = \ 95 - __CONFIGFS_EATTR_RO(_name, \ 96 - _fabric##_tpg_show_##_name); 97 - 98 - CONFIGFS_EATTR_STRUCT(target_fabric_wwn, target_fabric_configfs); 99 - #define TF_WWN_ATTR(_fabric, _name, _mode) \ 100 - static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \ 101 - __CONFIGFS_EATTR(_name, _mode, \ 102 - _fabric##_wwn_show_attr_##_name, \ 103 - _fabric##_wwn_store_attr_##_name); 104 - 105 - #define TF_WWN_ATTR_RO(_fabric, _name) \ 106 - static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \ 107 - __CONFIGFS_EATTR_RO(_name, \ 108 - _fabric##_wwn_show_attr_##_name); 109 - 110 - CONFIGFS_EATTR_STRUCT(target_fabric_discovery, target_fabric_configfs); 111 - #define TF_DISC_ATTR(_fabric, _name, _mode) \ 112 - static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \ 113 - __CONFIGFS_EATTR(_name, _mode, \ 114 - _fabric##_disc_show_##_name, \ 115 - _fabric##_disc_store_##_name); 116 - 117 - #define TF_DISC_ATTR_RO(_fabric, _name) \ 118 - static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \ 119 - __CONFIGFS_EATTR_RO(_name, \ 120 - _fabric##_disc_show_##_name); 121 - 122 - extern int target_fabric_setup_cits(struct target_fabric_configfs *);
+6
samples/Kconfig
··· 70 70 Builds a sample live patch that replaces the procfs handler 71 71 for /proc/cmdline to print "this has been live patched". 72 72 73 + config SAMPLE_CONFIGFS 74 + tristate "Build configfs patching sample -- loadable modules only" 75 + depends on CONFIGFS_FS && m 76 + help 77 + Builds a sample configfs interface. 78 + 73 79 endif # SAMPLES
+2 -1
samples/Makefile
··· 1 1 # Makefile for Linux samples code 2 2 3 3 obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \ 4 - hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ 4 + hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \ 5 + configfs/
+2
samples/configfs/Makefile
··· 1 + 2 + obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs_sample.o