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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux