Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Expose more descriptor items as device properties.



details:   https://anonhg.NetBSD.org/src/rev/d4020f663006
branches:  trunk
changeset: 959529:d4020f663006
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Feb 17 06:30:57 2021 +0000

description:
Expose more descriptor items as device properties.

diffstat:

 sys/dev/usb/usb_subr.c |  38 ++++++++++++++++++++++++++++++++------
 1 files changed, 32 insertions(+), 6 deletions(-)

diffs (75 lines):

diff -r c918bb0e3a1d -r d4020f663006 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c    Wed Feb 17 06:25:10 2021 +0000
+++ b/sys/dev/usb/usb_subr.c    Wed Feb 17 06:30:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_subr.c,v 1.248 2020/06/11 02:39:30 thorpej Exp $   */
+/*     $NetBSD: usb_subr.c,v 1.249 2021/02/17 06:30:57 mlelstv Exp $   */
 /*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.248 2020/06/11 02:39:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.249 2021/02/17 06:30:57 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -862,10 +862,36 @@
 }
 
 static void
-usbd_serialnumber(device_t dv, struct usbd_device *dev)
+usbd_properties(device_t dv, struct usbd_device *dev)
 {
+       usb_device_descriptor_t *dd = &dev->ud_ddesc;
+       prop_dictionary_t dict = device_properties(dv);
+       int class, subclass, release, proto, vendor, product;
+
+       class = dd->bDeviceClass;
+       subclass = dd->bDeviceSubClass;
+       release = UGETW(dd->bcdDevice);
+       proto = dd->bDeviceProtocol;
+       vendor = UGETW(dd->idVendor);
+       product = UGETW(dd->idProduct);
+
+       prop_dictionary_set_uint16(dict, "class", class);
+       prop_dictionary_set_uint16(dict, "subclass", subclass);
+       prop_dictionary_set_uint16(dict, "release", release);
+       prop_dictionary_set_uint16(dict, "proto", proto);
+       prop_dictionary_set_uint16(dict, "vendor", vendor);
+       prop_dictionary_set_uint16(dict, "product", product);
+
+       if (dev->ud_vendor) {
+               prop_dictionary_set_string(dict,
+                   "vendor-string", dev->ud_vendor);
+       }
+       if (dev->ud_product) {
+               prop_dictionary_set_string(dict,
+                   "product-string", dev->ud_product);
+       }
        if (dev->ud_serial) {
-               prop_dictionary_set_string(device_properties(dv),
+               prop_dictionary_set_string(dict,
                    "serialnumber", dev->ud_serial);
        }
 }
@@ -907,7 +933,7 @@
                dev->ud_subdevs[0] = dv;
                dev->ud_subdevlen = 1;
                dev->ud_nifaces_claimed = 1; /* XXX */
-               usbd_serialnumber(dv, dev);
+               usbd_properties(dv, dev);
        }
        config_pending_decr(parent);
        return USBD_NORMAL_COMPLETION;
@@ -983,7 +1009,7 @@
                if (!dv)
                        continue;
 
-               usbd_serialnumber(dv, dev);
+               usbd_properties(dv, dev);
 
                /* claim */
                ifaces[i] = NULL;



Home | Main Index | Thread Index | Old Index