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

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>

authored by

Andrzej Pietrasiewicz and committed by
Felipe Balbi
143d53e1 8fe20f66

+10 -5
+10 -5
drivers/usb/gadget/legacy/printer.c
··· 89 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 97 static struct printer_dev usb_printer_gadget; 93 98 94 99 /*-------------------------------------------------------------------------*/ ··· 978 973 static int printer_func_setup(struct usb_function *f, 979 974 const struct usb_ctrlrequest *ctrl) 980 975 { 981 - struct printer_dev *dev = container_of(f, struct printer_dev, function); 976 + struct printer_dev *dev = func_to_printer(f); 982 977 struct usb_composite_dev *cdev = f->config->cdev; 983 978 struct usb_request *req = cdev->req; 984 979 int value = -EOPNOTSUPP; ··· 1052 1047 struct usb_function *f) 1053 1048 { 1054 1049 struct usb_gadget *gadget = c->cdev->gadget; 1055 - struct printer_dev *dev = container_of(f, struct printer_dev, function); 1050 + struct printer_dev *dev = func_to_printer(f); 1056 1051 struct device *pdev; 1057 1052 struct usb_composite_dev *cdev = c->cdev; 1058 1053 struct usb_ep *in_ep; ··· 1164 1159 struct printer_dev *dev; 1165 1160 struct usb_request *req; 1166 1161 1167 - dev = container_of(f, struct printer_dev, function); 1162 + dev = func_to_printer(f); 1168 1163 1169 1164 device_destroy(usb_gadget_class, g_printer_devno); 1170 1165 ··· 1205 1200 static int printer_func_set_alt(struct usb_function *f, 1206 1201 unsigned intf, unsigned alt) 1207 1202 { 1208 - struct printer_dev *dev = container_of(f, struct printer_dev, function); 1203 + struct printer_dev *dev = func_to_printer(f); 1209 1204 int ret = -ENOTSUPP; 1210 1205 1211 1206 if (!alt) ··· 1216 1211 1217 1212 static void printer_func_disable(struct usb_function *f) 1218 1213 { 1219 - struct printer_dev *dev = container_of(f, struct printer_dev, function); 1214 + struct printer_dev *dev = func_to_printer(f); 1220 1215 unsigned long flags; 1221 1216 1222 1217 DBG(dev, "%s\n", __func__);