All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: hcd.h: construct hub class request conastants from simpler constants
@ 2016-11-18  9:30 Tal Shorer
  2016-11-18 10:01 ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Tal Shorer @ 2016-11-18  9:30 UTC (permalink / raw)
  To: gregkh, linux-usb, linux-kernel; +Cc: Tal Shorer

Currently, each hub class request constant is defined by a line like:

Where the "magic" number for the high byte is one of 0x20, 0xa0, 0x23,
0xa3.
The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
pops up is the difference between USB_RECIP_DEVICE (0x00) and
USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.

This patch eliminates those magic numbers by defining a macro to help
construct these hub class request from simpler constants.
Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 include/linux/usb/hcd.h | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 66fc137..2405853 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -566,21 +566,29 @@ extern void usb_ep0_reinit(struct usb_device *);
 	((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
 
 /* class requests from the USB 2.0 hub spec, table 11-15 */
+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
 /* GetBusState and SetHubDescriptor are optional, omitted */
-#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
-#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
-#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
-#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
-#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
-#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
-#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
+#define ClearHubFeature \
+	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature \
+	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor \
+	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
+#define GetPortStatus \
+	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
+#define SetHubFeature \
+	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
+#define SetPortFeature \
+	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
 
 
 /*-------------------------------------------------------------------------*/
 
 /* class requests from USB 3.1 hub spec, table 10-7 */
-#define SetHubDepth		(0x2000 | HUB_SET_DEPTH)
-#define GetPortErrorCount	(0xa300 | HUB_GET_PORT_ERR_COUNT)
+#define SetHubDepth HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, HUB_SET_DEPTH)
+#define GetPortErrorCount \
+	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_PORT_ERR_COUNT)
 
 /*
  * Generic bandwidth allocation constants/support
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] usb: hcd.h: construct hub class request conastants from simpler constants
  2016-11-18  9:30 [PATCH] usb: hcd.h: construct hub class request conastants from simpler constants Tal Shorer
@ 2016-11-18 10:01 ` Greg KH
  2016-11-18 11:18   ` [PATCH v2] " Tal Shorer
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2016-11-18 10:01 UTC (permalink / raw)
  To: Tal Shorer; +Cc: linux-usb, linux-kernel

On Fri, Nov 18, 2016 at 11:30:18AM +0200, Tal Shorer wrote:
> Currently, each hub class request constant is defined by a line like:
> 
> Where the "magic" number for the high byte is one of 0x20, 0xa0, 0x23,
> 0xa3.

I think your description here is missing something...

> The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
> pops up is the difference between USB_RECIP_DEVICE (0x00) and
> USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.
> 
> This patch eliminates those magic numbers by defining a macro to help
> construct these hub class request from simpler constants.
> Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
> and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).
> 
> Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
> ---
>  include/linux/usb/hcd.h | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index 66fc137..2405853 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -566,21 +566,29 @@ extern void usb_ep0_reinit(struct usb_device *);
>  	((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
>  
>  /* class requests from the USB 2.0 hub spec, table 11-15 */
> +#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
>  /* GetBusState and SetHubDescriptor are optional, omitted */
> -#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
> -#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
> -#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
> -#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
> -#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
> -#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
> -#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
> +#define ClearHubFeature \
> +	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
> +#define ClearPortFeature \
> +	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
> +#define GetHubDescriptor \
> +	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
> +#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
> +#define GetPortStatus \
> +	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
> +#define SetHubFeature \
> +	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
> +#define SetPortFeature \
> +	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)

That's a bit harder to read now, right?  Just put them all on one line
please.

>  /*-------------------------------------------------------------------------*/
>  
>  /* class requests from USB 3.1 hub spec, table 10-7 */
> -#define SetHubDepth		(0x2000 | HUB_SET_DEPTH)
> -#define GetPortErrorCount	(0xa300 | HUB_GET_PORT_ERR_COUNT)
> +#define SetHubDepth HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, HUB_SET_DEPTH)
> +#define GetPortErrorCount \
> +	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_PORT_ERR_COUNT)

Same here.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] usb: hcd.h: construct hub class request conastants from simpler constants
  2016-11-18 10:01 ` Greg KH
@ 2016-11-18 11:18   ` Tal Shorer
  2016-11-18 11:40     ` Greg KH
  2016-11-18 11:41     ` [PATCH v2] usb: hcd.h: construct hub class request conastants " Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Tal Shorer @ 2016-11-18 11:18 UTC (permalink / raw)
  To: gregkh, linux-usb, linux-kernel; +Cc: Tal Shorer

Currently, each hub class request constant is defined by a line like:

The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
pops up is the difference between USB_RECIP_DEVICE (0x00) and
USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.

This patch eliminates those magic numbers by defining a macro to help
construct these hub class request from simpler constants.
Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 include/linux/usb/hcd.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 66fc137..76159fb 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -566,21 +566,22 @@ extern void usb_ep0_reinit(struct usb_device *);
 	((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
 
 /* class requests from the USB 2.0 hub spec, table 11-15 */
+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
 /* GetBusState and SetHubDescriptor are optional, omitted */
-#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
-#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
-#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
-#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
-#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
-#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
-#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
+#define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
+#define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
+#define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
+#define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
 
 
 /*-------------------------------------------------------------------------*/
 
 /* class requests from USB 3.1 hub spec, table 10-7 */
-#define SetHubDepth		(0x2000 | HUB_SET_DEPTH)
-#define GetPortErrorCount	(0xa300 | HUB_GET_PORT_ERR_COUNT)
+#define SetHubDepth HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, HUB_SET_DEPTH)
+#define GetPortErrorCount HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_PORT_ERR_COUNT)
 
 /*
  * Generic bandwidth allocation constants/support
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: hcd.h: construct hub class request conastants from simpler constants
  2016-11-18 11:18   ` [PATCH v2] " Tal Shorer
@ 2016-11-18 11:40     ` Greg KH
  2016-11-18 12:17       ` [PATCH v3] usb: hcd.h: construct hub class request constants " Tal Shorer
  2016-11-18 11:41     ` [PATCH v2] usb: hcd.h: construct hub class request conastants " Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2016-11-18 11:40 UTC (permalink / raw)
  To: Tal Shorer; +Cc: linux-usb, linux-kernel

On Fri, Nov 18, 2016 at 01:18:19PM +0200, Tal Shorer wrote:
> Currently, each hub class request constant is defined by a line like:
> 
> The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.

Again, shouldn't there be something after your ":"?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] usb: hcd.h: construct hub class request conastants from simpler constants
  2016-11-18 11:18   ` [PATCH v2] " Tal Shorer
  2016-11-18 11:40     ` Greg KH
@ 2016-11-18 11:41     ` Greg KH
  1 sibling, 0 replies; 7+ messages in thread
From: Greg KH @ 2016-11-18 11:41 UTC (permalink / raw)
  To: Tal Shorer; +Cc: linux-usb, linux-kernel

On Fri, Nov 18, 2016 at 01:18:19PM +0200, Tal Shorer wrote:
> Currently, each hub class request constant is defined by a line like:
> 
> The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
> The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
> pops up is the difference between USB_RECIP_DEVICE (0x00) and
> USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.
> 
> This patch eliminates those magic numbers by defining a macro to help
> construct these hub class request from simpler constants.
> Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
> and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).
> 
> Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
> ---
>  include/linux/usb/hcd.h | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index 66fc137..76159fb 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -566,21 +566,22 @@ extern void usb_ep0_reinit(struct usb_device *);
>  	((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
>  
>  /* class requests from the USB 2.0 hub spec, table 11-15 */
> +#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
>  /* GetBusState and SetHubDescriptor are optional, omitted */
> -#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
> -#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
> -#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
> -#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
> -#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
> -#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
> -#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
> +#define ClearHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)

No use of tab?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3] usb: hcd.h: construct hub class request constants from simpler constants
  2016-11-18 11:40     ` Greg KH
@ 2016-11-18 12:17       ` Tal Shorer
  2016-12-03 13:52         ` Tal Shorer
  0 siblings, 1 reply; 7+ messages in thread
From: Tal Shorer @ 2016-11-18 12:17 UTC (permalink / raw)
  To: gregkh, linux-usb, linux-kernel; +Cc: Tal Shorer

Currently, each hub class request constant is defined by a line like:
#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)

The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
pops up is the difference between USB_RECIP_DEVICE (0x00) and
USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.

This patch eliminates those magic numbers by defining a macro to help
construct these hub class request from simpler constants.
Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).

Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
---
 include/linux/usb/hcd.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 66fc137..40edf6a 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -566,21 +566,22 @@ extern void usb_ep0_reinit(struct usb_device *);
 	((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
 
 /* class requests from the USB 2.0 hub spec, table 11-15 */
+#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
 /* GetBusState and SetHubDescriptor are optional, omitted */
-#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
-#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
-#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
-#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
-#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
-#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
-#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
+#define ClearHubFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature	HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus		HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
+#define GetPortStatus		HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
+#define SetHubFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
+#define SetPortFeature		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
 
 
 /*-------------------------------------------------------------------------*/
 
 /* class requests from USB 3.1 hub spec, table 10-7 */
-#define SetHubDepth		(0x2000 | HUB_SET_DEPTH)
-#define GetPortErrorCount	(0xa300 | HUB_GET_PORT_ERR_COUNT)
+#define SetHubDepth		HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, HUB_SET_DEPTH)
+#define GetPortErrorCount	HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_PORT_ERR_COUNT)
 
 /*
  * Generic bandwidth allocation constants/support
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3] usb: hcd.h: construct hub class request constants from simpler constants
  2016-11-18 12:17       ` [PATCH v3] usb: hcd.h: construct hub class request constants " Tal Shorer
@ 2016-12-03 13:52         ` Tal Shorer
  0 siblings, 0 replies; 7+ messages in thread
From: Tal Shorer @ 2016-12-03 13:52 UTC (permalink / raw)
  To: <gregkh@linuxfoundation.org>,
	USB list, <linux-kernel@vger.kernel.org>
  Cc: Tal Shorer

On Fri, Nov 18, 2016 at 2:17 PM, Tal Shorer <tal.shorer@gmail.com> wrote:
> Currently, each hub class request constant is defined by a line like:
> #define ClearHubFeature         (0x2000 | USB_REQ_CLEAR_FEATURE)
>
> The "magic" number for the high byte is one of 0x20, 0xa0, 0x23, 0xa3.
> The 0x80 bit that changes inditace USB_DIR_IN, and the 0x03 that
> pops up is the difference between USB_RECIP_DEVICE (0x00) and
> USB_RECIP_OTHER (0x03). The constant 0x20 bit is USB_TYPE_CLASS.
>
> This patch eliminates those magic numbers by defining a macro to help
> construct these hub class request from simpler constants.
> Note that USB_RT_HUB is defined as (USB_TYPE_CLASS | USB_RECIP_DEVICE)
> and that USB_RT_PORT is defined as (USB_TYPE_CLASS | USB_RECIP_OTHER).
>
> Signed-off-by: Tal Shorer <tal.shorer@gmail.com>
> ---
>  include/linux/usb/hcd.h | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index 66fc137..40edf6a 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -566,21 +566,22 @@ extern void usb_ep0_reinit(struct usb_device *);
>         ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
>
>  /* class requests from the USB 2.0 hub spec, table 11-15 */
> +#define HUB_CLASS_REQ(dir, type, request) ((((dir) | (type)) << 8) | (request))
>  /* GetBusState and SetHubDescriptor are optional, omitted */
> -#define ClearHubFeature                (0x2000 | USB_REQ_CLEAR_FEATURE)
> -#define ClearPortFeature       (0x2300 | USB_REQ_CLEAR_FEATURE)
> -#define GetHubDescriptor       (0xa000 | USB_REQ_GET_DESCRIPTOR)
> -#define GetHubStatus           (0xa000 | USB_REQ_GET_STATUS)
> -#define GetPortStatus          (0xa300 | USB_REQ_GET_STATUS)
> -#define SetHubFeature          (0x2000 | USB_REQ_SET_FEATURE)
> -#define SetPortFeature         (0x2300 | USB_REQ_SET_FEATURE)
> +#define ClearHubFeature                HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_CLEAR_FEATURE)
> +#define ClearPortFeature       HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_CLEAR_FEATURE)
> +#define GetHubDescriptor       HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_DESCRIPTOR)
> +#define GetHubStatus           HUB_CLASS_REQ(USB_DIR_IN, USB_RT_HUB, USB_REQ_GET_STATUS)
> +#define GetPortStatus          HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
> +#define SetHubFeature          HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
> +#define SetPortFeature         HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
>
>
>  /*-------------------------------------------------------------------------*/
>
>  /* class requests from USB 3.1 hub spec, table 10-7 */
> -#define SetHubDepth            (0x2000 | HUB_SET_DEPTH)
> -#define GetPortErrorCount      (0xa300 | HUB_GET_PORT_ERR_COUNT)
> +#define SetHubDepth            HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, HUB_SET_DEPTH)
> +#define GetPortErrorCount      HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_PORT_ERR_COUNT)
>
>  /*
>   * Generic bandwidth allocation constants/support
> --
> 2.5.0
>
ping?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-12-03 13:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-18  9:30 [PATCH] usb: hcd.h: construct hub class request conastants from simpler constants Tal Shorer
2016-11-18 10:01 ` Greg KH
2016-11-18 11:18   ` [PATCH v2] " Tal Shorer
2016-11-18 11:40     ` Greg KH
2016-11-18 12:17       ` [PATCH v3] usb: hcd.h: construct hub class request constants " Tal Shorer
2016-12-03 13:52         ` Tal Shorer
2016-11-18 11:41     ` [PATCH v2] usb: hcd.h: construct hub class request conastants " Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.