forked from mirrors/linux
		
	gpio: gpio-mxc: Use devm functions
By using devm functions we can get a simpler code. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Acked-by: Shawn Guo <shawn.guo@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
		
							parent
							
								
									04777396d8
								
							
						
					
					
						commit
						8cd73e4e38
					
				
					 1 changed files with 8 additions and 28 deletions
				
			
		| 
						 | 
					@ -405,34 +405,19 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mxc_gpio_get_hw(pdev);
 | 
						mxc_gpio_get_hw(pdev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port = kzalloc(sizeof(struct mxc_gpio_port), GFP_KERNEL);
 | 
						port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
 | 
				
			||||||
	if (!port)
 | 
						if (!port)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | 
						iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 | 
				
			||||||
	if (!iores) {
 | 
						port->base = devm_ioremap_resource(&pdev->dev, iores);
 | 
				
			||||||
		err = -ENODEV;
 | 
						if (IS_ERR(port->base))
 | 
				
			||||||
		goto out_kfree;
 | 
							return PTR_ERR(port->base);
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!request_mem_region(iores->start, resource_size(iores),
 | 
					 | 
				
			||||||
				pdev->name)) {
 | 
					 | 
				
			||||||
		err = -EBUSY;
 | 
					 | 
				
			||||||
		goto out_kfree;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	port->base = ioremap(iores->start, resource_size(iores));
 | 
					 | 
				
			||||||
	if (!port->base) {
 | 
					 | 
				
			||||||
		err = -ENOMEM;
 | 
					 | 
				
			||||||
		goto out_release_mem;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->irq_high = platform_get_irq(pdev, 1);
 | 
						port->irq_high = platform_get_irq(pdev, 1);
 | 
				
			||||||
	port->irq = platform_get_irq(pdev, 0);
 | 
						port->irq = platform_get_irq(pdev, 0);
 | 
				
			||||||
	if (port->irq < 0) {
 | 
						if (port->irq < 0)
 | 
				
			||||||
		err = -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
		goto out_iounmap;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* disable the interrupt and clear the status */
 | 
						/* disable the interrupt and clear the status */
 | 
				
			||||||
	writel(0, port->base + GPIO_IMR);
 | 
						writel(0, port->base + GPIO_IMR);
 | 
				
			||||||
| 
						 | 
					@ -462,7 +447,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 | 
				
			||||||
			 port->base + GPIO_DR, NULL,
 | 
								 port->base + GPIO_DR, NULL,
 | 
				
			||||||
			 port->base + GPIO_GDIR, NULL, 0);
 | 
								 port->base + GPIO_GDIR, NULL, 0);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto out_iounmap;
 | 
							goto out_bgio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	port->bgc.gc.to_irq = mxc_gpio_to_irq;
 | 
						port->bgc.gc.to_irq = mxc_gpio_to_irq;
 | 
				
			||||||
	port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
 | 
						port->bgc.gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
 | 
				
			||||||
| 
						 | 
					@ -498,12 +483,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 | 
				
			||||||
	WARN_ON(gpiochip_remove(&port->bgc.gc) < 0);
 | 
						WARN_ON(gpiochip_remove(&port->bgc.gc) < 0);
 | 
				
			||||||
out_bgpio_remove:
 | 
					out_bgpio_remove:
 | 
				
			||||||
	bgpio_remove(&port->bgc);
 | 
						bgpio_remove(&port->bgc);
 | 
				
			||||||
out_iounmap:
 | 
					out_bgio:
 | 
				
			||||||
	iounmap(port->base);
 | 
					 | 
				
			||||||
out_release_mem:
 | 
					 | 
				
			||||||
	release_mem_region(iores->start, resource_size(iores));
 | 
					 | 
				
			||||||
out_kfree:
 | 
					 | 
				
			||||||
	kfree(port);
 | 
					 | 
				
			||||||
	dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
 | 
						dev_info(&pdev->dev, "%s failed with errno %d\n", __func__, err);
 | 
				
			||||||
	return err;
 | 
						return err;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue