Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Move usb_desc_* into usbdi_util.c, no functional...



details:   https://anonhg.NetBSD.org/src/rev/5a439ffd7649
branches:  trunk
changeset: 744896:5a439ffd7649
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Feb 16 09:40:35 2020 +0000

description:
Move usb_desc_* into usbdi_util.c, no functional change.

diffstat:

 sys/dev/usb/usbdi.c      |  78 +----------------------------------------------
 sys/dev/usb/usbdi.h      |  13 +-------
 sys/dev/usb/usbdi_util.c |  79 ++++++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/usb/usbdi_util.h |  13 +++++++-
 4 files changed, 92 insertions(+), 91 deletions(-)

diffs (253 lines):

diff -r d1a32ca8b490 -r 5a439ffd7649 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Sun Feb 16 07:29:48 2020 +0000
+++ b/sys/dev/usb/usbdi.c       Sun Feb 16 09:40:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.192 2020/02/12 16:01:00 riastradh Exp $    */
+/*     $NetBSD: usbdi.c,v 1.193 2020/02/16 09:40:35 maxv Exp $ */
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.192 2020/02/12 16:01:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.193 2020/02/16 09:40:35 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1271,80 +1271,6 @@
        return NULL;
 }
 
-
-void
-usb_desc_iter_init(struct usbd_device *dev, usbd_desc_iter_t *iter)
-{
-       const usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
-
-       iter->cur = (const uByte *)cd;
-       iter->end = (const uByte *)cd + UGETW(cd->wTotalLength);
-}
-
-const usb_descriptor_t *
-usb_desc_iter_peek(usbd_desc_iter_t *iter)
-{
-       const usb_descriptor_t *desc;
-
-       if (iter->cur + sizeof(usb_descriptor_t) >= iter->end) {
-               if (iter->cur != iter->end)
-                       printf("%s: bad descriptor\n", __func__);
-               return NULL;
-       }
-       desc = (const usb_descriptor_t *)iter->cur;
-       if (desc->bLength == 0) {
-               printf("%s: descriptor length = 0\n", __func__);
-               return NULL;
-       }
-       if (iter->cur + desc->bLength > iter->end) {
-               printf("%s: descriptor length too large\n", __func__);
-               return NULL;
-       }
-       return desc;
-}
-
-const usb_descriptor_t *
-usb_desc_iter_next(usbd_desc_iter_t *iter)
-{
-       const usb_descriptor_t *desc = usb_desc_iter_peek(iter);
-       if (desc == NULL)
-               return NULL;
-       iter->cur += desc->bLength;
-       return desc;
-}
-
-/* Return the next interface descriptor, skipping over any other
- * descriptors.  Returns NULL at the end or on error. */
-const usb_interface_descriptor_t *
-usb_desc_iter_next_interface(usbd_desc_iter_t *iter)
-{
-       const usb_descriptor_t *desc;
-
-       while ((desc = usb_desc_iter_peek(iter)) != NULL &&
-              desc->bDescriptorType != UDESC_INTERFACE)
-       {
-               usb_desc_iter_next(iter);
-       }
-
-       return (const usb_interface_descriptor_t *)usb_desc_iter_next(iter);
-}
-
-/* Returns the next non-interface descriptor, returning NULL when the
- * next descriptor would be an interface descriptor. */
-const usb_descriptor_t *
-usb_desc_iter_next_non_interface(usbd_desc_iter_t *iter)
-{
-       const usb_descriptor_t *desc;
-
-       if ((desc = usb_desc_iter_peek(iter)) != NULL &&
-           desc->bDescriptorType != UDESC_INTERFACE)
-       {
-               return usb_desc_iter_next(iter);
-       } else {
-               return NULL;
-       }
-}
-
 usbd_status
 usbd_get_string(struct usbd_device *dev, int si, char *buf)
 {
diff -r d1a32ca8b490 -r 5a439ffd7649 sys/dev/usb/usbdi.h
--- a/sys/dev/usb/usbdi.h       Sun Feb 16 07:29:48 2020 +0000
+++ b/sys/dev/usb/usbdi.h       Sun Feb 16 09:40:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.h,v 1.101 2020/02/12 16:01:00 riastradh Exp $    */
+/*     $NetBSD: usbdi.h,v 1.102 2020/02/16 09:40:35 maxv Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $      */
 
 /*
@@ -193,17 +193,6 @@
 bool usbd_xfer_trycomplete(struct usbd_xfer *);
 void usbd_xfer_abort(struct usbd_xfer *);
 
-/* An iterator for descriptors. */
-typedef struct {
-       const uByte *cur;
-       const uByte *end;
-} usbd_desc_iter_t;
-void usb_desc_iter_init(struct usbd_device *, usbd_desc_iter_t *);
-const usb_descriptor_t *usb_desc_iter_peek(usbd_desc_iter_t *);
-const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *);
-const usb_interface_descriptor_t *usb_desc_iter_next_interface(usbd_desc_iter_t *);
-const usb_descriptor_t *usb_desc_iter_next_non_interface(usbd_desc_iter_t *);
-
 /* Used to clear endpoint stalls from the softint */
 void usbd_clear_endpoint_stall_task(void *);
 
diff -r d1a32ca8b490 -r 5a439ffd7649 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c  Sun Feb 16 07:29:48 2020 +0000
+++ b/sys/dev/usb/usbdi_util.c  Sun Feb 16 09:40:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.c,v 1.79 2020/02/10 09:15:27 skrll Exp $    */
+/*     $NetBSD: usbdi_util.c,v 1.80 2020/02/16 09:40:35 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.79 2020/02/10 09:15:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.80 2020/02/16 09:40:35 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -717,6 +717,81 @@
        wakeup(dv); /* XXXSMP ok */
 }
 
+/* -------------------------------------------------------------------------- */
+
+void
+usb_desc_iter_init(struct usbd_device *dev, usbd_desc_iter_t *iter)
+{
+       const usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
+
+       iter->cur = (const uByte *)cd;
+       iter->end = (const uByte *)cd + UGETW(cd->wTotalLength);
+}
+
+const usb_descriptor_t *
+usb_desc_iter_peek(usbd_desc_iter_t *iter)
+{
+       const usb_descriptor_t *desc;
+
+       if (iter->cur + sizeof(usb_descriptor_t) >= iter->end) {
+               if (iter->cur != iter->end)
+                       printf("%s: bad descriptor\n", __func__);
+               return NULL;
+       }
+       desc = (const usb_descriptor_t *)iter->cur;
+       if (desc->bLength == 0) {
+               printf("%s: descriptor length = 0\n", __func__);
+               return NULL;
+       }
+       if (iter->cur + desc->bLength > iter->end) {
+               printf("%s: descriptor length too large\n", __func__);
+               return NULL;
+       }
+       return desc;
+}
+
+const usb_descriptor_t *
+usb_desc_iter_next(usbd_desc_iter_t *iter)
+{
+       const usb_descriptor_t *desc = usb_desc_iter_peek(iter);
+       if (desc == NULL)
+               return NULL;
+       iter->cur += desc->bLength;
+       return desc;
+}
+
+/* Return the next interface descriptor, skipping over any other
+ * descriptors.  Returns NULL at the end or on error. */
+const usb_interface_descriptor_t *
+usb_desc_iter_next_interface(usbd_desc_iter_t *iter)
+{
+       const usb_descriptor_t *desc;
+
+       while ((desc = usb_desc_iter_peek(iter)) != NULL &&
+              desc->bDescriptorType != UDESC_INTERFACE)
+       {
+               usb_desc_iter_next(iter);
+       }
+
+       return (const usb_interface_descriptor_t *)usb_desc_iter_next(iter);
+}
+
+/* Returns the next non-interface descriptor, returning NULL when the
+ * next descriptor would be an interface descriptor. */
+const usb_descriptor_t *
+usb_desc_iter_next_non_interface(usbd_desc_iter_t *iter)
+{
+       const usb_descriptor_t *desc;
+
+       if ((desc = usb_desc_iter_peek(iter)) != NULL &&
+           desc->bDescriptorType != UDESC_INTERFACE)
+       {
+               return usb_desc_iter_next(iter);
+       } else {
+               return NULL;
+       }
+}
+
 const usb_cdc_descriptor_t *
 usb_find_desc(struct usbd_device *dev, int type, int subtype)
 {
diff -r d1a32ca8b490 -r 5a439ffd7649 sys/dev/usb/usbdi_util.h
--- a/sys/dev/usb/usbdi_util.h  Sun Feb 16 07:29:48 2020 +0000
+++ b/sys/dev/usb/usbdi_util.h  Sun Feb 16 09:40:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.h,v 1.52 2020/02/08 08:47:27 maxv Exp $     */
+/*     $NetBSD: usbdi_util.h,v 1.53 2020/02/16 09:40:35 maxv Exp $     */
 
 /*
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -100,6 +100,17 @@
        uByte           bDescriptorSubtype;
 } UPACKED usb_cdc_descriptor_t;
 
+/* An iterator for descriptors. */
+typedef struct {
+       const uByte *cur;
+       const uByte *end;
+} usbd_desc_iter_t;
+void usb_desc_iter_init(struct usbd_device *, usbd_desc_iter_t *);
+const usb_descriptor_t *usb_desc_iter_peek(usbd_desc_iter_t *);
+const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *);
+const usb_interface_descriptor_t *usb_desc_iter_next_interface(usbd_desc_iter_t *);
+const usb_descriptor_t *usb_desc_iter_next_non_interface(usbd_desc_iter_t *);
+
 const usb_cdc_descriptor_t *usb_find_desc(struct usbd_device *, int,
                                      int);
 const usb_cdc_descriptor_t *usb_find_desc_if(struct usbd_device *, int,



Home | Main Index | Thread Index | Old Index