[PATCH 11/22] gpio: xilinx: Use platform_driver

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

 



From: Michal Simek <michal.simek@xxxxxxxxxx>
Date: Tue, 3 Sep 2013 17:06:19 +0200

Register driver as platform driver.
Based on this change, probe function uses devm_
which clear incorrect kfree(chip) usage.

Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx>
Signed-off-by: Alexander Hedges <ahedges@xxxxxxx>
(cherry picked from commit 616ac116ab2dcfe603c67ea3c8f70d5889aa6fc9)
---
 drivers/gpio/gpio-xilinx.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index f81f90a11963..8e5d7440dbf0 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -492,11 +492,11 @@ static int xgpio_remove(struct platform_device *pdev)
  */
 static int xgpio_of_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	struct xgpio_instance *chip;
 	int status = 0;
-	struct device_node *np = pdev->dev.of_node;
-	u32 ngpio;
 	const u32 *tree_info;
+	u32 ngpio;
 
 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
 	if (!chip)
@@ -533,7 +533,6 @@ static int xgpio_of_probe(struct platform_device *pdev)
 	/* Call the OF gpio helper to setup and register the GPIO device */
 	status = of_mm_gpiochip_add(np, &chip->mmchip);
 	if (status) {
-		kfree(chip);
 		pr_err("%s: error in probe function with status %d\n",
 		       np->full_name, status);
 		return status;
@@ -542,7 +541,6 @@ static int xgpio_of_probe(struct platform_device *pdev)
 	status = xgpio_irq_setup(np, chip);
 
 	if (status) {
-		kfree(chip);
 		pr_err("%s: GPIO IRQ initialization failed %d\n",
 		       np->full_name, status);
 		return status;
@@ -553,7 +551,7 @@ static int xgpio_of_probe(struct platform_device *pdev)
 
 	tree_info = of_get_property(np, "xlnx,is-dual", NULL);
 	if (tree_info && be32_to_cpup(tree_info)) {
-		chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+		chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
 		if (!chip)
 			return -ENOMEM;
 
@@ -593,7 +591,6 @@ static int xgpio_of_probe(struct platform_device *pdev)
 
 		status = xgpio_irq_setup(np, chip);
 		if (status) {
-			kfree(chip);
 			pr_err("%s: GPIO IRQ initialization failed %d\n",
 			      np->full_name, status);
 			return status;
@@ -602,7 +599,6 @@ static int xgpio_of_probe(struct platform_device *pdev)
 		/* Call the OF gpio helper to setup and register the GPIO dev */
 		status = of_mm_gpiochip_add(np, &chip->mmchip);
 		if (status) {
-			kfree(chip);
 			pr_err("%s: error in probe function with status %d\n",
 			       np->full_name, status);
 			return status;
@@ -618,6 +614,7 @@ static const struct of_device_id xgpio_of_match[] = {
 	{ .compatible = "xlnx,xps-gpio-1.00.a", },
 	{ /* end of list */ },
 };
+MODULE_DEVICE_TABLE(of, xgpio_of_match);
 
 static struct platform_driver xilinx_gpio_driver = {
 	.probe		= xgpio_of_probe,
-- 
2.17.1

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux