diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2015-03-03 04:52:22 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-03-10 16:33:38 -0400 |
commit | 143d53e10ecfeee7245341aa9c50515b5680ffd4 (patch) | |
tree | 9c63564a5b942dd002e4cdb8762aee275e4dc8b7 | |
parent | 8fe20f661f3cfbb6778368eb3c73f8a6438ac640 (diff) |
usb: gadget: printer: add container_of helper for printer_dev
5 uses of container_of() in the same context justify wrapping it
in a static inline function.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/legacy/printer.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 806475c19934..955847fe8092 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c | |||
@@ -89,6 +89,11 @@ struct printer_dev { | |||
89 | struct usb_function function; | 89 | struct usb_function function; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static inline struct printer_dev *func_to_printer(struct usb_function *f) | ||
93 | { | ||
94 | return container_of(f, struct printer_dev, function); | ||
95 | } | ||
96 | |||
92 | static struct printer_dev usb_printer_gadget; | 97 | static struct printer_dev usb_printer_gadget; |
93 | 98 | ||
94 | /*-------------------------------------------------------------------------*/ | 99 | /*-------------------------------------------------------------------------*/ |
@@ -973,7 +978,7 @@ static void printer_soft_reset(struct printer_dev *dev) | |||
973 | static int printer_func_setup(struct usb_function *f, | 978 | static int printer_func_setup(struct usb_function *f, |
974 | const struct usb_ctrlrequest *ctrl) | 979 | const struct usb_ctrlrequest *ctrl) |
975 | { | 980 | { |
976 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 981 | struct printer_dev *dev = func_to_printer(f); |
977 | struct usb_composite_dev *cdev = f->config->cdev; | 982 | struct usb_composite_dev *cdev = f->config->cdev; |
978 | struct usb_request *req = cdev->req; | 983 | struct usb_request *req = cdev->req; |
979 | int value = -EOPNOTSUPP; | 984 | int value = -EOPNOTSUPP; |
@@ -1047,7 +1052,7 @@ static int __init printer_func_bind(struct usb_configuration *c, | |||
1047 | struct usb_function *f) | 1052 | struct usb_function *f) |
1048 | { | 1053 | { |
1049 | struct usb_gadget *gadget = c->cdev->gadget; | 1054 | struct usb_gadget *gadget = c->cdev->gadget; |
1050 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 1055 | struct printer_dev *dev = func_to_printer(f); |
1051 | struct device *pdev; | 1056 | struct device *pdev; |
1052 | struct usb_composite_dev *cdev = c->cdev; | 1057 | struct usb_composite_dev *cdev = c->cdev; |
1053 | struct usb_ep *in_ep; | 1058 | struct usb_ep *in_ep; |
@@ -1159,7 +1164,7 @@ static void printer_func_unbind(struct usb_configuration *c, | |||
1159 | struct printer_dev *dev; | 1164 | struct printer_dev *dev; |
1160 | struct usb_request *req; | 1165 | struct usb_request *req; |
1161 | 1166 | ||
1162 | dev = container_of(f, struct printer_dev, function); | 1167 | dev = func_to_printer(f); |
1163 | 1168 | ||
1164 | device_destroy(usb_gadget_class, g_printer_devno); | 1169 | device_destroy(usb_gadget_class, g_printer_devno); |
1165 | 1170 | ||
@@ -1200,7 +1205,7 @@ static void printer_func_unbind(struct usb_configuration *c, | |||
1200 | static int printer_func_set_alt(struct usb_function *f, | 1205 | static int printer_func_set_alt(struct usb_function *f, |
1201 | unsigned intf, unsigned alt) | 1206 | unsigned intf, unsigned alt) |
1202 | { | 1207 | { |
1203 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 1208 | struct printer_dev *dev = func_to_printer(f); |
1204 | int ret = -ENOTSUPP; | 1209 | int ret = -ENOTSUPP; |
1205 | 1210 | ||
1206 | if (!alt) | 1211 | if (!alt) |
@@ -1211,7 +1216,7 @@ static int printer_func_set_alt(struct usb_function *f, | |||
1211 | 1216 | ||
1212 | static void printer_func_disable(struct usb_function *f) | 1217 | static void printer_func_disable(struct usb_function *f) |
1213 | { | 1218 | { |
1214 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 1219 | struct printer_dev *dev = func_to_printer(f); |
1215 | unsigned long flags; | 1220 | unsigned long flags; |
1216 | 1221 | ||
1217 | DBG(dev, "%s\n", __func__); | 1222 | DBG(dev, "%s\n", __func__); |