aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-06-03 08:31:16 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-06-17 01:38:50 -0400
commit6f8bf50031a68f533ae7eba3d3277c38ee7806f5 (patch)
tree58430315d7f81a74155699d24203acb087574707 /drivers/gpio
parent644c8df2fb276e6cdfab18d60e9e0bf7a5b65b9a (diff)
GPIO: xilinx: Simplify driver probe function
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> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-xilinx.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 9ae7aa8ca48a..2aad53497a63 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)
170 return -ENOMEM; 170 return -ENOMEM;
171 171
172 /* Update GPIO state shadow register with default value */ 172 /* Update GPIO state shadow register with default value */
173 tree_info = of_get_property(np, "xlnx,dout-default", NULL); 173 of_property_read_u32(np, "xlnx,dout-default", &chip->gpio_state);
174 if (tree_info) 174
175 chip->gpio_state = be32_to_cpup(tree_info); 175 /* By default, all pins are inputs */
176 chip->gpio_dir = 0xFFFFFFFF;
176 177
177 /* Update GPIO direction shadow register with default value */ 178 /* Update GPIO direction shadow register with default value */
178 chip->gpio_dir = 0xFFFFFFFF; /* By default, all pins are inputs */ 179 of_property_read_u32(np, "xlnx,tri-default", &chip->gpio_dir);
179 tree_info = of_get_property(np, "xlnx,tri-default", NULL); 180
180 if (tree_info) 181 /* By default assume full GPIO controller */
181 chip->gpio_dir = be32_to_cpup(tree_info); 182 chip->mmchip.gc.ngpio = 32;
182 183
183 /* Check device node and parent device node for device width */ 184 /* Check device node and parent device node for device width */
184 chip->mmchip.gc.ngpio = 32; /* By default assume full GPIO controller */ 185 of_property_read_u32(np, "xlnx,gpio-width",
185 tree_info = of_get_property(np, "xlnx,gpio-width", NULL); 186 (u32 *)&chip->mmchip.gc.ngpio);
186 if (!tree_info)
187 tree_info = of_get_property(np->parent,
188 "xlnx,gpio-width", NULL);
189 if (tree_info)
190 chip->mmchip.gc.ngpio = be32_to_cpup(tree_info);
191 187
192 spin_lock_init(&chip->gpio_lock); 188 spin_lock_init(&chip->gpio_lock);
193 189