public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@ti.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	<balbi@kernel.org>, <grygorii.strashko@ti.com>
Cc: <tony@atomide.com>, <Joao.Pinto@synopsys.com>,
	<peter.chen@freescale.com>, <jun.li@freescale.com>,
	<yoshihiro.shimoda.uh@renesas.com>, <nsekhar@ti.com>,
	<b-liu@ti.com>, <linux-usb@vger.kernel.org>,
	<linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v10 5/5] usb: dwc3: core: cleanup IRQ resources
Date: Fri, 10 Jun 2016 14:35:20 +0300	[thread overview]
Message-ID: <575AA5F8.90305@ti.com> (raw)
In-Reply-To: <c59b5dcf-87ff-df86-897c-8c7a9f4beb20@cogentembedded.com>

On 10/06/16 13:39, Sergei Shtylyov wrote:
> Hello.
> 
> On 6/10/2016 12:56 PM, Roger Quadros wrote:
> 
>> Implementations might use different IRQs for
>> host, gadget so use named interrupt resources
>> to allow device tree to specify the interrupts.
>>
>> Following are the interrupt names
>>
>> Peripheral Interrupt - peripheral
>> HOST Interrupt - host
>>
>> Maintain backward compatibility for a single named
>> interrupt ("dwc3_usb3") for all interrupts as well as
>> unnamed interrupt at index 0 for all interrupts.
>>
>> As platform_get_irq_() variants are used, tackle
> 
>    platform_get_irq().

OK.
> 
>> the -EPROBE_DEFER case as well.
>>
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> ---
>> v10:
>> - don't mention otg irq since we are not using it yet
>> - use platform_get_irq() and friends and check -EPROBE_DEFER case.
>>
>>  drivers/usb/dwc3/core.c   | 22 ++++++++--------------
>>  drivers/usb/dwc3/gadget.c | 29 ++++++++++++++++++++++++++---
>>  drivers/usb/dwc3/host.c   | 41 ++++++++++++++++++++++++++++++++++++++++-
>>  3 files changed, 74 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 8fceeb1..131e7eb 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
> [...]
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 0f6fb8e..774a0d8 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
> [...]
>> @@ -2866,7 +2865,31 @@ static irqreturn_t dwc3_interrupt(int irq, void *_evt)
>>   */
>>  int dwc3_gadget_init(struct dwc3 *dwc)
>>  {
>> -    int                    ret;
>> +    int ret, irq;
>> +    struct platform_device *dwc3_pdev = to_platform_device(dwc->dev);
>> +
>> +    irq = platform_get_irq_byname(dwc3_pdev, "peripheral");
>> +    if (irq == -EPROBE_DEFER)
>> +        return irq;
>> +
>> +    if (irq <= 0) {
>> +        irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
>> +        if (irq == -EPROBE_DEFER)
>> +            return irq;
>> +
>> +        if (irq <= 0) {
>> +            irq = platform_get_irq(dwc3_pdev, 0);
>> +            if (irq <= 0) {
>> +                if (irq != -EPROBE_DEFER) {
>> +                    dev_err(dwc->dev,
>> +                        "missing peripheral IRQ\n");
>> +                }
>> +                return irq;
> 
>    Iff irq == 0, you'll return success despite IRQ was "invalid". Was that intended?

good catch. It wasn't intended. I guess i'll return -EINVAL then?

> 
>> +            }
>> +        }
>> +    }
>> +
>> +    dwc->irq_gadget = irq;
>>
>>      dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req),
>>              &dwc->ctrl_req_addr, GFP_KERNEL);
>> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
>> index c679f63..eb5e8f9 100644
>> --- a/drivers/usb/dwc3/host.c
>> +++ b/drivers/usb/dwc3/host.c
>> @@ -24,7 +24,46 @@ int dwc3_host_init(struct dwc3 *dwc)
>>  {
>>      struct platform_device    *xhci;
>>      struct usb_xhci_pdata    pdata;
>> -    int            ret;
>> +    int            ret, irq;
>> +    struct resource        *res;
>> +    struct platform_device    *dwc3_pdev = to_platform_device(dwc->dev);
>> +
>> +    irq = platform_get_irq_byname(dwc3_pdev, "host");
>> +    if (irq == -EPROBE_DEFER)
>> +        return irq;
>> +
>> +    if (irq <= 0) {
>> +        irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
>> +        if (irq == -EPROBE_DEFER)
>> +            return irq;
>> +
>> +        if (irq <= 0) {
>> +            irq = platform_get_irq(dwc3_pdev, 0);
>> +            if (irq <= 0) {
>> +                if (irq != -EPROBE_DEFER) {
>> +                    dev_err(dwc->dev,
>> +                        "missing host IRQ\n");
>> +                }
>> +                return irq;
> 
>    Iff irq == 0, you'll return success despite IRQ was "invalid". Was that intended?
> 
>> +            } else {
>> +                res = platform_get_resource(dwc3_pdev,
>> +                                IORESOURCE_IRQ, 0);
>> +            }
>> +        } else {
>> +            res = platform_get_resource_byname(dwc3_pdev,
>> +                               IORESOURCE_IRQ,
>> +                               "dwc_usb3");
>> +        }
>> +
>> +    } else {
>> +        res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
>> +                           "host");
>> +    }
>> +
>> +    dwc->xhci_resources[1].start = irq;
>> +    dwc->xhci_resources[1].end = irq;
>> +    dwc->xhci_resources[1].flags = res->flags;
>> +    dwc->xhci_resources[1].name = res->name;
>>
>>      xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
>>      if (!xhci) {
> 

--
cheers,
-roger

  reply	other threads:[~2016-06-10 11:35 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11 14:36 [PATCH v8 0/5] dwc3: omap: fixes and dual-role preparation Roger Quadros
2016-05-11 14:36 ` [PATCH v8 1/5] usb: dwc3: omap: use request_threaded_irq() Roger Quadros
2016-05-11 14:36 ` [PATCH v8 2/5] usb: dwc3: omap: Mark the interrupt handler as shared Roger Quadros
2016-05-11 14:36 ` [PATCH v8 3/5] usb: dwc3: omap: Don't set POWERPRESENT Roger Quadros
2016-05-11 14:36 ` [PATCH v8 4/5] usb: dwc3: omap: Pass VBUS and ID events transparently Roger Quadros
2016-05-11 14:36 ` [PATCH v8 5/5] usb: dwc3: core: cleanup IRQ resources Roger Quadros
2016-05-24  9:35   ` Felipe Balbi
2016-05-24 12:35     ` Roger Quadros
2016-06-01  7:46   ` [PATCH v9 " Roger Quadros
2016-06-01  8:06     ` Felipe Balbi
2016-06-07  9:28       ` Roger Quadros
2016-06-02 11:52     ` Grygorii Strashko
2016-06-07  9:34       ` Roger Quadros
2016-06-07 11:49         ` Grygorii Strashko
2016-06-07 12:44           ` Roger Quadros
2016-06-07 13:09             ` Felipe Balbi
2016-06-07 14:05               ` Roger Quadros
2016-06-10  7:56           ` Roger Quadros
2016-06-10  8:02       ` Roger Quadros
2016-06-10  8:04         ` Roger Quadros
2016-06-10  8:18           ` Felipe Balbi
2016-06-10  8:32             ` Roger Quadros
2016-06-10  9:18               ` Felipe Balbi
2016-06-10  8:11         ` Felipe Balbi
2016-06-10  9:56     ` [PATCH v10 " Roger Quadros
2016-06-10 10:39       ` Sergei Shtylyov
2016-06-10 11:35         ` Roger Quadros [this message]
2016-06-10 11:44           ` Sergei Shtylyov
2016-06-10 11:46             ` Roger Quadros
2016-06-10 12:22               ` Sergei Shtylyov
2016-06-10 11:48       ` [PATCH v11 " Roger Quadros

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=575AA5F8.90305@ti.com \
    --to=rogerq@ti.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=b-liu@ti.com \
    --cc=balbi@kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=jun.li@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=peter.chen@freescale.com \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=tony@atomide.com \
    --cc=yoshihiro.shimoda.uh@renesas.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