From: Greg KH <gregkh@linuxfoundation.org>
To: Tal Shorer <tal.shorer@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] usb: hcd.h: construct hub class request conastants from simpler constants
Date: Fri, 18 Nov 2016 12:41:04 +0100 [thread overview]
Message-ID: <20161118114104.GB12190@kroah.com> (raw)
In-Reply-To: <1479467899-18330-1-git-send-email-tal.shorer@gmail.com>
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?
prev parent reply other threads:[~2016-11-18 11:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161118114104.GB12190@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=tal.shorer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).