Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Reorder usbdi_util.{c,h}, for clarity. No functi...



details:   https://anonhg.NetBSD.org/src/rev/f32ed3590819
branches:  trunk
changeset: 1007151:f32ed3590819
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Feb 08 08:18:06 2020 +0000

description:
Reorder usbdi_util.{c,h}, for clarity. No functional change.

diffstat:

 sys/dev/usb/usbdi_util.c |  120 +++++++++++++++++++++++++---------------------
 sys/dev/usb/usbdi_util.h |   68 +++++++++++++-------------
 2 files changed, 100 insertions(+), 88 deletions(-)

diffs (289 lines):

diff -r bc0cc52b8095 -r f32ed3590819 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c  Sat Feb 08 07:57:16 2020 +0000
+++ b/sys/dev/usb/usbdi_util.c  Sat Feb 08 08:18:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $     */
+/*     $NetBSD: usbdi_util.c,v 1.77 2020/02/08 08:18:06 maxv Exp $     */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.77 2020/02/08 08:18:06 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -154,6 +154,8 @@
                             0, USB_DEVICE_DESCRIPTOR_SIZE, d);
 }
 
+/* -------------------------------------------------------------------------- */
+
 usbd_status
 usbd_get_device_status(struct usbd_device *dev, usb_status_t *st)
 {
@@ -184,22 +186,6 @@
 }
 
 usbd_status
-usbd_set_address(struct usbd_device *dev, int addr)
-{
-       USBHIST_FUNC();
-       USBHIST_CALLARGS(usbdebug, "dev %#jx addr %jd",
-           (uintptr_t)dev, addr, 0, 0);
-       usb_device_request_t req;
-
-       req.bmRequestType = UT_WRITE_DEVICE;
-       req.bRequest = UR_SET_ADDRESS;
-       USETW(req.wValue, addr);
-       USETW(req.wIndex, 0);
-       USETW(req.wLength, 0);
-       return usbd_do_request(dev, &req, 0);
-}
-
-usbd_status
 usbd_get_port_status(struct usbd_device *dev, int port, usb_port_status_t *ps)
 {
        USBHIST_FUNC();
@@ -233,6 +219,8 @@
        return usbd_do_request(dev, &req, pse);
 }
 
+/* -------------------------------------------------------------------------- */
+
 usbd_status
 usbd_clear_hub_feature(struct usbd_device *dev, int sel)
 {
@@ -343,6 +331,62 @@
        return usbd_do_request(dev, &req, 0);
 }
 
+/* -------------------------------------------------------------------------- */
+
+usbd_status
+usbd_get_config(struct usbd_device *dev, uint8_t *conf)
+{
+       USBHIST_FUNC();
+       USBHIST_CALLARGS(usbdebug, "dev %#jx", (uintptr_t)dev, 0, 0, 0);
+       usb_device_request_t req;
+
+       req.bmRequestType = UT_READ_DEVICE;
+       req.bRequest = UR_GET_CONFIG;
+       USETW(req.wValue, 0);
+       USETW(req.wIndex, 0);
+       USETW(req.wLength, 1);
+       return usbd_do_request(dev, &req, conf);
+}
+
+usbd_status
+usbd_set_address(struct usbd_device *dev, int addr)
+{
+       USBHIST_FUNC();
+       USBHIST_CALLARGS(usbdebug, "dev %#jx addr %jd",
+           (uintptr_t)dev, addr, 0, 0);
+       usb_device_request_t req;
+
+       req.bmRequestType = UT_WRITE_DEVICE;
+       req.bRequest = UR_SET_ADDRESS;
+       USETW(req.wValue, addr);
+       USETW(req.wIndex, 0);
+       USETW(req.wLength, 0);
+       return usbd_do_request(dev, &req, 0);
+}
+
+usbd_status
+usbd_set_idle(struct usbd_interface *iface, int duration, int id)
+{
+       usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
+       struct usbd_device *dev;
+       usb_device_request_t req;
+
+       USBHIST_FUNC();
+       USBHIST_CALLARGS(usbdebug, "duration %jd id %jd", duration, id, 0, 0);
+
+       if (ifd == NULL)
+               return USBD_IOERROR;
+       usbd_interface2device_handle(iface, &dev);
+       req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
+       req.bRequest = UR_SET_IDLE;
+       USETW2(req.wValue, duration, id);
+       USETW(req.wIndex, ifd->bInterfaceNumber);
+       USETW(req.wLength, 0);
+       return usbd_do_request(dev, &req, 0);
+}
+
+/* -------------------------------------------------------------------------- */
+
 usbd_status
 usbd_get_protocol(struct usbd_interface *iface, uint8_t *report)
 {
@@ -389,6 +433,8 @@
        return usbd_do_request(dev, &req, 0);
 }
 
+/* -------------------------------------------------------------------------- */
+
 usbd_status
 usbd_set_report(struct usbd_interface *iface, int type, int id, void *data,
                int len)
@@ -433,27 +479,6 @@
 }
 
 usbd_status
-usbd_set_idle(struct usbd_interface *iface, int duration, int id)
-{
-       usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
-       struct usbd_device *dev;
-       usb_device_request_t req;
-
-       USBHIST_FUNC();
-       USBHIST_CALLARGS(usbdebug, "duration %jd id %jd", duration, id, 0, 0);
-
-       if (ifd == NULL)
-               return USBD_IOERROR;
-       usbd_interface2device_handle(iface, &dev);
-       req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
-       req.bRequest = UR_SET_IDLE;
-       USETW2(req.wValue, duration, id);
-       USETW(req.wIndex, ifd->bInterfaceNumber);
-       USETW(req.wLength, 0);
-       return usbd_do_request(dev, &req, 0);
-}
-
-usbd_status
 usbd_get_report_descriptor(struct usbd_device *dev, int ifcno,
                           int size, void *d)
 {
@@ -470,6 +495,8 @@
        return usbd_do_request(dev, &req, d);
 }
 
+/* -------------------------------------------------------------------------- */
+
 usb_hid_descriptor_t *
 usbd_get_hid_descriptor(struct usbd_interface *ifc)
 {
@@ -529,21 +556,6 @@
 }
 
 usbd_status
-usbd_get_config(struct usbd_device *dev, uint8_t *conf)
-{
-       USBHIST_FUNC();
-       USBHIST_CALLARGS(usbdebug, "dev %#jx", (uintptr_t)dev, 0, 0, 0);
-       usb_device_request_t req;
-
-       req.bmRequestType = UT_READ_DEVICE;
-       req.bRequest = UR_GET_CONFIG;
-       USETW(req.wValue, 0);
-       USETW(req.wIndex, 0);
-       USETW(req.wLength, 1);
-       return usbd_do_request(dev, &req, conf);
-}
-
-usbd_status
 usbd_bulk_transfer(struct usbd_xfer *xfer, struct usbd_pipe *pipe,
     uint16_t flags, uint32_t timeout, void *buf, uint32_t *size)
 {
diff -r bc0cc52b8095 -r f32ed3590819 sys/dev/usb/usbdi_util.h
--- a/sys/dev/usb/usbdi_util.h  Sat Feb 08 07:57:16 2020 +0000
+++ b/sys/dev/usb/usbdi_util.h  Sat Feb 08 08:18:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.h,v 1.50 2020/02/08 07:53:23 maxv Exp $     */
+/*     $NetBSD: usbdi_util.h,v 1.51 2020/02/08 08:18:06 maxv Exp $     */
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -35,56 +35,56 @@
 
 #include <dev/usb/usbhid.h>
 
-usbd_status    usbd_get_desc(struct usbd_device *, int,
-                             int, int, void *);
+usbd_status    usbd_get_desc(struct usbd_device *, int, int, int, void *);
 usbd_status    usbd_get_config_desc(struct usbd_device *, int,
-                                    usb_config_descriptor_t *);
-usbd_status    usbd_get_config_desc_full(struct usbd_device *, int, void *, int);
+                   usb_config_descriptor_t *);
+usbd_status    usbd_get_config_desc_full(struct usbd_device *, int, void *,
+                   int);
 usbd_status    usbd_get_bos_desc(struct usbd_device *, int,
-                                    usb_bos_descriptor_t *);
+                   usb_bos_descriptor_t *);
 usbd_status    usbd_get_bos_desc_full(struct usbd_device *, int, void *, int);
 usbd_status    usbd_get_device_desc(struct usbd_device *,
-                                    usb_device_descriptor_t *);
-usbd_status    usbd_get_desc_fake(struct usbd_device *, int,
-                                  int, int, void *);
-usbd_status    usbd_set_address(struct usbd_device *, int);
-usbd_status    usbd_get_port_status(struct usbd_device *,
-                                    int, usb_port_status_t *);
-usbd_status    usbd_get_port_status_ext(struct usbd_device *,
-                                    int, usb_port_status_ext_t *);
+                   usb_device_descriptor_t *);
+usbd_status    usbd_get_string_desc(struct usbd_device *, int, int,
+                   usb_string_descriptor_t *, int *);
+
+usbd_status    usbd_get_device_status(struct usbd_device *, usb_status_t *);
+usbd_status    usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *);
+usbd_status    usbd_get_port_status(struct usbd_device *, int,
+                   usb_port_status_t *);
+usbd_status    usbd_get_port_status_ext(struct usbd_device *, int,
+                   usb_port_status_ext_t *);
+
+usbd_status    usbd_get_desc_fake(struct usbd_device *, int, int, int, void *);
+
+usbd_status    usbd_clear_hub_feature(struct usbd_device *, int);
 usbd_status    usbd_set_hub_feature(struct usbd_device *, int);
-usbd_status    usbd_clear_hub_feature(struct usbd_device *, int);
+usbd_status    usbd_clear_port_feature(struct usbd_device *, int, int);
 usbd_status    usbd_set_port_feature(struct usbd_device *, int, int);
-usbd_status    usbd_clear_port_feature(struct usbd_device *, int, int);
 usbd_status    usbd_set_port_u1_timeout(struct usbd_device *, int, int);
 usbd_status    usbd_set_port_u2_timeout(struct usbd_device *, int, int);
 usbd_status    usbd_clear_endpoint_feature(struct usbd_device *, int, int);
-usbd_status    usbd_get_device_status(struct usbd_device *, usb_status_t *);
-usbd_status    usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *);
+
+usbd_status    usbd_get_config(struct usbd_device *, uint8_t *);
+usbd_status    usbd_set_address(struct usbd_device *, int);
+usbd_status    usbd_set_idle(struct usbd_interface *, int, int);
+
 usbd_status    usbd_get_protocol(struct usbd_interface *, uint8_t *);
 usbd_status    usbd_set_protocol(struct usbd_interface *, int);
-usbd_status    usbd_get_report_descriptor(struct usbd_device *, int,
-                                          int, void *);
+
+usbd_status    usbd_set_report(struct usbd_interface *, int, int, void *, int);
+usbd_status    usbd_get_report(struct usbd_interface *, int, int, void *, int);
+usbd_status    usbd_get_report_descriptor(struct usbd_device *, int, int,
+                   void *);
+
 usb_hid_descriptor_t *usbd_get_hid_descriptor(struct usbd_interface *);
-usbd_status    usbd_set_report(struct usbd_interface *, int, int,
-                               void *, int);
-usbd_status    usbd_get_report(struct usbd_interface *, int, int,
-                               void *, int);
-usbd_status    usbd_set_idle(struct usbd_interface *, int, int);
-usbd_status    usbd_read_report_desc(struct usbd_interface *, void **,
-                                     int *);
-usbd_status    usbd_get_config(struct usbd_device *, uint8_t *);
-usbd_status    usbd_get_string_desc(struct usbd_device *, int,
-                                    int, usb_string_descriptor_t *,
-                                    int *);
-
+usbd_status    usbd_read_report_desc(struct usbd_interface *, void **, int *);
 
 usbd_status    usbd_set_config_no(struct usbd_device *, int, int);
 usbd_status    usbd_set_config_index(struct usbd_device *, int, int);
 
 usbd_status    usbd_bulk_transfer(struct usbd_xfer *, struct usbd_pipe *,
-               uint16_t, uint32_t, void *, uint32_t *);
-
+                   uint16_t, uint32_t, void *, uint32_t *);
 usbd_status    usbd_intr_transfer(struct usbd_xfer *, struct usbd_pipe *,
                    uint16_t, uint32_t, void *, uint32_t *);
 



Home | Main Index | Thread Index | Old Index