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

usb: gadget: udc: add a 'function' sysfs file

This file will print out the name of the currently running USB Gadget
Driver. It can be read even when there are no functions loaded.

Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

+21
+8
Documentation/ABI/stable/sysfs-class-udc
··· 91 91 'configured', and 'suspended'; however not all USB Device 92 92 Controllers support reporting all states. 93 93 Users: 94 + 95 + What: /sys/class/udc/<udc>/function 96 + Date: June 2017 97 + KernelVersion: 4.13 98 + Contact: Felipe Balbi <balbi@kernel.org> 99 + Description: 100 + Prints out name of currently running USB Gadget Driver. 101 + Users:
+13
drivers/usb/gadget/udc/core.c
··· 1460 1460 } 1461 1461 static DEVICE_ATTR_RO(state); 1462 1462 1463 + static ssize_t function_show(struct device *dev, struct device_attribute *attr, 1464 + char *buf) 1465 + { 1466 + struct usb_udc *udc = container_of(dev, struct usb_udc, dev); 1467 + struct usb_gadget_driver *drv = udc->driver; 1468 + 1469 + if (!drv || !drv->function) 1470 + return 0; 1471 + return scnprintf(buf, PAGE_SIZE, "%s\n", drv->function); 1472 + } 1473 + static DEVICE_ATTR_RO(function); 1474 + 1463 1475 #define USB_UDC_SPEED_ATTR(name, param) \ 1464 1476 ssize_t name##_show(struct device *dev, \ 1465 1477 struct device_attribute *attr, char *buf) \ ··· 1507 1495 &dev_attr_srp.attr, 1508 1496 &dev_attr_soft_connect.attr, 1509 1497 &dev_attr_state.attr, 1498 + &dev_attr_function.attr, 1510 1499 &dev_attr_current_speed.attr, 1511 1500 &dev_attr_maximum_speed.attr, 1512 1501