From: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
To: Tatyana Brokhman <tlinder-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
Cc: gregkh-l3A5Bk7waGM@public.gmane.org,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
balbi-l0cyMroinI0@public.gmane.org,
ablay-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Subject: [PATCH 1/5] usb/gadget: cleanup of "Add SuperSpeed support to the Gadget Framework"
Date: Tue, 12 Apr 2011 21:34:52 +0200 [thread overview]
Message-ID: <1302636896-12717-2-git-send-email-bigeasy@linutronix.de> (raw)
In-Reply-To: <1302636896-12717-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
style, some endianess fixups
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
---
drivers/usb/gadget/Kconfig | 1 -
drivers/usb/gadget/composite.c | 62 +++++++++++++++++----------------------
include/linux/usb/gadget.h | 2 +-
3 files changed, 28 insertions(+), 37 deletions(-)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index b4130bc..21429c7 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -609,7 +609,6 @@ config USB_GADGET_SUPERSPEED
boolean "Gadget operating in Super Speed"
depends on USB_GADGET
depends on USB_GADGET_DUALSPEED
- default n
help
Enabling this feature enables Super Speed support in the Gadget
driver. It means that gadget drivers should provide extra (SuperSpeed)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index d5fe1c2..a94b7b7 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -76,10 +76,7 @@ static char composite_manufacturer[50];
/* Default endpoint companion descriptor */
static struct usb_ss_ep_comp_descriptor default_ep_comp_desc = {
.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
- .bLength = 0x06,
- .bMaxBurst = 0, /* the default is we don't support bursting */
- .bmAttributes = 0, /* 2^0 streams supported */
- .wBytesPerInterval = 0,
+ .bLength = sizeof(struct usb_ss_ep_comp_descriptor),
};
/**
@@ -96,13 +93,13 @@ static struct usb_ss_ep_comp_descriptor default_ep_comp_desc = {
*/
static void create_ss_descriptors(struct usb_function *f)
{
- unsigned bytes; /* number of bytes to allocate */
- unsigned n_desc; /* number of descriptors */
- void *mem; /* allocated memory to copy to */
- struct usb_descriptor_header **tmp;
- struct usb_endpoint_descriptor *ep_desc ;
- struct usb_ss_ep_comp_descriptor *ep_comp_desc;
- struct usb_descriptor_header **src = f->hs_descriptors;
+ struct usb_ss_ep_comp_descriptor *ep_comp_desc;
+ struct usb_endpoint_descriptor *ep_desc;
+ struct usb_descriptor_header **src = f->hs_descriptors;
+ struct usb_descriptor_header **tmp;
+ unsigned n_desc;
+ unsigned bytes;
+ void *mem;
if (!f->hs_descriptors)
return;
@@ -163,7 +160,7 @@ static void create_ss_descriptors(struct usb_function *f)
*tmp = mem;
tmp++;
/* Update wBytesPerInterval for periodic endpoints */
- ep_comp_desc = (struct usb_ss_ep_comp_descriptor *)mem;
+ ep_comp_desc = mem;
switch (ep_desc->bmAttributes &
USB_ENDPOINT_XFERTYPE_MASK) {
case USB_ENDPOINT_XFER_INT:
@@ -609,47 +606,44 @@ static int count_configs(struct usb_composite_dev *cdev, unsigned type)
*/
static int bos(struct usb_composite_dev *cdev)
{
- struct usb_bos_descriptor *bos = cdev->req->buf;
- struct usb_ext_cap_descriptor *usb_ext = NULL;
- struct usb_ss_cap_descriptor *ss_cap = NULL;
-
+ struct usb_ext_cap_descriptor *usb_ext;
+ struct usb_ss_cap_descriptor *ss_cap;
struct usb_dcd_config_params dcd_config_params;
+ struct usb_bos_descriptor *bos = cdev->req->buf;
bos->bLength = USB_DT_BOS_SIZE;
bos->bDescriptorType = USB_DT_BOS;
- bos->wTotalLength = USB_DT_BOS_SIZE;
+ bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE);
bos->bNumDeviceCaps = 0;
/*
* A SuperSpeed device shall include the USB2.0 extension descriptor
* and shall support LPM when operating in USB2.0 HS mode.
*/
- usb_ext = (struct usb_ext_cap_descriptor *)
- (cdev->req->buf+bos->wTotalLength);
+ usb_ext = cdev->req->buf + bos->wTotalLength;
bos->bNumDeviceCaps++;
- bos->wTotalLength += USB_DT_USB_EXT_CAP_SIZE;
+ le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE);
usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
- usb_ext->bmAttributes = USB_LPM_SUPPORT;
+ usb_ext->bmAttributes = cpu_to_le16(USB_LPM_SUPPORT);
/*
* The Superspeed USB Capability descriptor shall be implemented by all
* SuperSpeed devices.
*/
- ss_cap = (struct usb_ss_cap_descriptor *)
- (cdev->req->buf+bos->wTotalLength);
+ ss_cap = cdev->req->buf + bos->wTotalLength;
bos->bNumDeviceCaps++;
- bos->wTotalLength += USB_DT_USB_SS_CAP_SIZE;
+ le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE);
ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE;
ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE;
ss_cap->bmAttributes = 0; /* LTM is not supported yet */
- ss_cap->wSpeedSupported = USB_LOW_SPEED_OPERATION |
+ ss_cap->wSpeedSupported = cpu_to_le16(USB_LOW_SPEED_OPERATION |
USB_FULL_SPEED_OPERATION |
USB_HIGH_SPEED_OPERATION |
- USB_5GBPS_OPERATION;
+ USB_5GBPS_OPERATION);
ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION;
/* Get Controller configuration */
@@ -657,12 +651,13 @@ static int bos(struct usb_composite_dev *cdev)
cdev->gadget->ops->get_config_params(&dcd_config_params);
else {
dcd_config_params.bU1devExitLat = USB_DEFULT_U1_DEV_EXIT_LAT;
- dcd_config_params.bU2DevExitLat = USB_DEFULT_U2_DEV_EXIT_LAT;
+ dcd_config_params.bU2DevExitLat =
+ cpu_to_le16(USB_DEFULT_U2_DEV_EXIT_LAT);
}
ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
- return bos->wTotalLength;
+ return le16_to_cpu(bos->wTotalLength);
}
static void device_qual(struct usb_composite_dev *cdev)
@@ -1285,7 +1280,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
status = f->get_status ? f->get_status(f) : 0;
if (status < 0)
break;
- *((u16 *)req->buf) = status & 0x0000ffff;
+ *((u16 *)req->buf) = le16_to_cpu(status & 0x0000ffff);
break;
/*
* Function drivers should handle SetFeature/ClearFeature
@@ -1305,12 +1300,9 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
f = cdev->config->interface[intf];
if (!f)
break;
- value = f->func_suspend ?
- f->func_suspend(f,
- (u8)((w_index &
- USB_INTR_FUNC_SUSPEND_OPT_MASK)
- >> 8)) :
- 0;
+ value = 0;
+ if (f->func_suspend)
+ value = f->func_suspend(f, w_index >> 8);
if (value < 0) {
ERROR(cdev, "func_suspend() returned "
"error %d\n", value);
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 92c2d62..9d496a4 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -428,7 +428,7 @@ static inline void usb_ep_fifo_flush(struct usb_ep *ep)
struct usb_dcd_config_params {
__u8 bU1devExitLat; /* U1 Device exit Latency */
#define USB_DEFULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */
- __u16 bU2DevExitLat; /* U2 Device exit Latency */
+ __le16 bU2DevExitLat; /* U2 Device exit Latency */
#define USB_DEFULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */
};
--
1.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-04-12 19:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 8:04 [PATCH 5/5 v5] usb:gadget: Add SuperSpeed support to the Gadget Framework Tatyana Brokhman
[not found] ` <1300867498-20997-1-git-send-email-tlinder-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-03-25 13:41 ` Felipe Balbi
2011-03-28 8:45 ` Tanya Brokhman
2011-03-28 8:54 ` Felipe Balbi
2011-03-28 9:15 ` Tanya Brokhman
2011-04-11 17:59 ` Sebastian Andrzej Siewior
2011-04-12 19:34 ` Sebastian Andrzej Siewior
[not found] ` <1302636896-12717-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2011-04-12 19:34 ` Sebastian Andrzej Siewior [this message]
2011-04-13 8:17 ` [PATCH 1/5] usb/gadget: cleanup of "Add SuperSpeed support to the Gadget Framework" Felipe Balbi
2011-04-12 19:34 ` [PATCH 5/5] usb/gadget: don't auto-create SS descriptors if HS are avilable Sebastian Andrzej Siewior
2011-04-12 19:34 ` [PATCH 2/5] usb/gadget: rename bos to get_bos_descr in composite Sebastian Andrzej Siewior
2011-04-12 19:34 ` [PATCH 3/5] usb/gadget: rename create_ss_descriptors() to usb_create_ss_descriptors() Sebastian Andrzej Siewior
2011-04-12 19:34 ` [PATCH 4/5] usb/gadget: don't deploy SS descriptors if SS is not enabled Sebastian Andrzej Siewior
2011-04-13 10:46 ` Sergei Shtylyov
[not found] ` <4DA57F0F.1090609-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2011-04-13 10:56 ` Sebastian Andrzej Siewior
2011-04-13 10:59 ` Michal Nazarewicz
2011-04-13 11:12 ` [PATCH 5/5 v5] usb:gadget: Add SuperSpeed support to the Gadget Framework Tanya Brokhman
2011-04-14 7:36 ` Tanya Brokhman
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=1302636896-12717-2-git-send-email-bigeasy@linutronix.de \
--to=bigeasy-hfztesqfncyowbw4kg4ksq@public.gmane.org \
--cc=ablay-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=balbi-l0cyMroinI0@public.gmane.org \
--cc=gregkh-l3A5Bk7waGM@public.gmane.org \
--cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=tlinder-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
/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).