diff options
Diffstat (limited to 'drivers/gpio/gpio-pl061.c')
| -rw-r--r-- | drivers/gpio/gpio-pl061.c | 66 | 
1 files changed, 23 insertions, 43 deletions
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index b4b5da4fd2c..c1720de18a4 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c @@ -48,12 +48,7 @@ struct pl061_context_save_regs {  #endif  struct pl061_gpio { -	/* Each of the two spinlocks protects a different set of hardware -	 * regiters and data structurs. This decouples the code of the IRQ from -	 * the GPIO code. This also makes the case of a GPIO routine call from -	 * the IRQ code simpler. -	 */ -	spinlock_t		lock;		/* GPIO registers */ +	spinlock_t		lock;  	void __iomem		*base;  	int			irq_base; @@ -216,39 +211,34 @@ static void __init pl061_init_gc(struct pl061_gpio *chip, int irq_base)  			       IRQ_GC_INIT_NESTED_LOCK, IRQ_NOREQUEST, 0);  } -static int pl061_probe(struct amba_device *dev, const struct amba_id *id) +static int pl061_probe(struct amba_device *adev, const struct amba_id *id)  { -	struct pl061_platform_data *pdata; +	struct device *dev = &adev->dev; +	struct pl061_platform_data *pdata = dev->platform_data;  	struct pl061_gpio *chip;  	int ret, irq, i; -	chip = kzalloc(sizeof(*chip), GFP_KERNEL); +	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);  	if (chip == NULL)  		return -ENOMEM; -	pdata = dev->dev.platform_data;  	if (pdata) {  		chip->gc.base = pdata->gpio_base;  		chip->irq_base = pdata->irq_base; -	} else if (dev->dev.of_node) { +	} else if (adev->dev.of_node) {  		chip->gc.base = -1;  		chip->irq_base = 0; -	} else { -		ret = -ENODEV; -		goto free_mem; -	} +	} else +		return -ENODEV; -	if (!request_mem_region(dev->res.start, -				resource_size(&dev->res), "pl061")) { -		ret = -EBUSY; -		goto free_mem; -	} +	if (!devm_request_mem_region(dev, adev->res.start, +				resource_size(&adev->res), "pl061")) +		return -EBUSY; -	chip->base = ioremap(dev->res.start, resource_size(&dev->res)); -	if (chip->base == NULL) { -		ret = -ENOMEM; -		goto release_region; -	} +	chip->base = devm_ioremap(dev, adev->res.start, +				resource_size(&adev->res)); +	if (chip->base == NULL) +		return -ENOMEM;  	spin_lock_init(&chip->lock); @@ -258,13 +248,13 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)  	chip->gc.set = pl061_set_value;  	chip->gc.to_irq = pl061_to_irq;  	chip->gc.ngpio = PL061_GPIO_NR; -	chip->gc.label = dev_name(&dev->dev); -	chip->gc.dev = &dev->dev; +	chip->gc.label = dev_name(dev); +	chip->gc.dev = dev;  	chip->gc.owner = THIS_MODULE;  	ret = gpiochip_add(&chip->gc);  	if (ret) -		goto iounmap; +		return ret;  	/*  	 * irq_chip support @@ -276,11 +266,10 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)  	pl061_init_gc(chip, chip->irq_base);  	writeb(0, chip->base + GPIOIE); /* disable irqs */ -	irq = dev->irq[0]; -	if (irq < 0) { -		ret = -ENODEV; -		goto iounmap; -	} +	irq = adev->irq[0]; +	if (irq < 0) +		return -ENODEV; +  	irq_set_chained_handler(irq, pl061_irq_handler);  	irq_set_handler_data(irq, chip); @@ -294,18 +283,9 @@ static int pl061_probe(struct amba_device *dev, const struct amba_id *id)  		}  	} -	amba_set_drvdata(dev, chip); +	amba_set_drvdata(adev, chip);  	return 0; - -iounmap: -	iounmap(chip->base); -release_region: -	release_mem_region(dev->res.start, resource_size(&dev->res)); -free_mem: -	kfree(chip); - -	return ret;  }  #ifdef CONFIG_PM  |