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 7bd1d4093c ("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 517982229f
("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
  ...
This commit is contained in:
Linus Torvalds 2015-11-13 20:04:17 -08:00
Родитель 5d2eb548b3 517982229f
Коммит 9aa3d651a9
58 изменённых файлов: 2684 добавлений и 5523 удалений

Просмотреть файл

@ -1,5 +1,3 @@
subdir-y := configfs
# List of programs to build
hostprogs-y := dnotify_test

Просмотреть файл

@ -1,3 +0,0 @@
ifneq ($(CONFIG_CONFIGFS_FS),)
obj-m += configfs_example_explicit.o configfs_example_macros.o
endif

Просмотреть файл

@ -160,12 +160,6 @@ among other things. For that, it needs a type.
struct configfs_item_operations {
void (*release)(struct config_item *);
ssize_t (*show_attribute)(struct config_item *,
struct configfs_attribute *,
char *);
ssize_t (*store_attribute)(struct config_item *,
struct configfs_attribute *,
const char *, size_t);
int (*allow_link)(struct config_item *src,
struct config_item *target);
int (*drop_link)(struct config_item *src,
@ -183,9 +177,7 @@ The most basic function of a config_item_type is to define what
operations can be performed on a config_item. All items that have been
allocated dynamically will need to provide the ct_item_ops->release()
method. This method is called when the config_item's reference count
reaches zero. Items that wish to display an attribute need to provide
the ct_item_ops->show_attribute() method. Similarly, storing a new
attribute value uses the store_attribute() method.
reaches zero.
[struct configfs_attribute]
@ -193,6 +185,8 @@ attribute value uses the store_attribute() method.
char *ca_name;
struct module *ca_owner;
umode_t ca_mode;
ssize_t (*show)(struct config_item *, char *);
ssize_t (*store)(struct config_item *, const char *, size_t);
};
When a config_item wants an attribute to appear as a file in the item's
@ -202,10 +196,10 @@ config_item_type->ct_attrs. When the item appears in configfs, the
attribute file will appear with the configfs_attribute->ca_name
filename. configfs_attribute->ca_mode specifies the file permissions.
If an attribute is readable and the config_item provides a
ct_item_ops->show_attribute() method, that method will be called
whenever userspace asks for a read(2) on the attribute. The converse
will happen for write(2).
If an attribute is readable and provides a ->show method, that method will
be called whenever userspace asks for a read(2) on the attribute. If an
attribute is writable and provides a ->store method, that method will be
be called whenever userspace asks for a write(2) on the attribute.
[struct config_group]
@ -311,20 +305,10 @@ the subsystem must be ready for it.
[An Example]
The best example of these basic concepts is the simple_children
subsystem/group and the simple_child item in configfs_example_explicit.c
and configfs_example_macros.c. It shows a trivial object displaying and
storing an attribute, and a simple group creating and destroying these
children.
The only difference between configfs_example_explicit.c and
configfs_example_macros.c is how the attributes of the childless item
are defined. The childless item has extended attributes, each with
their own show()/store() operation. This follows a convention commonly
used in sysfs. configfs_example_explicit.c creates these attributes
by explicitly defining the structures involved. Conversely
configfs_example_macros.c uses some convenience macros from configfs.h
to define the attributes. These macros are similar to their sysfs
counterparts.
subsystem/group and the simple_child item in
samples/configfs/configfs_sample.c. It shows a trivial object displaying
and storing an attribute, and a simple group creating and destroying
these children.
[Hierarchy Navigation and the Subsystem Mutex]

Просмотреть файл

@ -1,483 +0,0 @@
/*
* vim: noexpandtab ts=8 sts=0 sw=8:
*
* configfs_example_explicit.c - This file is a demonstration module
* containing a number of configfs subsystems. It explicitly defines
* each structure without using the helper macros defined in
* configfs.h.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
* Based on sysfs:
* sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
*
* configfs Copyright (C) 2005 Oracle. All rights reserved.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/configfs.h>
/*
* 01-childless
*
* This first example is a childless subsystem. It cannot create
* any config_items. It just has attributes.
*
* Note that we are enclosing the configfs_subsystem inside a container.
* This is not necessary if a subsystem has no attributes directly
* on the subsystem. See the next example, 02-simple-children, for
* such a subsystem.
*/
struct childless {
struct configfs_subsystem subsys;
int showme;
int storeme;
};
struct childless_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct childless *, char *);
ssize_t (*store)(struct childless *, const char *, size_t);
};
static inline struct childless *to_childless(struct config_item *item)
{
return item ? container_of(to_configfs_subsystem(to_config_group(item)), struct childless, subsys) : NULL;
}
static ssize_t childless_showme_read(struct childless *childless,
char *page)
{
ssize_t pos;
pos = sprintf(page, "%d\n", childless->showme);
childless->showme++;
return pos;
}
static ssize_t childless_storeme_read(struct childless *childless,
char *page)
{
return sprintf(page, "%d\n", childless->storeme);
}
static ssize_t childless_storeme_write(struct childless *childless,
const char *page,
size_t count)
{
unsigned long tmp;
char *p = (char *) page;
tmp = simple_strtoul(p, &p, 10);
if ((*p != '\0') && (*p != '\n'))
return -EINVAL;
if (tmp > INT_MAX)
return -ERANGE;
childless->storeme = tmp;
return count;
}
static ssize_t childless_description_read(struct childless *childless,
char *page)
{
return sprintf(page,
"[01-childless]\n"
"\n"
"The childless subsystem is the simplest possible subsystem in\n"
"configfs. It does not support the creation of child config_items.\n"
"It only has a few attributes. In fact, it isn't much different\n"
"than a directory in /proc.\n");
}
static struct childless_attribute childless_attr_showme = {
.attr = { .ca_owner = THIS_MODULE, .ca_name = "showme", .ca_mode = S_IRUGO },
.show = childless_showme_read,
};
static struct childless_attribute childless_attr_storeme = {
.attr = { .ca_owner = THIS_MODULE, .ca_name = "storeme", .ca_mode = S_IRUGO | S_IWUSR },
.show = childless_storeme_read,
.store = childless_storeme_write,
};
static struct childless_attribute childless_attr_description = {
.attr = { .ca_owner = THIS_MODULE, .ca_name = "description", .ca_mode = S_IRUGO },
.show = childless_description_read,
};
static struct configfs_attribute *childless_attrs[] = {
&childless_attr_showme.attr,
&childless_attr_storeme.attr,
&childless_attr_description.attr,
NULL,
};
static ssize_t childless_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct childless *childless = to_childless(item);
struct childless_attribute *childless_attr =
container_of(attr, struct childless_attribute, attr);
ssize_t ret = 0;
if (childless_attr->show)
ret = childless_attr->show(childless, page);
return ret;
}
static ssize_t childless_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct childless *childless = to_childless(item);
struct childless_attribute *childless_attr =
container_of(attr, struct childless_attribute, attr);
ssize_t ret = -EINVAL;
if (childless_attr->store)
ret = childless_attr->store(childless, page, count);
return ret;
}
static struct configfs_item_operations childless_item_ops = {
.show_attribute = childless_attr_show,
.store_attribute = childless_attr_store,
};
static struct config_item_type childless_type = {
.ct_item_ops = &childless_item_ops,
.ct_attrs = childless_attrs,
.ct_owner = THIS_MODULE,
};
static struct childless childless_subsys = {
.subsys = {
.su_group = {
.cg_item = {
.ci_namebuf = "01-childless",
.ci_type = &childless_type,
},
},
},
};
/* ----------------------------------------------------------------- */
/*
* 02-simple-children
*
* This example merely has a simple one-attribute child. Note that
* there is no extra attribute structure, as the child's attribute is
* known from the get-go. Also, there is no container for the
* subsystem, as it has no attributes of its own.
*/
struct simple_child {
struct config_item item;
int storeme;
};
static inline struct simple_child *to_simple_child(struct config_item *item)
{
return item ? container_of(item, struct simple_child, item) : NULL;
}
static struct configfs_attribute simple_child_attr_storeme = {
.ca_owner = THIS_MODULE,
.ca_name = "storeme",
.ca_mode = S_IRUGO | S_IWUSR,
};
static struct configfs_attribute *simple_child_attrs[] = {
&simple_child_attr_storeme,
NULL,
};
static ssize_t simple_child_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
ssize_t count;
struct simple_child *simple_child = to_simple_child(item);
count = sprintf(page, "%d\n", simple_child->storeme);
return count;
}
static ssize_t simple_child_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct simple_child *simple_child = to_simple_child(item);
unsigned long tmp;
char *p = (char *) page;
tmp = simple_strtoul(p, &p, 10);
if (!p || (*p && (*p != '\n')))
return -EINVAL;
if (tmp > INT_MAX)
return -ERANGE;
simple_child->storeme = tmp;
return count;
}
static void simple_child_release(struct config_item *item)
{
kfree(to_simple_child(item));
}
static struct configfs_item_operations simple_child_item_ops = {
.release = simple_child_release,
.show_attribute = simple_child_attr_show,
.store_attribute = simple_child_attr_store,
};
static struct config_item_type simple_child_type = {
.ct_item_ops = &simple_child_item_ops,
.ct_attrs = simple_child_attrs,
.ct_owner = THIS_MODULE,
};
struct simple_children {
struct config_group group;
};
static inline struct simple_children *to_simple_children(struct config_item *item)
{
return item ? container_of(to_config_group(item), struct simple_children, group) : NULL;
}
static struct config_item *simple_children_make_item(struct config_group *group, const char *name)
{
struct simple_child *simple_child;
simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL);
if (!simple_child)
return ERR_PTR(-ENOMEM);
config_item_init_type_name(&simple_child->item, name,
&simple_child_type);
simple_child->storeme = 0;
return &simple_child->item;
}
static struct configfs_attribute simple_children_attr_description = {
.ca_owner = THIS_MODULE,
.ca_name = "description",
.ca_mode = S_IRUGO,
};
static struct configfs_attribute *simple_children_attrs[] = {
&simple_children_attr_description,
NULL,
};
static ssize_t simple_children_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
return sprintf(page,
"[02-simple-children]\n"
"\n"
"This subsystem allows the creation of child config_items. These\n"
"items have only one attribute that is readable and writeable.\n");
}
static void simple_children_release(struct config_item *item)
{
kfree(to_simple_children(item));
}
static struct configfs_item_operations simple_children_item_ops = {
.release = simple_children_release,
.show_attribute = simple_children_attr_show,
};
/*
* Note that, since no extra work is required on ->drop_item(),
* no ->drop_item() is provided.
*/
static struct configfs_group_operations simple_children_group_ops = {
.make_item = simple_children_make_item,
};
static struct config_item_type simple_children_type = {
.ct_item_ops = &simple_children_item_ops,
.ct_group_ops = &simple_children_group_ops,
.ct_attrs = simple_children_attrs,
.ct_owner = THIS_MODULE,
};
static struct configfs_subsystem simple_children_subsys = {
.su_group = {
.cg_item = {
.ci_namebuf = "02-simple-children",
.ci_type = &simple_children_type,
},
},
};
/* ----------------------------------------------------------------- */
/*
* 03-group-children
*
* This example reuses the simple_children group from above. However,
* the simple_children group is not the subsystem itself, it is a
* child of the subsystem. Creation of a group in the subsystem creates
* a new simple_children group. That group can then have simple_child
* children of its own.
*/
static struct config_group *group_children_make_group(struct config_group *group, const char *name)
{
struct simple_children *simple_children;
simple_children = kzalloc(sizeof(struct simple_children),
GFP_KERNEL);
if (!simple_children)
return ERR_PTR(-ENOMEM);
config_group_init_type_name(&simple_children->group, name,
&simple_children_type);
return &simple_children->group;
}
static struct configfs_attribute group_children_attr_description = {
.ca_owner = THIS_MODULE,
.ca_name = "description",
.ca_mode = S_IRUGO,
};
static struct configfs_attribute *group_children_attrs[] = {
&group_children_attr_description,
NULL,
};
static ssize_t group_children_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
return sprintf(page,
"[03-group-children]\n"
"\n"
"This subsystem allows the creation of child config_groups. These\n"
"groups are like the subsystem simple-children.\n");
}
static struct configfs_item_operations group_children_item_ops = {
.show_attribute = group_children_attr_show,
};
/*
* Note that, since no extra work is required on ->drop_item(),
* no ->drop_item() is provided.
*/
static struct configfs_group_operations group_children_group_ops = {
.make_group = group_children_make_group,
};
static struct config_item_type group_children_type = {
.ct_item_ops = &group_children_item_ops,
.ct_group_ops = &group_children_group_ops,
.ct_attrs = group_children_attrs,
.ct_owner = THIS_MODULE,
};
static struct configfs_subsystem group_children_subsys = {
.su_group = {
.cg_item = {
.ci_namebuf = "03-group-children",
.ci_type = &group_children_type,
},
},
};
/* ----------------------------------------------------------------- */
/*
* We're now done with our subsystem definitions.
* For convenience in this module, here's a list of them all. It
* allows the init function to easily register them. Most modules
* will only have one subsystem, and will only call register_subsystem
* on it directly.
*/
static struct configfs_subsystem *example_subsys[] = {
&childless_subsys.subsys,
&simple_children_subsys,
&group_children_subsys,
NULL,
};
static int __init configfs_example_init(void)
{
int ret;
int i;
struct configfs_subsystem *subsys;
for (i = 0; example_subsys[i]; i++) {
subsys = example_subsys[i];
config_group_init(&subsys->su_group);
mutex_init(&subsys->su_mutex);
ret = configfs_register_subsystem(subsys);
if (ret) {
printk(KERN_ERR "Error %d while registering subsystem %s\n",
ret,
subsys->su_group.cg_item.ci_namebuf);
goto out_unregister;
}
}
return 0;
out_unregister:
for (i--; i >= 0; i--)
configfs_unregister_subsystem(example_subsys[i]);
return ret;
}
static void __exit configfs_example_exit(void)
{
int i;
for (i = 0; example_subsys[i]; i++)
configfs_unregister_subsystem(example_subsys[i]);
}
module_init(configfs_example_init);
module_exit(configfs_example_exit);
MODULE_LICENSE("GPL");

Просмотреть файл

@ -203,8 +203,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
buf += "#include <scsi/scsi_proto.h>\n\n"
buf += "#include <target/target_core_base.h>\n"
buf += "#include <target/target_core_fabric.h>\n"
buf += "#include <target/target_core_fabric_configfs.h>\n"
buf += "#include <target/configfs_macros.h>\n\n"
buf += "#include \"" + fabric_mod_name + "_base.h\"\n"
buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n"
@ -283,19 +281,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
buf += " struct " + fabric_mod_name + "_" + fabric_mod_port + ", " + fabric_mod_port + "_wwn);\n"
buf += " kfree(" + fabric_mod_port + ");\n"
buf += "}\n\n"
buf += "static ssize_t " + fabric_mod_name + "_wwn_show_attr_version(\n"
buf += " struct target_fabric_configfs *tf,\n"
buf += " char *page)\n"
buf += "{\n"
buf += " return sprintf(page, \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n"
buf += " \"on \"UTS_RELEASE\"\\n\", " + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n"
buf += " utsname()->machine);\n"
buf += "}\n\n"
buf += "TF_WWN_ATTR_RO(" + fabric_mod_name + ", version);\n\n"
buf += "static struct configfs_attribute *" + fabric_mod_name + "_wwn_attrs[] = {\n"
buf += " &" + fabric_mod_name + "_wwn_version.attr,\n"
buf += " NULL,\n"
buf += "};\n\n"
buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n"
buf += " .module = THIS_MODULE,\n"
@ -328,8 +313,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n"
buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
buf += "\n"
buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs,\n"
buf += "};\n\n"
buf += "static int __init " + fabric_mod_name + "_init(void)\n"

Просмотреть файл

@ -76,9 +76,10 @@ to_stp_policy_node(struct config_item *item)
NULL;
}
static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node,
char *page)
static ssize_t
stp_policy_node_masters_show(struct config_item *item, char *page)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
ssize_t count;
count = sprintf(page, "%u %u\n", policy_node->first_master,
@ -88,9 +89,10 @@ static ssize_t stp_policy_node_masters_show(struct stp_policy_node *policy_node,
}
static ssize_t
stp_policy_node_masters_store(struct stp_policy_node *policy_node,
const char *page, size_t count)
stp_policy_node_masters_store(struct config_item *item, const char *page,
size_t count)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
unsigned int first, last;
struct stm_device *stm;
char *p = (char *)page;
@ -123,8 +125,9 @@ unlock:
}
static ssize_t
stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page)
stp_policy_node_channels_show(struct config_item *item, char *page)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
ssize_t count;
count = sprintf(page, "%u %u\n", policy_node->first_channel,
@ -134,9 +137,10 @@ stp_policy_node_channels_show(struct stp_policy_node *policy_node, char *page)
}
static ssize_t
stp_policy_node_channels_store(struct stp_policy_node *policy_node,
const char *page, size_t count)
stp_policy_node_channels_store(struct config_item *item, const char *page,
size_t count)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
unsigned int first, last;
struct stm_device *stm;
char *p = (char *)page;
@ -171,71 +175,16 @@ static void stp_policy_node_release(struct config_item *item)
kfree(to_stp_policy_node(item));
}
struct stp_policy_node_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct stp_policy_node *, char *);
ssize_t (*store)(struct stp_policy_node *, const char *, size_t);
};
static ssize_t stp_policy_node_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
struct stp_policy_node_attribute *pn_attr =
container_of(attr, struct stp_policy_node_attribute, attr);
ssize_t count = 0;
if (pn_attr->show)
count = pn_attr->show(policy_node, page);
return count;
}
static ssize_t stp_policy_node_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t len)
{
struct stp_policy_node *policy_node = to_stp_policy_node(item);
struct stp_policy_node_attribute *pn_attr =
container_of(attr, struct stp_policy_node_attribute, attr);
ssize_t count = -EINVAL;
if (pn_attr->store)
count = pn_attr->store(policy_node, page, len);
return count;
}
static struct configfs_item_operations stp_policy_node_item_ops = {
.release = stp_policy_node_release,
.show_attribute = stp_policy_node_attr_show,
.store_attribute = stp_policy_node_attr_store,
};
static struct stp_policy_node_attribute stp_policy_node_attr_range = {
.attr = {
.ca_owner = THIS_MODULE,
.ca_name = "masters",
.ca_mode = S_IRUGO | S_IWUSR,
},
.show = stp_policy_node_masters_show,
.store = stp_policy_node_masters_store,
};
static struct stp_policy_node_attribute stp_policy_node_attr_channels = {
.attr = {
.ca_owner = THIS_MODULE,
.ca_name = "channels",
.ca_mode = S_IRUGO | S_IWUSR,
},
.show = stp_policy_node_channels_show,
.store = stp_policy_node_channels_store,
};
CONFIGFS_ATTR(stp_policy_node_, masters);
CONFIGFS_ATTR(stp_policy_node_, channels);
static struct configfs_attribute *stp_policy_node_attrs[] = {
&stp_policy_node_attr_range.attr,
&stp_policy_node_attr_channels.attr,
&stp_policy_node_attr_masters,
&stp_policy_node_attr_channels,
NULL,
};
@ -298,20 +247,8 @@ static struct config_item_type stp_policy_node_type = {
/*
* Root group: policies.
*/
static struct configfs_attribute stp_policy_attr_device = {
.ca_owner = THIS_MODULE,
.ca_name = "device",
.ca_mode = S_IRUGO,
};
static struct configfs_attribute *stp_policy_attrs[] = {
&stp_policy_attr_device,
NULL,
};
static ssize_t stp_policy_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
static ssize_t stp_policy_device_show(struct config_item *item,
char *page)
{
struct stp_policy *policy = to_stp_policy(item);
ssize_t count;
@ -324,6 +261,13 @@ static ssize_t stp_policy_attr_show(struct config_item *item,
return count;
}
CONFIGFS_ATTR_RO(stp_policy_, device);
static struct configfs_attribute *stp_policy_attrs[] = {
&stp_policy_attr_device,
NULL,
};
void stp_policy_unbind(struct stp_policy *policy)
{
struct stm_device *stm = policy->stm;
@ -350,7 +294,6 @@ static void stp_policy_release(struct config_item *item)
static struct configfs_item_operations stp_policy_item_ops = {
.release = stp_policy_release,
.show_attribute = stp_policy_attr_show,
};
static struct configfs_group_operations stp_policy_group_ops = {

Просмотреть файл

@ -43,9 +43,7 @@
#include <linux/atomic.h>
#include <scsi/scsi_proto.h>
#include <scsi/scsi_tcq.h>
#include <target/configfs_macros.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric_configfs.h>
#include <target/target_core_fabric.h>
#include "ib_srpt.h"
@ -3546,20 +3544,19 @@ static void srpt_cleanup_nodeacl(struct se_node_acl *se_nacl)
spin_unlock_irq(&sport->port_acl_lock);
}
static ssize_t srpt_tpg_attrib_show_srp_max_rdma_size(
struct se_portal_group *se_tpg,
char *page)
static ssize_t srpt_tpg_attrib_srp_max_rdma_size_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
return sprintf(page, "%u\n", sport->port_attrib.srp_max_rdma_size);
}
static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t srpt_tpg_attrib_srp_max_rdma_size_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
unsigned long val;
int ret;
@ -3584,22 +3581,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rdma_size(
return count;
}
TF_TPG_ATTRIB_ATTR(srpt, srp_max_rdma_size, S_IRUGO | S_IWUSR);
static ssize_t srpt_tpg_attrib_show_srp_max_rsp_size(
struct se_portal_group *se_tpg,
char *page)
static ssize_t srpt_tpg_attrib_srp_max_rsp_size_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
return sprintf(page, "%u\n", sport->port_attrib.srp_max_rsp_size);
}
static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t srpt_tpg_attrib_srp_max_rsp_size_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
unsigned long val;
int ret;
@ -3624,22 +3618,19 @@ static ssize_t srpt_tpg_attrib_store_srp_max_rsp_size(
return count;
}
TF_TPG_ATTRIB_ATTR(srpt, srp_max_rsp_size, S_IRUGO | S_IWUSR);
static ssize_t srpt_tpg_attrib_show_srp_sq_size(
struct se_portal_group *se_tpg,
char *page)
static ssize_t srpt_tpg_attrib_srp_sq_size_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
return sprintf(page, "%u\n", sport->port_attrib.srp_sq_size);
}
static ssize_t srpt_tpg_attrib_store_srp_sq_size(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t srpt_tpg_attrib_srp_sq_size_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
unsigned long val;
int ret;
@ -3664,29 +3655,29 @@ static ssize_t srpt_tpg_attrib_store_srp_sq_size(
return count;
}
TF_TPG_ATTRIB_ATTR(srpt, srp_sq_size, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rdma_size);
CONFIGFS_ATTR(srpt_tpg_attrib_, srp_max_rsp_size);
CONFIGFS_ATTR(srpt_tpg_attrib_, srp_sq_size);
static struct configfs_attribute *srpt_tpg_attrib_attrs[] = {
&srpt_tpg_attrib_srp_max_rdma_size.attr,
&srpt_tpg_attrib_srp_max_rsp_size.attr,
&srpt_tpg_attrib_srp_sq_size.attr,
&srpt_tpg_attrib_attr_srp_max_rdma_size,
&srpt_tpg_attrib_attr_srp_max_rsp_size,
&srpt_tpg_attrib_attr_srp_sq_size,
NULL,
};
static ssize_t srpt_tpg_show_enable(
struct se_portal_group *se_tpg,
char *page)
static ssize_t srpt_tpg_enable_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
return snprintf(page, PAGE_SIZE, "%d\n", (sport->enabled) ? 1: 0);
}
static ssize_t srpt_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t srpt_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct srpt_port *sport = container_of(se_tpg, struct srpt_port, port_tpg_1);
unsigned long tmp;
int ret;
@ -3709,10 +3700,10 @@ static ssize_t srpt_tpg_store_enable(
return count;
}
TF_TPG_BASE_ATTR(srpt, enable, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(srpt_tpg_, enable);
static struct configfs_attribute *srpt_tpg_attrs[] = {
&srpt_tpg_enable.attr,
&srpt_tpg_attr_enable,
NULL,
};
@ -3782,16 +3773,15 @@ static void srpt_drop_tport(struct se_wwn *wwn)
pr_debug("drop_tport(%s\n", config_item_name(&sport->port_wwn.wwn_group.cg_item));
}
static ssize_t srpt_wwn_show_attr_version(struct target_fabric_configfs *tf,
char *buf)
static ssize_t srpt_wwn_version_show(struct config_item *item, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%s\n", DRV_VERSION);
}
TF_WWN_ATTR_RO(srpt, version);
CONFIGFS_ATTR_RO(srpt_wwn_, version);
static struct configfs_attribute *srpt_wwn_attrs[] = {
&srpt_wwn_version.attr,
&srpt_wwn_attr_version,
NULL,
};

Просмотреть файл

@ -220,11 +220,17 @@ static irqreturn_t spear_pcie_gadget_irq(int irq, void *dev_id)
/*
* configfs interfaces show/store functions
*/
static ssize_t pcie_gadget_show_link(
struct spear_pcie_gadget_config *config,
char *buf)
static struct pcie_gadget_target *to_target(struct config_item *item)
{
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
return item ?
container_of(to_configfs_subsystem(to_config_group(item)),
struct pcie_gadget_target, subsys) : NULL;
}
static ssize_t pcie_gadget_link_show(struct config_item *item, char *buf)
{
struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
if (readl(&app_reg->app_status_1) & ((u32)1 << XMLH_LINK_UP_ID))
return sprintf(buf, "UP");
@ -232,11 +238,10 @@ static ssize_t pcie_gadget_show_link(
return sprintf(buf, "DOWN");
}
static ssize_t pcie_gadget_store_link(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_link_store(struct config_item *item,
const char *buf, size_t count)
{
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
if (sysfs_streq(buf, "UP"))
writel(readl(&app_reg->app_ctrl_0) | (1 << APP_LTSSM_ENABLE_ID),
@ -250,17 +255,15 @@ static ssize_t pcie_gadget_store_link(
return count;
}
static ssize_t pcie_gadget_show_int_type(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_int_type_show(struct config_item *item, char *buf)
{
return sprintf(buf, "%s", config->int_type);
return sprintf(buf, "%s", to_target(item)->int_type);
}
static ssize_t pcie_gadget_store_int_type(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_int_type_store(struct config_item *item,
const char *buf, size_t count)
{
struct spear_pcie_gadget_config *config = to_target(item)
u32 cap, vec, flags;
ulong vector;
@ -288,11 +291,10 @@ static ssize_t pcie_gadget_store_int_type(
return count;
}
static ssize_t pcie_gadget_show_no_of_msi(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_no_of_msi_show(struct config_item *item, char *buf)
{
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
u32 cap, vec, flags;
ulong vector;
@ -313,13 +315,12 @@ static ssize_t pcie_gadget_show_no_of_msi(
return sprintf(buf, "%lu", vector);
}
static ssize_t pcie_gadget_store_no_of_msi(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_no_of_msi_store(struct config_item *item,
const char *buf, size_t count)
{
int ret;
ret = kstrtoul(buf, 0, &config->requested_msi);
ret = kstrtoul(buf, 0, &to_target(item)->requested_msi);
if (ret)
return ret;
@ -329,11 +330,10 @@ static ssize_t pcie_gadget_store_no_of_msi(
return count;
}
static ssize_t pcie_gadget_store_inta(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_inta_store(struct config_item *item,
const char *buf, size_t count)
{
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
ulong en;
int ret;
@ -351,10 +351,10 @@ static ssize_t pcie_gadget_store_inta(
return count;
}
static ssize_t pcie_gadget_store_send_msi(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_send_msi_store(struct config_item *item,
const char *buf, size_t count)
{
struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
ulong vector;
u32 ven_msi;
@ -388,19 +388,16 @@ static ssize_t pcie_gadget_store_send_msi(
return count;
}
static ssize_t pcie_gadget_show_vendor_id(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_vendor_id_show(struct config_item *item, char *buf)
{
u32 id;
spear_dbi_read_reg(config, PCI_VENDOR_ID, 2, &id);
spear_dbi_read_reg(to_target(item), PCI_VENDOR_ID, 2, &id);
return sprintf(buf, "%x", id);
}
static ssize_t pcie_gadget_store_vendor_id(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_vendor_id_store(struct config_item *item,
const char *buf, size_t count)
{
ulong id;
@ -410,24 +407,21 @@ static ssize_t pcie_gadget_store_vendor_id(
if (ret)
return ret;
spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id);
spear_dbi_write_reg(to_target(item), PCI_VENDOR_ID, 2, id);
return count;
}
static ssize_t pcie_gadget_show_device_id(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_device_id_show(struct config_item *item, char *buf)
{
u32 id;
spear_dbi_read_reg(config, PCI_DEVICE_ID, 2, &id);
spear_dbi_read_reg(to_target(item), PCI_DEVICE_ID, 2, &id);
return sprintf(buf, "%x", id);
}
static ssize_t pcie_gadget_store_device_id(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_device_id_store(struct config_item *item,
const char *buf, size_t count)
{
ulong id;
@ -437,22 +431,20 @@ static ssize_t pcie_gadget_store_device_id(
if (ret)
return ret;
spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id);
spear_dbi_write_reg(to_target(item), PCI_DEVICE_ID, 2, id);
return count;
}
static ssize_t pcie_gadget_show_bar0_size(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_bar0_size_show(struct config_item *item, char *buf)
{
return sprintf(buf, "%lx", config->bar0_size);
return sprintf(buf, "%lx", to_target(item)->bar0_size);
}
static ssize_t pcie_gadget_store_bar0_size(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_size_store(struct config_item *item,
const char *buf, size_t count)
{
struct spear_pcie_gadget_config *config = to_target(item)
ulong size;
u32 pos, pos1;
u32 no_of_bit = 0;
@ -489,21 +481,20 @@ static ssize_t pcie_gadget_store_bar0_size(
return count;
}
static ssize_t pcie_gadget_show_bar0_address(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_address_show(struct config_item *item,
char *buf)
{
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
struct pcie_app_reg __iomem *app_reg = to_target(item)->va_app_base;
u32 address = readl(&app_reg->pim0_mem_addr_start);
return sprintf(buf, "%x", address);
}
static ssize_t pcie_gadget_store_bar0_address(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_address_store(struct config_item *item,
const char *buf, size_t count)
{
struct spear_pcie_gadget_config *config = to_target(item)
struct pcie_app_reg __iomem *app_reg = config->va_app_base;
ulong address;
int ret;
@ -524,15 +515,13 @@ static ssize_t pcie_gadget_store_bar0_address(
return count;
}
static ssize_t pcie_gadget_show_bar0_rw_offset(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_rw_offset_show(struct config_item *item,
char *buf)
{
return sprintf(buf, "%lx", config->bar0_rw_offset);
return sprintf(buf, "%lx", to_target(item)->bar0_rw_offset);
}
static ssize_t pcie_gadget_store_bar0_rw_offset(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_rw_offset_store(struct config_item *item,
const char *buf, size_t count)
{
ulong offset;
@ -545,15 +534,14 @@ static ssize_t pcie_gadget_store_bar0_rw_offset(
if (offset % 4)
return -EINVAL;
config->bar0_rw_offset = offset;
to_target(item)->bar0_rw_offset = offset;
return count;
}
static ssize_t pcie_gadget_show_bar0_data(
struct spear_pcie_gadget_config *config,
char *buf)
static ssize_t pcie_gadget_bar0_data_show(struct config_item *item, char *buf)
{
struct spear_pcie_gadget_config *config = to_target(item)
ulong data;
if (!config->va_bar0_address)
@ -564,10 +552,10 @@ static ssize_t pcie_gadget_show_bar0_data(
return sprintf(buf, "%lx", data);
}
static ssize_t pcie_gadget_store_bar0_data(
struct spear_pcie_gadget_config *config,
static ssize_t pcie_gadget_bar0_data_store(struct config_item *item,
const char *buf, size_t count)
{
struct spear_pcie_gadget_config *config = to_target(item)
ulong data;
int ret;
@ -583,97 +571,35 @@ static ssize_t pcie_gadget_store_bar0_data(
return count;
}
/*
* Attribute definitions.
*/
#define PCIE_GADGET_TARGET_ATTR_RO(_name) \
static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \
__CONFIGFS_ATTR(_name, S_IRUGO, pcie_gadget_show_##_name, NULL)
#define PCIE_GADGET_TARGET_ATTR_WO(_name) \
static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \
__CONFIGFS_ATTR(_name, S_IWUSR, NULL, pcie_gadget_store_##_name)
#define PCIE_GADGET_TARGET_ATTR_RW(_name) \
static struct pcie_gadget_target_attr pcie_gadget_target_##_name = \
__CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, pcie_gadget_show_##_name, \
pcie_gadget_store_##_name)
PCIE_GADGET_TARGET_ATTR_RW(link);
PCIE_GADGET_TARGET_ATTR_RW(int_type);
PCIE_GADGET_TARGET_ATTR_RW(no_of_msi);
PCIE_GADGET_TARGET_ATTR_WO(inta);
PCIE_GADGET_TARGET_ATTR_WO(send_msi);
PCIE_GADGET_TARGET_ATTR_RW(vendor_id);
PCIE_GADGET_TARGET_ATTR_RW(device_id);
PCIE_GADGET_TARGET_ATTR_RW(bar0_size);
PCIE_GADGET_TARGET_ATTR_RW(bar0_address);
PCIE_GADGET_TARGET_ATTR_RW(bar0_rw_offset);
PCIE_GADGET_TARGET_ATTR_RW(bar0_data);
CONFIGFS_ATTR(pcie_gadget_, link);
CONFIGFS_ATTR(pcie_gadget_, int_type);
CONFIGFS_ATTR(pcie_gadget_, no_of_msi);
CONFIGFS_ATTR_WO(pcie_gadget_, inta);
CONFIGFS_ATTR_WO(pcie_gadget_, send_msi);
CONFIGFS_ATTR(pcie_gadget_, vendor_id);
CONFIGFS_ATTR(pcie_gadget_, device_id);
CONFIGFS_ATTR(pcie_gadget_, bar0_size);
CONFIGFS_ATTR(pcie_gadget_, bar0_address);
CONFIGFS_ATTR(pcie_gadget_, bar0_rw_offset);
CONFIGFS_ATTR(pcie_gadget_, bar0_data);
static struct configfs_attribute *pcie_gadget_target_attrs[] = {
&pcie_gadget_target_link.attr,
&pcie_gadget_target_int_type.attr,
&pcie_gadget_target_no_of_msi.attr,
&pcie_gadget_target_inta.attr,
&pcie_gadget_target_send_msi.attr,
&pcie_gadget_target_vendor_id.attr,
&pcie_gadget_target_device_id.attr,
&pcie_gadget_target_bar0_size.attr,
&pcie_gadget_target_bar0_address.attr,
&pcie_gadget_target_bar0_rw_offset.attr,
&pcie_gadget_target_bar0_data.attr,
&pcie_gadget_attr_link,
&pcie_gadget_attr_int_type,
&pcie_gadget_attr_no_of_msi,
&pcie_gadget_attr_inta,
&pcie_gadget_attr_send_msi,
&pcie_gadget_attr_vendor_id,
&pcie_gadget_attr_device_id,
&pcie_gadget_attr_bar0_size,
&pcie_gadget_attr_bar0_address,
&pcie_gadget_attr_bar0_rw_offset,
&pcie_gadget_attr_bar0_data,
NULL,
};
static struct pcie_gadget_target *to_target(struct config_item *item)
{
return item ?
container_of(to_configfs_subsystem(to_config_group(item)),
struct pcie_gadget_target, subsys) : NULL;
}
/*
* Item operations and type for pcie_gadget_target.
*/
static ssize_t pcie_gadget_target_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *buf)
{
ssize_t ret = -EINVAL;
struct pcie_gadget_target *target = to_target(item);
struct pcie_gadget_target_attr *t_attr =
container_of(attr, struct pcie_gadget_target_attr, attr);
if (t_attr->show)
ret = t_attr->show(&target->config, buf);
return ret;
}
static ssize_t pcie_gadget_target_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *buf,
size_t count)
{
ssize_t ret = -EINVAL;
struct pcie_gadget_target *target = to_target(item);
struct pcie_gadget_target_attr *t_attr =
container_of(attr, struct pcie_gadget_target_attr, attr);
if (t_attr->store)
ret = t_attr->store(&target->config, buf, count);
return ret;
}
static struct configfs_item_operations pcie_gadget_target_item_ops = {
.show_attribute = pcie_gadget_target_attr_show,
.store_attribute = pcie_gadget_target_attr_store,
};
static struct config_item_type pcie_gadget_target_type = {
.ct_attrs = pcie_gadget_target_attrs,
.ct_item_ops = &pcie_gadget_target_item_ops,
.ct_owner = THIS_MODULE,
};

Просмотреть файл

@ -244,15 +244,6 @@ static void free_param_target(struct netconsole_target *nt)
* <target>/...
*/
struct netconsole_target_attr {
struct configfs_attribute attr;
ssize_t (*show)(struct netconsole_target *nt,
char *buf);
ssize_t (*store)(struct netconsole_target *nt,
const char *buf,
size_t count);
};
static struct netconsole_target *to_target(struct config_item *item)
{
return item ?
@ -264,58 +255,62 @@ static struct netconsole_target *to_target(struct config_item *item)
* Attribute operations for netconsole_target.
*/
static ssize_t show_enabled(struct netconsole_target *nt, char *buf)
static ssize_t enabled_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", nt->enabled);
return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->enabled);
}
static ssize_t show_extended(struct netconsole_target *nt, char *buf)
static ssize_t extended_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", nt->extended);
return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->extended);
}
static ssize_t show_dev_name(struct netconsole_target *nt, char *buf)
static ssize_t dev_name_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", nt->np.dev_name);
return snprintf(buf, PAGE_SIZE, "%s\n", to_target(item)->np.dev_name);
}
static ssize_t show_local_port(struct netconsole_target *nt, char *buf)
static ssize_t local_port_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.local_port);
return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.local_port);
}
static ssize_t show_remote_port(struct netconsole_target *nt, char *buf)
static ssize_t remote_port_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", nt->np.remote_port);
return snprintf(buf, PAGE_SIZE, "%d\n", to_target(item)->np.remote_port);
}
static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
static ssize_t local_ip_show(struct config_item *item, char *buf)
{
struct netconsole_target *nt = to_target(item);
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip);
}
static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
static ssize_t remote_ip_show(struct config_item *item, char *buf)
{
struct netconsole_target *nt = to_target(item);
if (nt->np.ipv6)
return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6);
else
return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip);
}
static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
static ssize_t local_mac_show(struct config_item *item, char *buf)
{
struct net_device *dev = nt->np.dev;
struct net_device *dev = to_target(item)->np.dev;
static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
return snprintf(buf, PAGE_SIZE, "%pM\n", dev ? dev->dev_addr : bcast);
}
static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
static ssize_t remote_mac_show(struct config_item *item, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%pM\n", nt->np.remote_mac);
return snprintf(buf, PAGE_SIZE, "%pM\n", to_target(item)->np.remote_mac);
}
/*
@ -325,23 +320,26 @@ static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
* would enable him to dynamically add new netpoll targets for new
* network interfaces as and when they come up).
*/
static ssize_t store_enabled(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t enabled_store(struct config_item *item,
const char *buf, size_t count)
{
struct netconsole_target *nt = to_target(item);
unsigned long flags;
int enabled;
int err;
mutex_lock(&dynamic_netconsole_mutex);
err = kstrtoint(buf, 10, &enabled);
if (err < 0)
return err;
goto out_unlock;
err = -EINVAL;
if (enabled < 0 || enabled > 1)
return -EINVAL;
goto out_unlock;
if ((bool)enabled == nt->enabled) {
pr_info("network logging has already %s\n",
nt->enabled ? "started" : "stopped");
return -EINVAL;
goto out_unlock;
}
if (enabled) { /* true */
@ -358,7 +356,7 @@ static ssize_t store_enabled(struct netconsole_target *nt,
err = netpoll_setup(&nt->np);
if (err)
return err;
goto out_unlock;
pr_info("netconsole: network logging started\n");
} else { /* false */
@ -374,42 +372,56 @@ static ssize_t store_enabled(struct netconsole_target *nt,
nt->enabled = enabled;
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return err;
}
static ssize_t store_extended(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t extended_store(struct config_item *item, const char *buf,
size_t count)
{
struct netconsole_target *nt = to_target(item);
int extended;
int err;
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
err = -EINVAL;
goto out_unlock;
}
err = kstrtoint(buf, 10, &extended);
if (err < 0)
return err;
if (extended < 0 || extended > 1)
return -EINVAL;
goto out_unlock;
if (extended < 0 || extended > 1) {
err = -EINVAL;
goto out_unlock;
}
nt->extended = extended;
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return err;
}
static ssize_t store_dev_name(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t dev_name_store(struct config_item *item, const char *buf,
size_t count)
{
struct netconsole_target *nt = to_target(item);
size_t len;
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
mutex_unlock(&dynamic_netconsole_mutex);
return -EINVAL;
}
@ -420,53 +432,66 @@ static ssize_t store_dev_name(struct netconsole_target *nt,
if (nt->np.dev_name[len - 1] == '\n')
nt->np.dev_name[len - 1] = '\0';
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
}
static ssize_t store_local_port(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t local_port_store(struct config_item *item, const char *buf,
size_t count)
{
int rv;
struct netconsole_target *nt = to_target(item);
int rv = -EINVAL;
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
goto out_unlock;
}
rv = kstrtou16(buf, 10, &nt->np.local_port);
if (rv < 0)
return rv;
goto out_unlock;
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return rv;
}
static ssize_t store_remote_port(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t remote_port_store(struct config_item *item,
const char *buf, size_t count)
{
int rv;
struct netconsole_target *nt = to_target(item);
int rv = -EINVAL;
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
goto out_unlock;
}
rv = kstrtou16(buf, 10, &nt->np.remote_port);
if (rv < 0)
return rv;
goto out_unlock;
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return rv;
}
static ssize_t store_local_ip(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t local_ip_store(struct config_item *item, const char *buf,
size_t count)
{
struct netconsole_target *nt = to_target(item);
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
goto out_unlock;
}
if (strnchr(buf, count, ':')) {
@ -474,29 +499,35 @@ static ssize_t store_local_ip(struct netconsole_target *nt,
if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) {
if (*end && *end != '\n') {
pr_err("invalid IPv6 address at: <%c>\n", *end);
return -EINVAL;
goto out_unlock;
}
nt->np.ipv6 = true;
} else
return -EINVAL;
goto out_unlock;
} else {
if (!nt->np.ipv6) {
nt->np.local_ip.ip = in_aton(buf);
} else
return -EINVAL;
goto out_unlock;
}
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return -EINVAL;
}
static ssize_t store_remote_ip(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t remote_ip_store(struct config_item *item, const char *buf,
size_t count)
{
struct netconsole_target *nt = to_target(item);
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
goto out_unlock;
}
if (strnchr(buf, count, ':')) {
@ -504,74 +535,71 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,
if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) {
if (*end && *end != '\n') {
pr_err("invalid IPv6 address at: <%c>\n", *end);
return -EINVAL;
goto out_unlock;
}
nt->np.ipv6 = true;
} else
return -EINVAL;
goto out_unlock;
} else {
if (!nt->np.ipv6) {
nt->np.remote_ip.ip = in_aton(buf);
} else
return -EINVAL;
goto out_unlock;
}
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return -EINVAL;
}
static ssize_t store_remote_mac(struct netconsole_target *nt,
const char *buf,
size_t count)
static ssize_t remote_mac_store(struct config_item *item, const char *buf,
size_t count)
{
struct netconsole_target *nt = to_target(item);
u8 remote_mac[ETH_ALEN];
mutex_lock(&dynamic_netconsole_mutex);
if (nt->enabled) {
pr_err("target (%s) is enabled, disable to update parameters\n",
config_item_name(&nt->item));
return -EINVAL;
goto out_unlock;
}
if (!mac_pton(buf, remote_mac))
return -EINVAL;
goto out_unlock;
if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n')
return -EINVAL;
goto out_unlock;
memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN);
mutex_unlock(&dynamic_netconsole_mutex);
return strnlen(buf, count);
out_unlock:
mutex_unlock(&dynamic_netconsole_mutex);
return -EINVAL;
}
/*
* Attribute definitions for netconsole_target.
*/
#define NETCONSOLE_TARGET_ATTR_RO(_name) \
static struct netconsole_target_attr netconsole_target_##_name = \
__CONFIGFS_ATTR(_name, S_IRUGO, show_##_name, NULL)
#define NETCONSOLE_TARGET_ATTR_RW(_name) \
static struct netconsole_target_attr netconsole_target_##_name = \
__CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, show_##_name, store_##_name)
NETCONSOLE_TARGET_ATTR_RW(enabled);
NETCONSOLE_TARGET_ATTR_RW(extended);
NETCONSOLE_TARGET_ATTR_RW(dev_name);
NETCONSOLE_TARGET_ATTR_RW(local_port);
NETCONSOLE_TARGET_ATTR_RW(remote_port);
NETCONSOLE_TARGET_ATTR_RW(local_ip);
NETCONSOLE_TARGET_ATTR_RW(remote_ip);
NETCONSOLE_TARGET_ATTR_RO(local_mac);
NETCONSOLE_TARGET_ATTR_RW(remote_mac);
CONFIGFS_ATTR(, enabled);
CONFIGFS_ATTR(, extended);
CONFIGFS_ATTR(, dev_name);
CONFIGFS_ATTR(, local_port);
CONFIGFS_ATTR(, remote_port);
CONFIGFS_ATTR(, local_ip);
CONFIGFS_ATTR(, remote_ip);
CONFIGFS_ATTR_RO(, local_mac);
CONFIGFS_ATTR(, remote_mac);
static struct configfs_attribute *netconsole_target_attrs[] = {
&netconsole_target_enabled.attr,
&netconsole_target_extended.attr,
&netconsole_target_dev_name.attr,
&netconsole_target_local_port.attr,
&netconsole_target_remote_port.attr,
&netconsole_target_local_ip.attr,
&netconsole_target_remote_ip.attr,
&netconsole_target_local_mac.attr,
&netconsole_target_remote_mac.attr,
&attr_enabled,
&attr_extended,
&attr_dev_name,
&attr_local_port,
&attr_remote_port,
&attr_local_ip,
&attr_remote_ip,
&attr_local_mac,
&attr_remote_mac,
NULL,
};
@ -584,43 +612,8 @@ static void netconsole_target_release(struct config_item *item)
kfree(to_target(item));
}
static ssize_t netconsole_target_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *buf)
{
ssize_t ret = -EINVAL;
struct netconsole_target *nt = to_target(item);
struct netconsole_target_attr *na =
container_of(attr, struct netconsole_target_attr, attr);
if (na->show)
ret = na->show(nt, buf);
return ret;
}
static ssize_t netconsole_target_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *buf,
size_t count)
{
ssize_t ret = -EINVAL;
struct netconsole_target *nt = to_target(item);
struct netconsole_target_attr *na =
container_of(attr, struct netconsole_target_attr, attr);
mutex_lock(&dynamic_netconsole_mutex);
if (na->store)
ret = na->store(nt, buf, count);
mutex_unlock(&dynamic_netconsole_mutex);
return ret;
}
static struct configfs_item_operations netconsole_target_item_ops = {
.release = netconsole_target_release,
.show_attribute = netconsole_target_attr_show,
.store_attribute = netconsole_target_attr_store,
};
static struct config_item_type netconsole_target_type = {

Просмотреть файл

@ -43,8 +43,6 @@
#include <scsi/scsi_cmnd.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include "qla_def.h"
#include "qla_target.h"
@ -729,23 +727,23 @@ static int tcm_qla2xxx_init_nodeacl(struct se_node_acl *se_nacl,
#define DEF_QLA_TPG_ATTRIB(name) \
\
static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \
struct se_portal_group *se_tpg, \
char *page) \
static ssize_t tcm_qla2xxx_tpg_attrib_##name##_show( \
struct config_item *item, char *page) \
{ \
struct se_portal_group *se_tpg = attrib_to_tpg(item); \
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
struct tcm_qla2xxx_tpg, se_tpg); \
\
return sprintf(page, "%u\n", tpg->tpg_attrib.name); \
} \
\
static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \
struct se_portal_group *se_tpg, \
const char *page, \
size_t count) \
static ssize_t tcm_qla2xxx_tpg_attrib_##name##_store( \
struct config_item *item, const char *page, size_t count) \
{ \
struct se_portal_group *se_tpg = attrib_to_tpg(item); \
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
struct tcm_qla2xxx_tpg, se_tpg); \
struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
unsigned long val; \
int ret; \
\
@ -755,81 +753,39 @@ static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \
" ret: %d\n", ret); \
return -EINVAL; \
} \
ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \
\
return (!ret) ? count : -EINVAL; \
}
#define DEF_QLA_TPG_ATTR_BOOL(_name) \
\
static int tcm_qla2xxx_set_attrib_##_name( \
struct tcm_qla2xxx_tpg *tpg, \
unsigned long val) \
{ \
struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
\
if ((val != 0) && (val != 1)) { \
pr_err("Illegal boolean value %lu\n", val); \
return -EINVAL; \
} \
\
a->_name = val; \
return 0; \
}
a->name = val; \
\
return count; \
} \
CONFIGFS_ATTR(tcm_qla2xxx_tpg_attrib_, name)
#define QLA_TPG_ATTR(_name, _mode) \
TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode);
/*
* Define tcm_qla2xxx_tpg_attrib_s_generate_node_acls
*/
DEF_QLA_TPG_ATTR_BOOL(generate_node_acls);
DEF_QLA_TPG_ATTRIB(generate_node_acls);
QLA_TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR);
/*
Define tcm_qla2xxx_attrib_s_cache_dynamic_acls
*/
DEF_QLA_TPG_ATTR_BOOL(cache_dynamic_acls);
DEF_QLA_TPG_ATTRIB(cache_dynamic_acls);
QLA_TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR);
/*
* Define tcm_qla2xxx_tpg_attrib_s_demo_mode_write_protect
*/
DEF_QLA_TPG_ATTR_BOOL(demo_mode_write_protect);
DEF_QLA_TPG_ATTRIB(demo_mode_write_protect);
QLA_TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR);
/*
* Define tcm_qla2xxx_tpg_attrib_s_prod_mode_write_protect
*/
DEF_QLA_TPG_ATTR_BOOL(prod_mode_write_protect);
DEF_QLA_TPG_ATTRIB(prod_mode_write_protect);
QLA_TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR);
/*
* Define tcm_qla2xxx_tpg_attrib_s_demo_mode_login_only
*/
DEF_QLA_TPG_ATTR_BOOL(demo_mode_login_only);
DEF_QLA_TPG_ATTRIB(demo_mode_login_only);
QLA_TPG_ATTR(demo_mode_login_only, S_IRUGO | S_IWUSR);
static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
&tcm_qla2xxx_tpg_attrib_generate_node_acls.attr,
&tcm_qla2xxx_tpg_attrib_cache_dynamic_acls.attr,
&tcm_qla2xxx_tpg_attrib_demo_mode_write_protect.attr,
&tcm_qla2xxx_tpg_attrib_prod_mode_write_protect.attr,
&tcm_qla2xxx_tpg_attrib_demo_mode_login_only.attr,
&tcm_qla2xxx_tpg_attrib_attr_generate_node_acls,
&tcm_qla2xxx_tpg_attrib_attr_cache_dynamic_acls,
&tcm_qla2xxx_tpg_attrib_attr_demo_mode_write_protect,
&tcm_qla2xxx_tpg_attrib_attr_prod_mode_write_protect,
&tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only,
NULL,
};
/* End items for tcm_qla2xxx_tpg_attrib_cit */
static ssize_t tcm_qla2xxx_tpg_show_enable(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
struct tcm_qla2xxx_tpg, se_tpg);
@ -865,11 +821,10 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
complete(&base_tpg->tpg_base_comp);
}
static ssize_t tcm_qla2xxx_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
struct tcm_qla2xxx_tpg, se_tpg);
unsigned long op;
@ -909,22 +864,16 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
return count;
}
TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR);
static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_qla2xxx_tpg_dynamic_sessions_show(struct config_item *item,
char *page)
{
return target_show_dynamic_sessions(se_tpg, page);
return target_show_dynamic_sessions(to_tpg(item), page);
}
TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions);
static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
struct tcm_qla2xxx_tpg, se_tpg);
unsigned long val;
@ -943,21 +892,24 @@ static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type(
return count;
}
static ssize_t tcm_qla2xxx_tpg_show_fabric_prot_type(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
struct tcm_qla2xxx_tpg, se_tpg);
return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type);
}
TF_TPG_BASE_ATTR(tcm_qla2xxx, fabric_prot_type, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR_WO(tcm_qla2xxx_tpg_, enable);
CONFIGFS_ATTR_RO(tcm_qla2xxx_tpg_, dynamic_sessions);
CONFIGFS_ATTR(tcm_qla2xxx_tpg_, fabric_prot_type);
static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = {
&tcm_qla2xxx_tpg_enable.attr,
&tcm_qla2xxx_tpg_dynamic_sessions.attr,
&tcm_qla2xxx_tpg_fabric_prot_type.attr,
&tcm_qla2xxx_tpg_attr_enable,
&tcm_qla2xxx_tpg_attr_dynamic_sessions,
&tcm_qla2xxx_tpg_attr_fabric_prot_type,
NULL,
};
@ -1030,18 +982,16 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg)
kfree(tpg);
}
static ssize_t tcm_qla2xxx_npiv_tpg_show_enable(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_qla2xxx_npiv_tpg_enable_show(struct config_item *item,
char *page)
{
return tcm_qla2xxx_tpg_show_enable(se_tpg, page);
return tcm_qla2xxx_tpg_enable_show(item, page);
}
static ssize_t tcm_qla2xxx_npiv_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
struct tcm_qla2xxx_lport, lport_wwn);
@ -1077,10 +1027,10 @@ static ssize_t tcm_qla2xxx_npiv_tpg_store_enable(
return count;
}
TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(tcm_qla2xxx_npiv_tpg_, enable);
static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = {
&tcm_qla2xxx_npiv_tpg_enable.attr,
&tcm_qla2xxx_npiv_tpg_attr_enable,
NULL,
};
@ -1783,9 +1733,8 @@ static void tcm_qla2xxx_npiv_drop_lport(struct se_wwn *wwn)
}
static ssize_t tcm_qla2xxx_wwn_show_attr_version(
struct target_fabric_configfs *tf,
char *page)
static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item,
char *page)
{
return sprintf(page,
"TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
@ -1793,10 +1742,10 @@ static ssize_t tcm_qla2xxx_wwn_show_attr_version(
utsname()->machine);
}
TF_WWN_ATTR_RO(tcm_qla2xxx, version);
CONFIGFS_ATTR_RO(tcm_qla2xxx_wwn_, version);
static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
&tcm_qla2xxx_wwn_version.attr,
&tcm_qla2xxx_wwn_attr_version,
NULL,
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -34,7 +34,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include "tcm_loop.h"
@ -763,21 +762,20 @@ static void tcm_loop_port_unlink(
/* End items for tcm_loop_port_cit */
static ssize_t tcm_loop_tpg_attrib_show_fabric_prot_type(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_show(
struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg,
tl_se_tpg);
return sprintf(page, "%d\n", tl_tpg->tl_fabric_prot_type);
}
static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_loop_tpg_attrib_fabric_prot_type_store(
struct config_item *item, const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg, struct tcm_loop_tpg,
tl_se_tpg);
unsigned long val;
@ -796,10 +794,10 @@ static ssize_t tcm_loop_tpg_attrib_store_fabric_prot_type(
return count;
}
TF_TPG_ATTRIB_ATTR(tcm_loop, fabric_prot_type, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(tcm_loop_tpg_attrib_, fabric_prot_type);
static struct configfs_attribute *tcm_loop_tpg_attrib_attrs[] = {
&tcm_loop_tpg_attrib_fabric_prot_type.attr,
&tcm_loop_tpg_attrib_attr_fabric_prot_type,
NULL,
};
@ -894,10 +892,9 @@ static int tcm_loop_drop_nexus(
/* End items for tcm_loop_nexus_cit */
static ssize_t tcm_loop_tpg_show_nexus(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_loop_tpg_nexus_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg,
struct tcm_loop_tpg, tl_se_tpg);
struct tcm_loop_nexus *tl_nexus;
@ -913,11 +910,10 @@ static ssize_t tcm_loop_tpg_show_nexus(
return ret;
}
static ssize_t tcm_loop_tpg_store_nexus(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_loop_tpg_nexus_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg,
struct tcm_loop_tpg, tl_se_tpg);
struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba;
@ -992,12 +988,10 @@ check_newline:
return count;
}
TF_TPG_BASE_ATTR(tcm_loop, nexus, S_IRUGO | S_IWUSR);
static ssize_t tcm_loop_tpg_show_transport_status(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_loop_tpg_transport_status_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg,
struct tcm_loop_tpg, tl_se_tpg);
const char *status = NULL;
@ -1020,11 +1014,10 @@ static ssize_t tcm_loop_tpg_show_transport_status(
return ret;
}
static ssize_t tcm_loop_tpg_store_transport_status(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_loop_tpg_transport_status_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct tcm_loop_tpg *tl_tpg = container_of(se_tpg,
struct tcm_loop_tpg, tl_se_tpg);
@ -1044,11 +1037,12 @@ static ssize_t tcm_loop_tpg_store_transport_status(
return -EINVAL;
}
TF_TPG_BASE_ATTR(tcm_loop, transport_status, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(tcm_loop_tpg_, nexus);
CONFIGFS_ATTR(tcm_loop_tpg_, transport_status);
static struct configfs_attribute *tcm_loop_tpg_attrs[] = {
&tcm_loop_tpg_nexus.attr,
&tcm_loop_tpg_transport_status.attr,
&tcm_loop_tpg_attr_nexus,
&tcm_loop_tpg_attr_transport_status,
NULL,
};
@ -1216,17 +1210,15 @@ static void tcm_loop_drop_scsi_hba(
}
/* Start items for tcm_loop_cit */
static ssize_t tcm_loop_wwn_show_attr_version(
struct target_fabric_configfs *tf,
char *page)
static ssize_t tcm_loop_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "TCM Loopback Fabric module %s\n", TCM_LOOP_VERSION);
}
TF_WWN_ATTR_RO(tcm_loop, version);
CONFIGFS_ATTR_RO(tcm_loop_wwn_, version);
static struct configfs_attribute *tcm_loop_wwn_attrs[] = {
&tcm_loop_wwn_version.attr,
&tcm_loop_wwn_attr_version,
NULL,
};

Просмотреть файл

@ -35,8 +35,6 @@
#include <target/target_core_base.h>
#include <target/target_core_backend.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include <asm/unaligned.h>
#include "sbp_target.h"
@ -2111,24 +2109,21 @@ static void sbp_drop_tport(struct se_wwn *wwn)
kfree(tport);
}
static ssize_t sbp_wwn_show_attr_version(
struct target_fabric_configfs *tf,
char *page)
static ssize_t sbp_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "FireWire SBP fabric module %s\n", SBP_VERSION);
}
TF_WWN_ATTR_RO(sbp, version);
CONFIGFS_ATTR_RO(sbp_wwn_, version);
static struct configfs_attribute *sbp_wwn_attrs[] = {
&sbp_wwn_version.attr,
&sbp_wwn_attr_version,
NULL,
};
static ssize_t sbp_tpg_show_directory_id(
struct se_portal_group *se_tpg,
char *page)
static ssize_t sbp_tpg_directory_id_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
@ -2138,11 +2133,10 @@ static ssize_t sbp_tpg_show_directory_id(
return sprintf(page, "%06x\n", tport->directory_id);
}
static ssize_t sbp_tpg_store_directory_id(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t sbp_tpg_directory_id_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
unsigned long val;
@ -2166,20 +2160,18 @@ static ssize_t sbp_tpg_store_directory_id(
return count;
}
static ssize_t sbp_tpg_show_enable(
struct se_portal_group *se_tpg,
char *page)
static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
return sprintf(page, "%d\n", tport->enable);
}
static ssize_t sbp_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t sbp_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
unsigned long val;
@ -2219,29 +2211,28 @@ static ssize_t sbp_tpg_store_enable(
return count;
}
TF_TPG_BASE_ATTR(sbp, directory_id, S_IRUGO | S_IWUSR);
TF_TPG_BASE_ATTR(sbp, enable, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(sbp_tpg_, directory_id);
CONFIGFS_ATTR(sbp_tpg_, enable);
static struct configfs_attribute *sbp_tpg_base_attrs[] = {
&sbp_tpg_directory_id.attr,
&sbp_tpg_enable.attr,
&sbp_tpg_attr_directory_id,
&sbp_tpg_attr_enable,
NULL,
};
static ssize_t sbp_tpg_attrib_show_mgt_orb_timeout(
struct se_portal_group *se_tpg,
static ssize_t sbp_tpg_attrib_mgt_orb_timeout_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
return sprintf(page, "%d\n", tport->mgt_orb_timeout);
}
static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t sbp_tpg_attrib_mgt_orb_timeout_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
unsigned long val;
@ -2264,20 +2255,19 @@ static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout(
return count;
}
static ssize_t sbp_tpg_attrib_show_max_reconnect_timeout(
struct se_portal_group *se_tpg,
static ssize_t sbp_tpg_attrib_max_reconnect_timeout_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
return sprintf(page, "%d\n", tport->max_reconnect_timeout);
}
static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t sbp_tpg_attrib_max_reconnect_timeout_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
unsigned long val;
@ -2300,20 +2290,19 @@ static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout(
return count;
}
static ssize_t sbp_tpg_attrib_show_max_logins_per_lun(
struct se_portal_group *se_tpg,
static ssize_t sbp_tpg_attrib_max_logins_per_lun_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
return sprintf(page, "%d\n", tport->max_logins_per_lun);
}
static ssize_t sbp_tpg_attrib_store_max_logins_per_lun(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t sbp_tpg_attrib_max_logins_per_lun_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg);
struct sbp_tport *tport = tpg->tport;
unsigned long val;
@ -2330,14 +2319,14 @@ static ssize_t sbp_tpg_attrib_store_max_logins_per_lun(
return count;
}
TF_TPG_ATTRIB_ATTR(sbp, mgt_orb_timeout, S_IRUGO | S_IWUSR);
TF_TPG_ATTRIB_ATTR(sbp, max_reconnect_timeout, S_IRUGO | S_IWUSR);
TF_TPG_ATTRIB_ATTR(sbp, max_logins_per_lun, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(sbp_tpg_attrib_, mgt_orb_timeout);
CONFIGFS_ATTR(sbp_tpg_attrib_, max_reconnect_timeout);
CONFIGFS_ATTR(sbp_tpg_attrib_, max_logins_per_lun);
static struct configfs_attribute *sbp_tpg_attrib_attrs[] = {
&sbp_tpg_attrib_mgt_orb_timeout.attr,
&sbp_tpg_attrib_max_reconnect_timeout.attr,
&sbp_tpg_attrib_max_logins_per_lun.attr,
&sbp_tpg_attrib_attr_mgt_orb_timeout,
&sbp_tpg_attrib_attr_max_reconnect_timeout,
&sbp_tpg_attrib_attr_max_logins_per_lun,
NULL,
};

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -35,8 +35,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include "target_core_internal.h"
#include "target_core_alua.h"
@ -152,17 +150,16 @@ static int target_fabric_mappedlun_unlink(
return core_dev_del_initiator_node_lun_acl(lun, lacl);
}
CONFIGFS_EATTR_STRUCT(target_fabric_mappedlun, se_lun_acl);
#define TCM_MAPPEDLUN_ATTR(_name, _mode) \
static struct target_fabric_mappedlun_attribute target_fabric_mappedlun_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
target_fabric_mappedlun_show_##_name, \
target_fabric_mappedlun_store_##_name);
static ssize_t target_fabric_mappedlun_show_write_protect(
struct se_lun_acl *lacl,
char *page)
static struct se_lun_acl *item_to_lun_acl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_lun_acl,
se_lun_group);
}
static ssize_t target_fabric_mappedlun_write_protect_show(
struct config_item *item, char *page)
{
struct se_lun_acl *lacl = item_to_lun_acl(item);
struct se_node_acl *se_nacl = lacl->se_lun_nacl;
struct se_dev_entry *deve;
ssize_t len = 0;
@ -178,11 +175,10 @@ static ssize_t target_fabric_mappedlun_show_write_protect(
return len;
}
static ssize_t target_fabric_mappedlun_store_write_protect(
struct se_lun_acl *lacl,
const char *page,
size_t count)
static ssize_t target_fabric_mappedlun_write_protect_store(
struct config_item *item, const char *page, size_t count)
{
struct se_lun_acl *lacl = item_to_lun_acl(item);
struct se_node_acl *se_nacl = lacl->se_lun_nacl;
struct se_portal_group *se_tpg = se_nacl->se_tpg;
unsigned long op;
@ -209,9 +205,12 @@ static ssize_t target_fabric_mappedlun_store_write_protect(
}
TCM_MAPPEDLUN_ATTR(write_protect, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(target_fabric_mappedlun_, write_protect);
CONFIGFS_EATTR_OPS(target_fabric_mappedlun, se_lun_acl, se_lun_group);
static struct configfs_attribute *target_fabric_mappedlun_attrs[] = {
&target_fabric_mappedlun_attr_write_protect,
NULL,
};
static void target_fabric_mappedlun_release(struct config_item *item)
{
@ -222,15 +221,8 @@ static void target_fabric_mappedlun_release(struct config_item *item)
core_dev_free_initiator_node_lun_acl(se_tpg, lacl);
}
static struct configfs_attribute *target_fabric_mappedlun_attrs[] = {
&target_fabric_mappedlun_write_protect.attr,
NULL,
};
static struct configfs_item_operations target_fabric_mappedlun_item_ops = {
.release = target_fabric_mappedlun_release,
.show_attribute = target_fabric_mappedlun_attr_show,
.store_attribute = target_fabric_mappedlun_attr_store,
.allow_link = target_fabric_mappedlun_link,
.drop_link = target_fabric_mappedlun_unlink,
};
@ -266,49 +258,12 @@ TF_CIT_SETUP(tpg_mappedlun_stat, NULL, &target_fabric_mappedlun_stat_group_ops,
/* End of tfc_tpg_mappedlun_port_cit */
/* Start of tfc_tpg_nacl_attrib_cit */
CONFIGFS_EATTR_OPS(target_fabric_nacl_attrib, se_node_acl, acl_attrib_group);
static struct configfs_item_operations target_fabric_nacl_attrib_item_ops = {
.show_attribute = target_fabric_nacl_attrib_attr_show,
.store_attribute = target_fabric_nacl_attrib_attr_store,
};
TF_CIT_SETUP_DRV(tpg_nacl_attrib, &target_fabric_nacl_attrib_item_ops, NULL);
/* End of tfc_tpg_nacl_attrib_cit */
/* Start of tfc_tpg_nacl_auth_cit */
CONFIGFS_EATTR_OPS(target_fabric_nacl_auth, se_node_acl, acl_auth_group);
static struct configfs_item_operations target_fabric_nacl_auth_item_ops = {
.show_attribute = target_fabric_nacl_auth_attr_show,
.store_attribute = target_fabric_nacl_auth_attr_store,
};
TF_CIT_SETUP_DRV(tpg_nacl_auth, &target_fabric_nacl_auth_item_ops, NULL);
/* End of tfc_tpg_nacl_auth_cit */
/* Start of tfc_tpg_nacl_param_cit */
CONFIGFS_EATTR_OPS(target_fabric_nacl_param, se_node_acl, acl_param_group);
static struct configfs_item_operations target_fabric_nacl_param_item_ops = {
.show_attribute = target_fabric_nacl_param_attr_show,
.store_attribute = target_fabric_nacl_param_attr_store,
};
TF_CIT_SETUP_DRV(tpg_nacl_param, &target_fabric_nacl_param_item_ops, NULL);
/* End of tfc_tpg_nacl_param_cit */
TF_CIT_SETUP_DRV(tpg_nacl_attrib, NULL, NULL);
TF_CIT_SETUP_DRV(tpg_nacl_auth, NULL, NULL);
TF_CIT_SETUP_DRV(tpg_nacl_param, NULL, NULL);
/* Start of tfc_tpg_nacl_base_cit */
CONFIGFS_EATTR_OPS(target_fabric_nacl_base, se_node_acl, acl_group);
static struct config_group *target_fabric_make_mappedlun(
struct config_group *group,
const char *name)
@ -438,8 +393,6 @@ static void target_fabric_nacl_base_release(struct config_item *item)
static struct configfs_item_operations target_fabric_nacl_base_item_ops = {
.release = target_fabric_nacl_base_release,
.show_attribute = target_fabric_nacl_base_attr_show,
.store_attribute = target_fabric_nacl_base_attr_store,
};
static struct configfs_group_operations target_fabric_nacl_base_group_ops = {
@ -540,8 +493,6 @@ TF_CIT_SETUP(tpg_nacl, NULL, &target_fabric_nacl_group_ops, NULL);
/* Start of tfc_tpg_np_base_cit */
CONFIGFS_EATTR_OPS(target_fabric_np_base, se_tpg_np, tpg_np_group);
static void target_fabric_np_base_release(struct config_item *item)
{
struct se_tpg_np *se_tpg_np = container_of(to_config_group(item),
@ -554,8 +505,6 @@ static void target_fabric_np_base_release(struct config_item *item)
static struct configfs_item_operations target_fabric_np_base_item_ops = {
.release = target_fabric_np_base_release,
.show_attribute = target_fabric_np_base_attr_show,
.store_attribute = target_fabric_np_base_attr_store,
};
TF_CIT_SETUP_DRV(tpg_np_base, &target_fabric_np_base_item_ops, NULL);
@ -610,132 +559,113 @@ TF_CIT_SETUP(tpg_np, NULL, &target_fabric_np_group_ops, NULL);
/* Start of tfc_tpg_port_cit */
CONFIGFS_EATTR_STRUCT(target_fabric_port, se_lun);
#define TCM_PORT_ATTR(_name, _mode) \
static struct target_fabric_port_attribute target_fabric_port_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
target_fabric_port_show_attr_##_name, \
target_fabric_port_store_attr_##_name);
#define TCM_PORT_ATTOR_RO(_name) \
__CONFIGFS_EATTR_RO(_name, \
target_fabric_port_show_attr_##_name);
/*
* alua_tg_pt_gp
*/
static ssize_t target_fabric_port_show_attr_alua_tg_pt_gp(
struct se_lun *lun,
char *page)
static struct se_lun *item_to_lun(struct config_item *item)
{
return container_of(to_config_group(item), struct se_lun,
lun_group);
}
static ssize_t target_fabric_port_alua_tg_pt_gp_show(struct config_item *item,
char *page)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_show_tg_pt_gp_info(lun, page);
}
static ssize_t target_fabric_port_store_attr_alua_tg_pt_gp(
struct se_lun *lun,
const char *page,
size_t count)
static ssize_t target_fabric_port_alua_tg_pt_gp_store(struct config_item *item,
const char *page, size_t count)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_store_tg_pt_gp_info(lun, page, count);
}
TCM_PORT_ATTR(alua_tg_pt_gp, S_IRUGO | S_IWUSR);
/*
* alua_tg_pt_offline
*/
static ssize_t target_fabric_port_show_attr_alua_tg_pt_offline(
struct se_lun *lun,
char *page)
static ssize_t target_fabric_port_alua_tg_pt_offline_show(
struct config_item *item, char *page)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_show_offline_bit(lun, page);
}
static ssize_t target_fabric_port_store_attr_alua_tg_pt_offline(
struct se_lun *lun,
const char *page,
size_t count)
static ssize_t target_fabric_port_alua_tg_pt_offline_store(
struct config_item *item, const char *page, size_t count)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_store_offline_bit(lun, page, count);
}
TCM_PORT_ATTR(alua_tg_pt_offline, S_IRUGO | S_IWUSR);
/*
* alua_tg_pt_status
*/
static ssize_t target_fabric_port_show_attr_alua_tg_pt_status(
struct se_lun *lun,
char *page)
static ssize_t target_fabric_port_alua_tg_pt_status_show(
struct config_item *item, char *page)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_show_secondary_status(lun, page);
}
static ssize_t target_fabric_port_store_attr_alua_tg_pt_status(
struct se_lun *lun,
const char *page,
size_t count)
static ssize_t target_fabric_port_alua_tg_pt_status_store(
struct config_item *item, const char *page, size_t count)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_store_secondary_status(lun, page, count);
}
TCM_PORT_ATTR(alua_tg_pt_status, S_IRUGO | S_IWUSR);
/*
* alua_tg_pt_write_md
*/
static ssize_t target_fabric_port_show_attr_alua_tg_pt_write_md(
struct se_lun *lun,
char *page)
static ssize_t target_fabric_port_alua_tg_pt_write_md_show(
struct config_item *item, char *page)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_show_secondary_write_metadata(lun, page);
}
static ssize_t target_fabric_port_store_attr_alua_tg_pt_write_md(
struct se_lun *lun,
const char *page,
size_t count)
static ssize_t target_fabric_port_alua_tg_pt_write_md_store(
struct config_item *item, const char *page, size_t count)
{
struct se_lun *lun = item_to_lun(item);
if (!lun || !lun->lun_se_dev)
return -ENODEV;
return core_alua_store_secondary_write_metadata(lun, page, count);
}
TCM_PORT_ATTR(alua_tg_pt_write_md, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_gp);
CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_offline);
CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_status);
CONFIGFS_ATTR(target_fabric_port_, alua_tg_pt_write_md);
static struct configfs_attribute *target_fabric_port_attrs[] = {
&target_fabric_port_alua_tg_pt_gp.attr,
&target_fabric_port_alua_tg_pt_offline.attr,
&target_fabric_port_alua_tg_pt_status.attr,
&target_fabric_port_alua_tg_pt_write_md.attr,
&target_fabric_port_attr_alua_tg_pt_gp,
&target_fabric_port_attr_alua_tg_pt_offline,
&target_fabric_port_attr_alua_tg_pt_status,
&target_fabric_port_attr_alua_tg_pt_write_md,
NULL,
};
CONFIGFS_EATTR_OPS(target_fabric_port, se_lun, lun_group);
static int target_fabric_port_link(
struct config_item *lun_ci,
struct config_item *se_dev_ci)
@ -821,8 +751,6 @@ static void target_fabric_port_release(struct config_item *item)
}
static struct configfs_item_operations target_fabric_port_item_ops = {
.show_attribute = target_fabric_port_attr_show,
.store_attribute = target_fabric_port_attr_store,
.release = target_fabric_port_release,
.allow_link = target_fabric_port_link,
.drop_link = target_fabric_port_unlink,
@ -952,50 +880,11 @@ TF_CIT_SETUP(tpg_lun, NULL, &target_fabric_lun_group_ops, NULL);
/* End of tfc_tpg_lun_cit */
/* Start of tfc_tpg_attrib_cit */
CONFIGFS_EATTR_OPS(target_fabric_tpg_attrib, se_portal_group, tpg_attrib_group);
static struct configfs_item_operations target_fabric_tpg_attrib_item_ops = {
.show_attribute = target_fabric_tpg_attrib_attr_show,
.store_attribute = target_fabric_tpg_attrib_attr_store,
};
TF_CIT_SETUP_DRV(tpg_attrib, &target_fabric_tpg_attrib_item_ops, NULL);
/* End of tfc_tpg_attrib_cit */
/* Start of tfc_tpg_auth_cit */
CONFIGFS_EATTR_OPS(target_fabric_tpg_auth, se_portal_group, tpg_auth_group);
static struct configfs_item_operations target_fabric_tpg_auth_item_ops = {
.show_attribute = target_fabric_tpg_auth_attr_show,
.store_attribute = target_fabric_tpg_auth_attr_store,
};
TF_CIT_SETUP_DRV(tpg_auth, &target_fabric_tpg_auth_item_ops, NULL);
/* End of tfc_tpg_attrib_cit */
/* Start of tfc_tpg_param_cit */
CONFIGFS_EATTR_OPS(target_fabric_tpg_param, se_portal_group, tpg_param_group);
static struct configfs_item_operations target_fabric_tpg_param_item_ops = {
.show_attribute = target_fabric_tpg_param_attr_show,
.store_attribute = target_fabric_tpg_param_attr_store,
};
TF_CIT_SETUP_DRV(tpg_param, &target_fabric_tpg_param_item_ops, NULL);
/* End of tfc_tpg_param_cit */
TF_CIT_SETUP_DRV(tpg_attrib, NULL, NULL);
TF_CIT_SETUP_DRV(tpg_auth, NULL, NULL);
TF_CIT_SETUP_DRV(tpg_param, NULL, NULL);
/* Start of tfc_tpg_base_cit */
/*
* For use with TF_TPG_ATTR() and TF_TPG_ATTR_RO()
*/
CONFIGFS_EATTR_OPS(target_fabric_tpg, se_portal_group, tpg_group);
static void target_fabric_tpg_release(struct config_item *item)
{
@ -1009,8 +898,6 @@ static void target_fabric_tpg_release(struct config_item *item)
static struct configfs_item_operations target_fabric_tpg_base_item_ops = {
.release = target_fabric_tpg_release,
.show_attribute = target_fabric_tpg_attr_show,
.store_attribute = target_fabric_tpg_attr_store,
};
TF_CIT_SETUP_DRV(tpg_base, &target_fabric_tpg_base_item_ops, NULL);
@ -1176,33 +1063,9 @@ static struct configfs_group_operations target_fabric_wwn_group_ops = {
.make_group = target_fabric_make_wwn,
.drop_item = target_fabric_drop_wwn,
};
/*
* For use with TF_WWN_ATTR() and TF_WWN_ATTR_RO()
*/
CONFIGFS_EATTR_OPS(target_fabric_wwn, target_fabric_configfs, tf_group);
static struct configfs_item_operations target_fabric_wwn_item_ops = {
.show_attribute = target_fabric_wwn_attr_show,
.store_attribute = target_fabric_wwn_attr_store,
};
TF_CIT_SETUP_DRV(wwn, &target_fabric_wwn_item_ops, &target_fabric_wwn_group_ops);
/* End of tfc_wwn_cit */
/* Start of tfc_discovery_cit */
CONFIGFS_EATTR_OPS(target_fabric_discovery, target_fabric_configfs,
tf_disc_group);
static struct configfs_item_operations target_fabric_discovery_item_ops = {
.show_attribute = target_fabric_discovery_attr_show,
.store_attribute = target_fabric_discovery_attr_store,
};
TF_CIT_SETUP_DRV(discovery, &target_fabric_discovery_item_ops, NULL);
/* End of tfc_discovery_cit */
TF_CIT_SETUP_DRV(wwn, NULL, &target_fabric_wwn_group_ops);
TF_CIT_SETUP_DRV(discovery, NULL, NULL);
int target_fabric_setup_cits(struct target_fabric_configfs *tf)
{

Просмотреть файл

@ -87,6 +87,9 @@ void target_free_device(struct se_device *);
/* target_core_configfs.c */
void target_setup_backend_cits(struct target_backend *);
/* target_core_fabric_configfs.c */
int target_fabric_setup_cits(struct target_fabric_configfs *);
/* target_core_fabric_lib.c */
int target_get_pr_transport_id_len(struct se_node_acl *nacl,
struct t10_pr_registration *pr_reg, int *format_code);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -36,7 +36,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/configfs_macros.h>
#include "tcm_fc.h"

Просмотреть файл

@ -38,8 +38,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include "tcm_fc.h"
@ -131,55 +129,51 @@ static ssize_t ft_wwn_store(void *arg, const char *buf, size_t len)
* ACL auth ops.
*/
static ssize_t ft_nacl_show_port_name(
struct se_node_acl *se_nacl,
char *page)
static ssize_t ft_nacl_port_name_show(struct config_item *item, char *page)
{
struct se_node_acl *se_nacl = acl_to_nacl(item);
struct ft_node_acl *acl = container_of(se_nacl,
struct ft_node_acl, se_node_acl);
return ft_wwn_show(&acl->node_auth.port_name, page);
}
static ssize_t ft_nacl_store_port_name(
struct se_node_acl *se_nacl,
const char *page,
size_t count)
static ssize_t ft_nacl_port_name_store(struct config_item *item,
const char *page, size_t count)
{
struct se_node_acl *se_nacl = acl_to_nacl(item);
struct ft_node_acl *acl = container_of(se_nacl,
struct ft_node_acl, se_node_acl);
return ft_wwn_store(&acl->node_auth.port_name, page, count);
}
TF_NACL_BASE_ATTR(ft, port_name, S_IRUGO | S_IWUSR);
static ssize_t ft_nacl_show_node_name(
struct se_node_acl *se_nacl,
char *page)
static ssize_t ft_nacl_node_name_show(struct config_item *item,
char *page)
{
struct se_node_acl *se_nacl = acl_to_nacl(item);
struct ft_node_acl *acl = container_of(se_nacl,
struct ft_node_acl, se_node_acl);
return ft_wwn_show(&acl->node_auth.node_name, page);
}
static ssize_t ft_nacl_store_node_name(
struct se_node_acl *se_nacl,
const char *page,
size_t count)
static ssize_t ft_nacl_node_name_store(struct config_item *item,
const char *page, size_t count)
{
struct se_node_acl *se_nacl = acl_to_nacl(item);
struct ft_node_acl *acl = container_of(se_nacl,
struct ft_node_acl, se_node_acl);
return ft_wwn_store(&acl->node_auth.node_name, page, count);
}
TF_NACL_BASE_ATTR(ft, node_name, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(ft_nacl_, node_name);
CONFIGFS_ATTR(ft_nacl_, port_name);
static struct configfs_attribute *ft_nacl_base_attrs[] = {
&ft_nacl_port_name.attr,
&ft_nacl_node_name.attr,
&ft_nacl_attr_port_name,
&ft_nacl_attr_node_name,
NULL,
};
@ -386,18 +380,16 @@ static void ft_del_wwn(struct se_wwn *wwn)
kfree(ft_wwn);
}
static ssize_t ft_wwn_show_attr_version(
struct target_fabric_configfs *tf,
char *page)
static ssize_t ft_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "TCM FC " FT_VERSION " on %s/%s on "
""UTS_RELEASE"\n", utsname()->sysname, utsname()->machine);
}
TF_WWN_ATTR_RO(ft, version);
CONFIGFS_ATTR_RO(ft_wwn_, version);
static struct configfs_attribute *ft_wwn_attrs[] = {
&ft_wwn_version.attr,
&ft_wwn_attr_version,
NULL,
};

Просмотреть файл

@ -44,7 +44,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/configfs_macros.h>
#include "tcm_fc.h"

Просмотреть файл

@ -36,7 +36,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/configfs_macros.h>
#include "tcm_fc.h"

Просмотреть файл

@ -64,6 +64,11 @@ struct gadget_info {
char qw_sign[OS_STRING_QW_SIGN_LEN];
};
static inline struct gadget_info *to_gadget_info(struct config_item *item)
{
return container_of(to_config_group(item), struct gadget_info, group);
}
struct config_usb_cfg {
struct config_group group;
struct config_group strings_group;
@ -74,6 +79,12 @@ struct config_usb_cfg {
struct usb_gadget_strings *gstrings[MAX_USB_STRING_LANGS + 1];
};
static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item)
{
return container_of(to_config_group(item), struct config_usb_cfg,
group);
}
struct gadget_strings {
struct usb_gadget_strings stringtab_dev;
struct usb_string strings[USB_GADGET_FIRST_AVAIL_IDX];
@ -117,32 +128,25 @@ static int usb_string_copy(const char *s, char **s_copy)
return 0;
}
CONFIGFS_ATTR_STRUCT(gadget_info);
CONFIGFS_ATTR_STRUCT(config_usb_cfg);
#define GI_DEVICE_DESC_ITEM_ATTR(name) \
static struct gadget_info_attribute gadget_cdev_desc_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
gadget_dev_desc_##name##_show, \
gadget_dev_desc_##name##_store)
#define GI_DEVICE_DESC_SIMPLE_R_u8(__name) \
static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
{ \
return sprintf(page, "0x%02x\n", gi->cdev.desc.__name); \
return sprintf(page, "0x%02x\n", \
to_gadget_info(item)->cdev.desc.__name); \
}
#define GI_DEVICE_DESC_SIMPLE_R_u16(__name) \
static ssize_t gadget_dev_desc_##__name##_show(struct gadget_info *gi, \
static ssize_t gadget_dev_desc_##__name##_show(struct config_item *item, \
char *page) \
{ \
return sprintf(page, "0x%04x\n", le16_to_cpup(&gi->cdev.desc.__name)); \
return sprintf(page, "0x%04x\n", \
le16_to_cpup(&to_gadget_info(item)->cdev.desc.__name)); \
}
#define GI_DEVICE_DESC_SIMPLE_W_u8(_name) \
static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
u8 val; \
@ -150,12 +154,12 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou8(page, 0, &val); \
if (ret) \
return ret; \
gi->cdev.desc._name = val; \
to_gadget_info(item)->cdev.desc._name = val; \
return len; \
}
#define GI_DEVICE_DESC_SIMPLE_W_u16(_name) \
static ssize_t gadget_dev_desc_##_name##_store(struct gadget_info *gi, \
static ssize_t gadget_dev_desc_##_name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
u16 val; \
@ -163,7 +167,7 @@ CONFIGFS_ATTR_STRUCT(config_usb_cfg);
ret = kstrtou16(page, 0, &val); \
if (ret) \
return ret; \
gi->cdev.desc._name = cpu_to_le16p(&val); \
to_gadget_info(item)->cdev.desc._name = cpu_to_le16p(&val); \
return len; \
}
@ -193,7 +197,7 @@ static ssize_t is_valid_bcd(u16 bcd_val)
return 0;
}
static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi,
static ssize_t gadget_dev_desc_bcdDevice_store(struct config_item *item,
const char *page, size_t len)
{
u16 bcdDevice;
@ -206,11 +210,11 @@ static ssize_t gadget_dev_desc_bcdDevice_store(struct gadget_info *gi,
if (ret)
return ret;
gi->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
to_gadget_info(item)->cdev.desc.bcdDevice = cpu_to_le16(bcdDevice);
return len;
}
static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi,
static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item,
const char *page, size_t len)
{
u16 bcdUSB;
@ -223,13 +227,13 @@ static ssize_t gadget_dev_desc_bcdUSB_store(struct gadget_info *gi,
if (ret)
return ret;
gi->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB);
to_gadget_info(item)->cdev.desc.bcdUSB = cpu_to_le16(bcdUSB);
return len;
}
static ssize_t gadget_dev_desc_UDC_show(struct gadget_info *gi, char *page)
static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page)
{
return sprintf(page, "%s\n", gi->udc_name ?: "");
return sprintf(page, "%s\n", to_gadget_info(item)->udc_name ?: "");
}
static int unregister_gadget(struct gadget_info *gi)
@ -247,9 +251,10 @@ static int unregister_gadget(struct gadget_info *gi)
return 0;
}
static ssize_t gadget_dev_desc_UDC_store(struct gadget_info *gi,
static ssize_t gadget_dev_desc_UDC_store(struct config_item *item,
const char *page, size_t len)
{
struct gadget_info *gi = to_gadget_info(item);
char *name;
int ret;
@ -283,34 +288,29 @@ err:
return ret;
}
GI_DEVICE_DESC_ITEM_ATTR(bDeviceClass);
GI_DEVICE_DESC_ITEM_ATTR(bDeviceSubClass);
GI_DEVICE_DESC_ITEM_ATTR(bDeviceProtocol);
GI_DEVICE_DESC_ITEM_ATTR(bMaxPacketSize0);
GI_DEVICE_DESC_ITEM_ATTR(idVendor);
GI_DEVICE_DESC_ITEM_ATTR(idProduct);
GI_DEVICE_DESC_ITEM_ATTR(bcdDevice);
GI_DEVICE_DESC_ITEM_ATTR(bcdUSB);
GI_DEVICE_DESC_ITEM_ATTR(UDC);
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceClass);
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceSubClass);
CONFIGFS_ATTR(gadget_dev_desc_, bDeviceProtocol);
CONFIGFS_ATTR(gadget_dev_desc_, bMaxPacketSize0);
CONFIGFS_ATTR(gadget_dev_desc_, idVendor);
CONFIGFS_ATTR(gadget_dev_desc_, idProduct);
CONFIGFS_ATTR(gadget_dev_desc_, bcdDevice);
CONFIGFS_ATTR(gadget_dev_desc_, bcdUSB);
CONFIGFS_ATTR(gadget_dev_desc_, UDC);
static struct configfs_attribute *gadget_root_attrs[] = {
&gadget_cdev_desc_bDeviceClass.attr,
&gadget_cdev_desc_bDeviceSubClass.attr,
&gadget_cdev_desc_bDeviceProtocol.attr,
&gadget_cdev_desc_bMaxPacketSize0.attr,
&gadget_cdev_desc_idVendor.attr,
&gadget_cdev_desc_idProduct.attr,
&gadget_cdev_desc_bcdDevice.attr,
&gadget_cdev_desc_bcdUSB.attr,
&gadget_cdev_desc_UDC.attr,
&gadget_dev_desc_attr_bDeviceClass,
&gadget_dev_desc_attr_bDeviceSubClass,
&gadget_dev_desc_attr_bDeviceProtocol,
&gadget_dev_desc_attr_bMaxPacketSize0,
&gadget_dev_desc_attr_idVendor,
&gadget_dev_desc_attr_idProduct,
&gadget_dev_desc_attr_bcdDevice,
&gadget_dev_desc_attr_bcdUSB,
&gadget_dev_desc_attr_UDC,
NULL,
};
static inline struct gadget_info *to_gadget_info(struct config_item *item)
{
return container_of(to_config_group(item), struct gadget_info, group);
}
static inline struct gadget_strings *to_gadget_strings(struct config_item *item)
{
return container_of(to_config_group(item), struct gadget_strings,
@ -324,12 +324,6 @@ static inline struct gadget_config_name *to_gadget_config_name(
group);
}
static inline struct config_usb_cfg *to_config_usb_cfg(struct config_item *item)
{
return container_of(to_config_group(item), struct config_usb_cfg,
group);
}
static inline struct usb_function_instance *to_usb_function_instance(
struct config_item *item)
{
@ -348,12 +342,8 @@ static void gadget_info_attr_release(struct config_item *item)
kfree(gi);
}
CONFIGFS_ATTR_OPS(gadget_info);
static struct configfs_item_operations gadget_root_item_ops = {
.release = gadget_info_attr_release,
.show_attribute = gadget_info_attr_show,
.store_attribute = gadget_info_attr_store,
};
static void gadget_config_attr_release(struct config_item *item)
@ -454,24 +444,20 @@ static int config_usb_cfg_unlink(
return 0;
}
CONFIGFS_ATTR_OPS(config_usb_cfg);
static struct configfs_item_operations gadget_config_item_ops = {
.release = gadget_config_attr_release,
.show_attribute = config_usb_cfg_attr_show,
.store_attribute = config_usb_cfg_attr_store,
.allow_link = config_usb_cfg_link,
.drop_link = config_usb_cfg_unlink,
};
static ssize_t gadget_config_desc_MaxPower_show(struct config_usb_cfg *cfg,
static ssize_t gadget_config_desc_MaxPower_show(struct config_item *item,
char *page)
{
return sprintf(page, "%u\n", cfg->c.MaxPower);
return sprintf(page, "%u\n", to_config_usb_cfg(item)->c.MaxPower);
}
static ssize_t gadget_config_desc_MaxPower_store(struct config_usb_cfg *cfg,
static ssize_t gadget_config_desc_MaxPower_store(struct config_item *item,
const char *page, size_t len)
{
u16 val;
@ -481,17 +467,18 @@ static ssize_t gadget_config_desc_MaxPower_store(struct config_usb_cfg *cfg,
return ret;
if (DIV_ROUND_UP(val, 8) > 0xff)
return -ERANGE;
cfg->c.MaxPower = val;
to_config_usb_cfg(item)->c.MaxPower = val;
return len;
}
static ssize_t gadget_config_desc_bmAttributes_show(struct config_usb_cfg *cfg,
static ssize_t gadget_config_desc_bmAttributes_show(struct config_item *item,
char *page)
{
return sprintf(page, "0x%02x\n", cfg->c.bmAttributes);
return sprintf(page, "0x%02x\n",
to_config_usb_cfg(item)->c.bmAttributes);
}
static ssize_t gadget_config_desc_bmAttributes_store(struct config_usb_cfg *cfg,
static ssize_t gadget_config_desc_bmAttributes_store(struct config_item *item,
const char *page, size_t len)
{
u8 val;
@ -504,22 +491,16 @@ static ssize_t gadget_config_desc_bmAttributes_store(struct config_usb_cfg *cfg,
if (val & ~(USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER |
USB_CONFIG_ATT_WAKEUP))
return -EINVAL;
cfg->c.bmAttributes = val;
to_config_usb_cfg(item)->c.bmAttributes = val;
return len;
}
#define CFG_CONFIG_DESC_ITEM_ATTR(name) \
static struct config_usb_cfg_attribute gadget_usb_cfg_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
gadget_config_desc_##name##_show, \
gadget_config_desc_##name##_store)
CFG_CONFIG_DESC_ITEM_ATTR(MaxPower);
CFG_CONFIG_DESC_ITEM_ATTR(bmAttributes);
CONFIGFS_ATTR(gadget_config_desc_, MaxPower);
CONFIGFS_ATTR(gadget_config_desc_, bmAttributes);
static struct configfs_attribute *gadget_config_attrs[] = {
&gadget_usb_cfg_MaxPower.attr,
&gadget_usb_cfg_bmAttributes.attr,
&gadget_config_desc_attr_MaxPower,
&gadget_config_desc_attr_bmAttributes,
NULL,
};
@ -616,11 +597,10 @@ static struct config_item_type functions_type = {
.ct_owner = THIS_MODULE,
};
CONFIGFS_ATTR_STRUCT(gadget_config_name);
GS_STRINGS_RW(gadget_config_name, configuration);
static struct configfs_attribute *gadget_config_name_langid_attrs[] = {
&gadget_config_name_configuration.attr,
&gadget_config_name_attr_configuration,
NULL,
};
@ -719,15 +699,14 @@ static struct config_item_type config_desc_type = {
.ct_owner = THIS_MODULE,
};
CONFIGFS_ATTR_STRUCT(gadget_strings);
GS_STRINGS_RW(gadget_strings, manufacturer);
GS_STRINGS_RW(gadget_strings, product);
GS_STRINGS_RW(gadget_strings, serialnumber);
static struct configfs_attribute *gadget_strings_langid_attrs[] = {
&gadget_strings_manufacturer.attr,
&gadget_strings_product.attr,
&gadget_strings_serialnumber.attr,
&gadget_strings_attr_manufacturer,
&gadget_strings_attr_product,
&gadget_strings_attr_serialnumber,
NULL,
};
@ -751,27 +730,25 @@ static inline struct os_desc *to_os_desc(struct config_item *item)
return container_of(to_config_group(item), struct os_desc, group);
}
CONFIGFS_ATTR_STRUCT(os_desc);
CONFIGFS_ATTR_OPS(os_desc);
static ssize_t os_desc_use_show(struct os_desc *os_desc, char *page)
static inline struct gadget_info *os_desc_item_to_gadget_info(
struct config_item *item)
{
struct gadget_info *gi;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
return sprintf(page, "%d", gi->use_os_desc);
return to_gadget_info(to_os_desc(item)->group.cg_item.ci_parent);
}
static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page,
static ssize_t os_desc_use_show(struct config_item *item, char *page)
{
return sprintf(page, "%d",
os_desc_item_to_gadget_info(item)->use_os_desc);
}
static ssize_t os_desc_use_store(struct config_item *item, const char *page,
size_t len)
{
struct gadget_info *gi;
struct gadget_info *gi = os_desc_item_to_gadget_info(item);
int ret;
bool use;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
mutex_lock(&gi->lock);
ret = strtobool(page, &use);
if (!ret) {
@ -783,29 +760,19 @@ static ssize_t os_desc_use_store(struct os_desc *os_desc, const char *page,
return ret;
}
static struct os_desc_attribute os_desc_use =
__CONFIGFS_ATTR(use, S_IRUGO | S_IWUSR,
os_desc_use_show,
os_desc_use_store);
static ssize_t os_desc_b_vendor_code_show(struct os_desc *os_desc, char *page)
static ssize_t os_desc_b_vendor_code_show(struct config_item *item, char *page)
{
struct gadget_info *gi;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
return sprintf(page, "%d", gi->b_vendor_code);
return sprintf(page, "%d",
os_desc_item_to_gadget_info(item)->b_vendor_code);
}
static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc,
static ssize_t os_desc_b_vendor_code_store(struct config_item *item,
const char *page, size_t len)
{
struct gadget_info *gi;
struct gadget_info *gi = os_desc_item_to_gadget_info(item);
int ret;
u8 b_vendor_code;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
mutex_lock(&gi->lock);
ret = kstrtou8(page, 0, &b_vendor_code);
if (!ret) {
@ -817,29 +784,20 @@ static ssize_t os_desc_b_vendor_code_store(struct os_desc *os_desc,
return ret;
}
static struct os_desc_attribute os_desc_b_vendor_code =
__CONFIGFS_ATTR(b_vendor_code, S_IRUGO | S_IWUSR,
os_desc_b_vendor_code_show,
os_desc_b_vendor_code_store);
static ssize_t os_desc_qw_sign_show(struct os_desc *os_desc, char *page)
static ssize_t os_desc_qw_sign_show(struct config_item *item, char *page)
{
struct gadget_info *gi;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
struct gadget_info *gi = os_desc_item_to_gadget_info(item);
memcpy(page, gi->qw_sign, OS_STRING_QW_SIGN_LEN);
return OS_STRING_QW_SIGN_LEN;
}
static ssize_t os_desc_qw_sign_store(struct os_desc *os_desc, const char *page,
static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page,
size_t len)
{
struct gadget_info *gi;
struct gadget_info *gi = os_desc_item_to_gadget_info(item);
int res, l;
gi = to_gadget_info(os_desc->group.cg_item.ci_parent);
l = min((int)len, OS_STRING_QW_SIGN_LEN >> 1);
if (page[l - 1] == '\n')
--l;
@ -855,15 +813,14 @@ static ssize_t os_desc_qw_sign_store(struct os_desc *os_desc, const char *page,
return res;
}
static struct os_desc_attribute os_desc_qw_sign =
__CONFIGFS_ATTR(qw_sign, S_IRUGO | S_IWUSR,
os_desc_qw_sign_show,
os_desc_qw_sign_store);
CONFIGFS_ATTR(os_desc_, use);
CONFIGFS_ATTR(os_desc_, b_vendor_code);
CONFIGFS_ATTR(os_desc_, qw_sign);
static struct configfs_attribute *os_desc_attrs[] = {
&os_desc_use.attr,
&os_desc_b_vendor_code.attr,
&os_desc_qw_sign.attr,
&os_desc_attr_use,
&os_desc_attr_b_vendor_code,
&os_desc_attr_qw_sign,
NULL,
};
@ -926,8 +883,6 @@ static int os_desc_unlink(struct config_item *os_desc_ci,
static struct configfs_item_operations os_desc_ops = {
.release = os_desc_attr_release,
.show_attribute = os_desc_attr_show,
.store_attribute = os_desc_attr_store,
.allow_link = os_desc_link,
.drop_link = os_desc_unlink,
};
@ -938,28 +893,21 @@ static struct config_item_type os_desc_type = {
.ct_owner = THIS_MODULE,
};
CONFIGFS_ATTR_STRUCT(usb_os_desc);
CONFIGFS_ATTR_OPS(usb_os_desc);
static inline struct usb_os_desc_ext_prop
*to_usb_os_desc_ext_prop(struct config_item *item)
{
return container_of(item, struct usb_os_desc_ext_prop, item);
}
CONFIGFS_ATTR_STRUCT(usb_os_desc_ext_prop);
CONFIGFS_ATTR_OPS(usb_os_desc_ext_prop);
static ssize_t ext_prop_type_show(struct usb_os_desc_ext_prop *ext_prop,
char *page)
static ssize_t ext_prop_type_show(struct config_item *item, char *page)
{
return sprintf(page, "%d", ext_prop->type);
return sprintf(page, "%d", to_usb_os_desc_ext_prop(item)->type);
}
static ssize_t ext_prop_type_store(struct usb_os_desc_ext_prop *ext_prop,
static ssize_t ext_prop_type_store(struct config_item *item,
const char *page, size_t len)
{
struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item);
struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent);
u8 type;
int ret;
@ -997,9 +945,9 @@ end:
return ret;
}
static ssize_t ext_prop_data_show(struct usb_os_desc_ext_prop *ext_prop,
char *page)
static ssize_t ext_prop_data_show(struct config_item *item, char *page)
{
struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item);
int len = ext_prop->data_len;
if (ext_prop->type == USB_EXT_PROP_UNICODE ||
@ -1011,9 +959,10 @@ static ssize_t ext_prop_data_show(struct usb_os_desc_ext_prop *ext_prop,
return len;
}
static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop,
static ssize_t ext_prop_data_store(struct config_item *item,
const char *page, size_t len)
{
struct usb_os_desc_ext_prop *ext_prop = to_usb_os_desc_ext_prop(item);
struct usb_os_desc *desc = to_usb_os_desc(ext_prop->item.ci_parent);
char *new_data;
size_t ret_len = len;
@ -1044,17 +993,12 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop,
return ret_len;
}
static struct usb_os_desc_ext_prop_attribute ext_prop_type =
__CONFIGFS_ATTR(type, S_IRUGO | S_IWUSR,
ext_prop_type_show, ext_prop_type_store);
static struct usb_os_desc_ext_prop_attribute ext_prop_data =
__CONFIGFS_ATTR(data, S_IRUGO | S_IWUSR,
ext_prop_data_show, ext_prop_data_store);
CONFIGFS_ATTR(ext_prop_, type);
CONFIGFS_ATTR(ext_prop_, data);
static struct configfs_attribute *ext_prop_attrs[] = {
&ext_prop_type.attr,
&ext_prop_data.attr,
&ext_prop_attr_type,
&ext_prop_attr_data,
NULL,
};
@ -1067,8 +1011,6 @@ static void usb_os_desc_ext_prop_release(struct config_item *item)
static struct configfs_item_operations ext_prop_ops = {
.release = usb_os_desc_ext_prop_release,
.show_attribute = usb_os_desc_ext_prop_attr_show,
.store_attribute = usb_os_desc_ext_prop_attr_store,
};
static struct config_item *ext_prop_make(
@ -1137,21 +1079,17 @@ static struct configfs_group_operations interf_grp_ops = {
.drop_item = &ext_prop_drop,
};
static struct configfs_item_operations interf_item_ops = {
.show_attribute = usb_os_desc_attr_show,
.store_attribute = usb_os_desc_attr_store,
};
static ssize_t interf_grp_compatible_id_show(struct usb_os_desc *desc,
static ssize_t interf_grp_compatible_id_show(struct config_item *item,
char *page)
{
memcpy(page, desc->ext_compat_id, 8);
memcpy(page, to_usb_os_desc(item)->ext_compat_id, 8);
return 8;
}
static ssize_t interf_grp_compatible_id_store(struct usb_os_desc *desc,
static ssize_t interf_grp_compatible_id_store(struct config_item *item,
const char *page, size_t len)
{
struct usb_os_desc *desc = to_usb_os_desc(item);
int l;
l = min_t(int, 8, len);
@ -1167,21 +1105,17 @@ static ssize_t interf_grp_compatible_id_store(struct usb_os_desc *desc,
return len;
}
static struct usb_os_desc_attribute interf_grp_attr_compatible_id =
__CONFIGFS_ATTR(compatible_id, S_IRUGO | S_IWUSR,
interf_grp_compatible_id_show,
interf_grp_compatible_id_store);
static ssize_t interf_grp_sub_compatible_id_show(struct usb_os_desc *desc,
static ssize_t interf_grp_sub_compatible_id_show(struct config_item *item,
char *page)
{
memcpy(page, desc->ext_compat_id + 8, 8);
memcpy(page, to_usb_os_desc(item)->ext_compat_id + 8, 8);
return 8;
}
static ssize_t interf_grp_sub_compatible_id_store(struct usb_os_desc *desc,
static ssize_t interf_grp_sub_compatible_id_store(struct config_item *item,
const char *page, size_t len)
{
struct usb_os_desc *desc = to_usb_os_desc(item);
int l;
l = min_t(int, 8, len);
@ -1197,14 +1131,12 @@ static ssize_t interf_grp_sub_compatible_id_store(struct usb_os_desc *desc,
return len;
}
static struct usb_os_desc_attribute interf_grp_attr_sub_compatible_id =
__CONFIGFS_ATTR(sub_compatible_id, S_IRUGO | S_IWUSR,
interf_grp_sub_compatible_id_show,
interf_grp_sub_compatible_id_store);
CONFIGFS_ATTR(interf_grp_, compatible_id);
CONFIGFS_ATTR(interf_grp_, sub_compatible_id);
static struct configfs_attribute *interf_grp_attrs[] = {
&interf_grp_attr_compatible_id.attr,
&interf_grp_attr_sub_compatible_id.attr,
&interf_grp_attr_compatible_id,
&interf_grp_attr_sub_compatible_id,
NULL
};
@ -1242,7 +1174,6 @@ int usb_os_desc_prepare_interf_dir(struct config_group *parent,
f_default_groups[0] = os_desc_group;
os_desc_group->default_groups = interface_groups;
interface_type->ct_item_ops = &interf_item_ops;
interface_type->ct_group_ops = &interf_grp_ops;
interface_type->ct_attrs = interf_grp_attrs;
interface_type->ct_owner = owner;

Просмотреть файл

@ -761,21 +761,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_serial_opts);
static ssize_t f_acm_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
struct f_serial_opts_attribute *f_serial_opts_attr =
container_of(attr, struct f_serial_opts_attribute, attr);
ssize_t ret = 0;
if (f_serial_opts_attr->show)
ret = f_serial_opts_attr->show(opts, page);
return ret;
}
static void acm_attr_release(struct config_item *item)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
@ -785,20 +770,17 @@ static void acm_attr_release(struct config_item *item)
static struct configfs_item_operations acm_item_ops = {
.release = acm_attr_release,
.show_attribute = f_acm_attr_show,
};
static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
{
return sprintf(page, "%u\n", opts->port_num);
return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
}
static struct f_serial_opts_attribute f_acm_port_num =
__CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
CONFIGFS_ATTR_RO(f_acm_port_, num);
static struct configfs_attribute *acm_attrs[] = {
&f_acm_port_num.attr,
&f_acm_port_attr_num,
NULL,
};

Просмотреть файл

@ -838,10 +838,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
static struct configfs_attribute *ecm_attrs[] = {
&f_ecm_opts_dev_addr.attr,
&f_ecm_opts_host_addr.attr,
&f_ecm_opts_qmult.attr,
&f_ecm_opts_ifname.attr,
&ecm_opts_attr_dev_addr,
&ecm_opts_attr_host_addr,
&ecm_opts_attr_qmult,
&ecm_opts_attr_ifname,
NULL,
};

Просмотреть файл

@ -545,10 +545,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
static struct configfs_attribute *eem_attrs[] = {
&f_eem_opts_dev_addr.attr,
&f_eem_opts_host_addr.attr,
&f_eem_opts_qmult.attr,
&f_eem_opts_ifname.attr,
&eem_opts_attr_dev_addr,
&eem_opts_attr_host_addr,
&eem_opts_attr_qmult,
&eem_opts_attr_ifname,
NULL,
};

Просмотреть файл

@ -705,9 +705,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_hid_opts);
CONFIGFS_ATTR_OPS(f_hid_opts);
static void hid_attr_release(struct config_item *item)
{
struct f_hid_opts *opts = to_f_hid_opts(item);
@ -717,13 +714,12 @@ static void hid_attr_release(struct config_item *item)
static struct configfs_item_operations hidg_item_ops = {
.release = hid_attr_release,
.show_attribute = f_hid_opts_attr_show,
.store_attribute = f_hid_opts_attr_store,
};
#define F_HID_OPT(name, prec, limit) \
static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\
{ \
struct f_hid_opts *opts = to_f_hid_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -733,9 +729,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
return result; \
} \
\
static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts, \
static ssize_t f_hid_opts_##name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_hid_opts *opts = to_f_hid_opts(item); \
int ret; \
u##prec num; \
\
@ -761,16 +758,15 @@ end: \
return ret; \
} \
\
static struct f_hid_opts_attribute f_hid_opts_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
f_hid_opts_##name##_store)
CONFIGFS_ATTR(f_hid_opts_, name)
F_HID_OPT(subclass, 8, 255);
F_HID_OPT(protocol, 8, 255);
F_HID_OPT(report_length, 16, 65535);
static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char *page)
{
struct f_hid_opts *opts = to_f_hid_opts(item);
int result;
mutex_lock(&opts->lock);
@ -781,9 +777,10 @@ static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
return result;
}
static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
static ssize_t f_hid_opts_report_desc_store(struct config_item *item,
const char *page, size_t len)
{
struct f_hid_opts *opts = to_f_hid_opts(item);
int ret = -EBUSY;
char *d;
@ -810,16 +807,13 @@ end:
return ret;
}
static struct f_hid_opts_attribute f_hid_opts_report_desc =
__CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
f_hid_opts_report_desc_show,
f_hid_opts_report_desc_store);
CONFIGFS_ATTR(f_hid_opts_, report_desc);
static struct configfs_attribute *hid_attrs[] = {
&f_hid_opts_subclass.attr,
&f_hid_opts_protocol.attr,
&f_hid_opts_report_length.attr,
&f_hid_opts_report_desc.attr,
&f_hid_opts_attr_subclass,
&f_hid_opts_attr_protocol,
&f_hid_opts_attr_report_length,
&f_hid_opts_attr_report_desc,
NULL,
};

Просмотреть файл

@ -465,9 +465,6 @@ static inline struct f_lb_opts *to_f_lb_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_lb_opts);
CONFIGFS_ATTR_OPS(f_lb_opts);
static void lb_attr_release(struct config_item *item)
{
struct f_lb_opts *lb_opts = to_f_lb_opts(item);
@ -477,12 +474,11 @@ static void lb_attr_release(struct config_item *item)
static struct configfs_item_operations lb_item_ops = {
.release = lb_attr_release,
.show_attribute = f_lb_opts_attr_show,
.store_attribute = f_lb_opts_attr_store,
};
static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page)
static ssize_t f_lb_opts_qlen_show(struct config_item *item, char *page)
{
struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
mutex_lock(&opts->lock);
@ -492,9 +488,10 @@ static ssize_t f_lb_opts_qlen_show(struct f_lb_opts *opts, char *page)
return result;
}
static ssize_t f_lb_opts_qlen_store(struct f_lb_opts *opts,
static ssize_t f_lb_opts_qlen_store(struct config_item *item,
const char *page, size_t len)
{
struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
@ -515,13 +512,11 @@ end:
return ret;
}
static struct f_lb_opts_attribute f_lb_opts_qlen =
__CONFIGFS_ATTR(qlen, S_IRUGO | S_IWUSR,
f_lb_opts_qlen_show,
f_lb_opts_qlen_store);
CONFIGFS_ATTR(f_lb_opts_, qlen);
static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page)
static ssize_t f_lb_opts_bulk_buflen_show(struct config_item *item, char *page)
{
struct f_lb_opts *opts = to_f_lb_opts(item);
int result;
mutex_lock(&opts->lock);
@ -531,9 +526,10 @@ static ssize_t f_lb_opts_bulk_buflen_show(struct f_lb_opts *opts, char *page)
return result;
}
static ssize_t f_lb_opts_bulk_buflen_store(struct f_lb_opts *opts,
static ssize_t f_lb_opts_bulk_buflen_store(struct config_item *item,
const char *page, size_t len)
{
struct f_lb_opts *opts = to_f_lb_opts(item);
int ret;
u32 num;
@ -554,14 +550,11 @@ end:
return ret;
}
static struct f_lb_opts_attribute f_lb_opts_bulk_buflen =
__CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR,
f_lb_opts_bulk_buflen_show,
f_lb_opts_bulk_buflen_store);
CONFIGFS_ATTR(f_lb_opts_, bulk_buflen);
static struct configfs_attribute *lb_attrs[] = {
&f_lb_opts_qlen.attr,
&f_lb_opts_bulk_buflen.attr,
&f_lb_opts_attr_qlen,
&f_lb_opts_attr_bulk_buflen,
NULL,
};

Просмотреть файл

@ -3140,9 +3140,6 @@ static inline struct fsg_opts *to_fsg_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(fsg_lun_opts);
CONFIGFS_ATTR_OPS(fsg_lun_opts);
static void fsg_lun_attr_release(struct config_item *item)
{
struct fsg_lun_opts *lun_opts;
@ -3153,110 +3150,93 @@ static void fsg_lun_attr_release(struct config_item *item)
static struct configfs_item_operations fsg_lun_item_ops = {
.release = fsg_lun_attr_release,
.show_attribute = fsg_lun_opts_attr_show,
.store_attribute = fsg_lun_opts_attr_store,
};
static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page)
static ssize_t fsg_lun_opts_file_show(struct config_item *item, char *page)
{
struct fsg_opts *fsg_opts;
fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
return fsg_show_file(opts->lun, &fsg_opts->common->filesem, page);
}
static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_file_store(struct config_item *item,
const char *page, size_t len)
{
struct fsg_opts *fsg_opts;
fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
return fsg_store_file(opts->lun, &fsg_opts->common->filesem, page, len);
}
static struct fsg_lun_opts_attribute fsg_lun_opts_file =
__CONFIGFS_ATTR(file, S_IRUGO | S_IWUSR, fsg_lun_opts_file_show,
fsg_lun_opts_file_store);
CONFIGFS_ATTR(fsg_lun_opts_, file);
static ssize_t fsg_lun_opts_ro_show(struct fsg_lun_opts *opts, char *page)
static ssize_t fsg_lun_opts_ro_show(struct config_item *item, char *page)
{
return fsg_show_ro(opts->lun, page);
return fsg_show_ro(to_fsg_lun_opts(item)->lun, page);
}
static ssize_t fsg_lun_opts_ro_store(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_ro_store(struct config_item *item,
const char *page, size_t len)
{
struct fsg_opts *fsg_opts;
fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
return fsg_store_ro(opts->lun, &fsg_opts->common->filesem, page, len);
}
static struct fsg_lun_opts_attribute fsg_lun_opts_ro =
__CONFIGFS_ATTR(ro, S_IRUGO | S_IWUSR, fsg_lun_opts_ro_show,
fsg_lun_opts_ro_store);
CONFIGFS_ATTR(fsg_lun_opts_, ro);
static ssize_t fsg_lun_opts_removable_show(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_removable_show(struct config_item *item,
char *page)
{
return fsg_show_removable(opts->lun, page);
return fsg_show_removable(to_fsg_lun_opts(item)->lun, page);
}
static ssize_t fsg_lun_opts_removable_store(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_removable_store(struct config_item *item,
const char *page, size_t len)
{
return fsg_store_removable(opts->lun, page, len);
return fsg_store_removable(to_fsg_lun_opts(item)->lun, page, len);
}
static struct fsg_lun_opts_attribute fsg_lun_opts_removable =
__CONFIGFS_ATTR(removable, S_IRUGO | S_IWUSR,
fsg_lun_opts_removable_show,
fsg_lun_opts_removable_store);
CONFIGFS_ATTR(fsg_lun_opts_, removable);
static ssize_t fsg_lun_opts_cdrom_show(struct fsg_lun_opts *opts, char *page)
static ssize_t fsg_lun_opts_cdrom_show(struct config_item *item, char *page)
{
return fsg_show_cdrom(opts->lun, page);
return fsg_show_cdrom(to_fsg_lun_opts(item)->lun, page);
}
static ssize_t fsg_lun_opts_cdrom_store(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_cdrom_store(struct config_item *item,
const char *page, size_t len)
{
struct fsg_opts *fsg_opts;
fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
struct fsg_lun_opts *opts = to_fsg_lun_opts(item);
struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent);
return fsg_store_cdrom(opts->lun, &fsg_opts->common->filesem, page,
len);
}
static struct fsg_lun_opts_attribute fsg_lun_opts_cdrom =
__CONFIGFS_ATTR(cdrom, S_IRUGO | S_IWUSR, fsg_lun_opts_cdrom_show,
fsg_lun_opts_cdrom_store);
CONFIGFS_ATTR(fsg_lun_opts_, cdrom);
static ssize_t fsg_lun_opts_nofua_show(struct fsg_lun_opts *opts, char *page)
static ssize_t fsg_lun_opts_nofua_show(struct config_item *item, char *page)
{
return fsg_show_nofua(opts->lun, page);
return fsg_show_nofua(to_fsg_lun_opts(item)->lun, page);
}
static ssize_t fsg_lun_opts_nofua_store(struct fsg_lun_opts *opts,
static ssize_t fsg_lun_opts_nofua_store(struct config_item *item,
const char *page, size_t len)
{
return fsg_store_nofua(opts->lun, page, len);
return fsg_store_nofua(to_fsg_lun_opts(item)->lun, page, len);
}
static struct fsg_lun_opts_attribute fsg_lun_opts_nofua =
__CONFIGFS_ATTR(nofua, S_IRUGO | S_IWUSR, fsg_lun_opts_nofua_show,
fsg_lun_opts_nofua_store);
CONFIGFS_ATTR(fsg_lun_opts_, nofua);
static struct configfs_attribute *fsg_lun_attrs[] = {
&fsg_lun_opts_file.attr,
&fsg_lun_opts_ro.attr,
&fsg_lun_opts_removable.attr,
&fsg_lun_opts_cdrom.attr,
&fsg_lun_opts_nofua.attr,
&fsg_lun_opts_attr_file,
&fsg_lun_opts_attr_ro,
&fsg_lun_opts_attr_removable,
&fsg_lun_opts_attr_cdrom,
&fsg_lun_opts_attr_nofua,
NULL,
};
@ -3348,9 +3328,6 @@ static void fsg_lun_drop(struct config_group *group, struct config_item *item)
config_item_put(item);
}
CONFIGFS_ATTR_STRUCT(fsg_opts);
CONFIGFS_ATTR_OPS(fsg_opts);
static void fsg_attr_release(struct config_item *item)
{
struct fsg_opts *opts = to_fsg_opts(item);
@ -3360,12 +3337,11 @@ static void fsg_attr_release(struct config_item *item)
static struct configfs_item_operations fsg_item_ops = {
.release = fsg_attr_release,
.show_attribute = fsg_opts_attr_show,
.store_attribute = fsg_opts_attr_store,
};
static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page)
static ssize_t fsg_opts_stall_show(struct config_item *item, char *page)
{
struct fsg_opts *opts = to_fsg_opts(item);
int result;
mutex_lock(&opts->lock);
@ -3375,9 +3351,10 @@ static ssize_t fsg_opts_stall_show(struct fsg_opts *opts, char *page)
return result;
}
static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page,
static ssize_t fsg_opts_stall_store(struct config_item *item, const char *page,
size_t len)
{
struct fsg_opts *opts = to_fsg_opts(item);
int ret;
bool stall;
@ -3399,13 +3376,12 @@ static ssize_t fsg_opts_stall_store(struct fsg_opts *opts, const char *page,
return ret;
}
static struct fsg_opts_attribute fsg_opts_stall =
__CONFIGFS_ATTR(stall, S_IRUGO | S_IWUSR, fsg_opts_stall_show,
fsg_opts_stall_store);
CONFIGFS_ATTR(fsg_opts_, stall);
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
static ssize_t fsg_opts_num_buffers_show(struct fsg_opts *opts, char *page)
static ssize_t fsg_opts_num_buffers_show(struct config_item *item, char *page)
{
struct fsg_opts *opts = to_fsg_opts(item);
int result;
mutex_lock(&opts->lock);
@ -3415,9 +3391,10 @@ static ssize_t fsg_opts_num_buffers_show(struct fsg_opts *opts, char *page)
return result;
}
static ssize_t fsg_opts_num_buffers_store(struct fsg_opts *opts,
static ssize_t fsg_opts_num_buffers_store(struct config_item *item,
const char *page, size_t len)
{
struct fsg_opts *opts = to_fsg_opts(item);
int ret;
u8 num;
@ -3442,17 +3419,13 @@ end:
return ret;
}
static struct fsg_opts_attribute fsg_opts_num_buffers =
__CONFIGFS_ATTR(num_buffers, S_IRUGO | S_IWUSR,
fsg_opts_num_buffers_show,
fsg_opts_num_buffers_store);
CONFIGFS_ATTR(fsg_opts_, num_buffers);
#endif
static struct configfs_attribute *fsg_attrs[] = {
&fsg_opts_stall.attr,
&fsg_opts_attr_stall,
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
&fsg_opts_num_buffers.attr,
&fsg_opts_attr_num_buffers,
#endif
NULL,
};

Просмотреть файл

@ -902,9 +902,6 @@ static inline struct f_midi_opts *to_f_midi_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_midi_opts);
CONFIGFS_ATTR_OPS(f_midi_opts);
static void midi_attr_release(struct config_item *item)
{
struct f_midi_opts *opts = to_f_midi_opts(item);
@ -914,13 +911,12 @@ static void midi_attr_release(struct config_item *item)
static struct configfs_item_operations midi_item_ops = {
.release = midi_attr_release,
.show_attribute = f_midi_opts_attr_show,
.store_attribute = f_midi_opts_attr_store,
};
#define F_MIDI_OPT(name, test_limit, limit) \
static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) \
static ssize_t f_midi_opts_##name##_show(struct config_item *item, char *page) \
{ \
struct f_midi_opts *opts = to_f_midi_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -930,9 +926,10 @@ static ssize_t f_midi_opts_##name##_show(struct f_midi_opts *opts, char *page) \
return result; \
} \
\
static ssize_t f_midi_opts_##name##_store(struct f_midi_opts *opts, \
static ssize_t f_midi_opts_##name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_midi_opts *opts = to_f_midi_opts(item); \
int ret; \
u32 num; \
\
@ -958,9 +955,7 @@ end: \
return ret; \
} \
\
static struct f_midi_opts_attribute f_midi_opts_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_midi_opts_##name##_show, \
f_midi_opts_##name##_store)
CONFIGFS_ATTR(f_midi_opts_, name);
F_MIDI_OPT(index, true, SNDRV_CARDS);
F_MIDI_OPT(buflen, false, 0);
@ -968,8 +963,9 @@ F_MIDI_OPT(qlen, false, 0);
F_MIDI_OPT(in_ports, true, MAX_PORTS);
F_MIDI_OPT(out_ports, true, MAX_PORTS);
static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
static ssize_t f_midi_opts_id_show(struct config_item *item, char *page)
{
struct f_midi_opts *opts = to_f_midi_opts(item);
int result;
mutex_lock(&opts->lock);
@ -985,9 +981,10 @@ static ssize_t f_midi_opts_id_show(struct f_midi_opts *opts, char *page)
return result;
}
static ssize_t f_midi_opts_id_store(struct f_midi_opts *opts,
static ssize_t f_midi_opts_id_store(struct config_item *item,
const char *page, size_t len)
{
struct f_midi_opts *opts = to_f_midi_opts(item);
int ret;
char *c;
@ -1012,17 +1009,15 @@ end:
return ret;
}
static struct f_midi_opts_attribute f_midi_opts_id =
__CONFIGFS_ATTR(id, S_IRUGO | S_IWUSR, f_midi_opts_id_show,
f_midi_opts_id_store);
CONFIGFS_ATTR(f_midi_opts_, id);
static struct configfs_attribute *midi_attrs[] = {
&f_midi_opts_index.attr,
&f_midi_opts_buflen.attr,
&f_midi_opts_qlen.attr,
&f_midi_opts_in_ports.attr,
&f_midi_opts_out_ports.attr,
&f_midi_opts_id.attr,
&f_midi_opts_attr_index,
&f_midi_opts_attr_buflen,
&f_midi_opts_attr_qlen,
&f_midi_opts_attr_in_ports,
&f_midi_opts_attr_out_ports,
&f_midi_opts_attr_id,
NULL,
};

Просмотреть файл

@ -1488,10 +1488,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
static struct configfs_attribute *ncm_attrs[] = {
&f_ncm_opts_dev_addr.attr,
&f_ncm_opts_host_addr.attr,
&f_ncm_opts_qmult.attr,
&f_ncm_opts_ifname.attr,
&ncm_opts_attr_dev_addr,
&ncm_opts_attr_host_addr,
&ncm_opts_attr_qmult,
&ncm_opts_attr_ifname,
NULL,
};

Просмотреть файл

@ -387,22 +387,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_serial_opts);
static ssize_t f_obex_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
struct f_serial_opts_attribute *f_serial_opts_attr =
container_of(attr, struct f_serial_opts_attribute, attr);
ssize_t ret = 0;
if (f_serial_opts_attr->show)
ret = f_serial_opts_attr->show(opts, page);
return ret;
}
static void obex_attr_release(struct config_item *item)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
@ -412,19 +396,17 @@ static void obex_attr_release(struct config_item *item)
static struct configfs_item_operations obex_item_ops = {
.release = obex_attr_release,
.show_attribute = f_obex_attr_show,
};
static ssize_t f_obex_port_num_show(struct f_serial_opts *opts, char *page)
static ssize_t f_obex_port_num_show(struct config_item *item, char *page)
{
return sprintf(page, "%u\n", opts->port_num);
return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
}
static struct f_serial_opts_attribute f_obex_port_num =
__CONFIGFS_ATTR_RO(port_num, f_obex_port_num_show);
CONFIGFS_ATTR_RO(f_obex_, port_num);
static struct configfs_attribute *acm_attrs[] = {
&f_obex_port_num.attr,
&f_obex_attr_port_num,
NULL,
};

Просмотреть файл

@ -583,21 +583,6 @@ static inline struct f_phonet_opts *to_f_phonet_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_phonet_opts);
static ssize_t f_phonet_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct f_phonet_opts *opts = to_f_phonet_opts(item);
struct f_phonet_opts_attribute *f_phonet_opts_attr =
container_of(attr, struct f_phonet_opts_attribute, attr);
ssize_t ret = 0;
if (f_phonet_opts_attr->show)
ret = f_phonet_opts_attr->show(opts, page);
return ret;
}
static void phonet_attr_release(struct config_item *item)
{
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@ -607,19 +592,17 @@ static void phonet_attr_release(struct config_item *item)
static struct configfs_item_operations phonet_item_ops = {
.release = phonet_attr_release,
.show_attribute = f_phonet_attr_show,
};
static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
{
return gether_get_ifname(opts->net, page, PAGE_SIZE);
return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
}
static struct f_phonet_opts_attribute f_phonet_ifname =
__CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
CONFIGFS_ATTR_RO(f_phonet_, ifname);
static struct configfs_attribute *phonet_attrs[] = {
&f_phonet_ifname.attr,
&f_phonet_attr_ifname,
NULL,
};

Просмотреть файл

@ -1146,9 +1146,6 @@ static inline struct f_printer_opts
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_printer_opts);
CONFIGFS_ATTR_OPS(f_printer_opts);
static void printer_attr_release(struct config_item *item)
{
struct f_printer_opts *opts = to_f_printer_opts(item);
@ -1158,13 +1155,12 @@ static void printer_attr_release(struct config_item *item)
static struct configfs_item_operations printer_item_ops = {
.release = printer_attr_release,
.show_attribute = f_printer_opts_attr_show,
.store_attribute = f_printer_opts_attr_store,
};
static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
static ssize_t f_printer_opts_pnp_string_show(struct config_item *item,
char *page)
{
struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1174,9 +1170,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
return result;
}
static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
static ssize_t f_printer_opts_pnp_string_store(struct config_item *item,
const char *page, size_t len)
{
struct f_printer_opts *opts = to_f_printer_opts(item);
int result, l;
mutex_lock(&opts->lock);
@ -1189,14 +1186,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
return result;
}
static struct f_printer_opts_attribute f_printer_opts_pnp_string =
__CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR,
f_printer_opts_pnp_string_show,
f_printer_opts_pnp_string_store);
CONFIGFS_ATTR(f_printer_opts_, pnp_string);
static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
static ssize_t f_printer_opts_q_len_show(struct config_item *item,
char *page)
{
struct f_printer_opts *opts = to_f_printer_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1206,9 +1201,10 @@ static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
return result;
}
static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts,
static ssize_t f_printer_opts_q_len_store(struct config_item *item,
const char *page, size_t len)
{
struct f_printer_opts *opts = to_f_printer_opts(item);
int ret;
u16 num;
@ -1229,13 +1225,11 @@ end:
return ret;
}
static struct f_printer_opts_attribute f_printer_opts_q_len =
__CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show,
f_printer_opts_q_len_store);
CONFIGFS_ATTR(f_printer_opts_, q_len);
static struct configfs_attribute *printer_attrs[] = {
&f_printer_opts_pnp_string.attr,
&f_printer_opts_q_len.attr,
&f_printer_opts_attr_pnp_string,
&f_printer_opts_attr_q_len,
NULL,
};

Просмотреть файл

@ -864,10 +864,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
static struct configfs_attribute *rndis_attrs[] = {
&f_rndis_opts_dev_addr.attr,
&f_rndis_opts_host_addr.attr,
&f_rndis_opts_qmult.attr,
&f_rndis_opts_ifname.attr,
&rndis_opts_attr_dev_addr,
&rndis_opts_attr_host_addr,
&rndis_opts_attr_qmult,
&rndis_opts_attr_ifname,
NULL,
};

Просмотреть файл

@ -258,22 +258,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_serial_opts);
static ssize_t f_serial_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
struct f_serial_opts_attribute *f_serial_opts_attr =
container_of(attr, struct f_serial_opts_attribute, attr);
ssize_t ret = 0;
if (f_serial_opts_attr->show)
ret = f_serial_opts_attr->show(opts, page);
return ret;
}
static void serial_attr_release(struct config_item *item)
{
struct f_serial_opts *opts = to_f_serial_opts(item);
@ -283,19 +267,17 @@ static void serial_attr_release(struct config_item *item)
static struct configfs_item_operations serial_item_ops = {
.release = serial_attr_release,
.show_attribute = f_serial_attr_show,
};
static ssize_t f_serial_port_num_show(struct f_serial_opts *opts, char *page)
static ssize_t f_serial_port_num_show(struct config_item *item, char *page)
{
return sprintf(page, "%u\n", opts->port_num);
return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
}
static struct f_serial_opts_attribute f_serial_port_num =
__CONFIGFS_ATTR_RO(port_num, f_serial_port_num_show);
CONFIGFS_ATTR_RO(f_serial_, port_num);
static struct configfs_attribute *acm_attrs[] = {
&f_serial_port_num.attr,
&f_serial_attr_port_num,
NULL,
};

Просмотреть файл

@ -889,9 +889,6 @@ static inline struct f_ss_opts *to_f_ss_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_ss_opts);
CONFIGFS_ATTR_OPS(f_ss_opts);
static void ss_attr_release(struct config_item *item)
{
struct f_ss_opts *ss_opts = to_f_ss_opts(item);
@ -901,12 +898,11 @@ static void ss_attr_release(struct config_item *item)
static struct configfs_item_operations ss_item_ops = {
.release = ss_attr_release,
.show_attribute = f_ss_opts_attr_show,
.store_attribute = f_ss_opts_attr_store,
};
static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_pattern_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -916,9 +912,10 @@ static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_pattern_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
@ -944,13 +941,11 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_pattern =
__CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR,
f_ss_opts_pattern_show,
f_ss_opts_pattern_store);
CONFIGFS_ATTR(f_ss_opts_, pattern);
static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_isoc_interval_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -960,9 +955,10 @@ static ssize_t f_ss_opts_isoc_interval_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_isoc_interval_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_isoc_interval_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
@ -988,13 +984,11 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_isoc_interval =
__CONFIGFS_ATTR(isoc_interval, S_IRUGO | S_IWUSR,
f_ss_opts_isoc_interval_show,
f_ss_opts_isoc_interval_store);
CONFIGFS_ATTR(f_ss_opts_, isoc_interval);
static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_isoc_maxpacket_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1004,9 +998,10 @@ static ssize_t f_ss_opts_isoc_maxpacket_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_isoc_maxpacket_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_isoc_maxpacket_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u16 num;
@ -1032,13 +1027,11 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_isoc_maxpacket =
__CONFIGFS_ATTR(isoc_maxpacket, S_IRUGO | S_IWUSR,
f_ss_opts_isoc_maxpacket_show,
f_ss_opts_isoc_maxpacket_store);
CONFIGFS_ATTR(f_ss_opts_, isoc_maxpacket);
static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_isoc_mult_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1048,9 +1041,10 @@ static ssize_t f_ss_opts_isoc_mult_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_isoc_mult_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_isoc_mult_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
@ -1076,13 +1070,11 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_isoc_mult =
__CONFIGFS_ATTR(isoc_mult, S_IRUGO | S_IWUSR,
f_ss_opts_isoc_mult_show,
f_ss_opts_isoc_mult_store);
CONFIGFS_ATTR(f_ss_opts_, isoc_mult);
static ssize_t f_ss_opts_isoc_maxburst_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_isoc_maxburst_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1092,9 +1084,10 @@ static ssize_t f_ss_opts_isoc_maxburst_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_isoc_maxburst_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_isoc_maxburst_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u8 num;
@ -1120,13 +1113,11 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_isoc_maxburst =
__CONFIGFS_ATTR(isoc_maxburst, S_IRUGO | S_IWUSR,
f_ss_opts_isoc_maxburst_show,
f_ss_opts_isoc_maxburst_store);
CONFIGFS_ATTR(f_ss_opts_, isoc_maxburst);
static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page)
static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *page)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int result;
mutex_lock(&opts->lock);
@ -1136,9 +1127,10 @@ static ssize_t f_ss_opts_bulk_buflen_show(struct f_ss_opts *opts, char *page)
return result;
}
static ssize_t f_ss_opts_bulk_buflen_store(struct f_ss_opts *opts,
static ssize_t f_ss_opts_bulk_buflen_store(struct config_item *item,
const char *page, size_t len)
{
struct f_ss_opts *opts = to_f_ss_opts(item);
int ret;
u32 num;
@ -1159,18 +1151,15 @@ end:
return ret;
}
static struct f_ss_opts_attribute f_ss_opts_bulk_buflen =
__CONFIGFS_ATTR(buflen, S_IRUGO | S_IWUSR,
f_ss_opts_bulk_buflen_show,
f_ss_opts_bulk_buflen_store);
CONFIGFS_ATTR(f_ss_opts_, bulk_buflen);
static struct configfs_attribute *ss_attrs[] = {
&f_ss_opts_pattern.attr,
&f_ss_opts_isoc_interval.attr,
&f_ss_opts_isoc_maxpacket.attr,
&f_ss_opts_isoc_mult.attr,
&f_ss_opts_isoc_maxburst.attr,
&f_ss_opts_bulk_buflen.attr,
&f_ss_opts_attr_pattern,
&f_ss_opts_attr_isoc_interval,
&f_ss_opts_attr_isoc_maxpacket,
&f_ss_opts_attr_isoc_mult,
&f_ss_opts_attr_isoc_maxburst,
&f_ss_opts_attr_bulk_buflen,
NULL,
};

Просмотреть файл

@ -405,10 +405,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
static struct configfs_attribute *gether_attrs[] = {
&f_gether_opts_dev_addr.attr,
&f_gether_opts_host_addr.attr,
&f_gether_opts_qmult.attr,
&f_gether_opts_ifname.attr,
&gether_opts_attr_dev_addr,
&gether_opts_attr_host_addr,
&gether_opts_attr_qmult,
&gether_opts_attr_ifname,
NULL,
};

Просмотреть файл

@ -769,9 +769,6 @@ static inline struct f_uac1_opts *to_f_uac1_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_uac1_opts);
CONFIGFS_ATTR_OPS(f_uac1_opts);
static void f_uac1_attr_release(struct config_item *item)
{
struct f_uac1_opts *opts = to_f_uac1_opts(item);
@ -781,14 +778,13 @@ static void f_uac1_attr_release(struct config_item *item)
static struct configfs_item_operations f_uac1_item_ops = {
.release = f_uac1_attr_release,
.show_attribute = f_uac1_opts_attr_show,
.store_attribute = f_uac1_opts_attr_store,
};
#define UAC1_INT_ATTRIBUTE(name) \
static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
char *page) \
{ \
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -798,9 +794,10 @@ static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
return result; \
} \
\
static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \
static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
int ret; \
u32 num; \
\
@ -822,19 +819,17 @@ end: \
return ret; \
} \
\
static struct f_uac1_opts_attribute f_uac1_opts_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
f_uac1_opts_##name##_show, \
f_uac1_opts_##name##_store)
CONFIGFS_ATTR(f_uac1_opts_, name)
UAC1_INT_ATTRIBUTE(req_buf_size);
UAC1_INT_ATTRIBUTE(req_count);
UAC1_INT_ATTRIBUTE(audio_buf_size);
#define UAC1_STR_ATTRIBUTE(name) \
static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
static ssize_t f_uac1_opts_##name##_show(struct config_item *item, \
char *page) \
{ \
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -844,9 +839,10 @@ static ssize_t f_uac1_opts_##name##_show(struct f_uac1_opts *opts, \
return result; \
} \
\
static ssize_t f_uac1_opts_##name##_store(struct f_uac1_opts *opts, \
static ssize_t f_uac1_opts_##name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_uac1_opts *opts = to_f_uac1_opts(item); \
int ret = -EBUSY; \
char *tmp; \
\
@ -870,22 +866,19 @@ end: \
return ret; \
} \
\
static struct f_uac1_opts_attribute f_uac1_opts_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
f_uac1_opts_##name##_show, \
f_uac1_opts_##name##_store)
CONFIGFS_ATTR(f_uac1_opts_, name)
UAC1_STR_ATTRIBUTE(fn_play);
UAC1_STR_ATTRIBUTE(fn_cap);
UAC1_STR_ATTRIBUTE(fn_cntl);
static struct configfs_attribute *f_uac1_attrs[] = {
&f_uac1_opts_req_buf_size.attr,
&f_uac1_opts_req_count.attr,
&f_uac1_opts_audio_buf_size.attr,
&f_uac1_opts_fn_play.attr,
&f_uac1_opts_fn_cap.attr,
&f_uac1_opts_fn_cntl.attr,
&f_uac1_opts_attr_req_buf_size,
&f_uac1_opts_attr_req_count,
&f_uac1_opts_attr_audio_buf_size,
&f_uac1_opts_attr_fn_play,
&f_uac1_opts_attr_fn_cap,
&f_uac1_opts_attr_fn_cntl,
NULL,
};

Просмотреть файл

@ -1439,9 +1439,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_uac2_opts);
CONFIGFS_ATTR_OPS(f_uac2_opts);
static void f_uac2_attr_release(struct config_item *item)
{
struct f_uac2_opts *opts = to_f_uac2_opts(item);
@ -1451,14 +1448,13 @@ static void f_uac2_attr_release(struct config_item *item)
static struct configfs_item_operations f_uac2_item_ops = {
.release = f_uac2_attr_release,
.show_attribute = f_uac2_opts_attr_show,
.store_attribute = f_uac2_opts_attr_store,
};
#define UAC2_ATTRIBUTE(name) \
static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \
static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \
char *page) \
{ \
struct f_uac2_opts *opts = to_f_uac2_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -1468,9 +1464,10 @@ static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \
return result; \
} \
\
static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts, \
static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_uac2_opts *opts = to_f_uac2_opts(item); \
int ret; \
u32 num; \
\
@ -1492,10 +1489,7 @@ end: \
return ret; \
} \
\
static struct f_uac2_opts_attribute f_uac2_opts_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
f_uac2_opts_##name##_show, \
f_uac2_opts_##name##_store)
CONFIGFS_ATTR(f_uac2_opts_, name)
UAC2_ATTRIBUTE(p_chmask);
UAC2_ATTRIBUTE(p_srate);
@ -1505,12 +1499,12 @@ UAC2_ATTRIBUTE(c_srate);
UAC2_ATTRIBUTE(c_ssize);
static struct configfs_attribute *f_uac2_attrs[] = {
&f_uac2_opts_p_chmask.attr,
&f_uac2_opts_p_srate.attr,
&f_uac2_opts_p_ssize.attr,
&f_uac2_opts_c_chmask.attr,
&f_uac2_opts_c_srate.attr,
&f_uac2_opts_c_ssize.attr,
&f_uac2_opts_attr_p_chmask,
&f_uac2_opts_attr_p_srate,
&f_uac2_opts_attr_p_ssize,
&f_uac2_opts_attr_c_chmask,
&f_uac2_opts_attr_c_srate,
&f_uac2_opts_attr_c_ssize,
NULL,
};

Просмотреть файл

@ -17,9 +17,6 @@
#define __U_ETHER_CONFIGFS_H
#define USB_ETHERNET_CONFIGFS_ITEM(_f_) \
CONFIGFS_ATTR_STRUCT(f_##_f_##_opts); \
CONFIGFS_ATTR_OPS(f_##_f_##_opts); \
\
static void _f_##_attr_release(struct config_item *item) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
@ -29,14 +26,13 @@
\
static struct configfs_item_operations _f_##_item_ops = { \
.release = _f_##_attr_release, \
.show_attribute = f_##_f_##_opts_attr_show, \
.store_attribute = f_##_f_##_opts_attr_store, \
}
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \
static ssize_t _f_##_opts_dev_addr_show(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_dev_addr_show(struct config_item *item, \
char *page) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -46,9 +42,10 @@
return result; \
} \
\
static ssize_t _f_##_opts_dev_addr_store(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_dev_addr_store(struct config_item *item, \
const char *page, size_t len)\
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \
\
mutex_lock(&opts->lock); \
@ -64,15 +61,13 @@
return ret; \
} \
\
static struct f_##_f_##_opts_attribute f_##_f_##_opts_dev_addr = \
__CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, \
_f_##_opts_dev_addr_show, \
_f_##_opts_dev_addr_store)
CONFIGFS_ATTR(_f_##_opts_, dev_addr)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \
static ssize_t _f_##_opts_host_addr_show(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_host_addr_show(struct config_item *item, \
char *page) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -82,9 +77,10 @@
return result; \
} \
\
static ssize_t _f_##_opts_host_addr_store(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_host_addr_store(struct config_item *item, \
const char *page, size_t len)\
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \
\
mutex_lock(&opts->lock); \
@ -100,15 +96,13 @@
return ret; \
} \
\
static struct f_##_f_##_opts_attribute f_##_f_##_opts_host_addr = \
__CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, \
_f_##_opts_host_addr_show, \
_f_##_opts_host_addr_store)
CONFIGFS_ATTR(_f_##_opts_, host_addr)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \
static ssize_t _f_##_opts_qmult_show(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_qmult_show(struct config_item *item, \
char *page) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
unsigned qmult; \
\
mutex_lock(&opts->lock); \
@ -117,9 +111,10 @@
return sprintf(page, "%d", qmult); \
} \
\
static ssize_t _f_##_opts_qmult_store(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_qmult_store(struct config_item *item, \
const char *page, size_t len)\
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
u8 val; \
int ret; \
\
@ -140,15 +135,13 @@ out: \
return ret; \
} \
\
static struct f_##_f_##_opts_attribute f_##_f_##_opts_qmult = \
__CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, \
_f_##_opts_qmult_show, \
_f_##_opts_qmult_store)
CONFIGFS_ATTR(_f_##_opts_, qmult)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \
static ssize_t _f_##_opts_ifname_show(struct f_##_f_##_opts *opts, \
static ssize_t _f_##_opts_ifname_show(struct config_item *item, \
char *page) \
{ \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \
\
mutex_lock(&opts->lock); \
@ -158,7 +151,6 @@ out: \
return ret; \
} \
\
static struct f_##_f_##_opts_attribute f_##_f_##_opts_ifname = \
__CONFIGFS_ATTR_RO(ifname, _f_##_opts_ifname_show)
CONFIGFS_ATTR_RO(_f_##_opts_, ifname)
#endif /* __U_ETHER_CONFIGFS_H */

Просмотреть файл

@ -17,19 +17,21 @@
#define UVCG_STREAMING_CONTROL_SIZE 1
#define CONFIGFS_ATTR_OPS_RO(_item) \
static ssize_t _item##_attr_show(struct config_item *item, \
struct configfs_attribute *attr, \
char *page) \
{ \
struct _item *_item = to_##_item(item); \
struct _item##_attribute *_item##_attr = \
container_of(attr, struct _item##_attribute, attr); \
ssize_t ret = 0; \
\
if (_item##_attr->show) \
ret = _item##_attr->show(_item, page); \
return ret; \
#define UVC_ATTR(prefix, cname, aname) \
static struct configfs_attribute prefix##attr_##cname = { \
.ca_name = __stringify(aname), \
.ca_mode = S_IRUGO, \
.ca_owner = THIS_MODULE, \
.show = prefix##cname##_show, \
.store = prefix##cname##_store, \
}
#define UVC_ATTR_RO(prefix, cname, aname) \
static struct configfs_attribute prefix##attr_##cname = { \
.ca_name = __stringify(aname), \
.ca_mode = S_IRUGO, \
.ca_owner = THIS_MODULE, \
.show = prefix##cname##_show, \
}
static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item);
@ -48,18 +50,11 @@ static struct uvcg_control_header *to_uvcg_control_header(struct config_item *it
return container_of(item, struct uvcg_control_header, item);
}
CONFIGFS_ATTR_STRUCT(uvcg_control_header);
CONFIGFS_ATTR_OPS(uvcg_control_header);
static struct configfs_item_operations uvcg_control_header_item_ops = {
.show_attribute = uvcg_control_header_attr_show,
.store_attribute = uvcg_control_header_attr_store,
};
#define UVCG_CTRL_HDR_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \
static ssize_t uvcg_control_header_##cname##_show( \
struct uvcg_control_header *ch, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_control_header *ch = to_uvcg_control_header(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@ -79,9 +74,10 @@ static ssize_t uvcg_control_header_##cname##_show( \
} \
\
static ssize_t \
uvcg_control_header_##cname##_store(struct uvcg_control_header *ch, \
uvcg_control_header_##cname##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct uvcg_control_header *ch = to_uvcg_control_header(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &ch->item.ci_group->cg_subsys->su_mutex;\
@ -115,11 +111,7 @@ end: \
return ret; \
} \
\
static struct uvcg_control_header_attribute \
uvcg_control_header_##cname = \
__CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \
uvcg_control_header_##cname##_show, \
uvcg_control_header_##cname##_store)
UVC_ATTR(uvcg_control_header_, cname, aname)
UVCG_CTRL_HDR_ATTR(bcd_uvc, bcdUVC, le16_to_cpu, kstrtou16, u16, cpu_to_le16,
0xffff);
@ -130,13 +122,12 @@ UVCG_CTRL_HDR_ATTR(dw_clock_frequency, dwClockFrequency, le32_to_cpu, kstrtou32,
#undef UVCG_CTRL_HDR_ATTR
static struct configfs_attribute *uvcg_control_header_attrs[] = {
&uvcg_control_header_bcd_uvc.attr,
&uvcg_control_header_dw_clock_frequency.attr,
&uvcg_control_header_attr_bcd_uvc,
&uvcg_control_header_attr_dw_clock_frequency,
NULL,
};
static struct config_item_type uvcg_control_header_type = {
.ct_item_ops = &uvcg_control_header_item_ops,
.ct_attrs = uvcg_control_header_attrs,
.ct_owner = THIS_MODULE,
};
@ -196,17 +187,11 @@ static inline struct uvcg_default_processing
struct uvcg_default_processing, group);
}
CONFIGFS_ATTR_STRUCT(uvcg_default_processing);
CONFIGFS_ATTR_OPS_RO(uvcg_default_processing);
static struct configfs_item_operations uvcg_default_processing_item_ops = {
.show_attribute = uvcg_default_processing_attr_show,
};
#define UVCG_DEFAULT_PROCESSING_ATTR(cname, aname, conv) \
static ssize_t uvcg_default_processing_##cname##_show( \
struct uvcg_default_processing *dp, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_default_processing *dp = to_uvcg_default_processing(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex; \
@ -227,9 +212,7 @@ static ssize_t uvcg_default_processing_##cname##_show( \
return result; \
} \
\
static struct uvcg_default_processing_attribute \
uvcg_default_processing_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_default_processing_##cname##_show)
UVC_ATTR_RO(uvcg_default_processing_, cname, aname)
#define identity_conv(x) (x)
@ -243,8 +226,9 @@ UVCG_DEFAULT_PROCESSING_ATTR(i_processing, iProcessing, identity_conv);
#undef UVCG_DEFAULT_PROCESSING_ATTR
static ssize_t uvcg_default_processing_bm_controls_show(
struct uvcg_default_processing *dp, char *page)
struct config_item *item, char *page)
{
struct uvcg_default_processing *dp = to_uvcg_default_processing(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct mutex *su_mutex = &dp->group.cg_subsys->su_mutex;
@ -270,22 +254,18 @@ static ssize_t uvcg_default_processing_bm_controls_show(
return result;
}
static struct uvcg_default_processing_attribute
uvcg_default_processing_bm_controls =
__CONFIGFS_ATTR_RO(bmControls,
uvcg_default_processing_bm_controls_show);
UVC_ATTR_RO(uvcg_default_processing_, bm_controls, bmControls);
static struct configfs_attribute *uvcg_default_processing_attrs[] = {
&uvcg_default_processing_b_unit_id.attr,
&uvcg_default_processing_b_source_id.attr,
&uvcg_default_processing_w_max_multiplier.attr,
&uvcg_default_processing_bm_controls.attr,
&uvcg_default_processing_i_processing.attr,
&uvcg_default_processing_attr_b_unit_id,
&uvcg_default_processing_attr_b_source_id,
&uvcg_default_processing_attr_w_max_multiplier,
&uvcg_default_processing_attr_bm_controls,
&uvcg_default_processing_attr_i_processing,
NULL,
};
static struct config_item_type uvcg_default_processing_type = {
.ct_item_ops = &uvcg_default_processing_item_ops,
.ct_attrs = uvcg_default_processing_attrs,
.ct_owner = THIS_MODULE,
};
@ -318,17 +298,11 @@ static inline struct uvcg_default_camera
struct uvcg_default_camera, group);
}
CONFIGFS_ATTR_STRUCT(uvcg_default_camera);
CONFIGFS_ATTR_OPS_RO(uvcg_default_camera);
static struct configfs_item_operations uvcg_default_camera_item_ops = {
.show_attribute = uvcg_default_camera_attr_show,
};
#define UVCG_DEFAULT_CAMERA_ATTR(cname, aname, conv) \
static ssize_t uvcg_default_camera_##cname##_show( \
struct uvcg_default_camera *dc, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_default_camera *dc = to_uvcg_default_camera(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \
@ -351,9 +325,7 @@ static ssize_t uvcg_default_camera_##cname##_show( \
return result; \
} \
\
static struct uvcg_default_camera_attribute \
uvcg_default_camera_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_default_camera_##cname##_show)
UVC_ATTR_RO(uvcg_default_camera_, cname, aname)
#define identity_conv(x) (x)
@ -373,8 +345,9 @@ UVCG_DEFAULT_CAMERA_ATTR(w_ocular_focal_length, wOcularFocalLength,
#undef UVCG_DEFAULT_CAMERA_ATTR
static ssize_t uvcg_default_camera_bm_controls_show(
struct uvcg_default_camera *dc, char *page)
struct config_item *item, char *page)
{
struct uvcg_default_camera *dc = to_uvcg_default_camera(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex;
@ -400,24 +373,21 @@ static ssize_t uvcg_default_camera_bm_controls_show(
return result;
}
static struct uvcg_default_camera_attribute
uvcg_default_camera_bm_controls =
__CONFIGFS_ATTR_RO(bmControls, uvcg_default_camera_bm_controls_show);
UVC_ATTR_RO(uvcg_default_camera_, bm_controls, bmControls);
static struct configfs_attribute *uvcg_default_camera_attrs[] = {
&uvcg_default_camera_b_terminal_id.attr,
&uvcg_default_camera_w_terminal_type.attr,
&uvcg_default_camera_b_assoc_terminal.attr,
&uvcg_default_camera_i_terminal.attr,
&uvcg_default_camera_w_objective_focal_length_min.attr,
&uvcg_default_camera_w_objective_focal_length_max.attr,
&uvcg_default_camera_w_ocular_focal_length.attr,
&uvcg_default_camera_bm_controls.attr,
&uvcg_default_camera_attr_b_terminal_id,
&uvcg_default_camera_attr_w_terminal_type,
&uvcg_default_camera_attr_b_assoc_terminal,
&uvcg_default_camera_attr_i_terminal,
&uvcg_default_camera_attr_w_objective_focal_length_min,
&uvcg_default_camera_attr_w_objective_focal_length_max,
&uvcg_default_camera_attr_w_ocular_focal_length,
&uvcg_default_camera_attr_bm_controls,
NULL,
};
static struct config_item_type uvcg_default_camera_type = {
.ct_item_ops = &uvcg_default_camera_item_ops,
.ct_attrs = uvcg_default_camera_attrs,
.ct_owner = THIS_MODULE,
};
@ -450,17 +420,11 @@ static inline struct uvcg_default_output
struct uvcg_default_output, group);
}
CONFIGFS_ATTR_STRUCT(uvcg_default_output);
CONFIGFS_ATTR_OPS_RO(uvcg_default_output);
static struct configfs_item_operations uvcg_default_output_item_ops = {
.show_attribute = uvcg_default_output_attr_show,
};
#define UVCG_DEFAULT_OUTPUT_ATTR(cname, aname, conv) \
static ssize_t uvcg_default_output_##cname##_show( \
struct uvcg_default_output *dout, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_default_output *dout = to_uvcg_default_output(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &dout->group.cg_subsys->su_mutex; \
@ -483,9 +447,7 @@ static ssize_t uvcg_default_output_##cname##_show( \
return result; \
} \
\
static struct uvcg_default_output_attribute \
uvcg_default_output_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_default_output_##cname##_show)
UVC_ATTR_RO(uvcg_default_output_, cname, aname)
#define identity_conv(x) (x)
@ -500,16 +462,15 @@ UVCG_DEFAULT_OUTPUT_ATTR(i_terminal, iTerminal, identity_conv);
#undef UVCG_DEFAULT_OUTPUT_ATTR
static struct configfs_attribute *uvcg_default_output_attrs[] = {
&uvcg_default_output_b_terminal_id.attr,
&uvcg_default_output_w_terminal_type.attr,
&uvcg_default_output_b_assoc_terminal.attr,
&uvcg_default_output_b_source_id.attr,
&uvcg_default_output_i_terminal.attr,
&uvcg_default_output_attr_b_terminal_id,
&uvcg_default_output_attr_w_terminal_type,
&uvcg_default_output_attr_b_assoc_terminal,
&uvcg_default_output_attr_b_source_id,
&uvcg_default_output_attr_i_terminal,
NULL,
};
static struct config_item_type uvcg_default_output_type = {
.ct_item_ops = &uvcg_default_output_item_ops,
.ct_attrs = uvcg_default_output_attrs,
.ct_owner = THIS_MODULE,
};
@ -800,9 +761,6 @@ static struct uvcg_streaming_header *to_uvcg_streaming_header(struct config_item
return container_of(item, struct uvcg_streaming_header, item);
}
CONFIGFS_ATTR_STRUCT(uvcg_streaming_header);
CONFIGFS_ATTR_OPS(uvcg_streaming_header);
static int uvcg_streaming_header_allow_link(struct config_item *src,
struct config_item *target)
{
@ -893,16 +851,15 @@ out:
}
static struct configfs_item_operations uvcg_streaming_header_item_ops = {
.show_attribute = uvcg_streaming_header_attr_show,
.store_attribute = uvcg_streaming_header_attr_store,
.allow_link = uvcg_streaming_header_allow_link,
.drop_link = uvcg_streaming_header_drop_link,
};
#define UVCG_STREAMING_HEADER_ATTR(cname, aname, conv) \
static ssize_t uvcg_streaming_header_##cname##_show( \
struct uvcg_streaming_header *sh, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_streaming_header *sh = to_uvcg_streaming_header(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &sh->item.ci_group->cg_subsys->su_mutex;\
@ -921,9 +878,7 @@ static ssize_t uvcg_streaming_header_##cname##_show( \
return result; \
} \
\
static struct uvcg_streaming_header_attribute \
uvcg_streaming_header_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_streaming_header_##cname##_show)
UVC_ATTR_RO(uvcg_streaming_header_, cname, aname)
#define identity_conv(x) (x)
@ -939,11 +894,11 @@ UVCG_STREAMING_HEADER_ATTR(b_trigger_usage, bTriggerUsage, identity_conv);
#undef UVCG_STREAMING_HEADER_ATTR
static struct configfs_attribute *uvcg_streaming_header_attrs[] = {
&uvcg_streaming_header_bm_info.attr,
&uvcg_streaming_header_b_terminal_link.attr,
&uvcg_streaming_header_b_still_capture_method.attr,
&uvcg_streaming_header_b_trigger_support.attr,
&uvcg_streaming_header_b_trigger_usage.attr,
&uvcg_streaming_header_attr_bm_info,
&uvcg_streaming_header_attr_b_terminal_link,
&uvcg_streaming_header_attr_b_still_capture_method,
&uvcg_streaming_header_attr_b_trigger_support,
&uvcg_streaming_header_attr_b_trigger_usage,
NULL,
};
@ -1022,17 +977,10 @@ static struct uvcg_frame *to_uvcg_frame(struct config_item *item)
return container_of(item, struct uvcg_frame, item);
}
CONFIGFS_ATTR_STRUCT(uvcg_frame);
CONFIGFS_ATTR_OPS(uvcg_frame);
static struct configfs_item_operations uvcg_frame_item_ops = {
.show_attribute = uvcg_frame_attr_show,
.store_attribute = uvcg_frame_attr_store,
};
#define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \
static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\
static ssize_t uvcg_frame_##cname##_show(struct config_item *item, char *page)\
{ \
struct uvcg_frame *f = to_uvcg_frame(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
@ -1051,9 +999,10 @@ static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\
return result; \
} \
\
static ssize_t uvcg_frame_##cname##_store(struct uvcg_frame *f, \
static ssize_t uvcg_frame_##cname##_store(struct config_item *item, \
const char *page, size_t len)\
{ \
struct uvcg_frame *f = to_uvcg_frame(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct uvcg_format *fmt; \
@ -1085,11 +1034,7 @@ end: \
return ret; \
} \
\
static struct uvcg_frame_attribute \
uvcg_frame_##cname = \
__CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \
uvcg_frame_##cname##_show, \
uvcg_frame_##cname##_store)
UVC_ATTR(uvcg_frame_, cname, aname);
#define noop_conversion(x) (x)
@ -1108,9 +1053,10 @@ UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval,
#undef UVCG_FRAME_ATTR
static ssize_t uvcg_frame_dw_frame_interval_show(struct uvcg_frame *frm,
static ssize_t uvcg_frame_dw_frame_interval_show(struct config_item *item,
char *page)
{
struct uvcg_frame *frm = to_uvcg_frame(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct mutex *su_mutex = &frm->item.ci_group->cg_subsys->su_mutex;
@ -1185,9 +1131,10 @@ static int __uvcg_iter_frm_intrv(const char *page, size_t len,
return 0;
}
static ssize_t uvcg_frame_dw_frame_interval_store(struct uvcg_frame *ch,
static ssize_t uvcg_frame_dw_frame_interval_store(struct config_item *item,
const char *page, size_t len)
{
struct uvcg_frame *ch = to_uvcg_frame(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct uvcg_format *fmt;
@ -1234,26 +1181,21 @@ end:
return ret;
}
static struct uvcg_frame_attribute
uvcg_frame_dw_frame_interval =
__CONFIGFS_ATTR(dwFrameInterval, S_IRUGO | S_IWUSR,
uvcg_frame_dw_frame_interval_show,
uvcg_frame_dw_frame_interval_store);
UVC_ATTR(uvcg_frame_, dw_frame_interval, dwFrameInterval);
static struct configfs_attribute *uvcg_frame_attrs[] = {
&uvcg_frame_bm_capabilities.attr,
&uvcg_frame_w_width.attr,
&uvcg_frame_w_height.attr,
&uvcg_frame_dw_min_bit_rate.attr,
&uvcg_frame_dw_max_bit_rate.attr,
&uvcg_frame_dw_max_video_frame_buffer_size.attr,
&uvcg_frame_dw_default_frame_interval.attr,
&uvcg_frame_dw_frame_interval.attr,
&uvcg_frame_attr_bm_capabilities,
&uvcg_frame_attr_w_width,
&uvcg_frame_attr_w_height,
&uvcg_frame_attr_dw_min_bit_rate,
&uvcg_frame_attr_dw_max_bit_rate,
&uvcg_frame_attr_dw_max_video_frame_buffer_size,
&uvcg_frame_attr_dw_default_frame_interval,
&uvcg_frame_attr_dw_frame_interval,
NULL,
};
static struct config_item_type uvcg_frame_type = {
.ct_item_ops = &uvcg_frame_item_ops,
.ct_attrs = uvcg_frame_attrs,
.ct_owner = THIS_MODULE,
};
@ -1333,22 +1275,15 @@ static struct uvcg_uncompressed *to_uvcg_uncompressed(struct config_item *item)
struct uvcg_uncompressed, fmt);
}
CONFIGFS_ATTR_STRUCT(uvcg_uncompressed);
CONFIGFS_ATTR_OPS(uvcg_uncompressed);
static struct configfs_item_operations uvcg_uncompressed_item_ops = {
.show_attribute = uvcg_uncompressed_attr_show,
.store_attribute = uvcg_uncompressed_attr_store,
};
static struct configfs_group_operations uvcg_uncompressed_group_ops = {
.make_item = uvcg_frame_make,
.drop_item = uvcg_frame_drop,
};
static ssize_t uvcg_uncompressed_guid_format_show(struct uvcg_uncompressed *ch,
static ssize_t uvcg_uncompressed_guid_format_show(struct config_item *item,
char *page)
{
struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
@ -1367,9 +1302,10 @@ static ssize_t uvcg_uncompressed_guid_format_show(struct uvcg_uncompressed *ch,
return sizeof(ch->desc.guidFormat);
}
static ssize_t uvcg_uncompressed_guid_format_store(struct uvcg_uncompressed *ch,
static ssize_t uvcg_uncompressed_guid_format_store(struct config_item *item,
const char *page, size_t len)
{
struct uvcg_uncompressed *ch = to_uvcg_uncompressed(item);
struct f_uvc_opts *opts;
struct config_item *opts_item;
struct mutex *su_mutex = &ch->fmt.group.cg_subsys->su_mutex;
@ -1396,16 +1332,13 @@ end:
return ret;
}
static struct uvcg_uncompressed_attribute uvcg_uncompressed_guid_format =
__CONFIGFS_ATTR(guidFormat, S_IRUGO | S_IWUSR,
uvcg_uncompressed_guid_format_show,
uvcg_uncompressed_guid_format_store);
UVC_ATTR(uvcg_uncompressed_, guid_format, guidFormat);
#define UVCG_UNCOMPRESSED_ATTR_RO(cname, aname, conv) \
static ssize_t uvcg_uncompressed_##cname##_show( \
struct uvcg_uncompressed *u, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1424,14 +1357,13 @@ static ssize_t uvcg_uncompressed_##cname##_show( \
return result; \
} \
\
static struct uvcg_uncompressed_attribute \
uvcg_uncompressed_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_uncompressed_##cname##_show)
UVC_ATTR_RO(uvcg_uncompressed_, cname, aname);
#define UVCG_UNCOMPRESSED_ATTR(cname, aname, conv) \
static ssize_t uvcg_uncompressed_##cname##_show( \
struct uvcg_uncompressed *u, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1451,9 +1383,10 @@ static ssize_t uvcg_uncompressed_##cname##_show( \
} \
\
static ssize_t \
uvcg_uncompressed_##cname##_store(struct uvcg_uncompressed *u, \
uvcg_uncompressed_##cname##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct uvcg_uncompressed *u = to_uvcg_uncompressed(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1487,11 +1420,7 @@ end: \
return ret; \
} \
\
static struct uvcg_uncompressed_attribute \
uvcg_uncompressed_##cname = \
__CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \
uvcg_uncompressed_##cname##_show, \
uvcg_uncompressed_##cname##_store)
UVC_ATTR(uvcg_uncompressed_, cname, aname);
#define identity_conv(x) (x)
@ -1508,36 +1437,34 @@ UVCG_UNCOMPRESSED_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
#undef UVCG_UNCOMPRESSED_ATTR_RO
static inline ssize_t
uvcg_uncompressed_bma_controls_show(struct uvcg_uncompressed *unc, char *page)
uvcg_uncompressed_bma_controls_show(struct config_item *item, char *page)
{
struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
return uvcg_format_bma_controls_show(&unc->fmt, page);
}
static inline ssize_t
uvcg_uncompressed_bma_controls_store(struct uvcg_uncompressed *ch,
uvcg_uncompressed_bma_controls_store(struct config_item *item,
const char *page, size_t len)
{
return uvcg_format_bma_controls_store(&ch->fmt, page, len);
struct uvcg_uncompressed *unc = to_uvcg_uncompressed(item);
return uvcg_format_bma_controls_store(&unc->fmt, page, len);
}
static struct uvcg_uncompressed_attribute uvcg_uncompressed_bma_controls =
__CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR,
uvcg_uncompressed_bma_controls_show,
uvcg_uncompressed_bma_controls_store);
UVC_ATTR(uvcg_uncompressed_, bma_controls, bmaControls);
static struct configfs_attribute *uvcg_uncompressed_attrs[] = {
&uvcg_uncompressed_guid_format.attr,
&uvcg_uncompressed_b_bits_per_pixel.attr,
&uvcg_uncompressed_b_default_frame_index.attr,
&uvcg_uncompressed_b_aspect_ratio_x.attr,
&uvcg_uncompressed_b_aspect_ratio_y.attr,
&uvcg_uncompressed_bm_interface_flags.attr,
&uvcg_uncompressed_bma_controls.attr,
&uvcg_uncompressed_attr_guid_format,
&uvcg_uncompressed_attr_b_bits_per_pixel,
&uvcg_uncompressed_attr_b_default_frame_index,
&uvcg_uncompressed_attr_b_aspect_ratio_x,
&uvcg_uncompressed_attr_b_aspect_ratio_y,
&uvcg_uncompressed_attr_bm_interface_flags,
&uvcg_uncompressed_attr_bma_controls,
NULL,
};
static struct config_item_type uvcg_uncompressed_type = {
.ct_item_ops = &uvcg_uncompressed_item_ops,
.ct_group_ops = &uvcg_uncompressed_group_ops,
.ct_attrs = uvcg_uncompressed_attrs,
.ct_owner = THIS_MODULE,
@ -1605,22 +1532,15 @@ static struct uvcg_mjpeg *to_uvcg_mjpeg(struct config_item *item)
struct uvcg_mjpeg, fmt);
}
CONFIGFS_ATTR_STRUCT(uvcg_mjpeg);
CONFIGFS_ATTR_OPS(uvcg_mjpeg);
static struct configfs_item_operations uvcg_mjpeg_item_ops = {
.show_attribute = uvcg_mjpeg_attr_show,
.store_attribute = uvcg_mjpeg_attr_store,
};
static struct configfs_group_operations uvcg_mjpeg_group_ops = {
.make_item = uvcg_frame_make,
.drop_item = uvcg_frame_drop,
};
#define UVCG_MJPEG_ATTR_RO(cname, aname, conv) \
static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\
static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
{ \
struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1639,13 +1559,12 @@ static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\
return result; \
} \
\
static struct uvcg_mjpeg_attribute \
uvcg_mjpeg_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_mjpeg_##cname##_show)
UVC_ATTR_RO(uvcg_mjpeg_, cname, aname)
#define UVCG_MJPEG_ATTR(cname, aname, conv) \
static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\
static ssize_t uvcg_mjpeg_##cname##_show(struct config_item *item, char *page)\
{ \
struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1665,9 +1584,10 @@ static ssize_t uvcg_mjpeg_##cname##_show(struct uvcg_mjpeg *u, char *page)\
} \
\
static ssize_t \
uvcg_mjpeg_##cname##_store(struct uvcg_mjpeg *u, \
uvcg_mjpeg_##cname##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct uvcg_mjpeg *u = to_uvcg_mjpeg(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &u->fmt.group.cg_subsys->su_mutex; \
@ -1701,11 +1621,7 @@ end: \
return ret; \
} \
\
static struct uvcg_mjpeg_attribute \
uvcg_mjpeg_##cname = \
__CONFIGFS_ATTR(aname, S_IRUGO | S_IWUSR, \
uvcg_mjpeg_##cname##_show, \
uvcg_mjpeg_##cname##_store)
UVC_ATTR(uvcg_mjpeg_, cname, aname)
#define identity_conv(x) (x)
@ -1722,35 +1638,33 @@ UVCG_MJPEG_ATTR_RO(bm_interface_flags, bmInterfaceFlags, identity_conv);
#undef UVCG_MJPEG_ATTR_RO
static inline ssize_t
uvcg_mjpeg_bma_controls_show(struct uvcg_mjpeg *unc, char *page)
uvcg_mjpeg_bma_controls_show(struct config_item *item, char *page)
{
return uvcg_format_bma_controls_show(&unc->fmt, page);
struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
return uvcg_format_bma_controls_show(&u->fmt, page);
}
static inline ssize_t
uvcg_mjpeg_bma_controls_store(struct uvcg_mjpeg *ch,
uvcg_mjpeg_bma_controls_store(struct config_item *item,
const char *page, size_t len)
{
return uvcg_format_bma_controls_store(&ch->fmt, page, len);
struct uvcg_mjpeg *u = to_uvcg_mjpeg(item);
return uvcg_format_bma_controls_store(&u->fmt, page, len);
}
static struct uvcg_mjpeg_attribute uvcg_mjpeg_bma_controls =
__CONFIGFS_ATTR(bmaControls, S_IRUGO | S_IWUSR,
uvcg_mjpeg_bma_controls_show,
uvcg_mjpeg_bma_controls_store);
UVC_ATTR(uvcg_mjpeg_, bma_controls, bmaControls);
static struct configfs_attribute *uvcg_mjpeg_attrs[] = {
&uvcg_mjpeg_b_default_frame_index.attr,
&uvcg_mjpeg_bm_flags.attr,
&uvcg_mjpeg_b_aspect_ratio_x.attr,
&uvcg_mjpeg_b_aspect_ratio_y.attr,
&uvcg_mjpeg_bm_interface_flags.attr,
&uvcg_mjpeg_bma_controls.attr,
&uvcg_mjpeg_attr_b_default_frame_index,
&uvcg_mjpeg_attr_bm_flags,
&uvcg_mjpeg_attr_b_aspect_ratio_x,
&uvcg_mjpeg_attr_b_aspect_ratio_y,
&uvcg_mjpeg_attr_bm_interface_flags,
&uvcg_mjpeg_attr_bma_controls,
NULL,
};
static struct config_item_type uvcg_mjpeg_type = {
.ct_item_ops = &uvcg_mjpeg_item_ops,
.ct_group_ops = &uvcg_mjpeg_group_ops,
.ct_attrs = uvcg_mjpeg_attrs,
.ct_owner = THIS_MODULE,
@ -1811,17 +1725,12 @@ static inline struct uvcg_default_color_matching
struct uvcg_default_color_matching, group);
}
CONFIGFS_ATTR_STRUCT(uvcg_default_color_matching);
CONFIGFS_ATTR_OPS_RO(uvcg_default_color_matching);
static struct configfs_item_operations uvcg_default_color_matching_item_ops = {
.show_attribute = uvcg_default_color_matching_attr_show,
};
#define UVCG_DEFAULT_COLOR_MATCHING_ATTR(cname, aname, conv) \
static ssize_t uvcg_default_color_matching_##cname##_show( \
struct uvcg_default_color_matching *dc, char *page) \
struct config_item *item, char *page) \
{ \
struct uvcg_default_color_matching *dc = \
to_uvcg_default_color_matching(item); \
struct f_uvc_opts *opts; \
struct config_item *opts_item; \
struct mutex *su_mutex = &dc->group.cg_subsys->su_mutex; \
@ -1842,9 +1751,7 @@ static ssize_t uvcg_default_color_matching_##cname##_show( \
return result; \
} \
\
static struct uvcg_default_color_matching_attribute \
uvcg_default_color_matching_##cname = \
__CONFIGFS_ATTR_RO(aname, uvcg_default_color_matching_##cname##_show)
UVC_ATTR_RO(uvcg_default_color_matching_, cname, aname)
#define identity_conv(x) (x)
@ -1860,14 +1767,13 @@ UVCG_DEFAULT_COLOR_MATCHING_ATTR(b_matrix_coefficients, bMatrixCoefficients,
#undef UVCG_DEFAULT_COLOR_MATCHING_ATTR
static struct configfs_attribute *uvcg_default_color_matching_attrs[] = {
&uvcg_default_color_matching_b_color_primaries.attr,
&uvcg_default_color_matching_b_transfer_characteristics.attr,
&uvcg_default_color_matching_b_matrix_coefficients.attr,
&uvcg_default_color_matching_attr_b_color_primaries,
&uvcg_default_color_matching_attr_b_transfer_characteristics,
&uvcg_default_color_matching_attr_b_matrix_coefficients,
NULL,
};
static struct config_item_type uvcg_default_color_matching_type = {
.ct_item_ops = &uvcg_default_color_matching_item_ops,
.ct_attrs = uvcg_default_color_matching_attrs,
.ct_owner = THIS_MODULE,
};
@ -2285,9 +2191,6 @@ static inline struct f_uvc_opts *to_f_uvc_opts(struct config_item *item)
func_inst.group);
}
CONFIGFS_ATTR_STRUCT(f_uvc_opts);
CONFIGFS_ATTR_OPS(f_uvc_opts);
static void uvc_attr_release(struct config_item *item)
{
struct f_uvc_opts *opts = to_f_uvc_opts(item);
@ -2297,14 +2200,13 @@ static void uvc_attr_release(struct config_item *item)
static struct configfs_item_operations uvc_item_ops = {
.release = uvc_attr_release,
.show_attribute = f_uvc_opts_attr_show,
.store_attribute = f_uvc_opts_attr_store,
};
#define UVCG_OPTS_ATTR(cname, conv, str2u, uxx, vnoc, limit) \
static ssize_t f_uvc_opts_##cname##_show( \
struct f_uvc_opts *opts, char *page) \
struct config_item *item, char *page) \
{ \
struct f_uvc_opts *opts = to_f_uvc_opts(item); \
int result; \
\
mutex_lock(&opts->lock); \
@ -2315,9 +2217,10 @@ static ssize_t f_uvc_opts_##cname##_show( \
} \
\
static ssize_t \
f_uvc_opts_##cname##_store(struct f_uvc_opts *opts, \
f_uvc_opts_##cname##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct f_uvc_opts *opts = to_f_uvc_opts(item); \
int ret; \
uxx num; \
\
@ -2342,11 +2245,7 @@ end: \
return ret; \
} \
\
static struct f_uvc_opts_attribute \
f_uvc_opts_attribute_##cname = \
__CONFIGFS_ATTR(cname, S_IRUGO | S_IWUSR, \
f_uvc_opts_##cname##_show, \
f_uvc_opts_##cname##_store)
UVC_ATTR(f_uvc_opts_, cname, aname)
#define identity_conv(x) (x)
@ -2362,9 +2261,9 @@ UVCG_OPTS_ATTR(streaming_maxburst, identity_conv, kstrtou8, u8, identity_conv,
#undef UVCG_OPTS_ATTR
static struct configfs_attribute *uvc_attrs[] = {
&f_uvc_opts_attribute_streaming_interval.attr,
&f_uvc_opts_attribute_streaming_maxpacket.attr,
&f_uvc_opts_attribute_streaming_maxburst.attr,
&f_uvc_opts_attr_streaming_interval,
&f_uvc_opts_attr_streaming_maxpacket,
&f_uvc_opts_attr_streaming_maxburst,
NULL,
};

Просмотреть файл

@ -19,8 +19,6 @@
#include <scsi/scsi_tcq.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include <asm/unaligned.h>
#include "tcm_usb_gadget.h"
@ -1467,23 +1465,21 @@ static void usbg_drop_tport(struct se_wwn *wwn)
/*
* If somebody feels like dropping the version property, go ahead.
*/
static ssize_t usbg_wwn_show_attr_version(
struct target_fabric_configfs *tf,
char *page)
static ssize_t usbg_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "usb-gadget fabric module\n");
}
TF_WWN_ATTR_RO(usbg, version);
CONFIGFS_ATTR_RO(usbg_wwn_, version);
static struct configfs_attribute *usbg_wwn_attrs[] = {
&usbg_wwn_version.attr,
&usbg_wwn_attr_version,
NULL,
};
static ssize_t tcm_usbg_tpg_show_enable(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_usbg_tpg_enable_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect);
@ -1492,11 +1488,10 @@ static ssize_t tcm_usbg_tpg_show_enable(
static int usbg_attach(struct usbg_tpg *);
static void usbg_detach(struct usbg_tpg *);
static ssize_t tcm_usbg_tpg_store_enable(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
unsigned long op;
ssize_t ret;
@ -1523,12 +1518,10 @@ static ssize_t tcm_usbg_tpg_store_enable(
out:
return count;
}
TF_TPG_BASE_ATTR(tcm_usbg, enable, S_IRUGO | S_IWUSR);
static ssize_t tcm_usbg_tpg_show_nexus(
struct se_portal_group *se_tpg,
char *page)
static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
struct tcm_usbg_nexus *tv_nexus;
ssize_t ret;
@ -1636,11 +1629,10 @@ out:
return ret;
}
static ssize_t tcm_usbg_tpg_store_nexus(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
unsigned char i_port[USBG_NAMELEN], *ptr;
int ret;
@ -1670,11 +1662,13 @@ static ssize_t tcm_usbg_tpg_store_nexus(
return ret;
return count;
}
TF_TPG_BASE_ATTR(tcm_usbg, nexus, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(tcm_usbg_tpg_, enable);
CONFIGFS_ATTR(tcm_usbg_tpg_, nexus);
static struct configfs_attribute *usbg_base_attrs[] = {
&tcm_usbg_tpg_enable.attr,
&tcm_usbg_tpg_nexus.attr,
&tcm_usbg_tpg_attr_enable,
&tcm_usbg_tpg_attr_nexus,
NULL,
};

Просмотреть файл

@ -42,8 +42,6 @@
#include <scsi/scsi_proto.h>
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <target/configfs_macros.h>
#include <linux/vhost.h>
#include <linux/virtio_scsi.h>
#include <linux/llist.h>
@ -1684,11 +1682,10 @@ static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus,
}
}
static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type(
struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_store(
struct config_item *item, const char *page, size_t count)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg);
unsigned long val;
@ -1707,19 +1704,20 @@ static ssize_t vhost_scsi_tpg_attrib_store_fabric_prot_type(
return count;
}
static ssize_t vhost_scsi_tpg_attrib_show_fabric_prot_type(
struct se_portal_group *se_tpg,
char *page)
static ssize_t vhost_scsi_tpg_attrib_fabric_prot_type_show(
struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = attrib_to_tpg(item);
struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg);
return sprintf(page, "%d\n", tpg->tv_fabric_prot_type);
}
TF_TPG_ATTRIB_ATTR(vhost_scsi, fabric_prot_type, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(vhost_scsi_tpg_attrib_, fabric_prot_type);
static struct configfs_attribute *vhost_scsi_tpg_attrib_attrs[] = {
&vhost_scsi_tpg_attrib_fabric_prot_type.attr,
&vhost_scsi_tpg_attrib_attr_fabric_prot_type,
NULL,
};
@ -1867,9 +1865,9 @@ static int vhost_scsi_drop_nexus(struct vhost_scsi_tpg *tpg)
return 0;
}
static ssize_t vhost_scsi_tpg_show_nexus(struct se_portal_group *se_tpg,
char *page)
static ssize_t vhost_scsi_tpg_nexus_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg);
struct vhost_scsi_nexus *tv_nexus;
@ -1888,10 +1886,10 @@ static ssize_t vhost_scsi_tpg_show_nexus(struct se_portal_group *se_tpg,
return ret;
}
static ssize_t vhost_scsi_tpg_store_nexus(struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t vhost_scsi_tpg_nexus_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct vhost_scsi_tpg *tpg = container_of(se_tpg,
struct vhost_scsi_tpg, se_tpg);
struct vhost_scsi_tport *tport_wwn = tpg->tport;
@ -1966,10 +1964,10 @@ check_newline:
return count;
}
TF_TPG_BASE_ATTR(vhost_scsi, nexus, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(vhost_scsi_tpg_, nexus);
static struct configfs_attribute *vhost_scsi_tpg_attrs[] = {
&vhost_scsi_tpg_nexus.attr,
&vhost_scsi_tpg_attr_nexus,
NULL,
};
@ -2105,18 +2103,17 @@ static void vhost_scsi_drop_tport(struct se_wwn *wwn)
}
static ssize_t
vhost_scsi_wwn_show_attr_version(struct target_fabric_configfs *tf,
char *page)
vhost_scsi_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "TCM_VHOST fabric module %s on %s/%s"
"on "UTS_RELEASE"\n", VHOST_SCSI_VERSION, utsname()->sysname,
utsname()->machine);
}
TF_WWN_ATTR_RO(vhost_scsi, version);
CONFIGFS_ATTR_RO(vhost_scsi_wwn_, version);
static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
&vhost_scsi_wwn_version.attr,
&vhost_scsi_wwn_attr_version,
NULL,
};

Просмотреть файл

@ -53,7 +53,6 @@
#include <target/target_core_base.h>
#include <target/target_core_fabric.h>
#include <target/target_core_fabric_configfs.h>
#include <asm/hypervisor.h>
@ -1438,9 +1437,10 @@ static void scsiback_aborted_task(struct se_cmd *se_cmd)
{
}
static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg,
static ssize_t scsiback_tpg_param_alias_show(struct config_item *item,
char *page)
{
struct se_portal_group *se_tpg = param_to_tpg(item);
struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg,
se_tpg);
ssize_t rb;
@ -1452,9 +1452,10 @@ static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg,
return rb;
}
static ssize_t scsiback_tpg_param_store_alias(struct se_portal_group *se_tpg,
static ssize_t scsiback_tpg_param_alias_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = param_to_tpg(item);
struct scsiback_tpg *tpg = container_of(se_tpg, struct scsiback_tpg,
se_tpg);
int len;
@ -1474,10 +1475,10 @@ static ssize_t scsiback_tpg_param_store_alias(struct se_portal_group *se_tpg,
return count;
}
TF_TPG_PARAM_ATTR(scsiback, alias, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(scsiback_tpg_param_, alias);
static struct configfs_attribute *scsiback_param_attrs[] = {
&scsiback_tpg_param_alias.attr,
&scsiback_tpg_param_attr_alias,
NULL,
};
@ -1585,9 +1586,9 @@ static int scsiback_drop_nexus(struct scsiback_tpg *tpg)
return 0;
}
static ssize_t scsiback_tpg_show_nexus(struct se_portal_group *se_tpg,
char *page)
static ssize_t scsiback_tpg_nexus_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct scsiback_tpg *tpg = container_of(se_tpg,
struct scsiback_tpg, se_tpg);
struct scsiback_nexus *tv_nexus;
@ -1606,10 +1607,10 @@ static ssize_t scsiback_tpg_show_nexus(struct se_portal_group *se_tpg,
return ret;
}
static ssize_t scsiback_tpg_store_nexus(struct se_portal_group *se_tpg,
const char *page,
size_t count)
static ssize_t scsiback_tpg_nexus_store(struct config_item *item,
const char *page, size_t count)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct scsiback_tpg *tpg = container_of(se_tpg,
struct scsiback_tpg, se_tpg);
struct scsiback_tport *tport_wwn = tpg->tport;
@ -1681,26 +1682,25 @@ check_newline:
return count;
}
TF_TPG_BASE_ATTR(scsiback, nexus, S_IRUGO | S_IWUSR);
CONFIGFS_ATTR(scsiback_tpg_, nexus);
static struct configfs_attribute *scsiback_tpg_attrs[] = {
&scsiback_tpg_nexus.attr,
&scsiback_tpg_attr_nexus,
NULL,
};
static ssize_t
scsiback_wwn_show_attr_version(struct target_fabric_configfs *tf,
char *page)
scsiback_wwn_version_show(struct config_item *item, char *page)
{
return sprintf(page, "xen-pvscsi fabric module %s on %s/%s on "
UTS_RELEASE"\n",
VSCSI_VERSION, utsname()->sysname, utsname()->machine);
}
TF_WWN_ATTR_RO(scsiback, version);
CONFIGFS_ATTR_RO(scsiback_wwn_, version);
static struct configfs_attribute *scsiback_wwn_attrs[] = {
&scsiback_wwn_version.attr,
&scsiback_wwn_attr_version,
NULL,
};

Просмотреть файл

@ -65,7 +65,6 @@ static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buf
{
struct configfs_attribute * attr = to_attr(dentry);
struct config_item * item = to_item(dentry->d_parent);
struct configfs_item_operations * ops = buffer->ops;
int ret = 0;
ssize_t count;
@ -74,7 +73,8 @@ static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buf
if (!buffer->page)
return -ENOMEM;
count = ops->show_attribute(item,attr,buffer->page);
count = attr->show(item, buffer->page);
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE);
if (count >= 0)
@ -171,9 +171,8 @@ flush_write_buffer(struct dentry * dentry, struct configfs_buffer * buffer, size
{
struct configfs_attribute * attr = to_attr(dentry);
struct config_item * item = to_item(dentry->d_parent);
struct configfs_item_operations * ops = buffer->ops;
return ops->store_attribute(item,attr,buffer->page,count);
return attr->store(item, buffer->page, count);
}
@ -237,8 +236,7 @@ static int check_perm(struct inode * inode, struct file * file)
* and we must have a store method.
*/
if (file->f_mode & FMODE_WRITE) {
if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute)
if (!(inode->i_mode & S_IWUGO) || !attr->store)
goto Eaccess;
}
@ -248,7 +246,7 @@ static int check_perm(struct inode * inode, struct file * file)
* must be a show method for it.
*/
if (file->f_mode & FMODE_READ) {
if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute)
if (!(inode->i_mode & S_IRUGO) || !attr->show)
goto Eaccess;
}

Просмотреть файл

@ -61,35 +61,8 @@ static struct config_item *make_node(struct config_group *, const char *);
static void drop_node(struct config_group *, struct config_item *);
static void release_node(struct config_item *);
static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a,
char *buf);
static ssize_t store_cluster(struct config_item *i,
struct configfs_attribute *a,
const char *buf, size_t len);
static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
char *buf);
static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a,
const char *buf, size_t len);
static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
char *buf);
static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
const char *buf, size_t len);
static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf);
static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf,
size_t len);
static ssize_t comm_local_read(struct dlm_comm *cm, char *buf);
static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
size_t len);
static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf,
size_t len);
static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf);
static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf);
static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
size_t len);
static ssize_t node_weight_read(struct dlm_node *nd, char *buf);
static ssize_t node_weight_write(struct dlm_node *nd, const char *buf,
size_t len);
static struct configfs_attribute *comm_attrs[];
static struct configfs_attribute *node_attrs[];
struct dlm_cluster {
struct config_group group;
@ -108,6 +81,12 @@ struct dlm_cluster {
char cl_cluster_name[DLM_LOCKSPACE_LEN];
};
static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
{
return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
NULL;
}
enum {
CLUSTER_ATTR_TCP_PORT = 0,
CLUSTER_ATTR_BUFFER_SIZE,
@ -124,33 +103,24 @@ enum {
CLUSTER_ATTR_CLUSTER_NAME,
};
struct cluster_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct dlm_cluster *, char *);
ssize_t (*store)(struct dlm_cluster *, const char *, size_t);
};
static ssize_t cluster_cluster_name_read(struct dlm_cluster *cl, char *buf)
static ssize_t cluster_cluster_name_show(struct config_item *item, char *buf)
{
struct dlm_cluster *cl = config_item_to_cluster(item);
return sprintf(buf, "%s\n", cl->cl_cluster_name);
}
static ssize_t cluster_cluster_name_write(struct dlm_cluster *cl,
static ssize_t cluster_cluster_name_store(struct config_item *item,
const char *buf, size_t len)
{
struct dlm_cluster *cl = config_item_to_cluster(item);
strlcpy(dlm_config.ci_cluster_name, buf,
sizeof(dlm_config.ci_cluster_name));
strlcpy(cl->cl_cluster_name, buf, sizeof(cl->cl_cluster_name));
return len;
}
static struct cluster_attribute cluster_attr_cluster_name = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "cluster_name",
.ca_mode = S_IRUGO | S_IWUSR },
.show = cluster_cluster_name_read,
.store = cluster_cluster_name_write,
};
CONFIGFS_ATTR(cluster_, cluster_name);
static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
int *info_field, int check_zero,
@ -175,17 +145,19 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,
}
#define CLUSTER_ATTR(name, check_zero) \
static ssize_t name##_write(struct dlm_cluster *cl, const char *buf, size_t len) \
static ssize_t cluster_##name##_store(struct config_item *item, \
const char *buf, size_t len) \
{ \
struct dlm_cluster *cl = config_item_to_cluster(item); \
return cluster_set(cl, &cl->cl_##name, &dlm_config.ci_##name, \
check_zero, buf, len); \
} \
static ssize_t name##_read(struct dlm_cluster *cl, char *buf) \
static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
{ \
struct dlm_cluster *cl = config_item_to_cluster(item); \
return snprintf(buf, PAGE_SIZE, "%u\n", cl->cl_##name); \
} \
static struct cluster_attribute cluster_attr_##name = \
__CONFIGFS_ATTR(name, 0644, name##_read, name##_write)
CONFIGFS_ATTR(cluster_, name);
CLUSTER_ATTR(tcp_port, 1);
CLUSTER_ATTR(buffer_size, 1);
@ -201,19 +173,19 @@ CLUSTER_ATTR(new_rsb_count, 0);
CLUSTER_ATTR(recover_callbacks, 0);
static struct configfs_attribute *cluster_attrs[] = {
[CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port.attr,
[CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size.attr,
[CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size.attr,
[CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer.attr,
[CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs.attr,
[CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs.attr,
[CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug.attr,
[CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol.attr,
[CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs.attr,
[CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us.attr,
[CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count.attr,
[CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks.attr,
[CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name.attr,
[CLUSTER_ATTR_TCP_PORT] = &cluster_attr_tcp_port,
[CLUSTER_ATTR_BUFFER_SIZE] = &cluster_attr_buffer_size,
[CLUSTER_ATTR_RSBTBL_SIZE] = &cluster_attr_rsbtbl_size,
[CLUSTER_ATTR_RECOVER_TIMER] = &cluster_attr_recover_timer,
[CLUSTER_ATTR_TOSS_SECS] = &cluster_attr_toss_secs,
[CLUSTER_ATTR_SCAN_SECS] = &cluster_attr_scan_secs,
[CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug,
[CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol,
[CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs,
[CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us,
[CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count,
[CLUSTER_ATTR_RECOVER_CALLBACKS] = &cluster_attr_recover_callbacks,
[CLUSTER_ATTR_CLUSTER_NAME] = &cluster_attr_cluster_name,
NULL,
};
@ -224,83 +196,11 @@ enum {
COMM_ATTR_ADDR_LIST,
};
struct comm_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct dlm_comm *, char *);
ssize_t (*store)(struct dlm_comm *, const char *, size_t);
};
static struct comm_attribute comm_attr_nodeid = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "nodeid",
.ca_mode = S_IRUGO | S_IWUSR },
.show = comm_nodeid_read,
.store = comm_nodeid_write,
};
static struct comm_attribute comm_attr_local = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "local",
.ca_mode = S_IRUGO | S_IWUSR },
.show = comm_local_read,
.store = comm_local_write,
};
static struct comm_attribute comm_attr_addr = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "addr",
.ca_mode = S_IWUSR },
.store = comm_addr_write,
};
static struct comm_attribute comm_attr_addr_list = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "addr_list",
.ca_mode = S_IRUGO },
.show = comm_addr_list_read,
};
static struct configfs_attribute *comm_attrs[] = {
[COMM_ATTR_NODEID] = &comm_attr_nodeid.attr,
[COMM_ATTR_LOCAL] = &comm_attr_local.attr,
[COMM_ATTR_ADDR] = &comm_attr_addr.attr,
[COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list.attr,
NULL,
};
enum {
NODE_ATTR_NODEID = 0,
NODE_ATTR_WEIGHT,
};
struct node_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct dlm_node *, char *);
ssize_t (*store)(struct dlm_node *, const char *, size_t);
};
static struct node_attribute node_attr_nodeid = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "nodeid",
.ca_mode = S_IRUGO | S_IWUSR },
.show = node_nodeid_read,
.store = node_nodeid_write,
};
static struct node_attribute node_attr_weight = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "weight",
.ca_mode = S_IRUGO | S_IWUSR },
.show = node_weight_read,
.store = node_weight_write,
};
static struct configfs_attribute *node_attrs[] = {
[NODE_ATTR_NODEID] = &node_attr_nodeid.attr,
[NODE_ATTR_WEIGHT] = &node_attr_weight.attr,
NULL,
};
struct dlm_clusters {
struct configfs_subsystem subsys;
};
@ -349,8 +249,6 @@ static struct configfs_group_operations clusters_ops = {
static struct configfs_item_operations cluster_ops = {
.release = release_cluster,
.show_attribute = show_cluster,
.store_attribute = store_cluster,
};
static struct configfs_group_operations spaces_ops = {
@ -369,8 +267,6 @@ static struct configfs_group_operations comms_ops = {
static struct configfs_item_operations comm_ops = {
.release = release_comm,
.show_attribute = show_comm,
.store_attribute = store_comm,
};
static struct configfs_group_operations nodes_ops = {
@ -380,8 +276,6 @@ static struct configfs_group_operations nodes_ops = {
static struct configfs_item_operations node_ops = {
.release = release_node,
.show_attribute = show_node,
.store_attribute = store_node,
};
static struct config_item_type clusters_type = {
@ -427,12 +321,6 @@ static struct config_item_type node_type = {
.ct_owner = THIS_MODULE,
};
static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
{
return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
NULL;
}
static struct dlm_space *config_item_to_space(struct config_item *i)
{
return i ? container_of(to_config_group(i), struct dlm_space, group) :
@ -687,66 +575,30 @@ void dlm_config_exit(void)
* Functions for user space to read/write attributes
*/
static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a,
char *buf)
static ssize_t comm_nodeid_show(struct config_item *item, char *buf)
{
struct dlm_cluster *cl = config_item_to_cluster(i);
struct cluster_attribute *cla =
container_of(a, struct cluster_attribute, attr);
return cla->show ? cla->show(cl, buf) : 0;
return sprintf(buf, "%d\n", config_item_to_comm(item)->nodeid);
}
static ssize_t store_cluster(struct config_item *i,
struct configfs_attribute *a,
const char *buf, size_t len)
{
struct dlm_cluster *cl = config_item_to_cluster(i);
struct cluster_attribute *cla =
container_of(a, struct cluster_attribute, attr);
return cla->store ? cla->store(cl, buf, len) : -EINVAL;
}
static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
char *buf)
{
struct dlm_comm *cm = config_item_to_comm(i);
struct comm_attribute *cma =
container_of(a, struct comm_attribute, attr);
return cma->show ? cma->show(cm, buf) : 0;
}
static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a,
const char *buf, size_t len)
{
struct dlm_comm *cm = config_item_to_comm(i);
struct comm_attribute *cma =
container_of(a, struct comm_attribute, attr);
return cma->store ? cma->store(cm, buf, len) : -EINVAL;
}
static ssize_t comm_nodeid_read(struct dlm_comm *cm, char *buf)
{
return sprintf(buf, "%d\n", cm->nodeid);
}
static ssize_t comm_nodeid_write(struct dlm_comm *cm, const char *buf,
static ssize_t comm_nodeid_store(struct config_item *item, const char *buf,
size_t len)
{
int rc = kstrtoint(buf, 0, &cm->nodeid);
int rc = kstrtoint(buf, 0, &config_item_to_comm(item)->nodeid);
if (rc)
return rc;
return len;
}
static ssize_t comm_local_read(struct dlm_comm *cm, char *buf)
static ssize_t comm_local_show(struct config_item *item, char *buf)
{
return sprintf(buf, "%d\n", cm->local);
return sprintf(buf, "%d\n", config_item_to_comm(item)->local);
}
static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
static ssize_t comm_local_store(struct config_item *item, const char *buf,
size_t len)
{
struct dlm_comm *cm = config_item_to_comm(item);
int rc = kstrtoint(buf, 0, &cm->local);
if (rc)
@ -756,8 +608,10 @@ static ssize_t comm_local_write(struct dlm_comm *cm, const char *buf,
return len;
}
static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
static ssize_t comm_addr_store(struct config_item *item, const char *buf,
size_t len)
{
struct dlm_comm *cm = config_item_to_comm(item);
struct sockaddr_storage *addr;
int rv;
@ -783,8 +637,9 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
return len;
}
static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf)
static ssize_t comm_addr_list_show(struct config_item *item, char *buf)
{
struct dlm_comm *cm = config_item_to_comm(item);
ssize_t s;
ssize_t allowance;
int i;
@ -827,32 +682,28 @@ static ssize_t comm_addr_list_read(struct dlm_comm *cm, char *buf)
return 4096 - allowance;
}
static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
char *buf)
CONFIGFS_ATTR(comm_, nodeid);
CONFIGFS_ATTR(comm_, local);
CONFIGFS_ATTR_WO(comm_, addr);
CONFIGFS_ATTR_RO(comm_, addr_list);
static struct configfs_attribute *comm_attrs[] = {
[COMM_ATTR_NODEID] = &comm_attr_nodeid,
[COMM_ATTR_LOCAL] = &comm_attr_local,
[COMM_ATTR_ADDR] = &comm_attr_addr,
[COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list,
NULL,
};
static ssize_t node_nodeid_show(struct config_item *item, char *buf)
{
struct dlm_node *nd = config_item_to_node(i);
struct node_attribute *nda =
container_of(a, struct node_attribute, attr);
return nda->show ? nda->show(nd, buf) : 0;
return sprintf(buf, "%d\n", config_item_to_node(item)->nodeid);
}
static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
const char *buf, size_t len)
{
struct dlm_node *nd = config_item_to_node(i);
struct node_attribute *nda =
container_of(a, struct node_attribute, attr);
return nda->store ? nda->store(nd, buf, len) : -EINVAL;
}
static ssize_t node_nodeid_read(struct dlm_node *nd, char *buf)
{
return sprintf(buf, "%d\n", nd->nodeid);
}
static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
static ssize_t node_nodeid_store(struct config_item *item, const char *buf,
size_t len)
{
struct dlm_node *nd = config_item_to_node(item);
uint32_t seq = 0;
int rc = kstrtoint(buf, 0, &nd->nodeid);
@ -863,21 +714,30 @@ static ssize_t node_nodeid_write(struct dlm_node *nd, const char *buf,
return len;
}
static ssize_t node_weight_read(struct dlm_node *nd, char *buf)
static ssize_t node_weight_show(struct config_item *item, char *buf)
{
return sprintf(buf, "%d\n", nd->weight);
return sprintf(buf, "%d\n", config_item_to_node(item)->weight);
}
static ssize_t node_weight_write(struct dlm_node *nd, const char *buf,
static ssize_t node_weight_store(struct config_item *item, const char *buf,
size_t len)
{
int rc = kstrtoint(buf, 0, &nd->weight);
int rc = kstrtoint(buf, 0, &config_item_to_node(item)->weight);
if (rc)
return rc;
return len;
}
CONFIGFS_ATTR(node_, nodeid);
CONFIGFS_ATTR(node_, weight);
static struct configfs_attribute *node_attrs[] = {
[NODE_ATTR_NODEID] = &node_attr_nodeid,
[NODE_ATTR_WEIGHT] = &node_attr_weight,
NULL,
};
/*
* Functions for the dlm to get the info that's been configured
*/

Просмотреть файл

@ -1480,16 +1480,17 @@ static int o2hb_read_block_input(struct o2hb_region *reg,
return 0;
}
static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg,
static ssize_t o2hb_region_block_bytes_show(struct config_item *item,
char *page)
{
return sprintf(page, "%u\n", reg->hr_block_bytes);
return sprintf(page, "%u\n", to_o2hb_region(item)->hr_block_bytes);
}
static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg,
static ssize_t o2hb_region_block_bytes_store(struct config_item *item,
const char *page,
size_t count)
{
struct o2hb_region *reg = to_o2hb_region(item);
int status;
unsigned long block_bytes;
unsigned int block_bits;
@ -1508,16 +1509,17 @@ static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg,
return count;
}
static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg,
static ssize_t o2hb_region_start_block_show(struct config_item *item,
char *page)
{
return sprintf(page, "%llu\n", reg->hr_start_block);
return sprintf(page, "%llu\n", to_o2hb_region(item)->hr_start_block);
}
static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg,
static ssize_t o2hb_region_start_block_store(struct config_item *item,
const char *page,
size_t count)
{
struct o2hb_region *reg = to_o2hb_region(item);
unsigned long long tmp;
char *p = (char *)page;
@ -1533,16 +1535,16 @@ static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg,
return count;
}
static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg,
char *page)
static ssize_t o2hb_region_blocks_show(struct config_item *item, char *page)
{
return sprintf(page, "%d\n", reg->hr_blocks);
return sprintf(page, "%d\n", to_o2hb_region(item)->hr_blocks);
}
static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg,
static ssize_t o2hb_region_blocks_store(struct config_item *item,
const char *page,
size_t count)
{
struct o2hb_region *reg = to_o2hb_region(item);
unsigned long tmp;
char *p = (char *)page;
@ -1561,13 +1563,12 @@ static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg,
return count;
}
static ssize_t o2hb_region_dev_read(struct o2hb_region *reg,
char *page)
static ssize_t o2hb_region_dev_show(struct config_item *item, char *page)
{
unsigned int ret = 0;
if (reg->hr_bdev)
ret = sprintf(page, "%s\n", reg->hr_dev_name);
if (to_o2hb_region(item)->hr_bdev)
ret = sprintf(page, "%s\n", to_o2hb_region(item)->hr_dev_name);
return ret;
}
@ -1677,10 +1678,11 @@ out:
}
/* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */
static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
static ssize_t o2hb_region_dev_store(struct config_item *item,
const char *page,
size_t count)
{
struct o2hb_region *reg = to_o2hb_region(item);
struct task_struct *hb_task;
long fd;
int sectsize;
@ -1841,9 +1843,9 @@ out:
return ret;
}
static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
char *page)
static ssize_t o2hb_region_pid_show(struct config_item *item, char *page)
{
struct o2hb_region *reg = to_o2hb_region(item);
pid_t pid = 0;
spin_lock(&o2hb_live_lock);
@ -1857,92 +1859,23 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,
return sprintf(page, "%u\n", pid);
}
struct o2hb_region_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct o2hb_region *, char *);
ssize_t (*store)(struct o2hb_region *, const char *, size_t);
};
static struct o2hb_region_attribute o2hb_region_attr_block_bytes = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "block_bytes",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_region_block_bytes_read,
.store = o2hb_region_block_bytes_write,
};
static struct o2hb_region_attribute o2hb_region_attr_start_block = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "start_block",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_region_start_block_read,
.store = o2hb_region_start_block_write,
};
static struct o2hb_region_attribute o2hb_region_attr_blocks = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "blocks",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_region_blocks_read,
.store = o2hb_region_blocks_write,
};
static struct o2hb_region_attribute o2hb_region_attr_dev = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "dev",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_region_dev_read,
.store = o2hb_region_dev_write,
};
static struct o2hb_region_attribute o2hb_region_attr_pid = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "pid",
.ca_mode = S_IRUGO | S_IRUSR },
.show = o2hb_region_pid_read,
};
CONFIGFS_ATTR(o2hb_region_, block_bytes);
CONFIGFS_ATTR(o2hb_region_, start_block);
CONFIGFS_ATTR(o2hb_region_, blocks);
CONFIGFS_ATTR(o2hb_region_, dev);
CONFIGFS_ATTR_RO(o2hb_region_, pid);
static struct configfs_attribute *o2hb_region_attrs[] = {
&o2hb_region_attr_block_bytes.attr,
&o2hb_region_attr_start_block.attr,
&o2hb_region_attr_blocks.attr,
&o2hb_region_attr_dev.attr,
&o2hb_region_attr_pid.attr,
&o2hb_region_attr_block_bytes,
&o2hb_region_attr_start_block,
&o2hb_region_attr_blocks,
&o2hb_region_attr_dev,
&o2hb_region_attr_pid,
NULL,
};
static ssize_t o2hb_region_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct o2hb_region *reg = to_o2hb_region(item);
struct o2hb_region_attribute *o2hb_region_attr =
container_of(attr, struct o2hb_region_attribute, attr);
ssize_t ret = 0;
if (o2hb_region_attr->show)
ret = o2hb_region_attr->show(reg, page);
return ret;
}
static ssize_t o2hb_region_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct o2hb_region *reg = to_o2hb_region(item);
struct o2hb_region_attribute *o2hb_region_attr =
container_of(attr, struct o2hb_region_attribute, attr);
ssize_t ret = -EINVAL;
if (o2hb_region_attr->store)
ret = o2hb_region_attr->store(reg, page, count);
return ret;
}
static struct configfs_item_operations o2hb_region_item_ops = {
.release = o2hb_region_release,
.show_attribute = o2hb_region_show,
.store_attribute = o2hb_region_store,
};
static struct config_item_type o2hb_region_type = {
@ -2137,49 +2070,14 @@ unlock:
spin_unlock(&o2hb_live_lock);
}
struct o2hb_heartbeat_group_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct o2hb_heartbeat_group *, char *);
ssize_t (*store)(struct o2hb_heartbeat_group *, const char *, size_t);
};
static ssize_t o2hb_heartbeat_group_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item));
struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr =
container_of(attr, struct o2hb_heartbeat_group_attribute, attr);
ssize_t ret = 0;
if (o2hb_heartbeat_group_attr->show)
ret = o2hb_heartbeat_group_attr->show(reg, page);
return ret;
}
static ssize_t o2hb_heartbeat_group_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item));
struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr =
container_of(attr, struct o2hb_heartbeat_group_attribute, attr);
ssize_t ret = -EINVAL;
if (o2hb_heartbeat_group_attr->store)
ret = o2hb_heartbeat_group_attr->store(reg, page, count);
return ret;
}
static ssize_t o2hb_heartbeat_group_threshold_show(struct o2hb_heartbeat_group *group,
char *page)
static ssize_t o2hb_heartbeat_group_threshold_show(struct config_item *item,
char *page)
{
return sprintf(page, "%u\n", o2hb_dead_threshold);
}
static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group *group,
const char *page,
size_t count)
static ssize_t o2hb_heartbeat_group_threshold_store(struct config_item *item,
const char *page, size_t count)
{
unsigned long tmp;
char *p = (char *)page;
@ -2194,17 +2092,15 @@ static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group
return count;
}
static
ssize_t o2hb_heartbeat_group_mode_show(struct o2hb_heartbeat_group *group,
char *page)
static ssize_t o2hb_heartbeat_group_mode_show(struct config_item *item,
char *page)
{
return sprintf(page, "%s\n",
o2hb_heartbeat_mode_desc[o2hb_heartbeat_mode]);
}
static
ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group,
const char *page, size_t count)
static ssize_t o2hb_heartbeat_group_mode_store(struct config_item *item,
const char *page, size_t count)
{
unsigned int i;
int ret;
@ -2229,33 +2125,15 @@ ssize_t o2hb_heartbeat_group_mode_store(struct o2hb_heartbeat_group *group,
}
static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "dead_threshold",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_heartbeat_group_threshold_show,
.store = o2hb_heartbeat_group_threshold_store,
};
static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_mode = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "mode",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2hb_heartbeat_group_mode_show,
.store = o2hb_heartbeat_group_mode_store,
};
CONFIGFS_ATTR(o2hb_heartbeat_group_, threshold);
CONFIGFS_ATTR(o2hb_heartbeat_group_, mode);
static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = {
&o2hb_heartbeat_group_attr_threshold.attr,
&o2hb_heartbeat_group_attr_mode.attr,
&o2hb_heartbeat_group_attr_threshold,
&o2hb_heartbeat_group_attr_mode,
NULL,
};
static struct configfs_item_operations o2hb_heartbeat_group_item_ops = {
.show_attribute = o2hb_heartbeat_group_show,
.store_attribute = o2hb_heartbeat_group_store,
};
static struct configfs_group_operations o2hb_heartbeat_group_group_ops = {
.make_item = o2hb_heartbeat_group_make_item,
.drop_item = o2hb_heartbeat_group_drop_item,
@ -2263,7 +2141,6 @@ static struct configfs_group_operations o2hb_heartbeat_group_group_ops = {
static struct config_item_type o2hb_heartbeat_group_type = {
.ct_group_ops = &o2hb_heartbeat_group_group_ops,
.ct_item_ops = &o2hb_heartbeat_group_item_ops,
.ct_attrs = o2hb_heartbeat_group_attrs,
.ct_owner = THIS_MODULE,
};

Просмотреть файл

@ -172,9 +172,9 @@ static void o2nm_node_release(struct config_item *item)
kfree(node);
}
static ssize_t o2nm_node_num_read(struct o2nm_node *node, char *page)
static ssize_t o2nm_node_num_show(struct config_item *item, char *page)
{
return sprintf(page, "%d\n", node->nd_num);
return sprintf(page, "%d\n", to_o2nm_node(item)->nd_num);
}
static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node)
@ -188,15 +188,16 @@ enum {
O2NM_NODE_ATTR_NUM = 0,
O2NM_NODE_ATTR_PORT,
O2NM_NODE_ATTR_ADDRESS,
O2NM_NODE_ATTR_LOCAL,
};
static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page,
static ssize_t o2nm_node_num_store(struct config_item *item, const char *page,
size_t count)
{
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
unsigned long tmp;
char *p = (char *)page;
int ret = 0;
tmp = simple_strtoul(p, &p, 0);
if (!p || (*p && (*p != '\n')))
@ -215,26 +216,30 @@ static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page,
write_lock(&cluster->cl_nodes_lock);
if (cluster->cl_nodes[tmp])
p = NULL;
ret = -EEXIST;
else if (test_and_set_bit(O2NM_NODE_ATTR_NUM,
&node->nd_set_attributes))
ret = -EBUSY;
else {
cluster->cl_nodes[tmp] = node;
node->nd_num = tmp;
set_bit(tmp, cluster->cl_nodes_bitmap);
}
write_unlock(&cluster->cl_nodes_lock);
if (p == NULL)
return -EEXIST;
if (ret)
return ret;
return count;
}
static ssize_t o2nm_node_ipv4_port_read(struct o2nm_node *node, char *page)
static ssize_t o2nm_node_ipv4_port_show(struct config_item *item, char *page)
{
return sprintf(page, "%u\n", ntohs(node->nd_ipv4_port));
return sprintf(page, "%u\n", ntohs(to_o2nm_node(item)->nd_ipv4_port));
}
static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node,
static ssize_t o2nm_node_ipv4_port_store(struct config_item *item,
const char *page, size_t count)
{
struct o2nm_node *node = to_o2nm_node(item);
unsigned long tmp;
char *p = (char *)page;
@ -247,20 +252,23 @@ static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node,
if (tmp >= (u16)-1)
return -ERANGE;
if (test_and_set_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes))
return -EBUSY;
node->nd_ipv4_port = htons(tmp);
return count;
}
static ssize_t o2nm_node_ipv4_address_read(struct o2nm_node *node, char *page)
static ssize_t o2nm_node_ipv4_address_show(struct config_item *item, char *page)
{
return sprintf(page, "%pI4\n", &node->nd_ipv4_address);
return sprintf(page, "%pI4\n", &to_o2nm_node(item)->nd_ipv4_address);
}
static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node,
static ssize_t o2nm_node_ipv4_address_store(struct config_item *item,
const char *page,
size_t count)
{
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
int ret, i;
struct rb_node **p, *parent;
@ -282,6 +290,9 @@ static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node,
write_lock(&cluster->cl_nodes_lock);
if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent))
ret = -EEXIST;
else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS,
&node->nd_set_attributes))
ret = -EBUSY;
else {
rb_link_node(&node->nd_ip_node, parent, p);
rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree);
@ -295,14 +306,15 @@ static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node,
return count;
}
static ssize_t o2nm_node_local_read(struct o2nm_node *node, char *page)
static ssize_t o2nm_node_local_show(struct config_item *item, char *page)
{
return sprintf(page, "%d\n", node->nd_local);
return sprintf(page, "%d\n", to_o2nm_node(item)->nd_local);
}
static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page,
static ssize_t o2nm_node_local_store(struct config_item *item, const char *page,
size_t count)
{
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node);
unsigned long tmp;
char *p = (char *)page;
@ -349,108 +361,21 @@ static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page,
return count;
}
struct o2nm_node_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct o2nm_node *, char *);
ssize_t (*store)(struct o2nm_node *, const char *, size_t);
};
static struct o2nm_node_attribute o2nm_node_attr_num = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "num",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_node_num_read,
.store = o2nm_node_num_write,
};
static struct o2nm_node_attribute o2nm_node_attr_ipv4_port = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "ipv4_port",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_node_ipv4_port_read,
.store = o2nm_node_ipv4_port_write,
};
static struct o2nm_node_attribute o2nm_node_attr_ipv4_address = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "ipv4_address",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_node_ipv4_address_read,
.store = o2nm_node_ipv4_address_write,
};
static struct o2nm_node_attribute o2nm_node_attr_local = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "local",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_node_local_read,
.store = o2nm_node_local_write,
};
CONFIGFS_ATTR(o2nm_node_, num);
CONFIGFS_ATTR(o2nm_node_, ipv4_port);
CONFIGFS_ATTR(o2nm_node_, ipv4_address);
CONFIGFS_ATTR(o2nm_node_, local);
static struct configfs_attribute *o2nm_node_attrs[] = {
[O2NM_NODE_ATTR_NUM] = &o2nm_node_attr_num.attr,
[O2NM_NODE_ATTR_PORT] = &o2nm_node_attr_ipv4_port.attr,
[O2NM_NODE_ATTR_ADDRESS] = &o2nm_node_attr_ipv4_address.attr,
[O2NM_NODE_ATTR_LOCAL] = &o2nm_node_attr_local.attr,
&o2nm_node_attr_num,
&o2nm_node_attr_ipv4_port,
&o2nm_node_attr_ipv4_address,
&o2nm_node_attr_local,
NULL,
};
static int o2nm_attr_index(struct configfs_attribute *attr)
{
int i;
for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) {
if (attr == o2nm_node_attrs[i])
return i;
}
BUG();
return 0;
}
static ssize_t o2nm_node_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_node_attribute *o2nm_node_attr =
container_of(attr, struct o2nm_node_attribute, attr);
ssize_t ret = 0;
if (o2nm_node_attr->show)
ret = o2nm_node_attr->show(node, page);
return ret;
}
static ssize_t o2nm_node_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct o2nm_node *node = to_o2nm_node(item);
struct o2nm_node_attribute *o2nm_node_attr =
container_of(attr, struct o2nm_node_attribute, attr);
ssize_t ret;
int attr_index = o2nm_attr_index(attr);
if (o2nm_node_attr->store == NULL) {
ret = -EINVAL;
goto out;
}
if (test_bit(attr_index, &node->nd_set_attributes))
return -EBUSY;
ret = o2nm_node_attr->store(node, page, count);
if (ret < count)
goto out;
set_bit(attr_index, &node->nd_set_attributes);
out:
return ret;
}
static struct configfs_item_operations o2nm_node_item_ops = {
.release = o2nm_node_release,
.show_attribute = o2nm_node_show,
.store_attribute = o2nm_node_store,
};
static struct config_item_type o2nm_node_type = {
@ -475,12 +400,6 @@ static struct o2nm_node_group *to_o2nm_node_group(struct config_group *group)
}
#endif
struct o2nm_cluster_attribute {
struct configfs_attribute attr;
ssize_t (*show)(struct o2nm_cluster *, char *);
ssize_t (*store)(struct o2nm_cluster *, const char *, size_t);
};
static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count,
unsigned int *val)
{
@ -501,15 +420,16 @@ static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count,
return count;
}
static ssize_t o2nm_cluster_attr_idle_timeout_ms_read(
struct o2nm_cluster *cluster, char *page)
static ssize_t o2nm_cluster_idle_timeout_ms_show(struct config_item *item,
char *page)
{
return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms);
return sprintf(page, "%u\n", to_o2nm_cluster(item)->cl_idle_timeout_ms);
}
static ssize_t o2nm_cluster_attr_idle_timeout_ms_write(
struct o2nm_cluster *cluster, const char *page, size_t count)
static ssize_t o2nm_cluster_idle_timeout_ms_store(struct config_item *item,
const char *page, size_t count)
{
struct o2nm_cluster *cluster = to_o2nm_cluster(item);
ssize_t ret;
unsigned int val;
@ -536,15 +456,17 @@ static ssize_t o2nm_cluster_attr_idle_timeout_ms_write(
return ret;
}
static ssize_t o2nm_cluster_attr_keepalive_delay_ms_read(
struct o2nm_cluster *cluster, char *page)
static ssize_t o2nm_cluster_keepalive_delay_ms_show(
struct config_item *item, char *page)
{
return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms);
return sprintf(page, "%u\n",
to_o2nm_cluster(item)->cl_keepalive_delay_ms);
}
static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write(
struct o2nm_cluster *cluster, const char *page, size_t count)
static ssize_t o2nm_cluster_keepalive_delay_ms_store(
struct config_item *item, const char *page, size_t count)
{
struct o2nm_cluster *cluster = to_o2nm_cluster(item);
ssize_t ret;
unsigned int val;
@ -571,22 +493,24 @@ static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write(
return ret;
}
static ssize_t o2nm_cluster_attr_reconnect_delay_ms_read(
struct o2nm_cluster *cluster, char *page)
static ssize_t o2nm_cluster_reconnect_delay_ms_show(
struct config_item *item, char *page)
{
return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms);
return sprintf(page, "%u\n",
to_o2nm_cluster(item)->cl_reconnect_delay_ms);
}
static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write(
struct o2nm_cluster *cluster, const char *page, size_t count)
static ssize_t o2nm_cluster_reconnect_delay_ms_store(
struct config_item *item, const char *page, size_t count)
{
return o2nm_cluster_attr_write(page, count,
&cluster->cl_reconnect_delay_ms);
&to_o2nm_cluster(item)->cl_reconnect_delay_ms);
}
static ssize_t o2nm_cluster_attr_fence_method_read(
struct o2nm_cluster *cluster, char *page)
static ssize_t o2nm_cluster_fence_method_show(
struct config_item *item, char *page)
{
struct o2nm_cluster *cluster = to_o2nm_cluster(item);
ssize_t ret = 0;
if (cluster)
@ -595,8 +519,8 @@ static ssize_t o2nm_cluster_attr_fence_method_read(
return ret;
}
static ssize_t o2nm_cluster_attr_fence_method_write(
struct o2nm_cluster *cluster, const char *page, size_t count)
static ssize_t o2nm_cluster_fence_method_store(
struct config_item *item, const char *page, size_t count)
{
unsigned int i;
@ -608,10 +532,10 @@ static ssize_t o2nm_cluster_attr_fence_method_write(
continue;
if (strncasecmp(page, o2nm_fence_method_desc[i], count - 1))
continue;
if (cluster->cl_fence_method != i) {
if (to_o2nm_cluster(item)->cl_fence_method != i) {
printk(KERN_INFO "ocfs2: Changing fence method to %s\n",
o2nm_fence_method_desc[i]);
cluster->cl_fence_method = i;
to_o2nm_cluster(item)->cl_fence_method = i;
}
return count;
}
@ -620,79 +544,18 @@ bail:
return -EINVAL;
}
static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "idle_timeout_ms",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_cluster_attr_idle_timeout_ms_read,
.store = o2nm_cluster_attr_idle_timeout_ms_write,
};
static struct o2nm_cluster_attribute o2nm_cluster_attr_keepalive_delay_ms = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "keepalive_delay_ms",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_cluster_attr_keepalive_delay_ms_read,
.store = o2nm_cluster_attr_keepalive_delay_ms_write,
};
static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "reconnect_delay_ms",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_cluster_attr_reconnect_delay_ms_read,
.store = o2nm_cluster_attr_reconnect_delay_ms_write,
};
static struct o2nm_cluster_attribute o2nm_cluster_attr_fence_method = {
.attr = { .ca_owner = THIS_MODULE,
.ca_name = "fence_method",
.ca_mode = S_IRUGO | S_IWUSR },
.show = o2nm_cluster_attr_fence_method_read,
.store = o2nm_cluster_attr_fence_method_write,
};
CONFIGFS_ATTR(o2nm_cluster_, idle_timeout_ms);
CONFIGFS_ATTR(o2nm_cluster_, keepalive_delay_ms);
CONFIGFS_ATTR(o2nm_cluster_, reconnect_delay_ms);
CONFIGFS_ATTR(o2nm_cluster_, fence_method);
static struct configfs_attribute *o2nm_cluster_attrs[] = {
&o2nm_cluster_attr_idle_timeout_ms.attr,
&o2nm_cluster_attr_keepalive_delay_ms.attr,
&o2nm_cluster_attr_reconnect_delay_ms.attr,
&o2nm_cluster_attr_fence_method.attr,
&o2nm_cluster_attr_idle_timeout_ms,
&o2nm_cluster_attr_keepalive_delay_ms,
&o2nm_cluster_attr_reconnect_delay_ms,
&o2nm_cluster_attr_fence_method,
NULL,
};
static ssize_t o2nm_cluster_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
{
struct o2nm_cluster *cluster = to_o2nm_cluster(item);
struct o2nm_cluster_attribute *o2nm_cluster_attr =
container_of(attr, struct o2nm_cluster_attribute, attr);
ssize_t ret = 0;
if (o2nm_cluster_attr->show)
ret = o2nm_cluster_attr->show(cluster, page);
return ret;
}
static ssize_t o2nm_cluster_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
{
struct o2nm_cluster *cluster = to_o2nm_cluster(item);
struct o2nm_cluster_attribute *o2nm_cluster_attr =
container_of(attr, struct o2nm_cluster_attribute, attr);
ssize_t ret;
if (o2nm_cluster_attr->store == NULL) {
ret = -EINVAL;
goto out;
}
ret = o2nm_cluster_attr->store(cluster, page, count);
if (ret < count)
goto out;
out:
return ret;
}
static struct config_item *o2nm_node_group_make_item(struct config_group *group,
const char *name)
@ -773,8 +636,6 @@ static void o2nm_cluster_release(struct config_item *item)
static struct configfs_item_operations o2nm_cluster_item_ops = {
.release = o2nm_cluster_release,
.show_attribute = o2nm_cluster_show,
.store_attribute = o2nm_cluster_store,
};
static struct config_item_type o2nm_cluster_type = {

Просмотреть файл

@ -125,86 +125,33 @@ struct configfs_attribute {
const char *ca_name;
struct module *ca_owner;
umode_t ca_mode;
ssize_t (*show)(struct config_item *, char *);
ssize_t (*store)(struct config_item *, const char *, size_t);
};
/*
* Users often need to create attribute structures for their configurable
* attributes, containing a configfs_attribute member and function pointers
* for the show() and store() operations on that attribute. If they don't
* need anything else on the extended attribute structure, they can use
* this macro to define it The argument _item is the name of the
* config_item structure.
*/
#define CONFIGFS_ATTR_STRUCT(_item) \
struct _item##_attribute { \
struct configfs_attribute attr; \
ssize_t (*show)(struct _item *, char *); \
ssize_t (*store)(struct _item *, const char *, size_t); \
#define CONFIGFS_ATTR(_pfx, _name) \
static struct configfs_attribute _pfx##attr_##_name = { \
.ca_name = __stringify(_name), \
.ca_mode = S_IRUGO | S_IWUSR, \
.ca_owner = THIS_MODULE, \
.show = _pfx##_name##_show, \
.store = _pfx##_name##_store, \
}
/*
* With the extended attribute structure, users can use this macro
* (similar to sysfs' __ATTR) to make defining attributes easier.
* An example:
* #define MYITEM_ATTR(_name, _mode, _show, _store) \
* struct myitem_attribute childless_attr_##_name = \
* __CONFIGFS_ATTR(_name, _mode, _show, _store)
*/
#define __CONFIGFS_ATTR(_name, _mode, _show, _store) \
{ \
.attr = { \
.ca_name = __stringify(_name), \
.ca_mode = _mode, \
.ca_owner = THIS_MODULE, \
}, \
.show = _show, \
.store = _store, \
}
/* Here is a readonly version, only requiring a show() operation */
#define __CONFIGFS_ATTR_RO(_name, _show) \
{ \
.attr = { \
.ca_name = __stringify(_name), \
.ca_mode = 0444, \
.ca_owner = THIS_MODULE, \
}, \
.show = _show, \
#define CONFIGFS_ATTR_RO(_pfx, _name) \
static struct configfs_attribute _pfx##attr_##_name = { \
.ca_name = __stringify(_name), \
.ca_mode = S_IRUGO, \
.ca_owner = THIS_MODULE, \
.show = _pfx##_name##_show, \
}
/*
* With these extended attributes, the simple show_attribute() and
* store_attribute() operations need to call the show() and store() of the
* attributes. This is a common pattern, so we provide a macro to define
* them. The argument _item is the name of the config_item structure.
* This macro expects the attributes to be named "struct <name>_attribute"
* and the function to_<name>() to exist;
*/
#define CONFIGFS_ATTR_OPS(_item) \
static ssize_t _item##_attr_show(struct config_item *item, \
struct configfs_attribute *attr, \
char *page) \
{ \
struct _item *_item = to_##_item(item); \
struct _item##_attribute *_item##_attr = \
container_of(attr, struct _item##_attribute, attr); \
ssize_t ret = 0; \
\
if (_item##_attr->show) \
ret = _item##_attr->show(_item, page); \
return ret; \
} \
static ssize_t _item##_attr_store(struct config_item *item, \
struct configfs_attribute *attr, \
const char *page, size_t count) \
{ \
struct _item *_item = to_##_item(item); \
struct _item##_attribute *_item##_attr = \
container_of(attr, struct _item##_attribute, attr); \
ssize_t ret = -EINVAL; \
\
if (_item##_attr->store) \
ret = _item##_attr->store(_item, page, count); \
return ret; \
#define CONFIGFS_ATTR_WO(_pfx, _name) \
static struct configfs_attribute _pfx##attr_##_name = { \
.ca_name = __stringify(_name), \
.ca_mode = S_IWUSR, \
.ca_owner = THIS_MODULE, \
.store = _pfx##_name##_store, \
}
/*
@ -223,8 +170,6 @@ static ssize_t _item##_attr_store(struct config_item *item, \
*/
struct configfs_item_operations {
void (*release)(struct config_item *);
ssize_t (*show_attribute)(struct config_item *, struct configfs_attribute *,char *);
ssize_t (*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t);
int (*allow_link)(struct config_item *src, struct config_item *target);
int (*drop_link)(struct config_item *src, struct config_item *target);
};

Просмотреть файл

@ -7,9 +7,10 @@ int check_user_usb_string(const char *name,
struct usb_gadget_strings *stringtab_dev);
#define GS_STRINGS_W(__struct, __name) \
static ssize_t __struct##_##__name##_store(struct __struct *gs, \
static ssize_t __struct##_##__name##_store(struct config_item *item, \
const char *page, size_t len) \
{ \
struct __struct *gs = to_##__struct(item); \
int ret; \
\
ret = usb_string_copy(page, &gs->__name); \
@ -19,30 +20,20 @@ int check_user_usb_string(const char *name,
}
#define GS_STRINGS_R(__struct, __name) \
static ssize_t __struct##_##__name##_show(struct __struct *gs, \
char *page) \
static ssize_t __struct##_##__name##_show(struct config_item *item, char *page) \
{ \
struct __struct *gs = to_##__struct(item); \
return sprintf(page, "%s\n", gs->__name ?: ""); \
}
#define GS_STRING_ITEM_ATTR(struct_name, name) \
static struct struct_name##_attribute struct_name##_##name = \
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \
struct_name##_##name##_show, \
struct_name##_##name##_store)
#define GS_STRINGS_RW(struct_name, _name) \
GS_STRINGS_R(struct_name, _name) \
GS_STRINGS_W(struct_name, _name) \
GS_STRING_ITEM_ATTR(struct_name, _name)
CONFIGFS_ATTR(struct_name##_, _name)
#define USB_CONFIG_STRING_RW_OPS(struct_in) \
CONFIGFS_ATTR_OPS(struct_in); \
\
static struct configfs_item_operations struct_in##_langid_item_ops = { \
.release = struct_in##_attr_release, \
.show_attribute = struct_in##_attr_show, \
.store_attribute = struct_in##_attr_store, \
}; \
\
static struct config_item_type struct_in##_langid_type = { \

Просмотреть файл

@ -1,147 +0,0 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
* configfs_macros.h - extends macros for configfs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
* Based on sysfs:
* sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
*
* Based on kobject.h:
* Copyright (c) 2002-2003 Patrick Mochel
* Copyright (c) 2002-2003 Open Source Development Labs
*
* configfs Copyright (C) 2005 Oracle. All rights reserved.
*
* Added CONFIGFS_EATTR() macros from original configfs.h macros
* Copright (C) 2008-2009 Nicholas A. Bellinger <nab@linux-iscsi.org>
*
* Please read Documentation/filesystems/configfs/configfs.txt before using
* the configfs interface, ESPECIALLY the parts about reference counts and
* item destructors.
*/
#ifndef _CONFIGFS_MACROS_H_
#define _CONFIGFS_MACROS_H_
#include <linux/configfs.h>
/*
* Users often need to create attribute structures for their configurable
* attributes, containing a configfs_attribute member and function pointers
* for the show() and store() operations on that attribute. If they don't
* need anything else on the extended attribute structure, they can use
* this macro to define it. The argument _name isends up as
* 'struct _name_attribute, as well as names of to CONFIGFS_ATTR_OPS() below.
* The argument _item is the name of the structure containing the
* struct config_item or struct config_group structure members
*/
#define CONFIGFS_EATTR_STRUCT(_name, _item) \
struct _name##_attribute { \
struct configfs_attribute attr; \
ssize_t (*show)(struct _item *, char *); \
ssize_t (*store)(struct _item *, const char *, size_t); \
}
/*
* With the extended attribute structure, users can use this macro
* (similar to sysfs' __ATTR) to make defining attributes easier.
* An example:
* #define MYITEM_EATTR(_name, _mode, _show, _store) \
* struct myitem_attribute childless_attr_##_name = \
* __CONFIGFS_EATTR(_name, _mode, _show, _store)
*/
#define __CONFIGFS_EATTR(_name, _mode, _show, _store) \
{ \
.attr = { \
.ca_name = __stringify(_name), \
.ca_mode = _mode, \
.ca_owner = THIS_MODULE, \
}, \
.show = _show, \
.store = _store, \
}
/* Here is a readonly version, only requiring a show() operation */
#define __CONFIGFS_EATTR_RO(_name, _show) \
{ \
.attr = { \
.ca_name = __stringify(_name), \
.ca_mode = 0444, \
.ca_owner = THIS_MODULE, \
}, \
.show = _show, \
}
/*
* With these extended attributes, the simple show_attribute() and
* store_attribute() operations need to call the show() and store() of the
* attributes. This is a common pattern, so we provide a macro to define
* them. The argument _name is the name of the attribute defined by
* CONFIGFS_ATTR_STRUCT(). The argument _item is the name of the structure
* containing the struct config_item or struct config_group structure member.
* The argument _item_member is the actual name of the struct config_* struct
* in your _item structure. Meaning my_structure->some_config_group.
* ^^_item^^^^^ ^^_item_member^^^
* This macro expects the attributes to be named "struct <name>_attribute".
*/
#define CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member) \
static struct _item *to_##_name(struct config_item *ci) \
{ \
return (ci) ? container_of(to_config_group(ci), struct _item, \
_item_member) : NULL; \
}
#define CONFIGFS_EATTR_OPS_SHOW(_name, _item) \
static ssize_t _name##_attr_show(struct config_item *item, \
struct configfs_attribute *attr, \
char *page) \
{ \
struct _item *_item = to_##_name(item); \
struct _name##_attribute * _name##_attr = \
container_of(attr, struct _name##_attribute, attr); \
ssize_t ret = 0; \
\
if (_name##_attr->show) \
ret = _name##_attr->show(_item, page); \
return ret; \
}
#define CONFIGFS_EATTR_OPS_STORE(_name, _item) \
static ssize_t _name##_attr_store(struct config_item *item, \
struct configfs_attribute *attr, \
const char *page, size_t count) \
{ \
struct _item *_item = to_##_name(item); \
struct _name##_attribute * _name##_attr = \
container_of(attr, struct _name##_attribute, attr); \
ssize_t ret = -EINVAL; \
\
if (_name##_attr->store) \
ret = _name##_attr->store(_item, page, count); \
return ret; \
}
#define CONFIGFS_EATTR_OPS(_name, _item, _item_member) \
CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
CONFIGFS_EATTR_OPS_SHOW(_name, _item); \
CONFIGFS_EATTR_OPS_STORE(_name, _item);
#define CONFIGFS_EATTR_OPS_RO(_name, _item, _item_member) \
CONFIGFS_EATTR_OPS_TO_FUNC(_name, _item, _item_member); \
CONFIGFS_EATTR_OPS_SHOW(_name, _item);
#endif /* _CONFIGFS_MACROS_H_ */

Просмотреть файл

@ -563,6 +563,36 @@ struct se_node_acl {
struct kref acl_kref;
};
static inline struct se_node_acl *acl_to_nacl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_node_acl,
acl_group);
}
static inline struct se_node_acl *attrib_to_nacl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_node_acl,
acl_attrib_group);
}
static inline struct se_node_acl *auth_to_nacl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_node_acl,
acl_auth_group);
}
static inline struct se_node_acl *param_to_nacl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_node_acl,
acl_param_group);
}
static inline struct se_node_acl *fabric_stat_to_nacl(struct config_item *item)
{
return container_of(to_config_group(item), struct se_node_acl,
acl_fabric_stat_group);
}
struct se_session {
unsigned sess_tearing_down:1;
u64 sess_bin_isid;
@ -821,6 +851,12 @@ struct se_tpg_np {
struct config_group tpg_np_group;
};
static inline struct se_tpg_np *to_tpg_np(struct config_item *item)
{
return container_of(to_config_group(item), struct se_tpg_np,
tpg_np_group);
}
struct se_portal_group {
/*
* PROTOCOL IDENTIFIER value per SPC4, 7.5.1.
@ -857,6 +893,30 @@ struct se_portal_group {
struct config_group tpg_param_group;
};
static inline struct se_portal_group *to_tpg(struct config_item *item)
{
return container_of(to_config_group(item), struct se_portal_group,
tpg_group);
}
static inline struct se_portal_group *attrib_to_tpg(struct config_item *item)
{
return container_of(to_config_group(item), struct se_portal_group,
tpg_attrib_group);
}
static inline struct se_portal_group *auth_to_tpg(struct config_item *item)
{
return container_of(to_config_group(item), struct se_portal_group,
tpg_auth_group);
}
static inline struct se_portal_group *param_to_tpg(struct config_item *item)
{
return container_of(to_config_group(item), struct se_portal_group,
tpg_param_group);
}
struct se_wwn {
struct target_fabric_configfs *wwn_tf;
struct config_group wwn_group;

Просмотреть файл

@ -1,122 +0,0 @@
/*
* Used for tfc_wwn_cit attributes
*/
#include <target/configfs_macros.h>
CONFIGFS_EATTR_STRUCT(target_fabric_nacl_attrib, se_node_acl);
#define TF_NACL_ATTRIB_ATTR(_fabric, _name, _mode) \
static struct target_fabric_nacl_attrib_attribute _fabric##_nacl_attrib_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_nacl_attrib_show_##_name, \
_fabric##_nacl_attrib_store_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_nacl_auth, se_node_acl);
#define TF_NACL_AUTH_ATTR(_fabric, _name, _mode) \
static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_nacl_auth_show_##_name, \
_fabric##_nacl_auth_store_##_name);
#define TF_NACL_AUTH_ATTR_RO(_fabric, _name) \
static struct target_fabric_nacl_auth_attribute _fabric##_nacl_auth_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_nacl_auth_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_nacl_param, se_node_acl);
#define TF_NACL_PARAM_ATTR(_fabric, _name, _mode) \
static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_nacl_param_show_##_name, \
_fabric##_nacl_param_store_##_name);
#define TF_NACL_PARAM_ATTR_RO(_fabric, _name) \
static struct target_fabric_nacl_param_attribute _fabric##_nacl_param_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_nacl_param_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_nacl_base, se_node_acl);
#define TF_NACL_BASE_ATTR(_fabric, _name, _mode) \
static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_nacl_show_##_name, \
_fabric##_nacl_store_##_name);
#define TF_NACL_BASE_ATTR_RO(_fabric, _name) \
static struct target_fabric_nacl_base_attribute _fabric##_nacl_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_nacl_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_np_base, se_tpg_np);
#define TF_NP_BASE_ATTR(_fabric, _name, _mode) \
static struct target_fabric_np_base_attribute _fabric##_np_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_np_show_##_name, \
_fabric##_np_store_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg_attrib, se_portal_group);
#define TF_TPG_ATTRIB_ATTR(_fabric, _name, _mode) \
static struct target_fabric_tpg_attrib_attribute _fabric##_tpg_attrib_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_tpg_attrib_show_##_name, \
_fabric##_tpg_attrib_store_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg_auth, se_portal_group);
#define TF_TPG_AUTH_ATTR(_fabric, _name, _mode) \
static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_tpg_auth_show_##_name, \
_fabric##_tpg_auth_store_##_name);
#define TF_TPG_AUTH_ATTR_RO(_fabric, _name) \
static struct target_fabric_tpg_auth_attribute _fabric##_tpg_auth_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_tpg_auth_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg_param, se_portal_group);
#define TF_TPG_PARAM_ATTR(_fabric, _name, _mode) \
static struct target_fabric_tpg_param_attribute _fabric##_tpg_param_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_tpg_param_show_##_name, \
_fabric##_tpg_param_store_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_tpg, se_portal_group);
#define TF_TPG_BASE_ATTR(_fabric, _name, _mode) \
static struct target_fabric_tpg_attribute _fabric##_tpg_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_tpg_show_##_name, \
_fabric##_tpg_store_##_name);
#define TF_TPG_BASE_ATTR_RO(_fabric, _name) \
static struct target_fabric_tpg_attribute _fabric##_tpg_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_tpg_show_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_wwn, target_fabric_configfs);
#define TF_WWN_ATTR(_fabric, _name, _mode) \
static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_wwn_show_attr_##_name, \
_fabric##_wwn_store_attr_##_name);
#define TF_WWN_ATTR_RO(_fabric, _name) \
static struct target_fabric_wwn_attribute _fabric##_wwn_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_wwn_show_attr_##_name);
CONFIGFS_EATTR_STRUCT(target_fabric_discovery, target_fabric_configfs);
#define TF_DISC_ATTR(_fabric, _name, _mode) \
static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \
__CONFIGFS_EATTR(_name, _mode, \
_fabric##_disc_show_##_name, \
_fabric##_disc_store_##_name);
#define TF_DISC_ATTR_RO(_fabric, _name) \
static struct target_fabric_discovery_attribute _fabric##_disc_##_name = \
__CONFIGFS_EATTR_RO(_name, \
_fabric##_disc_show_##_name);
extern int target_fabric_setup_cits(struct target_fabric_configfs *);

Просмотреть файл

@ -70,4 +70,10 @@ config SAMPLE_LIVEPATCH
Builds a sample live patch that replaces the procfs handler
for /proc/cmdline to print "this has been live patched".
config SAMPLE_CONFIGFS
tristate "Build configfs patching sample -- loadable modules only"
depends on CONFIGFS_FS && m
help
Builds a sample configfs interface.
endif # SAMPLES

Просмотреть файл

@ -1,4 +1,5 @@
# Makefile for Linux samples code
obj-$(CONFIG_SAMPLES) += kobject/ kprobes/ trace_events/ livepatch/ \
hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/
hw_breakpoint/ kfifo/ kdb/ hidraw/ rpmsg/ seccomp/ \
configfs/

Просмотреть файл

@ -0,0 +1,2 @@
obj-$(CONFIG_SAMPLE_CONFIGFS) += configfs_sample.o

Просмотреть файл

@ -54,18 +54,13 @@ struct childless {
static inline struct childless *to_childless(struct config_item *item)
{
return item ? container_of(to_configfs_subsystem(to_config_group(item)), struct childless, subsys) : NULL;
return item ? container_of(to_configfs_subsystem(to_config_group(item)),
struct childless, subsys) : NULL;
}
CONFIGFS_ATTR_STRUCT(childless);
#define CHILDLESS_ATTR(_name, _mode, _show, _store) \
struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR(_name, _mode, _show, _store)
#define CHILDLESS_ATTR_RO(_name, _show) \
struct childless_attribute childless_attr_##_name = __CONFIGFS_ATTR_RO(_name, _show);
static ssize_t childless_showme_read(struct childless *childless,
char *page)
static ssize_t childless_showme_show(struct config_item *item, char *page)
{
struct childless *childless = to_childless(item);
ssize_t pos;
pos = sprintf(page, "%d\n", childless->showme);
@ -74,16 +69,15 @@ static ssize_t childless_showme_read(struct childless *childless,
return pos;
}
static ssize_t childless_storeme_read(struct childless *childless,
char *page)
static ssize_t childless_storeme_show(struct config_item *item, char *page)
{
return sprintf(page, "%d\n", childless->storeme);
return sprintf(page, "%d\n", to_childless(item)->storeme);
}
static ssize_t childless_storeme_write(struct childless *childless,
const char *page,
size_t count)
static ssize_t childless_storeme_store(struct config_item *item,
const char *page, size_t count)
{
struct childless *childless = to_childless(item);
unsigned long tmp;
char *p = (char *) page;
@ -99,8 +93,7 @@ static ssize_t childless_storeme_write(struct childless *childless,
return count;
}
static ssize_t childless_description_read(struct childless *childless,
char *page)
static ssize_t childless_description_show(struct config_item *item, char *page)
{
return sprintf(page,
"[01-childless]\n"
@ -111,26 +104,18 @@ static ssize_t childless_description_read(struct childless *childless,
"than a directory in /proc.\n");
}
CHILDLESS_ATTR_RO(showme, childless_showme_read);
CHILDLESS_ATTR(storeme, S_IRUGO | S_IWUSR, childless_storeme_read,
childless_storeme_write);
CHILDLESS_ATTR_RO(description, childless_description_read);
CONFIGFS_ATTR_RO(childless_, showme);
CONFIGFS_ATTR(childless_, storeme);
CONFIGFS_ATTR_RO(childless_, description);
static struct configfs_attribute *childless_attrs[] = {
&childless_attr_showme.attr,
&childless_attr_storeme.attr,
&childless_attr_description.attr,
&childless_attr_showme,
&childless_attr_storeme,
&childless_attr_description,
NULL,
};
CONFIGFS_ATTR_OPS(childless);
static struct configfs_item_operations childless_item_ops = {
.show_attribute = childless_attr_show,
.store_attribute = childless_attr_store,
};
static struct config_item_type childless_type = {
.ct_item_ops = &childless_item_ops,
.ct_attrs = childless_attrs,
.ct_owner = THIS_MODULE,
};
@ -168,32 +153,13 @@ static inline struct simple_child *to_simple_child(struct config_item *item)
return item ? container_of(item, struct simple_child, item) : NULL;
}
static struct configfs_attribute simple_child_attr_storeme = {
.ca_owner = THIS_MODULE,
.ca_name = "storeme",
.ca_mode = S_IRUGO | S_IWUSR,
};
static struct configfs_attribute *simple_child_attrs[] = {
&simple_child_attr_storeme,
NULL,
};
static ssize_t simple_child_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
static ssize_t simple_child_storeme_show(struct config_item *item, char *page)
{
ssize_t count;
struct simple_child *simple_child = to_simple_child(item);
count = sprintf(page, "%d\n", simple_child->storeme);
return count;
return sprintf(page, "%d\n", to_simple_child(item)->storeme);
}
static ssize_t simple_child_attr_store(struct config_item *item,
struct configfs_attribute *attr,
const char *page, size_t count)
static ssize_t simple_child_storeme_store(struct config_item *item,
const char *page, size_t count)
{
struct simple_child *simple_child = to_simple_child(item);
unsigned long tmp;
@ -211,6 +177,13 @@ static ssize_t simple_child_attr_store(struct config_item *item,
return count;
}
CONFIGFS_ATTR(simple_child_, storeme);
static struct configfs_attribute *simple_child_attrs[] = {
&simple_child_attr_storeme,
NULL,
};
static void simple_child_release(struct config_item *item)
{
kfree(to_simple_child(item));
@ -218,8 +191,6 @@ static void simple_child_release(struct config_item *item)
static struct configfs_item_operations simple_child_item_ops = {
.release = simple_child_release,
.show_attribute = simple_child_attr_show,
.store_attribute = simple_child_attr_store,
};
static struct config_item_type simple_child_type = {
@ -235,10 +206,12 @@ struct simple_children {
static inline struct simple_children *to_simple_children(struct config_item *item)
{
return item ? container_of(to_config_group(item), struct simple_children, group) : NULL;
return item ? container_of(to_config_group(item),
struct simple_children, group) : NULL;
}
static struct config_item *simple_children_make_item(struct config_group *group, const char *name)
static struct config_item *simple_children_make_item(struct config_group *group,
const char *name)
{
struct simple_child *simple_child;
@ -254,20 +227,8 @@ static struct config_item *simple_children_make_item(struct config_group *group,
return &simple_child->item;
}
static struct configfs_attribute simple_children_attr_description = {
.ca_owner = THIS_MODULE,
.ca_name = "description",
.ca_mode = S_IRUGO,
};
static struct configfs_attribute *simple_children_attrs[] = {
&simple_children_attr_description,
NULL,
};
static ssize_t simple_children_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
static ssize_t simple_children_description_show(struct config_item *item,
char *page)
{
return sprintf(page,
"[02-simple-children]\n"
@ -276,6 +237,13 @@ static ssize_t simple_children_attr_show(struct config_item *item,
"items have only one attribute that is readable and writeable.\n");
}
CONFIGFS_ATTR_RO(simple_children_, description);
static struct configfs_attribute *simple_children_attrs[] = {
&simple_children_attr_description,
NULL,
};
static void simple_children_release(struct config_item *item)
{
kfree(to_simple_children(item));
@ -283,7 +251,6 @@ static void simple_children_release(struct config_item *item)
static struct configfs_item_operations simple_children_item_ops = {
.release = simple_children_release,
.show_attribute = simple_children_attr_show,
};
/*
@ -323,7 +290,8 @@ static struct configfs_subsystem simple_children_subsys = {
* children of its own.
*/
static struct config_group *group_children_make_group(struct config_group *group, const char *name)
static struct config_group *group_children_make_group(
struct config_group *group, const char *name)
{
struct simple_children *simple_children;
@ -338,20 +306,8 @@ static struct config_group *group_children_make_group(struct config_group *group
return &simple_children->group;
}
static struct configfs_attribute group_children_attr_description = {
.ca_owner = THIS_MODULE,
.ca_name = "description",
.ca_mode = S_IRUGO,
};
static struct configfs_attribute *group_children_attrs[] = {
&group_children_attr_description,
NULL,
};
static ssize_t group_children_attr_show(struct config_item *item,
struct configfs_attribute *attr,
char *page)
static ssize_t group_children_description_show(struct config_item *item,
char *page)
{
return sprintf(page,
"[03-group-children]\n"
@ -360,8 +316,11 @@ static ssize_t group_children_attr_show(struct config_item *item,
"groups are like the subsystem simple-children.\n");
}
static struct configfs_item_operations group_children_item_ops = {
.show_attribute = group_children_attr_show,
CONFIGFS_ATTR_RO(group_children_, description);
static struct configfs_attribute *group_children_attrs[] = {
&group_children_attr_description,
NULL,
};
/*
@ -373,7 +332,6 @@ static struct configfs_group_operations group_children_group_ops = {
};
static struct config_item_type group_children_type = {
.ct_item_ops = &group_children_item_ops,
.ct_group_ops = &group_children_group_ops,
.ct_attrs = group_children_attrs,
.ct_owner = THIS_MODULE,