From 1be5eb5197494a58c4a8c3845bb56ccc2c0cd625 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sun, 16 Mar 2014 22:15:43 +0100
Subject: [PATCH] usb4bsd: FWIW, add usb_template too.

---
 sys/bus/u4b/Makefile                      |   4 +-
 sys/bus/u4b/template/Makefile             |  39 ++++++++++
 sys/bus/u4b/template/usb_template.c       | 121 ++++++++++++++++--------------
 sys/bus/u4b/template/usb_template.h       |   2 +-
 sys/bus/u4b/template/usb_template_audio.c |  41 ++++------
 sys/bus/u4b/template/usb_template_cdce.c  |  72 ++++++------------
 sys/bus/u4b/template/usb_template_kbd.c   |  35 ++++-----
 sys/bus/u4b/template/usb_template_modem.c |  35 ++++-----
 sys/bus/u4b/template/usb_template_mouse.c |  35 ++++-----
 sys/bus/u4b/template/usb_template_msc.c   |  55 +++++---------
 sys/bus/u4b/template/usb_template_mtp.c   |  51 +++++--------
 sys/conf/files                            |  11 +++
 12 files changed, 231 insertions(+), 270 deletions(-)
 create mode 100644 sys/bus/u4b/template/Makefile

diff --git a/sys/bus/u4b/Makefile b/sys/bus/u4b/Makefile
index 6980e7d..0629967 100644
--- a/sys/bus/u4b/Makefile
+++ b/sys/bus/u4b/Makefile
@@ -1,5 +1,3 @@
-#SUBDIR=	template
-
-SUBDIR=	usb audio controller input misc net quirk serial storage wlan
+SUBDIR=	usb audio controller input misc net quirk serial storage template wlan
 
 .include <bsd.subdir.mk>
diff --git a/sys/bus/u4b/template/Makefile b/sys/bus/u4b/template/Makefile
new file mode 100644
index 0000000..acdcd12
--- /dev/null
+++ b/sys/bus/u4b/template/Makefile
@@ -0,0 +1,39 @@
+#
+# $FreeBSD: head/sys/modules/usb/template/Makefile 223467 2011-06-23 07:54:03Z hselasky $
+#
+# Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+#
+# 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 AUTHOR 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 AUTHOR 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.
+#
+
+KMOD=	usb_template
+SRCS=	opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h \
+	usb_template.c \
+	usb_template_audio.c \
+	usb_template_cdce.c \
+	usb_template_kbd.c \
+	usb_template_modem.c \
+	usb_template_mouse.c \
+	usb_template_msc.c \
+	usb_template_mtp.c
+
+.include <bsd.kmod.mk>
diff --git a/sys/bus/u4b/template/usb_template.c b/sys/bus/u4b/template/usb_template.c
index b929665..50db65a 100644
--- a/sys/bus/u4b/template/usb_template.c
+++ b/sys/bus/u4b/template/usb_template.c
@@ -1,4 +1,4 @@
-/* $FreeBSD$ */
+/* $FreeBSD: head/sys/dev/usb/template/usb_template.c 259218 2013-12-11 13:20:32Z hselasky $ */
 /*-
  * Copyright (c) 2007 Hans Petter Selasky. All rights reserved.
  *
@@ -29,8 +29,10 @@
  * USB templates.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -39,34 +41,34 @@
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_ioctl.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdi_util.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usb_ioctl.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usbdi_util.h>
 #include "usbdevs.h"
 
-#include <dev/usb/usb_cdc.h>
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_dynamic.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_device.h>
+#include <bus/u4b/usb_cdc.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_dynamic.h>
+#include <bus/u4b/usb_busdma.h>
+#include <bus/u4b/usb_process.h>
+#include <bus/u4b/usb_device.h>
 
 #define	USB_DEBUG_VAR usb_debug
-#include <dev/usb/usb_debug.h>
+#include <bus/u4b/usb_debug.h>
 
-#include <dev/usb/usb_controller.h>
-#include <dev/usb/usb_bus.h>
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/usb_controller.h>
+#include <bus/u4b/usb_bus.h>
+#include <bus/u4b/usb_request.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 MODULE_DEPEND(usb_template, usb, 1, 1, 1);
 MODULE_VERSION(usb_template, 1);
@@ -374,7 +376,7 @@ usb_make_config_desc(struct usb_temp_setup *temp,
 
 	/* Reset some counters */
 
-	temp->bInterfaceNumber = 0 - 1;
+	temp->bInterfaceNumber = 0xFF;
 	temp->bAlternateSetting = 0;
 
 	/* Scan all the USB interfaces */
@@ -841,24 +843,24 @@ usb_hw_ep_resolve(struct usb_device *udev,
 	struct usb_hw_ep_scratch *ues;
 	struct usb_hw_ep_scratch_sub *ep;
 	const struct usb_hw_ep_profile *pf;
-	struct usb_bus_methods *methods;
+	const struct usb_bus_methods *methods;
 	struct usb_device_descriptor *dd;
 	uint16_t mps;
 
-	if (desc == NULL) {
+	if (desc == NULL)
 		return (USB_ERR_INVAL);
-	}
+
 	/* get bus methods */
 	methods = udev->bus->methods;
 
-	if (methods->get_hw_ep_profile == NULL) {
+	if (methods->get_hw_ep_profile == NULL)
 		return (USB_ERR_INVAL);
-	}
+
 	if (desc->bDescriptorType == UDESC_DEVICE) {
 
-		if (desc->bLength < sizeof(*dd)) {
+		if (desc->bLength < sizeof(*dd))
 			return (USB_ERR_INVAL);
-		}
+
 		dd = (void *)desc;
 
 		/* get HW control endpoint 0 profile */
@@ -905,13 +907,12 @@ usb_hw_ep_resolve(struct usb_device *udev,
 		}
 		return (0);		/* success */
 	}
-	if (desc->bDescriptorType != UDESC_CONFIG) {
+	if (desc->bDescriptorType != UDESC_CONFIG)
 		return (USB_ERR_INVAL);
-	}
-	if (desc->bLength < sizeof(*(ues->cd))) {
+	if (desc->bLength < sizeof(*(ues->cd)))
 		return (USB_ERR_INVAL);
-	}
-	ues = udev->bus->scratch[0].hw_ep_scratch;
+
+	ues = udev->scratch.hw_ep_scratch;
 
 	memset(ues, 0, sizeof(*ues));
 
@@ -1232,13 +1233,18 @@ usb_temp_setup(struct usb_device *udev,
 {
 	struct usb_temp_setup *uts;
 	void *buf;
+	usb_error_t error;
 	uint8_t n;
+	uint8_t do_unlock;
 
-	if (tdd == NULL) {
-		/* be NULL safe */
+	/* be NULL safe */
+	if (tdd == NULL)
 		return (0);
-	}
-	uts = udev->bus->scratch[0].temp_setup;
+
+	/* Protect scratch area */
+	do_unlock = usbd_enum_lock(udev);
+
+	uts = udev->scratch.temp_setup;
 
 	memset(uts, 0, sizeof(*uts));
 
@@ -1251,17 +1257,24 @@ usb_temp_setup(struct usb_device *udev,
 
 	if (uts->err) {
 		/* some error happened */
-		return (uts->err);
+		goto done;
 	}
 	/* sanity check */
 	if (uts->size == 0) {
-		return (USB_ERR_INVAL);
+		uts->err = USB_ERR_INVAL;
+		goto done;
 	}
 	/* allocate zeroed memory */
-	uts->buf = malloc(uts->size, M_USB, M_WAITOK | M_ZERO);
+	uts->buf = usbd_alloc_config_desc(udev, uts->size);
+	/*
+	 * Allow malloc() to return NULL regardless of M_WAITOK flag.
+	 * This helps when porting the software to non-FreeBSD
+	 * systems.
+	 */
 	if (uts->buf == NULL) {
 		/* could not allocate memory */
-		return (USB_ERR_NOMEM);
+		uts->err = USB_ERR_NOMEM;
+		goto done;
 	}
 	/* second pass */
 
@@ -1276,7 +1289,7 @@ usb_temp_setup(struct usb_device *udev,
 
 	if (uts->err) {
 		/* some error happened during second pass */
-		goto error;
+		goto done;
 	}
 	/*
 	 * Resolve all endpoint addresses !
@@ -1287,7 +1300,7 @@ usb_temp_setup(struct usb_device *udev,
 		DPRINTFN(0, "Could not resolve endpoints for "
 		    "Device Descriptor, error = %s\n",
 		    usbd_errstr(uts->err));
-		goto error;
+		goto done;
 	}
 	for (n = 0;; n++) {
 
@@ -1300,14 +1313,16 @@ usb_temp_setup(struct usb_device *udev,
 			DPRINTFN(0, "Could not resolve endpoints for "
 			    "Config Descriptor %u, error = %s\n", n,
 			    usbd_errstr(uts->err));
-			goto error;
+			goto done;
 		}
 	}
-	return (uts->err);
-
-error:
-	usb_temp_unsetup(udev);
-	return (uts->err);
+done:
+	error = uts->err;
+	if (error)
+		usb_temp_unsetup(udev);
+	if (do_unlock)
+		usbd_enum_unlock(udev);
+	return (error);
 }
 
 /*------------------------------------------------------------------------*
@@ -1319,12 +1334,8 @@ error:
 void
 usb_temp_unsetup(struct usb_device *udev)
 {
-	if (udev->usb_template_ptr) {
-
-		free(udev->usb_template_ptr, M_USB);
-
-		udev->usb_template_ptr = NULL;
-	}
+	usbd_free_config_desc(udev, udev->usb_template_ptr);
+	udev->usb_template_ptr = NULL;
 }
 
 static usb_error_t
@@ -1370,5 +1381,5 @@ usb_temp_init(void *arg)
 	usb_temp_unsetup_p = &usb_temp_unsetup;
 }
 
-SYSINIT(usb_temp_init, SI_SUB_LOCK, SI_ORDER_FIRST, usb_temp_init, NULL);
-SYSUNINIT(usb_temp_unload, SI_SUB_LOCK, SI_ORDER_ANY, usb_temp_unload, NULL);
+SYSINIT(usb_temp_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, usb_temp_init, NULL);
+SYSUNINIT(usb_temp_unload, SI_SUB_DRIVERS, SI_ORDER_ANY, usb_temp_unload, NULL);
diff --git a/sys/bus/u4b/template/usb_template.h b/sys/bus/u4b/template/usb_template.h
index b05272f..6c94e66 100644
--- a/sys/bus/u4b/template/usb_template.h
+++ b/sys/bus/u4b/template/usb_template.h
@@ -1,4 +1,4 @@
-/* $FreeBSD$ */
+/* $FreeBSD: head/sys/dev/usb/template/usb_template.h 223467 2011-06-23 07:54:03Z hselasky $ */
 /*-
  * Copyright (c) 2007 Hans Petter Selasky <hselasky@FreeBSD.org>
  * All rights reserved.
diff --git a/sys/bus/u4b/template/usb_template_audio.c b/sys/bus/u4b/template/usb_template_audio.c
index 8e9e7f0..9fd50f8 100644
--- a/sys/bus/u4b/template/usb_template_audio.c
+++ b/sys/bus/u4b/template/usb_template_audio.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_audio.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
  *
@@ -30,8 +28,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB template for an USB Audio Device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -40,20 +40,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_cdc.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_cdc.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	INDEX_AUDIO_LANG,
@@ -64,30 +64,21 @@ enum {
 	INDEX_AUDIO_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_AUDIO_PRODUCT \
-  'A', 0, 'u', 0, 'd', 0, 'i', 0, 'o', 0, ' ', 0, \
-  'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
-  'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0, 
+  "A\0u\0d\0i\0o\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e"
 
 #define	STRING_AUDIO_MIXER \
-  'M', 0, 'i', 0, 'x', 0, 'e', 0, 'r', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "M\0i\0x\0e\0r\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_AUDIO_RECORD \
-  'R', 0, 'e', 0, 'c', 0, 'o', 0, 'r', 0, 'd', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "R\0e\0c\0o\0r\0d\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_AUDIO_PLAYBACK \
-  'P', 0, 'l', 0, 'a', 0, 'y', 0, 'b', 0, 'a', 0, 'c', 0, 'k', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "P\0l\0a\0y\0b\0a\0c\0k\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_AUDIO_MIXER, string_audio_mixer);
 USB_MAKE_STRING_DESC(STRING_AUDIO_RECORD, string_audio_record);
 USB_MAKE_STRING_DESC(STRING_AUDIO_PLAYBACK, string_audio_playback);
@@ -385,7 +376,7 @@ static const void *
 audio_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[INDEX_AUDIO_MAX] = {
-		[INDEX_AUDIO_LANG] = &string_lang,
+		[INDEX_AUDIO_LANG] = &usb_string_lang_en,
 		[INDEX_AUDIO_MIXER] = &string_audio_mixer,
 		[INDEX_AUDIO_RECORD] = &string_audio_record,
 		[INDEX_AUDIO_PLAYBACK] = &string_audio_playback,
@@ -393,7 +384,7 @@ audio_get_string_desc(uint16_t lang_id, uint8_t string_index)
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_cdce.c b/sys/bus/u4b/template/usb_template_cdce.c
index 481a69c..dd7de07 100644
--- a/sys/bus/u4b/template/usb_template_cdce.c
+++ b/sys/bus/u4b/template/usb_template_cdce.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_cdce.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2007 Hans Petter Selasky <hselasky@FreeBSD.org>
  * All rights reserved.
@@ -31,8 +29,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB templates for a CDC USB ethernet device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -41,20 +41,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_cdc.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_cdc.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	STRING_LANG_INDEX,
@@ -68,61 +68,31 @@ enum {
 	STRING_ETH_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_MAC \
-  '2', 0, 'A', 0, '2', 0, '3', 0, \
-  '4', 0, '5', 0, '6', 0, '7', 0, \
-  '8', 0, '9', 0, 'A', 0, 'B', 0,
+  "2\0A\0002\0003\0004\0005\0006\0007\08\09\0A\0B"
 
 #define	STRING_ETH_CONTROL \
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'E', 0, 't', 0, 'h', 0, 'e', 0, \
-  'r', 0, 'n', 0, 'e', 0, 't', 0, \
-  ' ', 0, 'C', 0, 'o', 0, 'm', 0, \
-  'm', 0, ' ', 0, 'i', 0, 'n', 0, \
-  't', 0, 'e', 0, 'r', 0, 'f', 0, \
-  'a', 0, 'c', 0, 'e', 0,
+  "U\0S\0B\0 \0E\0t\0h\0e\0r\0n\0e\0t\0 " \
+  "\0C\0o\0m\0m\0 \0I\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_ETH_DATA \
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'E', 0, 't', 0, 'h', 0, 'e', 0, \
-  'r', 0, 'n', 0, 'e', 0, 't', 0, \
-  ' ', 0, 'D', 0, 'a', 0, 't', 0, \
-  'a', 0, ' ', 0, 'i', 0, 'n', 0, \
-  't', 0, 'e', 0, 'r', 0, 'f', 0, \
-  'a', 0, 'c', 0, 'e', 0,
+  "U\0S\0B\0 \0E\0t\0h\0e\0r\0n\0e\0t\0 \0D\0a\0t\0a\0 " \
+  "\0I\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_ETH_CONFIG \
-  'D', 0, 'e', 0, 'f', 0, 'a', 0, \
-  'u', 0, 'l', 0, 't', 0, ' ', 0, \
-  'c', 0, 'o', 0, 'n', 0, 'f', 0, \
-  'i', 0, 'g', 0,
+  "D\0e\0f\0a\0u\0l\0t\0 \0c\0o\0n\0f\0i\0g"
 
 #define	STRING_ETH_VENDOR \
-  'F', 0, 'r', 0, 'e', 0, 'e', 0, \
-  'B', 0, 'S', 0, 'D', 0, ' ', 0, \
-  'f', 0, 'o', 0, 'u', 0, 'n', 0, \
-  'd', 0, 'a', 0, 't', 0, 'i', 0, \
-  'o', 0, 'n', 0,
+  "F\0r\0e\0e\0B\0S\0D\0 \0f\0o\0u\0n\0d\0a\0t\0i\0o\0n"
 
 #define	STRING_ETH_PRODUCT \
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'E', 0, 't', 0, 'h', 0, 'e', 0, \
-  'r', 0, 'n', 0, 'e', 0, 't', 0, \
-  ' ', 0, 'A', 0, 'd', 0, 'a', 0, \
-  'p', 0, 't', 0, 'e', 0, 'r', 0,
+  "U\0S\0B\0 \0E\0t\0h\0e\0r\0n\0e\0t\0 \0A\0d\0a\0p\0t\0e\0r"
 
 #define	STRING_ETH_SERIAL \
-  'D', 0, 'e', 0, 'c', 0, 'e', 0, \
-  'm', 0, 'b', 0, 'e', 0, 'r', 0, \
-  ' ', 0, '2', 0, '0', 0, '0', 0, \
-  '7', 0,
+  "D\0e\0c\0e\0m\0b\0e\0r\0 \0002\0000\0000\0007"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_MAC, string_mac);
 USB_MAKE_STRING_DESC(STRING_ETH_CONTROL, string_eth_control);
 USB_MAKE_STRING_DESC(STRING_ETH_DATA, string_eth_data);
@@ -286,7 +256,7 @@ static const void *
 eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[STRING_ETH_MAX] = {
-		[STRING_LANG_INDEX] = &string_lang,
+		[STRING_LANG_INDEX] = &usb_string_lang_en,
 		[STRING_MAC_INDEX] = &string_mac,
 		[STRING_ETH_CONTROL_INDEX] = &string_eth_control,
 		[STRING_ETH_DATA_INDEX] = &string_eth_data,
@@ -297,7 +267,7 @@ eth_get_string_desc(uint16_t lang_id, uint8_t string_index)
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_kbd.c b/sys/bus/u4b/template/usb_template_kbd.c
index 6295825..e81bbd5 100644
--- a/sys/bus/u4b/template/usb_template_kbd.c
+++ b/sys/bus/u4b/template/usb_template_kbd.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_kbd.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
  *
@@ -30,8 +28,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB template for an USB Keyboard Device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -40,20 +40,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_cdc.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_cdc.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	INDEX_LANG,
@@ -62,21 +62,14 @@ enum {
 	INDEX_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_PRODUCT \
-  'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \
-  'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
-  'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0, 
+  "K\0e\0y\0b\0o\0a\0r\0d\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e"
 
 #define	STRING_KEYBOARD \
-  'K', 0, 'e', 0, 'y', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0, 'd', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "K\0e\0y\0b\0o\0a\0r\0d\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_KEYBOARD, string_keyboard);
 USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
 
@@ -206,13 +199,13 @@ static const void *
 keyboard_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[INDEX_MAX] = {
-		[INDEX_LANG] = &string_lang,
+		[INDEX_LANG] = &usb_string_lang_en,
 		[INDEX_KEYBOARD] = &string_keyboard,
 		[INDEX_PRODUCT] = &string_product,
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_modem.c b/sys/bus/u4b/template/usb_template_modem.c
index abc6f26..5b65825 100644
--- a/sys/bus/u4b/template/usb_template_modem.c
+++ b/sys/bus/u4b/template/usb_template_modem.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_modem.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
  *
@@ -30,8 +28,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB template for an USB Modem Device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -40,20 +40,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_cdc.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_cdc.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	INDEX_LANG,
@@ -62,21 +62,14 @@ enum {
 	INDEX_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_PRODUCT \
-  'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
-  'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
-  'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0, ' ', 0, 
+  "M\0o\0d\0e\0m\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e"
 
 #define	STRING_MODEM \
-  'M', 0, 'o', 0, 'd', 0, 'e', 0, 'm', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "M\0o\0d\0e\0m\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_MODEM, string_modem);
 USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
 
@@ -234,13 +227,13 @@ static const void *
 modem_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[INDEX_MAX] = {
-		[INDEX_LANG] = &string_lang,
+		[INDEX_LANG] = &usb_string_lang_en,
 		[INDEX_MODEM] = &string_modem,
 		[INDEX_PRODUCT] = &string_product,
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_mouse.c b/sys/bus/u4b/template/usb_template_mouse.c
index 628c9a5..b11f4df 100644
--- a/sys/bus/u4b/template/usb_template_mouse.c
+++ b/sys/bus/u4b/template/usb_template_mouse.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_mouse.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
  *
@@ -30,8 +28,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB template for an USB Mouse Device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -40,20 +40,20 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usb_cdc.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+#include <bus/u4b/usb_cdc.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	INDEX_LANG,
@@ -62,21 +62,14 @@ enum {
 	INDEX_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_PRODUCT \
-  'M', 0, 'o', 0, 'u', 0, 's', 0, 'e', 0, ' ', 0, \
-  'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, \
-  'D', 0, 'e', 0, 'v', 0, 'i', 0, 'c', 0, 'e', 0,
+  "M\0o\0u\0s\0e\0 \0T\0e\0s\0t\0 \0D\0e\0v\0i\0c\0e"
 
 #define	STRING_MOUSE \
-  'M', 0, 'o', 0, 'u', 0, 's', 0, 'e', 0, ' ', 0, \
-  'i', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0,
+  "M\0o\0u\0s\0e\0 \0i\0n\0t\0e\0r\0f\0a\0c\0e"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_MOUSE, string_mouse);
 USB_MAKE_STRING_DESC(STRING_PRODUCT, string_product);
 
@@ -204,13 +197,13 @@ static const void *
 mouse_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[INDEX_MAX] = {
-		[INDEX_LANG] = &string_lang,
+		[INDEX_LANG] = &usb_string_lang_en,
 		[INDEX_MOUSE] = &string_mouse,
 		[INDEX_PRODUCT] = &string_product,
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_msc.c b/sys/bus/u4b/template/usb_template_msc.c
index 5c05ffe..01ce397 100644
--- a/sys/bus/u4b/template/usb_template_msc.c
+++ b/sys/bus/u4b/template/usb_template_msc.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_msc.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
  * All rights reserved.
@@ -31,8 +29,10 @@ __FBSDID("$FreeBSD$");
  * This file contains the USB templates for an USB Mass Storage Device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -41,19 +41,19 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
 
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 enum {
 	STRING_LANG_INDEX,
@@ -65,45 +65,24 @@ enum {
 	STRING_MSC_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_MSC_DATA	\
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'M', 0, 'a', 0, 's', 0, 's', 0, \
-  ' ', 0, 'S', 0, 't', 0, 'o', 0, \
-  'r', 0, 'a', 0, 'g', 0, 'e', 0, \
-  ' ', 0, 'I', 0, 'n', 0, 't', 0, \
-  'e', 0, 'r', 0, 'f', 0, 'a', 0, \
-  'c', 0, 'e', 0,
+  "U\0S\0B\0 \0M\0a\0s\0s\0 \0S\0t\0o\0r\0a\0g\0e\0 " \
+  "\0I\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_MSC_CONFIG \
-  'D', 0, 'e', 0, 'f', 0, 'a', 0, \
-  'u', 0, 'l', 0, 't', 0, ' ', 0, \
-  'c', 0, 'o', 0, 'n', 0, 'f', 0, \
-  'i', 0, 'g', 0,
+  "D\0e\0f\0a\0u\0l\0t\0 \0c\0o\0n\0f\0i\0g"
 
 #define	STRING_MSC_VENDOR \
-  'F', 0, 'r', 0, 'e', 0, 'e', 0, \
-  'B', 0, 'S', 0, 'D', 0, ' ', 0, \
-  'f', 0, 'o', 0, 'u', 0, 'n', 0, \
-  'd', 0, 'a', 0, 't', 0, 'i', 0, \
-  'o', 0, 'n', 0,
+  "F\0r\0e\0e\0B\0S\0D\0 \0f\0o\0u\0n\0d\0a\0t\0i\0o\0n"
 
 #define	STRING_MSC_PRODUCT \
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'M', 0, 'e', 0, 'm', 0, 'o', 0, \
-  'r', 0, 'y', 0, ' ', 0, 'S', 0, \
-  't', 0, 'i', 0, 'c', 0, 'k', 0
+  "U\0S\0B\0 \0M\0e\0m\0o\0r\0y\0 \0S\0t\0i\0c\0k"
 
 #define	STRING_MSC_SERIAL \
-  'M', 0, 'a', 0, 'r', 0, 'c', 0, \
-  'h', 0, ' ', 0, '2', 0, '0', 0, \
-  '0', 0, '8', 0,
+  "M\0a\0r\0c\0h\0 \0002\0000\0000\08"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_MSC_DATA, string_msc_data);
 USB_MAKE_STRING_DESC(STRING_MSC_CONFIG, string_msc_config);
 USB_MAKE_STRING_DESC(STRING_MSC_VENDOR, string_msc_vendor);
@@ -195,7 +174,7 @@ static const void *
 msc_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[STRING_MSC_MAX] = {
-		[STRING_LANG_INDEX] = &string_lang,
+		[STRING_LANG_INDEX] = &usb_string_lang_en,
 		[STRING_MSC_DATA_INDEX] = &string_msc_data,
 		[STRING_MSC_CONFIG_INDEX] = &string_msc_config,
 		[STRING_MSC_VENDOR_INDEX] = &string_msc_vendor,
@@ -204,7 +183,7 @@ msc_get_string_desc(uint16_t lang_id, uint8_t string_index)
 	};
 
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/bus/u4b/template/usb_template_mtp.c b/sys/bus/u4b/template/usb_template_mtp.c
index f48fbf4..768a1e5 100644
--- a/sys/bus/u4b/template/usb_template_mtp.c
+++ b/sys/bus/u4b/template/usb_template_mtp.c
@@ -1,6 +1,4 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
+/* $FreeBSD: head/sys/dev/usb/template/usb_template_mtp.c 246125 2013-01-30 16:05:54Z hselasky $ */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
  * All rights reserved.
@@ -38,8 +36,10 @@ __FBSDID("$FreeBSD$");
  * operating system the VID and PID of your device.
  */
 
+#ifdef USB_GLOBAL_INCLUDE_FILE
+#include USB_GLOBAL_INCLUDE_FILE
+#else
 #include <sys/stdint.h>
-#include <sys/stddef.h>
 #include <sys/param.h>
 #include <sys/queue.h>
 #include <sys/types.h>
@@ -48,18 +48,19 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/module.h>
 #include <sys/lock.h>
-#include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/sysctl.h>
-#include <sys/sx.h>
 #include <sys/unistd.h>
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/template/usb_template.h>
+#include <bus/u4b/usb.h>
+#include <bus/u4b/usbdi.h>
+#include <bus/u4b/usb_core.h>
+
+#include <bus/u4b/template/usb_template.h>
+#endif			/* USB_GLOBAL_INCLUDE_FILE */
 
 #define	MTP_BREQUEST 0x08
 
@@ -73,41 +74,23 @@ enum {
 	STRING_MTP_MAX,
 };
 
-#define	STRING_LANG \
-  0x09, 0x04,				/* American English */
-
 #define	STRING_MTP_DATA	\
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'M', 0, 'T', 0, 'P', 0, \
-  ' ', 0, 'I', 0, 'n', 0, 't', 0, \
-  'e', 0, 'r', 0, 'f', 0, 'a', 0, \
-  'c', 0, 'e', 0,
+  "U\0S\0B\0 \0M\0T\0P\0 \0I\0n\0t\0e\0r\0f\0a\0c\0e"
 
 #define	STRING_MTP_CONFIG \
-  'D', 0, 'e', 0, 'f', 0, 'a', 0, \
-  'u', 0, 'l', 0, 't', 0, ' ', 0, \
-  'c', 0, 'o', 0, 'n', 0, 'f', 0, \
-  'i', 0, 'g', 0,
+  "D\0e\0f\0a\0u\0l\0t\0 \0c\0o\0n\0f\0i\0g"
 
 #define	STRING_MTP_VENDOR \
-  'F', 0, 'r', 0, 'e', 0, 'e', 0, \
-  'B', 0, 'S', 0, 'D', 0, ' ', 0, \
-  'f', 0, 'o', 0, 'u', 0, 'n', 0, \
-  'd', 0, 'a', 0, 't', 0, 'i', 0, \
-  'o', 0, 'n', 0,
+  "F\0r\0e\0e\0B\0S\0D\0 \0f\0o\0u\0n\0d\0a\0t\0i\0o\0n"
 
 #define	STRING_MTP_PRODUCT \
-  'U', 0, 'S', 0, 'B', 0, ' ', 0, \
-  'M', 0, 'T', 0, 'P', 0,
+  "U\0S\0B\0 \0M\0T\0P"
 
 #define	STRING_MTP_SERIAL \
-  'J', 0, 'u', 0, 'n', 0, 'e', 0, \
-  ' ', 0, '2', 0, '0', 0, '0', 0, \
-  '8', 0,
+  "J\0u\0n\0e\0 \0002\0000\0000\08"
 
 /* make the real string descriptors */
 
-USB_MAKE_STRING_DESC(STRING_LANG, string_lang);
 USB_MAKE_STRING_DESC(STRING_MTP_DATA, string_mtp_data);
 USB_MAKE_STRING_DESC(STRING_MTP_CONFIG, string_mtp_config);
 USB_MAKE_STRING_DESC(STRING_MTP_VENDOR, string_mtp_vendor);
@@ -244,7 +227,7 @@ static const void *
 mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
 {
 	static const void *ptr[STRING_MTP_MAX] = {
-		[STRING_LANG_INDEX] = &string_lang,
+		[STRING_LANG_INDEX] = &usb_string_lang_en,
 		[STRING_MTP_DATA_INDEX] = &string_mtp_data,
 		[STRING_MTP_CONFIG_INDEX] = &string_mtp_config,
 		[STRING_MTP_VENDOR_INDEX] = &string_mtp_vendor,
@@ -266,7 +249,7 @@ mtp_get_string_desc(uint16_t lang_id, uint8_t string_index)
 		return (dummy_desc);
 	}
 	if (string_index == 0) {
-		return (&string_lang);
+		return (&usb_string_lang_en);
 	}
 	if (lang_id != 0x0409) {
 		return (NULL);
diff --git a/sys/conf/files b/sys/conf/files
index 2dfb9cd..2e8eadd 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -2551,6 +2551,17 @@ bus/u4b/input/uhid.c			optional uhid usb
 #
 bus/u4b/quirk/usb_quirk.c		optional usb
 #
+# USB templates
+#
+bus/u4b/template/usb_template.c		optional usb_template usb
+bus/u4b/template/usb_template_audio.c	optional usb_template usb
+bus/u4b/template/usb_template_cdce.c	optional usb_template usb
+bus/u4b/template/usb_template_kbd.c	optional usb_template usb
+bus/u4b/template/usb_template_modem.c	optional usb_template usb
+bus/u4b/template/usb_template_mouse.c	optional usb_template usb
+bus/u4b/template/usb_template_msc.c	optional usb_template usb
+bus/u4b/template/usb_template_mtp.c	optional usb_template usb
+#
 # Other drivers
 #
 bus/u4b/audio/uaudio.c			optional snd_uaudio usb
-- 
1.8.2.2

