linux-mips
[Top] [All Lists]

Re: [PATCH] MIPS: ralink: add support for periodic timer irq

To: John Crispin <blogic@openwrt.org>
Subject: Re: [PATCH] MIPS: ralink: add support for periodic timer irq
From: James Hogan <james.hogan@imgtec.com>
Date: Thu, 8 Aug 2013 12:18:48 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, <linux-mips@linux-mips.org>
In-reply-to: <1375959950-31024-1-git-send-email-blogic@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1375959950-31024-1-git-send-email-blogic@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
Hi John,

On 08/08/13 12:05, John Crispin wrote:
> +static int rt_timer_probe(struct platform_device *pdev)
> +{
> +     struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +     struct rt_timer *rt;
> +     struct clk *clk;
> +
> +     if (!res) {
> +             dev_err(&pdev->dev, "no memory resource found\n");
> +             return -EINVAL;
> +     }

devm_request_and_ioremap already error checks res so you don't need to
check it yourself (see devm_request_and_ioremap kerneldoc comment in
lib/devres.c).

> +
> +     rt = devm_kzalloc(&pdev->dev, sizeof(*rt), GFP_KERNEL);
> +     if (!rt) {
> +             dev_err(&pdev->dev, "failed to allocate memory\n");
> +             return -ENOMEM;
> +     }
> +
> +     rt->irq = platform_get_irq(pdev, 0);
> +     if (!rt->irq) {
> +             dev_err(&pdev->dev, "failed to load irq\n");
> +             return -ENOENT;
> +     }
> +
> +     rt->membase = devm_request_and_ioremap(&pdev->dev, res);
> +     if (!rt->membase) {
> +             dev_err(&pdev->dev, "failed to ioremap\n");
> +             return -ENOMEM;
> +     }

Cheers
James


<Prev in Thread] Current Thread [Next in Thread>