Commit aa48a415 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

usb-gadget/f_printer: use per-attribute show and store methods

To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 3755a273
...@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts ...@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts
func_inst.group); func_inst.group);
} }
CONFIGFS_ATTR_STRUCT(f_printer_opts);
CONFIGFS_ATTR_OPS(f_printer_opts);
static void printer_attr_release(struct config_item *item) static void printer_attr_release(struct config_item *item)
{ {
struct f_printer_opts *opts = to_f_printer_opts(item); struct f_printer_opts *opts = to_f_printer_opts(item);
...@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item *item) ...@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item *item)
static struct configfs_item_operations printer_item_ops = { static struct configfs_item_operations printer_item_ops = {
.release = printer_attr_release, .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) char *page)
{ {
struct f_printer_opts *opts = to_f_printer_opts(item);
int result; int result;
mutex_lock(&opts->lock); mutex_lock(&opts->lock);
...@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, ...@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts,
return result; 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) const char *page, size_t len)
{ {
struct f_printer_opts *opts = to_f_printer_opts(item);
int result, l; int result, l;
mutex_lock(&opts->lock); mutex_lock(&opts->lock);
...@@ -1191,14 +1188,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, ...@@ -1191,14 +1188,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts,
return result; return result;
} }
static struct f_printer_opts_attribute f_printer_opts_pnp_string = CONFIGFS_ATTR(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);
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) char *page)
{ {
struct f_printer_opts *opts = to_f_printer_opts(item);
int result; int result;
mutex_lock(&opts->lock); mutex_lock(&opts->lock);
...@@ -1208,9 +1203,10 @@ static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, ...@@ -1208,9 +1203,10 @@ static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts,
return result; 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) const char *page, size_t len)
{ {
struct f_printer_opts *opts = to_f_printer_opts(item);
int ret; int ret;
u16 num; u16 num;
...@@ -1231,13 +1227,11 @@ static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts, ...@@ -1231,13 +1227,11 @@ static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts,
return ret; return ret;
} }
static struct f_printer_opts_attribute f_printer_opts_q_len = CONFIGFS_ATTR(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);
static struct configfs_attribute *printer_attrs[] = { static struct configfs_attribute *printer_attrs[] = {
&f_printer_opts_pnp_string.attr, &f_printer_opts_attr_pnp_string,
&f_printer_opts_q_len.attr, &f_printer_opts_attr_q_len,
NULL, NULL,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment