Source-Changes-HG archive

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

[src/pgoyette-compat]: src/sys Split out the usb compat_30 code and add it to...



details:   https://anonhg.NetBSD.org/src/rev/8b2781b080c5
branches:  pgoyette-compat
changeset: 321119:8b2781b080c5
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Mar 29 11:20:02 2018 +0000

description:
Split out the usb compat_30 code and add it to the module

diffstat:

 sys/compat/common/compat_30_mod.c |   30 ++--
 sys/compat/common/compat_mod.c    |    7 +-
 sys/compat/common/compat_mod.h    |    4 +-
 sys/compat/common/files.common    |    3 +-
 sys/compat/common/usb_30_subr.c   |  243 ++++++++++++++++++++++++++++++++++++++
 sys/dev/usb/ugen.c                |   15 +-
 sys/dev/usb/uhid.c                |   15 +-
 sys/dev/usb/usb.c                 |  117 ++----------------
 sys/dev/usb/usb_subr.c            |   78 +-----------
 sys/dev/usb/usbdi.h               |   12 +-
 sys/kern/compat_stub.c            |   29 +++-
 sys/sys/compat_stub.h             |   27 ++++-
 12 files changed, 359 insertions(+), 221 deletions(-)

diffs (truncated from 892 to 300 lines):

diff -r b6602b9e73ce -r 8b2781b080c5 sys/compat/common/compat_30_mod.c
--- a/sys/compat/common/compat_30_mod.c Thu Mar 29 10:27:27 2018 +0000
+++ b/sys/compat/common/compat_30_mod.c Thu Mar 29 11:20:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $   */
+/*     $NetBSD: compat_30_mod.c,v 1.1.2.3 2018/03/29 11:20:02 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.2 2018/03/28 07:51:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_30_mod.c,v 1.1.2.3 2018/03/29 11:20:02 pgoyette Exp $");
 
 #include <sys/systm.h>
 #include <sys/module.h>
@@ -64,6 +64,7 @@
        }
        bio_30_init();
        vnd_30_init();
+       usb_30_init();
 
        return error;
 }
@@ -73,23 +74,26 @@
 {
        int error = 0;
 
+       usb_30_fini();
        vnd_30_fini();
        bio_30_fini();
 
        error = kern_time_30_fini();
-       if (error != 0) {
-               bio_30_init();
-               vnd_30_init();
-               return error;
-       }
+       if (error != 0)
+               goto err1;
 
        error = vfs_syscalls_30_fini();
-       if (error != 0) {
-               bio_30_init();
-               vnd_30_init();
-               kern_time_30_init();
-               return error;
-       }
+       if (error != 0)
+               goto err2;
+
+       return 0;
+
+ err2:
+       kern_time_30_init();
+ err1:
+       bio_30_init();
+       vnd_30_init();
+       usb_30_init();
 
        return error;
 }
diff -r b6602b9e73ce -r 8b2781b080c5 sys/compat/common/compat_mod.c
--- a/sys/compat/common/compat_mod.c    Thu Mar 29 10:27:27 2018 +0000
+++ b/sys/compat/common/compat_mod.c    Thu Mar 29 11:20:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.c,v 1.24.14.22 2018/03/28 04:18:24 pgoyette Exp $   */
+/*     $NetBSD: compat_mod.c,v 1.24.14.23 2018/03/29 11:20:02 pgoyette Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.22 2018/03/28 04:18:24 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_mod.c,v 1.24.14.23 2018/03/29 11:20:02 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -77,7 +77,8 @@
 #endif
 
 static const char * const compat_includes[] = {
-       "compat_80", "compat_70", "compat_60", "compat_50", 
+       "compat_80", "compat_70", "compat_60", "compat_50", "compat_40",
+       "compat_30",
        NULL
 };
 
diff -r b6602b9e73ce -r 8b2781b080c5 sys/compat/common/compat_mod.h
--- a/sys/compat/common/compat_mod.h    Thu Mar 29 10:27:27 2018 +0000
+++ b/sys/compat/common/compat_mod.h    Thu Mar 29 11:20:02 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_mod.h,v 1.1.42.11 2018/03/28 07:51:09 pgoyette Exp $    */
+/*     $NetBSD: compat_mod.h,v 1.1.42.12 2018/03/29 11:20:02 pgoyette Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -101,6 +101,8 @@
 void bio_30_fini(void);
 void vnd_30_init(void);
 void vnd_30_fini(void);
+void usb_30_init(void);
+void usb_30_fini(void);
 #endif
 
 #endif /* !_COMPAT_MOD_H_ */
diff -r b6602b9e73ce -r 8b2781b080c5 sys/compat/common/files.common
--- a/sys/compat/common/files.common    Thu Mar 29 10:27:27 2018 +0000
+++ b/sys/compat/common/files.common    Thu Mar 29 11:20:02 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.common,v 1.1.2.21 2018/03/28 07:51:09 pgoyette Exp $
+#      $NetBSD: files.common,v 1.1.2.22 2018/03/29 11:20:02 pgoyette Exp $
 
 #
 # Generic files, used by all compat options.
@@ -53,6 +53,7 @@
 file   compat/common/uipc_syscalls_30.c        compat_30
 file   compat/common/bio_30.c                  compat_30
 file   compat/common/vnd_30.c                  compat_30
+file   compat/common/usb_30_subr.c             compat_30
 
 # Compatibility code for NetBSD 4.0
 file   compat/common/compat_40_mod.c           compat_40
diff -r b6602b9e73ce -r 8b2781b080c5 sys/compat/common/usb_30_subr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/common/usb_30_subr.c   Thu Mar 29 11:20:02 2018 +0000
@@ -0,0 +1,243 @@
+/*     $NetBSD: usb_30_subr.c,v 1.1.2.1 2018/03/29 11:20:02 pgoyette Exp $     */
+/*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
+
+/*
+ * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson (lennart%augustsson.net@localhost) at
+ * Carlstedt Research & Technology.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: usb_30_subr.c,v 1.1.2.1 2018/03/29 11:20:02 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
+#include "opt_compat_netbsd.h"
+#include "opt_usb.h"
+#include "opt_usbverbose.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/kmem.h>
+#include <sys/device.h>
+#include <sys/select.h>
+#include <sys/proc.h>
+
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/compat_stub.h>
+
+#include <compat/common/compat_mod.h>
+
+#include <dev/usb/usb.h>
+
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdivar.h>
+#include <dev/usb/usbdevs.h>
+#include <dev/usb/usb_quirks.h>
+#include <dev/usb/usb_verbose.h>
+#include <dev/usb/usbhist.h>
+
+Static void usb_copy_old_devinfo(struct usb_device_info_old *,
+    const struct usb_device_info *);
+
+Static void
+usb_copy_old_devinfo(struct usb_device_info_old *uo,
+                    const struct usb_device_info *ue)
+{
+       const unsigned char *p;
+       unsigned char *q;
+       int i, n;
+
+       uo->udi_bus = ue->udi_bus;
+       uo->udi_addr = ue->udi_addr;
+       uo->udi_cookie = ue->udi_cookie;
+       for (i = 0, p = (const unsigned char *)ue->udi_product,
+            q = (unsigned char *)uo->udi_product;
+            *p && i < USB_MAX_STRING_LEN - 1; p++) {
+               if (*p < 0x80)
+                       q[i++] = *p;
+               else {
+                       q[i++] = '?';
+                       if ((*p & 0xe0) == 0xe0)
+                               p++;
+                       p++;
+               }
+       }
+       q[i] = 0;
+
+       for (i = 0, p = ue->udi_vendor, q = uo->udi_vendor;
+            *p && i < USB_MAX_STRING_LEN - 1; p++) {
+               if (* p < 0x80)
+                       q[i++] = *p;
+               else {
+                       q[i++] = '?';
+                       p++;
+                       if ((*p & 0xe0) == 0xe0)
+                               p++;
+               }
+       }
+       q[i] = 0;
+
+       memcpy(uo->udi_release, ue->udi_release, sizeof(uo->udi_release));
+
+       uo->udi_productNo = ue->udi_productNo;
+       uo->udi_vendorNo = ue->udi_vendorNo;
+       uo->udi_releaseNo = ue->udi_releaseNo;
+       uo->udi_class = ue->udi_class;
+       uo->udi_subclass = ue->udi_subclass;
+       uo->udi_protocol = ue->udi_protocol;
+       uo->udi_config = ue->udi_config;
+       uo->udi_speed = ue->udi_speed;
+       uo->udi_power = ue->udi_power;
+       uo->udi_nports = ue->udi_nports;
+
+       for (n=0; n<USB_MAX_DEVNAMES; n++)
+               memcpy(uo->udi_devnames[n],
+                      ue->udi_devnames[n], USB_MAX_DEVNAMELEN);
+       memcpy(uo->udi_ports, ue->udi_ports, sizeof(uo->udi_ports));
+}
+
+static int
+usbd_fill_deviceinfo_old(struct usbd_device *dev,
+    struct usb_device_info_old *di, int usedev)
+{
+       struct usbd_port *p;
+       int i, j, err;
+
+       di->udi_bus = device_unit(dev->ud_bus->ub_usbctl);
+       di->udi_addr = dev->ud_addr;
+       di->udi_cookie = dev->ud_cookie;
+       (*vec_usbd_devinfo_vp)(dev, di->udi_vendor, sizeof(di->udi_vendor),
+           di->udi_product, sizeof(di->udi_product), usedev, 0);
+       (*vec_usbd_printBCD)(di->udi_release, sizeof(di->udi_release),
+           UGETW(dev->ud_ddesc.bcdDevice));
+       di->udi_vendorNo = UGETW(dev->ud_ddesc.idVendor);
+       di->udi_productNo = UGETW(dev->ud_ddesc.idProduct);
+       di->udi_releaseNo = UGETW(dev->ud_ddesc.bcdDevice);
+       di->udi_class = dev->ud_ddesc.bDeviceClass;
+       di->udi_subclass = dev->ud_ddesc.bDeviceSubClass;
+       di->udi_protocol = dev->ud_ddesc.bDeviceProtocol;
+       di->udi_config = dev->ud_config;
+       di->udi_power = dev->ud_selfpowered ? 0 : dev->ud_power;
+       di->udi_speed = dev->ud_speed;
+
+       if (dev->ud_subdevlen > 0) {
+               for (i = 0, j = 0; i < dev->ud_subdevlen &&
+                            j < USB_MAX_DEVNAMES; i++) {
+                       if (!dev->ud_subdevs[i])
+                               continue;
+                       strncpy(di->udi_devnames[j],
+                           device_xname(dev->ud_subdevs[i]), USB_MAX_DEVNAMELEN);
+                       di->udi_devnames[j][USB_MAX_DEVNAMELEN-1] = '\0';
+                       j++;
+               }
+       } else {
+               j = 0;
+       }
+       for (/* j is set */; j < USB_MAX_DEVNAMES; j++)
+               di->udi_devnames[j][0] = 0;              /* empty */
+
+       if (!dev->ud_hub) {
+               di->udi_nports = 0;
+               return 0;



Home | Main Index | Thread Index | Old Index