[PATCH 03/22] gpio: gpio-xilinx: Remove CONFIG_OF conditionals

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

 



From: Michal Simek <michal.simek@xxxxxxxxxx>
Date: Tue, 27 Nov 2012 15:40:47 +0100

CONFIG_OF is mandatory for all Xilinx platforms. For this reason
all conditional compiling regarding this option can be removed.

Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx>
Signed-off-by: Alexander Hedges <ahedges@xxxxxxx>
(cherry picked from commit 324c11445a487744dd2e4c286b63e83fc18eae54)
---
 drivers/gpio/gpio-xilinx.c | 157 ++-----------------------------------
 1 file changed, 8 insertions(+), 149 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 815af3647d81..4f0d0b25a241 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -47,12 +47,7 @@
  * @gpio_lock: Lock used for synchronization
  */
 struct xgpio_instance {
-#ifdef CONFIG_OF
 	struct of_mm_gpio_chip mmchip;
-#else
-	struct gpio_chip gc;
-	void __iomem *regs;
-#endif
 	u32 gpio_state;		/* GPIO state shadow register */
 	u32 gpio_dir;		/* GPIO direction shadow register */
 	u32 offset;
@@ -72,17 +67,12 @@ struct xgpio_instance {
  */
 static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
-#ifdef CONFIG_OF
 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
 	struct xgpio_instance *chip =
 	    container_of(mm_gc, struct xgpio_instance, mmchip);
 
 	void __iomem *regs = mm_gc->regs + chip->offset;
-#else
-	struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-						   gc);
-	void __iomem *regs = chip->regs;
-#endif
+
 	return (xgpio_readreg(regs + XGPIO_DATA_OFFSET) >> gpio) & 1;
 }
 
@@ -98,16 +88,10 @@ static int xgpio_get(struct gpio_chip *gc, unsigned int gpio)
 static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	unsigned long flags;
-#ifdef CONFIG_OF
 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
 	struct xgpio_instance *chip =
 	    container_of(mm_gc, struct xgpio_instance, mmchip);
 	void __iomem *regs = mm_gc->regs;
-#else
-	struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-						   gc);
-	void __iomem *regs = chip->regs;
-#endif
 
 	spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -172,16 +156,10 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 {
 	unsigned long flags;
-#ifdef CONFIG_OF
 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
 	struct xgpio_instance *chip =
 	    container_of(mm_gc, struct xgpio_instance, mmchip);
 	void __iomem *regs = mm_gc->regs;
-#else
-	struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-						   gc);
-	void __iomem *regs = chip->regs;
-#endif
 
 	spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -209,15 +187,9 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
 static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 {
 	unsigned long flags;
-#ifdef CONFIG_OF
 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
 	struct xgpio_instance *chip = gpiochip_get_data(gc);
 	void __iomem *regs = mm_gc->regs;
-#else
-	struct xgpio_instance *chip = container_of(gc, struct xgpio_instance,
-						   gc);
-	void __iomem *regs = chip->regs;
-#endif
 
 	spin_lock_irqsave(&chip->gpio_lock, flags);
 
@@ -237,7 +209,6 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
 	return 0;
 }
 
-#ifdef CONFIG_OF
 /**
  * xgpio_save_regs - Set initial values of GPIO pins
  * @mm_gc: Pointer to memory mapped GPIO chip structure
@@ -389,138 +360,26 @@ static const struct of_device_id xgpio_of_match[] = {
 	{ /* end of list */ },
 };
 
-static struct platform_driver xgpio_driver = {
+static struct platform_driver xilinx_gpio_driver = {
 	.probe		= xgpio_of_probe,
 	.remove		= xgpio_remove,
-	.driver	= {
-		.name	= "xilinx_gpio",
-		.owner	= THIS_MODULE,
-	},
-};
-
-#else
-
-/**
- * xgpio_probe - Probe method for the GPIO device
- * @pdev:	platform device instance
- *
- * This function allocates memory resources for the xgpio device and initializes
- * the driver structures.
- *
- * Return:	0 on success, negative error otherwise.
- */
-static int __init xgpio_probe(struct platform_device *pdev)
-{
-	int ret;
-	struct xgpio_instance *chip;
-	struct gpio_chip *gc;
-	struct resource *mem_res = NULL;
-	struct xgpio_platform_data *pdata;
-
-	chip = kzalloc(sizeof(struct xgpio_instance), GFP_KERNEL);
-	if (!chip) {
-		dev_err(&pdev->dev, "couldn't allocate memory for gpio private "
-			"data\n");
-		return -ENOMEM;
-	}
-
-	platform_set_drvdata(pdev, chip);
-
-	mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem_res) {
-		dev_err(&pdev->dev, "No memory resource\n");
-		ret = -ENODEV;
-		goto err_free_gpio;
-	}
-
-	if (!request_mem_region(mem_res->start, resource_size(mem_res),
-				pdev->name)) {
-		dev_err(&pdev->dev, "Cannot request IO\n");
-		ret = -ENXIO;
-		goto err_free_gpio;
-	}
-
-	pdata = pdev->dev.platform_data;
-	if (pdata == NULL) {
-		dev_err(&pdev->dev, "Cannot find platform data\n");
-		return -ENODEV;
-	}
-
-	chip->regs = ioremap(mem_res->start, resource_size(mem_res));
-	if (chip->regs == NULL) {
-		dev_err(&pdev->dev, "Couldn't ioremap memory at 0x%08lx\n",
-			(unsigned long)mem_res->start);
-		ret = -ENOMEM;
-		goto err_release_region;
-	}
-
-	chip->gpio_state = pdata->state;
-	chip->gpio_dir = pdata->dir;
-
-	xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, chip->gpio_state);
-	xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET, chip->gpio_dir);
-
-	/* configure the gpio chip */
-	gc = &chip->gc;
-	gc->label = "xgpio";
-	gc->owner = THIS_MODULE;
-	gc->dev = &pdev->dev;
-	gc->get = xgpio_get;
-	gc->set = xgpio_set;
-	gc->direction_input = xgpio_dir_in;
-	gc->direction_output = xgpio_dir_out;
-	gc->dbg_show = NULL;
-	gc->base = 0;		/* default pin base */
-	gc->ngpio = pdata->width;
-	gc->can_sleep = 0;
-
-	ret = gpiochip_add(gc);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "gpio gc registration failed\n");
-		goto err_iounmap;
-	} else
-		dev_info(&pdev->dev, "gpio at 0x%08lx mapped to 0x%08lx\n",
-			 (unsigned long)mem_res->start,
-			 (unsigned long)chip->regs);
-
-	return 0;
-
-err_iounmap:
-	iounmap(chip->regs);
-err_release_region:
-	release_mem_region(mem_res->start, resource_size(mem_res));
-err_free_gpio:
-	platform_set_drvdata(pdev, NULL);
-	kfree(chip);
-
-	return ret;
-}
-
-static struct platform_driver xgpio_driver = {
-	.probe		= xgpio_probe,
-	.remove		= xgpio_remove,
-	.driver	= {
-		.name	= "xilinx_gpio",
-		.owner	= THIS_MODULE,
+	.driver		= {
+			.name = "xilinx-gpio",
+			.of_match_table	= xgpio_of_match,
 	},
 };
 
-#endif /* CONFIG_OF */
-
 static int __init xgpio_init(void)
 {
-#ifdef CONFIG_OF
-	return 0;
-#else
-	return platform_driver_register(&xgpio_driver);
-#endif
+	return platform_driver_register(&xilinx_gpio_driver);
 }
 
+/* Make sure we get initialized before anyone else tries to use us */
 subsys_initcall(xgpio_init);
 
 static void __exit xgpio_exit(void)
 {
-	platform_driver_unregister(&xgpio_driver);
+	platform_driver_unregister(&xilinx_gpio_driver);
 }
 module_exit(xgpio_exit);
 
-- 
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