Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Oct 2017 11:46:11 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324626 - head/sys/dev/usb/template
Message-ID:  <201710151146.v9FBkBNE082383@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sun Oct 15 11:46:11 2017
New Revision: 324626
URL: https://svnweb.freebsd.org/changeset/base/324626

Log:
  Replace some magic numbers in usb_template(4) code with #defines.
  There should be no functional changes.
  
  Reviewed by:	hselasky
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D12670

Modified:
  head/sys/dev/usb/template/usb_template_audio.c
  head/sys/dev/usb/template/usb_template_kbd.c
  head/sys/dev/usb/template/usb_template_midi.c
  head/sys/dev/usb/template/usb_template_modem.c
  head/sys/dev/usb/template/usb_template_mouse.c
  head/sys/dev/usb/template/usb_template_phone.c
  head/sys/dev/usb/template/usb_template_serialnet.c

Modified: head/sys/dev/usb/template/usb_template_audio.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_audio.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_audio.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -199,8 +199,8 @@ static const void *audio_raw_iface_0_desc[] = {
 static const struct usb_temp_interface_desc audio_iface_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = audio_raw_iface_0_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 1,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_AUDIO_MIXER,
 };
@@ -257,8 +257,8 @@ static const struct usb_temp_endpoint_desc *audio_ifac
 static const struct usb_temp_interface_desc audio_iface_1_alt_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = NULL,		/* no raw descriptors */
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_AUDIO_PLAYBACK,
 };
@@ -266,8 +266,8 @@ static const struct usb_temp_interface_desc audio_ifac
 static const struct usb_temp_interface_desc audio_iface_1_alt_1 = {
 	.ppEndpoints = audio_iface_1_ep,
 	.ppRawDesc = audio_raw_iface_1_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_AUDIO_PLAYBACK,
 	.isAltInterface = 1,		/* this is an alternate setting */
@@ -315,8 +315,8 @@ static const struct usb_temp_endpoint_desc *audio_ifac
 static const struct usb_temp_interface_desc audio_iface_2_alt_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = NULL,		/* no raw descriptors */
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_AUDIO_RECORD,
 };
@@ -324,8 +324,8 @@ static const struct usb_temp_interface_desc audio_ifac
 static const struct usb_temp_interface_desc audio_iface_2_alt_1 = {
 	.ppEndpoints = audio_iface_2_ep,
 	.ppRawDesc = audio_raw_iface_2_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_AUDIO_RECORD,
 	.isAltInterface = 1,		/* this is an alternate setting */

Modified: head/sys/dev/usb/template/usb_template_kbd.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_kbd.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_kbd.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -130,9 +130,9 @@ static const void *keyboard_iface_0_desc[] = {
 static const struct usb_temp_interface_desc keyboard_iface_0 = {
 	.ppRawDesc = keyboard_iface_0_desc,
 	.ppEndpoints = keyboard_endpoints,
-	.bInterfaceClass = 3,
-	.bInterfaceSubClass = 1,
-	.bInterfaceProtocol = 1,
+	.bInterfaceClass = UICLASS_HID,
+	.bInterfaceSubClass = UISUBCLASS_BOOT,
+	.bInterfaceProtocol = UIPROTO_BOOT_KEYBOARD,
 	.iInterface = INDEX_KEYBOARD,
 };
 

Modified: head/sys/dev/usb/template/usb_template_midi.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_midi.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_midi.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -89,8 +89,8 @@ static const void *midi_descs_0[] = {
 static const struct usb_temp_interface_desc midi_iface_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = midi_descs_0,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 1,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_MIDI_IF,
 };
@@ -171,8 +171,8 @@ static const void *midi_descs_1[] = {
 static const struct usb_temp_interface_desc midi_iface_1 = {
 	.ppRawDesc = midi_descs_1,
 	.ppEndpoints = midi_iface_1_ep,
-	.bInterfaceClass = 0x01,	/* MIDI */
-	.bInterfaceSubClass = 3,	/* MIDI streaming */
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_MIDISTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_MIDI_IF,
 };

Modified: head/sys/dev/usb/template/usb_template_modem.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_modem.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_modem.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -156,17 +156,17 @@ static const void *modem_iface_0_desc[] = {
 static const struct usb_temp_interface_desc modem_iface_0 = {
 	.ppRawDesc = modem_iface_0_desc,
 	.ppEndpoints = modem_iface_0_ep,
-	.bInterfaceClass = 2,
-	.bInterfaceSubClass = 2,
-	.bInterfaceProtocol = 1,
+	.bInterfaceClass = UICLASS_CDC,
+	.bInterfaceSubClass = UISUBCLASS_ABSTRACT_CONTROL_MODEL,
+	.bInterfaceProtocol = UIPROTO_CDC_AT,
 	.iInterface = INDEX_MODEM,
 };
 
 static const struct usb_temp_interface_desc modem_iface_1 = {
 	.ppEndpoints = modem_iface_1_ep,
-	.bInterfaceClass = 10,
-	.bInterfaceSubClass = 0,
-	.bInterfaceProtocol = 0,
+	.bInterfaceClass = UICLASS_CDC_DATA,
+	.bInterfaceSubClass = UISUBCLASS_DATA,
+	.bInterfaceProtocol = UIPROTO_CDC_NONE,
 	.iInterface = INDEX_MODEM,
 };
 

Modified: head/sys/dev/usb/template/usb_template_mouse.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_mouse.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_mouse.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -128,9 +128,9 @@ static const void *mouse_iface_0_desc[] = {
 static const struct usb_temp_interface_desc mouse_iface_0 = {
 	.ppRawDesc = mouse_iface_0_desc,
 	.ppEndpoints = mouse_endpoints,
-	.bInterfaceClass = 3,
-	.bInterfaceSubClass = 1,
-	.bInterfaceProtocol = 2,
+	.bInterfaceClass = UICLASS_HID,
+	.bInterfaceSubClass = UISUBCLASS_BOOT,
+	.bInterfaceProtocol = UIPROTO_MOUSE,
 	.iInterface = INDEX_MOUSE,
 };
 

Modified: head/sys/dev/usb/template/usb_template_phone.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_phone.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_phone.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -156,8 +156,8 @@ static const void *phone_raw_iface_0_desc[] = {
 static const struct usb_temp_interface_desc phone_iface_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = phone_raw_iface_0_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 1,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOCONTROL,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_MIXER,
 };
@@ -213,8 +213,8 @@ static const struct usb_temp_endpoint_desc *phone_ifac
 static const struct usb_temp_interface_desc phone_iface_1_alt_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = NULL,		/* no raw descriptors */
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_PLAYBACK,
 };
@@ -222,8 +222,8 @@ static const struct usb_temp_interface_desc phone_ifac
 static const struct usb_temp_interface_desc phone_iface_1_alt_1 = {
 	.ppEndpoints = phone_iface_1_ep,
 	.ppRawDesc = phone_raw_iface_1_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_PLAYBACK,
 	.isAltInterface = 1,		/* this is an alternate setting */
@@ -270,8 +270,8 @@ static const struct usb_temp_endpoint_desc *phone_ifac
 static const struct usb_temp_interface_desc phone_iface_2_alt_0 = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.ppRawDesc = NULL,		/* no raw descriptors */
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_RECORD,
 };
@@ -279,8 +279,8 @@ static const struct usb_temp_interface_desc phone_ifac
 static const struct usb_temp_interface_desc phone_iface_2_alt_1 = {
 	.ppEndpoints = phone_iface_2_ep,
 	.ppRawDesc = phone_raw_iface_2_desc,
-	.bInterfaceClass = 1,
-	.bInterfaceSubClass = 2,
+	.bInterfaceClass = UICLASS_AUDIO,
+	.bInterfaceSubClass = UISUBCLASS_AUDIOSTREAM,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_RECORD,
 	.isAltInterface = 1,		/* this is an alternate setting */
@@ -321,7 +321,7 @@ static const struct usb_temp_endpoint_desc *phone_ifac
 static const struct usb_temp_interface_desc phone_iface_3 = {
 	.ppEndpoints = phone_iface_3_ep,
 	.ppRawDesc = phone_hid_desc_0,
-	.bInterfaceClass = 3,
+	.bInterfaceClass = UICLASS_HID,
 	.bInterfaceSubClass = 0,
 	.bInterfaceProtocol = 0,
 	.iInterface = INDEX_PHONE_HID,

Modified: head/sys/dev/usb/template/usb_template_serialnet.c
==============================================================================
--- head/sys/dev/usb/template/usb_template_serialnet.c	Sun Oct 15 11:28:41 2017	(r324625)
+++ head/sys/dev/usb/template/usb_template_serialnet.c	Sun Oct 15 11:46:11 2017	(r324626)
@@ -202,7 +202,7 @@ static const struct usb_temp_interface_desc eth_contro
 	.ppRawDesc = eth_control_if_desc,
 	.bInterfaceClass = UICLASS_CDC,
 	.bInterfaceSubClass = UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL,
-	.bInterfaceProtocol = 0,
+	.bInterfaceProtocol = UIPROTO_CDC_NONE,
 	.iInterface = STRING_ETH_CONTROL_INDEX,
 };
 
@@ -215,7 +215,7 @@ static const struct usb_temp_endpoint_desc *eth_data_e
 static const struct usb_temp_interface_desc eth_data_null_interface = {
 	.ppEndpoints = NULL,		/* no endpoints */
 	.bInterfaceClass = UICLASS_CDC_DATA,
-	.bInterfaceSubClass = 0,
+	.bInterfaceSubClass = UISUBCLASS_DATA,
 	.bInterfaceProtocol = 0,
 	.iInterface = STRING_ETH_DATA_INDEX,
 };
@@ -304,16 +304,16 @@ static const void *modem_iface_0_desc[] = {
 static const struct usb_temp_interface_desc modem_iface_0 = {
 	.ppRawDesc = modem_iface_0_desc,
 	.ppEndpoints = modem_iface_0_ep,
-	.bInterfaceClass = 2,
-	.bInterfaceSubClass = 2,
-	.bInterfaceProtocol = 1,
+	.bInterfaceClass = UICLASS_CDC,
+	.bInterfaceSubClass = UISUBCLASS_ABSTRACT_CONTROL_MODEL,
+	.bInterfaceProtocol = UIPROTO_CDC_AT,
 	.iInterface = STRING_MODEM_INDEX,
 };
 
 static const struct usb_temp_interface_desc modem_iface_1 = {
 	.ppEndpoints = modem_iface_1_ep,
-	.bInterfaceClass = 10,
-	.bInterfaceSubClass = 0,
+	.bInterfaceClass = UICLASS_CDC_DATA,
+	.bInterfaceSubClass = UISUBCLASS_DATA,
 	.bInterfaceProtocol = 0,
 	.iInterface = STRING_MODEM_INDEX,
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710151146.v9FBkBNE082383>