diff mbox series

[v2,1/3] USB: gadget: Move gadget-related ioctl codes to gadget-ioctl.h

Message ID 20240118003758.1870691-2-vi@endrift.com (mailing list archive)
State New
Headers show
Series USB: gadget: f_hid: Add Feature reports | expand

Commit Message

Vicki Pfau Jan. 18, 2024, 12:37 a.m. UTC
Since multiple different gadget types use similar ranges of ioctl IDs,
put all of them in the same file to avoid accidentally creating
overlaps.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Vicki Pfau <vi@endrift.com>
---
 include/uapi/linux/usb/g_printer.h    | 23 ++----------------
 include/uapi/linux/usb/g_uvc.h        |  4 +--
 include/uapi/linux/usb/gadget-ioctl.h | 35 +++++++++++++++++++++++++++
 include/uapi/linux/usb/gadgetfs.h     | 27 +--------------------
 4 files changed, 39 insertions(+), 50 deletions(-)
 create mode 100644 include/uapi/linux/usb/gadget-ioctl.h

Comments

Greg KH Jan. 28, 2024, 1:34 a.m. UTC | #1
On Wed, Jan 17, 2024 at 04:37:55PM -0800, Vicki Pfau wrote:
> Since multiple different gadget types use similar ranges of ioctl IDs,
> put all of them in the same file to avoid accidentally creating
> overlaps.
> 
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Vicki Pfau <vi@endrift.com>
> ---
>  include/uapi/linux/usb/g_printer.h    | 23 ++----------------
>  include/uapi/linux/usb/g_uvc.h        |  4 +--
>  include/uapi/linux/usb/gadget-ioctl.h | 35 +++++++++++++++++++++++++++
>  include/uapi/linux/usb/gadgetfs.h     | 27 +--------------------
>  4 files changed, 39 insertions(+), 50 deletions(-)
>  create mode 100644 include/uapi/linux/usb/gadget-ioctl.h
> 
> diff --git a/include/uapi/linux/usb/g_printer.h b/include/uapi/linux/usb/g_printer.h
> index 7fc20e4b82f5..fc411ee3f5cc 100644
> --- a/include/uapi/linux/usb/g_printer.h
> +++ b/include/uapi/linux/usb/g_printer.h
> @@ -3,34 +3,15 @@
>   * g_printer.h -- Header file for USB Printer gadget driver
>   *
>   * Copyright (C) 2007 Craig W. Nadler
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>   */

Note, this "boiler-plate" text should be removed, you are right, but not
in this commit, as it has nothing to do with it, and should be a
stand-alone change.

So can you please split this out?

Otherwise, nice work,

greg k-h
diff mbox series

Patch

diff --git a/include/uapi/linux/usb/g_printer.h b/include/uapi/linux/usb/g_printer.h
index 7fc20e4b82f5..fc411ee3f5cc 100644
--- a/include/uapi/linux/usb/g_printer.h
+++ b/include/uapi/linux/usb/g_printer.h
@@ -3,34 +3,15 @@ 
  * g_printer.h -- Header file for USB Printer gadget driver
  *
  * Copyright (C) 2007 Craig W. Nadler
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #ifndef __LINUX_USB_G_PRINTER_H
 #define __LINUX_USB_G_PRINTER_H
 
+#include <linux/usb/gadget-ioctl.h>
+
 #define PRINTER_NOT_ERROR	0x08
 #define PRINTER_SELECTED	0x10
 #define PRINTER_PAPER_EMPTY	0x20
 
-/* The 'g' code is also used by gadgetfs ioctl requests.
- * Don't add any colliding codes to either driver, and keep
- * them in unique ranges (size 0x20 for now).
- */
-#define GADGET_GET_PRINTER_STATUS	_IOR('g', 0x21, unsigned char)
-#define GADGET_SET_PRINTER_STATUS	_IOWR('g', 0x22, unsigned char)
-
 #endif /* __LINUX_USB_G_PRINTER_H */
diff --git a/include/uapi/linux/usb/g_uvc.h b/include/uapi/linux/usb/g_uvc.h
index 8d7824dde1b2..7142e05abab1 100644
--- a/include/uapi/linux/usb/g_uvc.h
+++ b/include/uapi/linux/usb/g_uvc.h
@@ -8,9 +8,9 @@ 
 #ifndef __LINUX_USB_G_UVC_H
 #define __LINUX_USB_G_UVC_H
 
-#include <linux/ioctl.h>
 #include <linux/types.h>
 #include <linux/usb/ch9.h>
+#include <linux/usb/gadget-ioctl.h>
 
 #define UVC_EVENT_FIRST			(V4L2_EVENT_PRIVATE_START + 0)
 #define UVC_EVENT_CONNECT		(V4L2_EVENT_PRIVATE_START + 0)
@@ -37,6 +37,4 @@  struct uvc_event {
 	};
 };
 
-#define UVCIOC_SEND_RESPONSE		_IOW('U', 1, struct uvc_request_data)
-
 #endif /* __LINUX_USB_G_UVC_H */
diff --git a/include/uapi/linux/usb/gadget-ioctl.h b/include/uapi/linux/usb/gadget-ioctl.h
new file mode 100644
index 000000000000..b5f8f7894db7
--- /dev/null
+++ b/include/uapi/linux/usb/gadget-ioctl.h
@@ -0,0 +1,35 @@ 
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef __LINUX_USB_GADGET_IOCTL_H
+#define __LINUX_USB_GADGET_IOCTL_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+/* gadgetfs endpoint ioctls */
+
+/* IN transfers may be reported to the gadget driver as complete
+ *	when the fifo is loaded, before the host reads the data;
+ * OUT transfers may be reported to the host's "client" driver as
+ *	complete when they're sitting in the FIFO unread.
+ * THIS returns how many bytes are "unclaimed" in the endpoint fifo
+ * (needed for precise fault handling, when the hardware allows it)
+ */
+#define	GADGETFS_FIFO_STATUS	_IO('g', 1)
+
+/* discards any unclaimed data in the fifo. */
+#define	GADGETFS_FIFO_FLUSH	_IO('g', 2)
+
+/* resets endpoint halt+toggle; used to implement set_interface.
+ * some hardware (like pxa2xx) can't support this.
+ */
+#define	GADGETFS_CLEAR_HALT	_IO('g', 3)
+
+/* g_printer ioctls */
+#define GADGET_GET_PRINTER_STATUS	_IOR('g', 0x21, unsigned char)
+#define GADGET_SET_PRINTER_STATUS	_IOWR('g', 0x22, unsigned char)
+
+/* g_uvc ioctls */
+#define UVCIOC_SEND_RESPONSE		_IOW('U', 1, struct uvc_request_data)
+
+#endif /* __LINUX_USB_GADGET_IOCTL_H */
diff --git a/include/uapi/linux/usb/gadgetfs.h b/include/uapi/linux/usb/gadgetfs.h
index 835473910a49..e8629943d249 100644
--- a/include/uapi/linux/usb/gadgetfs.h
+++ b/include/uapi/linux/usb/gadgetfs.h
@@ -20,9 +20,9 @@ 
 #define __LINUX_USB_GADGETFS_H
 
 #include <linux/types.h>
-#include <linux/ioctl.h>
 
 #include <linux/usb/ch9.h>
+#include <linux/usb/gadget-ioctl.h>
 
 /*
  * Events are delivered on the ep0 file descriptor, when the user mode driver
@@ -61,29 +61,4 @@  struct usb_gadgetfs_event {
 	enum usb_gadgetfs_event_type	type;
 };
 
-
-/* The 'g' code is also used by printer gadget ioctl requests.
- * Don't add any colliding codes to either driver, and keep
- * them in unique ranges (size 0x20 for now).
- */
-
-/* endpoint ioctls */
-
-/* IN transfers may be reported to the gadget driver as complete
- *	when the fifo is loaded, before the host reads the data;
- * OUT transfers may be reported to the host's "client" driver as
- *	complete when they're sitting in the FIFO unread.
- * THIS returns how many bytes are "unclaimed" in the endpoint fifo
- * (needed for precise fault handling, when the hardware allows it)
- */
-#define	GADGETFS_FIFO_STATUS	_IO('g', 1)
-
-/* discards any unclaimed data in the fifo. */
-#define	GADGETFS_FIFO_FLUSH	_IO('g', 2)
-
-/* resets endpoint halt+toggle; used to implement set_interface.
- * some hardware (like pxa2xx) can't support this.
- */
-#define	GADGETFS_CLEAR_HALT	_IO('g', 3)
-
 #endif /* __LINUX_USB_GADGETFS_H */