devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/6] GPIO: xilinx: Simplify driver probe function
@ 2013-06-03 12:31 Michal Simek
  2013-06-03 12:31 ` [PATCH v2 2/6] GPIO: xilinx: Add support for dual channel Michal Simek
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Michal Simek @ 2013-06-03 12:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Michal Simek, Michal Simek, Linus Walleij, Arnd Bergmann,
	Grant Likely, Rob Herring, devicetree-discuss

[-- Attachment #1: Type: text/plain, Size: 1845 bytes --]

Simplification is done by using OF helper function
which increase readability of code and remove
(if (var) var = be32_to_cpup;) assignment.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2:
- New patch in this series

 drivers/gpio/gpio-xilinx.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 9ae7aa8..2aad534 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -170,24 +170,20 @@ static int xgpio_of_probe(struct device_node *np)
 		return -ENOMEM;

 	/* Update GPIO state shadow register with default value */
-	tree_info = of_get_property(np, "xlnx,dout-default", NULL);
-	if (tree_info)
-		chip->gpio_state = be32_to_cpup(tree_info);
+	of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state);
+
+	/* By default, all pins are inputs */
+	chip->gpio_dir = 0xFFFFFFFF;

 	/* Update GPIO direction shadow register with default value */
-	chip->gpio_dir = 0xFFFFFFFF; /* By default, all pins are inputs */
-	tree_info = of_get_property(np, "xlnx,tri-default", NULL);
-	if (tree_info)
-		chip->gpio_dir = be32_to_cpup(tree_info);
+	of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir);
+
+	/* By default assume full GPIO controller */
+	chip->mmchip.gc.ngpio = 32;

 	/* Check device node and parent device node for device width */
-	chip->mmchip.gc.ngpio = 32; /* By default assume full GPIO controller */
-	tree_info = of_get_property(np, "xlnx,gpio-width", NULL);
-	if (!tree_info)
-		tree_info = of_get_property(np->parent,
-					    "xlnx,gpio-width", NULL);
-	if (tree_info)
-		chip->mmchip.gc.ngpio = be32_to_cpup(tree_info);
+	of_property_read_u32(np, "xlnx,gpio-width",
+			      (u32 *)&chip->mmchip.gc.ngpio);

 	spin_lock_init(&chip->gpio_lock);

--
1.8.2.3


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-06-29 23:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 12:31 [PATCH v2 1/6] GPIO: xilinx: Simplify driver probe function Michal Simek
2013-06-03 12:31 ` [PATCH v2 2/6] GPIO: xilinx: Add support for dual channel Michal Simek
2013-06-17  5:44   ` Linus Walleij
2013-06-03 12:31 ` [PATCH v2 6/6] DT: Add documentation for gpio-xilinx Michal Simek
2013-06-17  5:50   ` Linus Walleij
2013-06-17  6:21     ` Michal Simek
2013-06-17  9:13       ` Linus Walleij
2013-06-24 11:54         ` Michal Simek
2013-06-29 23:21           ` Linus Walleij
2013-06-10  9:02 ` [PATCH v2 1/6] GPIO: xilinx: Simplify driver probe function Michal Simek
2013-06-17  5:25 ` Michal Simek
2013-06-17  5:39 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).