From: George Cherian <george.cherian@ti.com>
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org,
linux-omap@vger.kernel.org, linux-usb@vger.kernel.org
Cc: peter.chen@freescale.com, sojka@merica.cz,
mathias.nyman@intel.com, balbi@ti.com,
gregkh@linuxfoundation.org, tony@atomide.com,
bcousson@baylibre.com, kgene.kim@samsung.com,
ben-linux@fluff.org, linux@arm.linux.org.uk,
galak@codeaurora.org, ijc+devicetree@hellion.org.uk,
mark.rutland@arm.com, pawel.moll@arm.com, robh+dt@kernel.org,
George Cherian <george.cherian@ti.com>
Subject: [PATCH 11/19] usb: dwc3: Add seperate dwc3_gadget object to support gadget release
Date: Tue, 25 Nov 2014 18:41:47 +0530 [thread overview]
Message-ID: <1416921115-10467-12-git-send-email-george.cherian@ti.com> (raw)
In-Reply-To: <1416921115-10467-1-git-send-email-george.cherian@ti.com>
With the current implementation it's impossible to release the gadget.
Add a separate dwc3_gadget object to dwc3 structure so that the same
can be freed during the gadget release.
This is in prepration to adapt dwc3 gadget driver to drd library.
DRD library uses usb_del/add_gadget_udc while switching roles between
HOST and DEVICE modes. If the usb_gadget is not released during usb_del_gadget_udc,
the subsequent usb_add_gadget_udc would try to initialize an already initialized
kobject. To avoid this make sure we have an easily freeable object.
Signed-off-by: George Cherian <george.cherian@ti.com>
---
drivers/usb/dwc3/core.h | 7 ++-
drivers/usb/dwc3/ep0.c | 35 ++++++++------
drivers/usb/dwc3/gadget.c | 113 ++++++++++++++++++++++++++++++----------------
drivers/usb/dwc3/gadget.h | 1 +
4 files changed, 101 insertions(+), 55 deletions(-)
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 7c5ae37..7fbe736 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -626,6 +626,11 @@ struct dwc3_scratchpad_array {
__le64 dma_adr[DWC3_MAX_HIBER_SCRATCHBUFS];
};
+struct dwc3_gadget {
+ struct usb_gadget gadget;
+ struct dwc3 *dwc;
+};
+
/**
* struct dwc3 - representation of our controller
* @ctrl_req: usb control request which is used for ep0
@@ -736,7 +741,7 @@ struct dwc3 {
struct dwc3_event_buffer **ev_buffs;
struct dwc3_ep *eps[DWC3_ENDPOINTS_NUM];
- struct usb_gadget gadget;
+ struct dwc3_gadget *dwc_gadget;
struct usb_gadget_driver *gadget_driver;
struct usb_phy *usb2_phy;
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index baeedbd..e7409f1 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -109,6 +109,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
struct dwc3_request *req)
{
struct dwc3 *dwc = dep->dwc;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
req->request.actual = 0;
req->request.status = -EINPROGRESS;
@@ -152,7 +153,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep,
direction = !dwc->ep0_expect_in;
dwc->delayed_status = false;
- usb_gadget_set_state(&dwc->gadget, USB_STATE_CONFIGURED);
+ usb_gadget_set_state(&dwc_gadget->gadget, USB_STATE_CONFIGURED);
if (dwc->ep0state == EP0_STATUS_PHASE)
__dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
@@ -391,6 +392,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
struct usb_ctrlrequest *ctrl, int set)
{
struct dwc3_ep *dep;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
u32 recip;
u32 wValue;
u32 wIndex;
@@ -401,7 +403,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
wValue = le16_to_cpu(ctrl->wValue);
wIndex = le16_to_cpu(ctrl->wIndex);
recip = ctrl->bRequestType & USB_RECIP_MASK;
- state = dwc->gadget.state;
+ state = dwc_gadget->gadget.state;
switch (recip) {
case USB_RECIP_DEVICE:
@@ -499,7 +501,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
{
- enum usb_device_state state = dwc->gadget.state;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+ enum usb_device_state state = dwc_gadget->gadget.state;
u32 addr;
u32 reg;
@@ -521,26 +524,28 @@ static int dwc3_ep0_set_address(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
dwc3_writel(dwc->regs, DWC3_DCFG, reg);
if (addr)
- usb_gadget_set_state(&dwc->gadget, USB_STATE_ADDRESS);
+ usb_gadget_set_state(&dwc_gadget->gadget, USB_STATE_ADDRESS);
else
- usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT);
+ usb_gadget_set_state(&dwc_gadget->gadget, USB_STATE_DEFAULT);
return 0;
}
static int dwc3_ep0_delegate_req(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
int ret;
spin_unlock(&dwc->lock);
- ret = dwc->gadget_driver->setup(&dwc->gadget, ctrl);
+ ret = dwc->gadget_driver->setup(&dwc_gadget->gadget, ctrl);
spin_lock(&dwc->lock);
return ret;
}
static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
{
- enum usb_device_state state = dwc->gadget.state;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+ enum usb_device_state state = dwc_gadget->gadget.state;
u32 cfg;
int ret;
u32 reg;
@@ -564,8 +569,8 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
* to change the state on the next usb_ep_queue()
*/
if (ret == 0)
- usb_gadget_set_state(&dwc->gadget,
- USB_STATE_CONFIGURED);
+ usb_gadget_set_state(&dwc_gadget->gadget,
+ USB_STATE_CONFIGURED);
/*
* Enable transition to U1/U2 state when
@@ -583,8 +588,8 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
case USB_STATE_CONFIGURED:
ret = dwc3_ep0_delegate_req(dwc, ctrl);
if (!cfg && !ret)
- usb_gadget_set_state(&dwc->gadget,
- USB_STATE_ADDRESS);
+ usb_gadget_set_state(&dwc_gadget->gadget,
+ USB_STATE_ADDRESS);
break;
default:
ret = -EINVAL;
@@ -639,7 +644,8 @@ static void dwc3_ep0_set_sel_cmpl(struct usb_ep *ep, struct usb_request *req)
static int dwc3_ep0_set_sel(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
{
struct dwc3_ep *dep;
- enum usb_device_state state = dwc->gadget.state;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+ enum usb_device_state state = dwc_gadget->gadget.state;
u16 wLength;
u16 wValue;
@@ -918,6 +924,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
struct dwc3_ep *dep, struct dwc3_request *req)
{
int ret;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
req->direction = !!dep->number;
@@ -930,7 +937,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
u32 transfer_size;
u32 maxpacket;
- ret = usb_gadget_map_request(&dwc->gadget, &req->request,
+ ret = usb_gadget_map_request(&dwc_gadget->gadget, &req->request,
dep->number);
if (ret) {
dev_dbg(dwc->dev, "failed to map request\n");
@@ -953,7 +960,7 @@ static void __dwc3_ep0_do_control_data(struct dwc3 *dwc,
dwc->ep0_bounce_addr, transfer_size,
DWC3_TRBCTL_CONTROL_DATA);
} else {
- ret = usb_gadget_map_request(&dwc->gadget, &req->request,
+ ret = usb_gadget_map_request(&dwc_gadget->gadget, &req->request,
dep->number);
if (ret) {
dev_dbg(dwc->dev, "failed to map request\n");
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index f03b136..2c54d45 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -234,6 +234,7 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
int status)
{
struct dwc3 *dwc = dep->dwc;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
int i;
if (req->queued) {
@@ -261,8 +262,8 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
if (dwc->ep0_bounced && dep->number == 0)
dwc->ep0_bounced = false;
else
- usb_gadget_unmap_request(&dwc->gadget, &req->request,
- req->direction);
+ usb_gadget_unmap_request(&dwc_gadget->gadget, &req->request,
+ req->direction);
dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n",
req, dep->name, req->request.actual,
@@ -407,6 +408,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
bool ignore, bool restore)
{
struct dwc3_gadget_ep_cmd_params params;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
memset(¶ms, 0x00, sizeof(params));
@@ -414,7 +416,7 @@ static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep,
| DWC3_DEPCFG_MAX_PACKET_SIZE(usb_endpoint_maxp(desc));
/* Burst size is only needed in SuperSpeed mode */
- if (dwc->gadget.speed == USB_SPEED_SUPER) {
+ if (dwc_gadget->gadget.speed == USB_SPEED_SUPER) {
u32 burst = dep->endpoint.maxburst - 1;
params.param0 |= DWC3_DEPCFG_BURST_SIZE(burst);
@@ -928,6 +930,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param,
struct dwc3_gadget_ep_cmd_params params;
struct dwc3_request *req;
struct dwc3 *dwc = dep->dwc;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
int ret;
u32 cmd;
@@ -980,8 +983,8 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param,
* here and stop, unmap, free and del each of the linked
* requests instead of what we do now.
*/
- usb_gadget_unmap_request(&dwc->gadget, &req->request,
- req->direction);
+ usb_gadget_unmap_request(&dwc_gadget->gadget, &req->request,
+ req->direction);
list_del(&req->list);
return ret;
}
@@ -1029,6 +1032,7 @@ static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
{
struct dwc3 *dwc = dep->dwc;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
int ret;
req->request.actual = 0;
@@ -1048,7 +1052,7 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
* This will also avoid Host cancelling URBs due to too
* many NAKs.
*/
- ret = usb_gadget_map_request(&dwc->gadget, &req->request,
+ ret = usb_gadget_map_request(&dwc_gadget->gadget, &req->request,
dep->direction);
if (ret)
return ret;
@@ -1320,7 +1324,8 @@ static const struct usb_ep_ops dwc3_gadget_ep_ops = {
static int dwc3_gadget_get_frame(struct usb_gadget *g)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
u32 reg;
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
@@ -1329,7 +1334,8 @@ static int dwc3_gadget_get_frame(struct usb_gadget *g)
static int dwc3_gadget_wakeup(struct usb_gadget *g)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
unsigned long timeout;
unsigned long flags;
@@ -1410,7 +1416,8 @@ out:
static int dwc3_gadget_set_selfpowered(struct usb_gadget *g,
int is_selfpowered)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
unsigned long flags;
spin_lock_irqsave(&dwc->lock, flags);
@@ -1476,7 +1483,8 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on, int suspend)
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
unsigned long flags;
int ret;
@@ -1519,7 +1527,8 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc);
static int dwc3_gadget_start(struct usb_gadget *g,
struct usb_gadget_driver *driver)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
struct dwc3_ep *dep;
unsigned long flags;
int ret = 0;
@@ -1539,7 +1548,7 @@ static int dwc3_gadget_start(struct usb_gadget *g,
if (dwc->gadget_driver) {
dev_err(dwc->dev, "%s is already bound to %s\n",
- dwc->gadget.name,
+ dwc_gadget->gadget.name,
dwc->gadget_driver->driver.name);
ret = -EBUSY;
goto err1;
@@ -1632,7 +1641,8 @@ err0:
static int dwc3_gadget_stop(struct usb_gadget *g)
{
- struct dwc3 *dwc = gadget_to_dwc(g);
+ struct dwc3_gadget *dwc_gadget = gadget_to_dwc_gadget(g);
+ struct dwc3 *dwc = dwc_gadget->dwc;
unsigned long flags;
int irq;
@@ -1667,6 +1677,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
u8 num, u32 direction)
{
struct dwc3_ep *dep;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
u8 i;
for (i = 0; i < num; i++) {
@@ -1693,7 +1704,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
dep->endpoint.maxburst = 1;
dep->endpoint.ops = &dwc3_gadget_ep0_ops;
if (!epnum)
- dwc->gadget.ep0 = &dep->endpoint;
+ dwc_gadget->gadget.ep0 = &dep->endpoint;
} else {
int ret;
@@ -1701,7 +1712,7 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
dep->endpoint.max_streams = 15;
dep->endpoint.ops = &dwc3_gadget_ep_ops;
list_add_tail(&dep->endpoint.ep_list,
- &dwc->gadget.ep_list);
+ &dwc_gadget->gadget.ep_list);
ret = dwc3_alloc_trb_pool(dep);
if (ret)
@@ -1718,8 +1729,9 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc,
static int dwc3_gadget_init_endpoints(struct dwc3 *dwc)
{
int ret;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
- INIT_LIST_HEAD(&dwc->gadget.ep_list);
+ INIT_LIST_HEAD(&dwc_gadget->gadget.ep_list);
ret = dwc3_gadget_init_hw_endpoints(dwc, dwc->num_out_eps, 0);
if (ret < 0) {
@@ -2020,38 +2032,46 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
static void dwc3_disconnect_gadget(struct dwc3 *dwc)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+
if (dwc->gadget_driver && dwc->gadget_driver->disconnect) {
spin_unlock(&dwc->lock);
- dwc->gadget_driver->disconnect(&dwc->gadget);
+ dwc->gadget_driver->disconnect(&dwc_gadget->gadget);
spin_lock(&dwc->lock);
}
}
static void dwc3_suspend_gadget(struct dwc3 *dwc)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+
if (dwc->gadget_driver && dwc->gadget_driver->suspend) {
spin_unlock(&dwc->lock);
- dwc->gadget_driver->suspend(&dwc->gadget);
+ dwc->gadget_driver->suspend(&dwc_gadget->gadget);
spin_lock(&dwc->lock);
}
}
static void dwc3_resume_gadget(struct dwc3 *dwc)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+
if (dwc->gadget_driver && dwc->gadget_driver->resume) {
spin_unlock(&dwc->lock);
- dwc->gadget_driver->resume(&dwc->gadget);
+ dwc->gadget_driver->resume(&dwc_gadget->gadget);
}
}
static void dwc3_reset_gadget(struct dwc3 *dwc)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+
if (!dwc->gadget_driver)
return;
- if (dwc->gadget.speed != USB_SPEED_UNKNOWN) {
+ if (dwc_gadget->gadget.speed != USB_SPEED_UNKNOWN) {
spin_unlock(&dwc->lock);
- usb_gadget_udc_reset(&dwc->gadget, dwc->gadget_driver);
+ usb_gadget_udc_reset(&dwc_gadget->gadget, dwc->gadget_driver);
spin_lock(&dwc->lock);
}
}
@@ -2145,6 +2165,7 @@ static void dwc3_clear_stall_all_ep(struct dwc3 *dwc)
static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
{
int reg;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
reg &= ~DWC3_DCTL_INITU1ENA;
@@ -2156,9 +2177,9 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
dwc3_disconnect_gadget(dwc);
dwc->start_config_issued = false;
- dwc->gadget.speed = USB_SPEED_UNKNOWN;
+ dwc_gadget->gadget.speed = USB_SPEED_UNKNOWN;
dwc->setup_packet_pending = false;
- usb_gadget_set_state(&dwc->gadget, USB_STATE_NOTATTACHED);
+ usb_gadget_set_state(&dwc_gadget->gadget, USB_STATE_NOTATTACHED);
}
static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
@@ -2241,6 +2262,7 @@ static void dwc3_update_ram_clk_sel(struct dwc3 *dwc, u32 speed)
static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
{
struct dwc3_ep *dep;
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
int ret;
u32 reg;
u8 speed;
@@ -2270,24 +2292,24 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
dwc3_gadget_reset_interrupt(dwc);
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
- dwc->gadget.ep0->maxpacket = 512;
- dwc->gadget.speed = USB_SPEED_SUPER;
+ dwc_gadget->gadget.ep0->maxpacket = 512;
+ dwc_gadget->gadget.speed = USB_SPEED_SUPER;
break;
case DWC3_DCFG_HIGHSPEED:
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
- dwc->gadget.ep0->maxpacket = 64;
- dwc->gadget.speed = USB_SPEED_HIGH;
+ dwc_gadget->gadget.ep0->maxpacket = 64;
+ dwc_gadget->gadget.speed = USB_SPEED_HIGH;
break;
case DWC3_DCFG_FULLSPEED2:
case DWC3_DCFG_FULLSPEED1:
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(64);
- dwc->gadget.ep0->maxpacket = 64;
- dwc->gadget.speed = USB_SPEED_FULL;
+ dwc_gadget->gadget.ep0->maxpacket = 64;
+ dwc_gadget->gadget.speed = USB_SPEED_FULL;
break;
case DWC3_DCFG_LOWSPEED:
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(8);
- dwc->gadget.ep0->maxpacket = 8;
- dwc->gadget.speed = USB_SPEED_LOW;
+ dwc_gadget->gadget.ep0->maxpacket = 8;
+ dwc_gadget->gadget.speed = USB_SPEED_LOW;
break;
}
@@ -2351,12 +2373,13 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc)
{
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
/*
* TODO take core out of low power mode when that's
* implemented.
*/
- dwc->gadget_driver->resume(&dwc->gadget);
+ dwc->gadget_driver->resume(&dwc_gadget->gadget);
}
static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
@@ -2667,6 +2690,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc)
int dwc3_gadget_init(struct dwc3 *dwc)
{
int ret;
+ struct dwc3_gadget *dwc_gadget;
dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
&dwc->ctrl_req_addr, GFP_KERNEL);
@@ -2699,17 +2723,24 @@ int dwc3_gadget_init(struct dwc3 *dwc)
goto err3;
}
- dwc->gadget.ops = &dwc3_gadget_ops;
- dwc->gadget.max_speed = USB_SPEED_SUPER;
- dwc->gadget.speed = USB_SPEED_UNKNOWN;
- dwc->gadget.sg_supported = true;
- dwc->gadget.name = "dwc3-gadget";
+ dwc_gadget = kzalloc(sizeof(*dwc_gadget), GFP_KERNEL);
+ if (!dwc_gadget) {
+ ret = -ENOMEM;
+ goto err3;
+ }
+
+ dwc_gadget->gadget.ops = &dwc3_gadget_ops;
+ dwc_gadget->gadget.max_speed = USB_SPEED_SUPER;
+ dwc_gadget->gadget.speed = USB_SPEED_UNKNOWN;
+ dwc_gadget->gadget.sg_supported = true;
+ dwc_gadget->gadget.name = "dwc3-gadget";
+ dwc_gadget->dwc = dwc;
/*
* Per databook, DWC3 needs buffer size to be aligned to MaxPacketSize
* on ep out.
*/
- dwc->gadget.quirk_ep_out_aligned_size = true;
+ dwc_gadget->gadget.quirk_ep_out_aligned_size = true;
/*
* REVISIT: Here we should clear all pending IRQs to be
@@ -2720,7 +2751,7 @@ int dwc3_gadget_init(struct dwc3 *dwc)
if (ret)
goto err4;
- ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget);
+ ret = usb_add_gadget_udc(dwc->dev, &dwc_gadget->gadget);
if (ret) {
dev_err(dwc->dev, "failed to register udc\n");
goto err4;
@@ -2752,7 +2783,9 @@ err0:
void dwc3_gadget_exit(struct dwc3 *dwc)
{
- usb_del_gadget_udc(&dwc->gadget);
+ struct dwc3_gadget *dwc_gadget = dwc->dwc_gadget;
+
+ usb_del_gadget_udc(&dwc_gadget->gadget);
dwc3_gadget_free_endpoints(dwc);
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 18ae3ea..b6c3e40 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -26,6 +26,7 @@
struct dwc3;
#define to_dwc3_ep(ep) (container_of(ep, struct dwc3_ep, endpoint))
#define gadget_to_dwc(g) (container_of(g, struct dwc3, gadget))
+#define gadget_to_dwc_gadget(g) (container_of(g, struct dwc3_gadget, gadget))
/* DEPCFG parameter 1 */
#define DWC3_DEPCFG_INT_NUM(n) ((n) << 0)
--
1.8.3.1
next prev parent reply other threads:[~2014-11-25 13:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 13:11 [PATCH 00/19] Add Support for USB DRD in AM437x George Cherian
2014-11-25 13:11 ` [PATCH 01/19] usb: common: drd-lib: Add DRD lib for USB George Cherian
2014-11-26 5:14 ` Peter Chen
2014-11-25 13:11 ` [PATCH 02/19] usb: host xhci: fix up deallocation code George Cherian
2014-11-25 13:11 ` [PATCH 03/19] usb: host: xhci-plat: Add support to pass XHCI_DRD_SUPPORT quirk George Cherian
2014-11-25 13:11 ` [PATCH 04/19] usb: host xhci: Add XHCI_NEEDS_LHC_RESET quirk George Cherian
2014-11-25 13:11 ` [PATCH 05/19] usb: host: xhci-plat: Add support to pass " George Cherian
2014-11-25 13:11 ` [PATCH 06/19] usb: dwc3: host: Pass the XHCI_DRD_SUPPORT and " George Cherian
2014-11-27 2:00 ` Lu, Baolu
2014-11-25 13:11 ` [PATCH 07/19] usb: host: xhci: Adapt xhci to use usb drd library George Cherian
2014-11-25 13:11 ` [PATCH 08/19] usb: dwc3: core: Add dwc3_drd_helper function George Cherian
2014-11-25 13:11 ` [PATCH 09/19] usb: dwc3: dwc3-omap: Make the wrapper interrupt shared George Cherian
2014-11-25 13:11 ` [PATCH 10/19] usb: dwc3: core: Adapt to named interrupts George Cherian
2014-11-25 13:11 ` George Cherian [this message]
2014-11-25 13:11 ` [PATCH 12/19] usb: dwc3: gadget: Adapt gadget to drd library George Cherian
2014-11-25 13:11 ` [PATCH 13/19] usb: dwc3: core: Add DWC3 OTG specific register defines George Cherian
2014-11-25 13:11 ` [PATCH 14/19] usb: dwc3: otg: Add the initial otg driver for dwc3 George Cherian
2014-11-25 13:11 ` [PATCH 15/19] arm: dts: am4372: Add named interrupt property " George Cherian
2014-11-25 13:11 ` [PATCH 16/19] arm: dts: omap5: " George Cherian
2014-11-25 13:11 ` [PATCH 17/19] arm: dts: dra7: " George Cherian
2014-11-25 13:11 ` [PATCH 18/19] arm: dts: exynos5250: " George Cherian
2014-11-25 13:11 ` [PATCH 19/19] arm: dts: am43x evms: Make usb1 as OTG George Cherian
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=1416921115-10467-12-git-send-email-george.cherian@ti.com \
--to=george.cherian@ti.com \
--cc=balbi@ti.com \
--cc=bcousson@baylibre.com \
--cc=ben-linux@fluff.org \
--cc=galak@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kgene.kim@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=mathias.nyman@intel.com \
--cc=pawel.moll@arm.com \
--cc=peter.chen@freescale.com \
--cc=robh+dt@kernel.org \
--cc=sojka@merica.cz \
--cc=tony@atomide.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).