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

USB: export <linux/usb_gadgetfs> as <linux/usb/gadgetfs.h>

Make sure gadgetfs userspace interface is properly exported:

- Move <linux/usb_gadgetfs.h> to <linux/usb/gadgetfs.h>;
- Export it using Kbuild;
- Add an #include guard;
- Correct some internal documentation;
- Update struct layout so it's the same on 32/64 bit kernels.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


authored by

David Brownell and committed by
Greg Kroah-Hartman
a5262dcf 8234509c

+17 -10
+1 -1
drivers/usb/gadget/inode.c
··· 37 37 #include <linux/device.h> 38 38 #include <linux/moduleparam.h> 39 39 40 - #include <linux/usb_gadgetfs.h> 40 + #include <linux/usb/gadgetfs.h> 41 41 #include <linux/usb_gadget.h> 42 42 43 43
+1
include/linux/usb/Kbuild
··· 1 1 unifdef-y += audio.h 2 2 unifdef-y += cdc.h 3 3 unifdef-y += ch9.h 4 + unifdef-y += gadgetfs.h 4 5 unifdef-y += midi.h 5 6
+15 -9
include/linux/usb_gadgetfs.h include/linux/usb/gadgetfs.h
··· 1 + #ifndef __LINUX_USB_GADGETFS_H 2 + #define __LINUX_USB_GADGETFS_H 1 3 2 4 #include <asm/types.h> 3 5 #include <asm/ioctl.h> ··· 9 7 /* 10 8 * Filesystem based user-mode API to USB Gadget controller hardware 11 9 * 12 - * Almost everything can be done with only read and write operations, 10 + * Other than ep0 operations, most things are done by read() and write() 13 11 * on endpoint files found in one directory. They are configured by 14 12 * writing descriptors, and then may be used for normal stream style 15 13 * i/o requests. When ep0 is configured, the device can enumerate; 16 - * when it's closed, the device disconnects from usb. 14 + * when it's closed, the device disconnects from usb. Operations on 15 + * ep0 require ioctl() operations. 17 16 * 18 17 * Configuration and device descriptors get written to /dev/gadget/$CHIP, 19 18 * which may then be used to read usb_gadgetfs_event structs. The driver ··· 24 21 */ 25 22 26 23 /* 27 - * Events are delivered on the ep0 file descriptor, if the user mode driver 24 + * Events are delivered on the ep0 file descriptor, when the user mode driver 28 25 * reads from this file descriptor after writing the descriptors. Don't 29 - * stop polling this descriptor, if you write that kind of driver. 26 + * stop polling this descriptor. 30 27 */ 31 28 32 29 enum usb_gadgetfs_event_type { ··· 39 36 // and likely more ! 40 37 }; 41 38 39 + /* NOTE: this structure must stay the same size and layout on 40 + * both 32-bit and 64-bit kernels. 41 + */ 42 42 struct usb_gadgetfs_event { 43 - enum usb_gadgetfs_event_type type; 44 43 union { 45 44 // NOP, DISCONNECT, SUSPEND: nothing 46 45 // ... some hardware can't report disconnection ··· 51 46 enum usb_device_speed speed; 52 47 53 48 // SETUP: packet; DATA phase i/o precedes next event 54 - // (setup.bmRequestType & USB_DIR_IN) flags direction 49 + // (setup.bmRequestType & USB_DIR_IN) flags direction 55 50 // ... includes SET_CONFIGURATION, SET_INTERFACE 56 51 struct usb_ctrlrequest setup; 57 52 } u; 53 + enum usb_gadgetfs_event_type type; 58 54 }; 59 55 60 56 61 57 /* endpoint ioctls */ 62 58 63 59 /* IN transfers may be reported to the gadget driver as complete 64 - * when the fifo is loaded, before the host reads the data; 60 + * when the fifo is loaded, before the host reads the data; 65 61 * OUT transfers may be reported to the host's "client" driver as 66 - * complete when they're sitting in the FIFO unread. 62 + * complete when they're sitting in the FIFO unread. 67 63 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 68 64 * (needed for precise fault handling, when the hardware allows it) 69 65 */ ··· 78 72 */ 79 73 #define GADGETFS_CLEAR_HALT _IO('g',3) 80 74 81 - 75 + #endif /* __LINUX_USB_GADGETFS_H */