Linux USB
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Ladislav Michl <ladis@linux-mips.org>, linux-usb@vger.kernel.org
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [1/2] usb: gadget: udc: atmel: Use devm_ioremap_resource()
Date: Mon, 22 Jan 2018 18:34:21 +0300	[thread overview]
Message-ID: <becd55df-a060-ac77-29eb-dfe86ca880de@cogentembedded.com> (raw)

Hello!

On 01/22/2018 06:21 PM, Ladislav Michl wrote:

> As devm_ioremap_resource() checks for valid resource,
> make use of it instead of testing ourselves. As a bonus
> memory region is requested.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>  drivers/usb/gadget/udc/atmel_usba_udc.c | 40 ++++++++++++++++-----------------
>  1 file changed, 19 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 075eaaa8a408..403e06e7175f 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
[...]
> @@ -2284,10 +2284,24 @@ static int usba_udc_probe(struct platform_device *pdev)
>  	udc->gadget = usba_gadget_template;
>  	INIT_LIST_HEAD(&udc->gadget.ep_list);
>  
> -	regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> -	fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> -	if (!regs || !fifo)
> -		return -ENXIO;
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID);
> +	udc->regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(udc->regs)) {
> +		ret = PTR_ERR(udc->regs);
> +		dev_err(&pdev->dev, "Unable to map I/O memory: %d\n", ret);

   devm_ioremap_resource() prints out the error message.

> +		return ret;
> +	}
> +	dev_info(&pdev->dev, "MMIO registers at %pR mapped at %p\n",
> +		 res, udc->regs);
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID);
> +	udc->fifo = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(udc->fifo)) {
> +		ret = PTR_ERR(udc->fifo);
> +		dev_err(&pdev->dev, "Unable to map FIFO: %d\n", ret);

   Same comment here.

> +		return ret;
> +	}
> +	dev_info(&pdev->dev, "FIFO at %pR mapped at %p\n", res, udc->fifo);
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
[...]

MBR, Sergei
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-01-22 15:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 15:34 Sergei Shtylyov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-01-22 15:57 [1/2] usb: gadget: udc: atmel: Use devm_ioremap_resource() Ladislav Michl
2018-01-22 15:53 Sergei Shtylyov
2018-01-22 15:44 Ladislav Michl
2018-01-22 15:21 Ladislav Michl

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=becd55df-a060-ac77-29eb-dfe86ca880de@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=ladis@linux-mips.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nicolas.ferre@microchip.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