diff options
author | Christoph Hellwig <hch@lst.de> | 2015-10-03 09:32:45 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-10-14 01:14:51 -0400 |
commit | aa48a415270f7cf16ec0ef825d19b4f8bd1a875e (patch) | |
tree | af8f5f9cbe48a02b7cf2917b861f7875778c9090 | |
parent | 3755a273db8f523f8be6c18df9e1506faa93c664 (diff) |
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: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/usb/gadget/function/f_printer.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c index 8e2b6bea07bc..3a378460bf37 100644 --- a/drivers/usb/gadget/function/f_printer.c +++ b/drivers/usb/gadget/function/f_printer.c | |||
@@ -1148,9 +1148,6 @@ static inline struct f_printer_opts | |||
1148 | func_inst.group); | 1148 | func_inst.group); |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | CONFIGFS_ATTR_STRUCT(f_printer_opts); | ||
1152 | CONFIGFS_ATTR_OPS(f_printer_opts); | ||
1153 | |||
1154 | static void printer_attr_release(struct config_item *item) | 1151 | static void printer_attr_release(struct config_item *item) |
1155 | { | 1152 | { |
1156 | struct f_printer_opts *opts = to_f_printer_opts(item); | 1153 | struct f_printer_opts *opts = to_f_printer_opts(item); |
@@ -1160,13 +1157,12 @@ static void printer_attr_release(struct config_item *item) | |||
1160 | 1157 | ||
1161 | static struct configfs_item_operations printer_item_ops = { | 1158 | static struct configfs_item_operations printer_item_ops = { |
1162 | .release = printer_attr_release, | 1159 | .release = printer_attr_release, |
1163 | .show_attribute = f_printer_opts_attr_show, | ||
1164 | .store_attribute = f_printer_opts_attr_store, | ||
1165 | }; | 1160 | }; |
1166 | 1161 | ||
1167 | static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, | 1162 | static ssize_t f_printer_opts_pnp_string_show(struct config_item *item, |
1168 | char *page) | 1163 | char *page) |
1169 | { | 1164 | { |
1165 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1170 | int result; | 1166 | int result; |
1171 | 1167 | ||
1172 | mutex_lock(&opts->lock); | 1168 | mutex_lock(&opts->lock); |
@@ -1176,9 +1172,10 @@ static ssize_t f_printer_opts_pnp_string_show(struct f_printer_opts *opts, | |||
1176 | return result; | 1172 | return result; |
1177 | } | 1173 | } |
1178 | 1174 | ||
1179 | static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, | 1175 | static ssize_t f_printer_opts_pnp_string_store(struct config_item *item, |
1180 | const char *page, size_t len) | 1176 | const char *page, size_t len) |
1181 | { | 1177 | { |
1178 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1182 | int result, l; | 1179 | int result, l; |
1183 | 1180 | ||
1184 | mutex_lock(&opts->lock); | 1181 | mutex_lock(&opts->lock); |
@@ -1191,14 +1188,12 @@ static ssize_t f_printer_opts_pnp_string_store(struct f_printer_opts *opts, | |||
1191 | return result; | 1188 | return result; |
1192 | } | 1189 | } |
1193 | 1190 | ||
1194 | static struct f_printer_opts_attribute f_printer_opts_pnp_string = | 1191 | CONFIGFS_ATTR(f_printer_opts_, pnp_string); |
1195 | __CONFIGFS_ATTR(pnp_string, S_IRUGO | S_IWUSR, | ||
1196 | f_printer_opts_pnp_string_show, | ||
1197 | f_printer_opts_pnp_string_store); | ||
1198 | 1192 | ||
1199 | static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, | 1193 | static ssize_t f_printer_opts_q_len_show(struct config_item *item, |
1200 | char *page) | 1194 | char *page) |
1201 | { | 1195 | { |
1196 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1202 | int result; | 1197 | int result; |
1203 | 1198 | ||
1204 | mutex_lock(&opts->lock); | 1199 | mutex_lock(&opts->lock); |
@@ -1208,9 +1203,10 @@ static ssize_t f_printer_opts_q_len_show(struct f_printer_opts *opts, | |||
1208 | return result; | 1203 | return result; |
1209 | } | 1204 | } |
1210 | 1205 | ||
1211 | static ssize_t f_printer_opts_q_len_store(struct f_printer_opts *opts, | 1206 | static ssize_t f_printer_opts_q_len_store(struct config_item *item, |
1212 | const char *page, size_t len) | 1207 | const char *page, size_t len) |
1213 | { | 1208 | { |
1209 | struct f_printer_opts *opts = to_f_printer_opts(item); | ||
1214 | int ret; | 1210 | int ret; |
1215 | u16 num; | 1211 | u16 num; |
1216 | 1212 | ||
@@ -1231,13 +1227,11 @@ end: | |||
1231 | return ret; | 1227 | return ret; |
1232 | } | 1228 | } |
1233 | 1229 | ||
1234 | static struct f_printer_opts_attribute f_printer_opts_q_len = | 1230 | CONFIGFS_ATTR(f_printer_opts_, q_len); |
1235 | __CONFIGFS_ATTR(q_len, S_IRUGO | S_IWUSR, f_printer_opts_q_len_show, | ||
1236 | f_printer_opts_q_len_store); | ||
1237 | 1231 | ||
1238 | static struct configfs_attribute *printer_attrs[] = { | 1232 | static struct configfs_attribute *printer_attrs[] = { |
1239 | &f_printer_opts_pnp_string.attr, | 1233 | &f_printer_opts_attr_pnp_string, |
1240 | &f_printer_opts_q_len.attr, | 1234 | &f_printer_opts_attr_q_len, |
1241 | NULL, | 1235 | NULL, |
1242 | }; | 1236 | }; |
1243 | 1237 | ||