From: Nicolas Ferre <nicolas.ferre@microchip.com>
To: Ladislav Michl <ladis@linux-mips.org>, linux-usb@vger.kernel.org
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
Alexandre Belloni <alexandre.belloni@free-electrons.com>,
Cristian Birsan <Cristian.Birsan@microchip.com>
Subject: [v2] usb: gadget: udc: atmel: Use devm_ioremap_resource()
Date: Tue, 23 Jan 2018 09:37:34 +0800 [thread overview]
Message-ID: <7b95ba22-17fc-9696-a018-d1a9a39ae4e3@microchip.com> (raw)
On 23/01/2018 at 00:05, 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>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Thanks Ladislav.
Best regards,
Nicolas
> ---
> Changes:
> - v2: Drop uneeded error message
>
> drivers/usb/gadget/udc/atmel_usba_udc.c | 34 +++++++++++++--------------------
> 1 file changed, 13 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..f420710abdd7 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -2272,7 +2272,7 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev,
>
> static int usba_udc_probe(struct platform_device *pdev)
> {
> - struct resource *regs, *fifo;
> + struct resource *res;
> struct clk *pclk, *hclk;
> struct usba_udc *udc;
> int irq, ret, i;
> @@ -2284,10 +2284,18 @@ 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))
> + return PTR_ERR(udc->regs);
> + 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))
> + return PTR_ERR(udc->fifo);
> + dev_info(&pdev->dev, "FIFO at %pR mapped at %p\n", res, udc->fifo);
>
> irq = platform_get_irq(pdev, 0);
> if (irq < 0)
> @@ -2307,22 +2315,6 @@ static int usba_udc_probe(struct platform_device *pdev)
> udc->hclk = hclk;
> udc->vbus_pin = -ENODEV;
>
> - ret = -ENOMEM;
> - udc->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
> - if (!udc->regs) {
> - dev_err(&pdev->dev, "Unable to map I/O memory, aborting.\n");
> - return ret;
> - }
> - dev_info(&pdev->dev, "MMIO registers at 0x%08lx mapped at %p\n",
> - (unsigned long)regs->start, udc->regs);
> - udc->fifo = devm_ioremap(&pdev->dev, fifo->start, resource_size(fifo));
> - if (!udc->fifo) {
> - dev_err(&pdev->dev, "Unable to map FIFO, aborting.\n");
> - return ret;
> - }
> - dev_info(&pdev->dev, "FIFO at 0x%08lx mapped at %p\n",
> - (unsigned long)fifo->start, udc->fifo);
> -
> platform_set_drvdata(pdev, udc);
>
> /* Make sure we start from a clean slate */
>
next reply other threads:[~2018-01-23 1:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-23 1:37 Nicolas Ferre [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-01-22 16:05 [v2] usb: gadget: udc: atmel: Use devm_ioremap_resource() 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=7b95ba22-17fc-9696-a018-d1a9a39ae4e3@microchip.com \
--to=nicolas.ferre@microchip.com \
--cc=Cristian.Birsan@microchip.com \
--cc=alexandre.belloni@free-electrons.com \
--cc=ladis@linux-mips.org \
--cc=linux-usb@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.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).