aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-28 12:57:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-28 12:57:46 -0500
commitdda9cc3a14518fcf8a89faef15f0f704de3533f2 (patch)
tree8d947fe66a6a0a511100ffba0e3bf15f02950362 /drivers
parent962ba26326ba02ca5c67f18c6979c3adfd7c2097 (diff)
parente2f0b00560729c47f39b2bc624eb93d82dc0e3e8 (diff)
Merge tag 'gpio-v3.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Here us a bunch of patches for the v3.13 series. Most important stuff is related to fixes and documentation for the new GPIO descriptor API. If the diffstat is scary you'll notice most of it is to Documentation/*: - A big slew of documentation for the gpiod transition that happened in the merge window, no semantic effect, but we should provide proper documentation with the new API. - Fix flags related to the new API. - Fix to the find_chip_by_name() lookup function related to the new API. - Fix of_find_gpio() when not using device tree. - Bug fix for the TB10x direction setting. - Error path fixes from Dan Carpenter. - Nasty IRQdomain bug relating to taking an unitialized spinlock. - Minor fixes here and there" * tag 'gpio-v3.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: bcm281xx: Fix return value of bcm_kona_gpio_get() gpio: pl061: move irqdomain initialization gpio: ucb1400: Add MODULE_ALIAS gpiolib: fix of_find_gpio() when OF not defined gpio: fix memory leak in error path gpio: rcar: NULL dereference on error in probe() gpio: msm: make msm_gpio.summary_irq signed for error handling gpio: mvebu: make mvchip->irqbase signed for error handling gpiolib: use dedicated flags for GPIO properties gpiolib: fix find_chip_by_name() Documentation: gpiolib: document new interface gpio: tb10x: Set output value before setting direction to output
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpio-bcm-kona.c2
-rw-r--r--drivers/gpio/gpio-msm-v2.c2
-rw-r--r--drivers/gpio/gpio-mvebu.c2
-rw-r--r--drivers/gpio/gpio-pl061.c10
-rw-r--r--drivers/gpio/gpio-rcar.c2
-rw-r--r--drivers/gpio/gpio-tb10x.c1
-rw-r--r--drivers/gpio/gpio-ucb1400.c1
-rw-r--r--drivers/gpio/gpiolib.c58
8 files changed, 43 insertions, 35 deletions
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index 72c927dc3be1..54c18c220a60 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -158,7 +158,7 @@ static int bcm_kona_gpio_get(struct gpio_chip *chip, unsigned gpio)
158 spin_unlock_irqrestore(&kona_gpio->lock, flags); 158 spin_unlock_irqrestore(&kona_gpio->lock, flags);
159 159
160 /* return the specified bit status */ 160 /* return the specified bit status */
161 return !!(val & bit); 161 return !!(val & BIT(bit));
162} 162}
163 163
164static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) 164static int bcm_kona_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c
index f7a0cc4da950..7b37300973db 100644
--- a/drivers/gpio/gpio-msm-v2.c
+++ b/drivers/gpio/gpio-msm-v2.c
@@ -102,7 +102,7 @@ struct msm_gpio_dev {
102 DECLARE_BITMAP(wake_irqs, MAX_NR_GPIO); 102 DECLARE_BITMAP(wake_irqs, MAX_NR_GPIO);
103 DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO); 103 DECLARE_BITMAP(dual_edge_irqs, MAX_NR_GPIO);
104 struct irq_domain *domain; 104 struct irq_domain *domain;
105 unsigned int summary_irq; 105 int summary_irq;
106 void __iomem *msm_tlmm_base; 106 void __iomem *msm_tlmm_base;
107}; 107};
108 108
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 3c3321f94053..db3129043e63 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -79,7 +79,7 @@ struct mvebu_gpio_chip {
79 spinlock_t lock; 79 spinlock_t lock;
80 void __iomem *membase; 80 void __iomem *membase;
81 void __iomem *percpu_membase; 81 void __iomem *percpu_membase;
82 unsigned int irqbase; 82 int irqbase;
83 struct irq_domain *domain; 83 struct irq_domain *domain;
84 int soc_variant; 84 int soc_variant;
85}; 85};
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index f22f7f3e2e53..b4d42112d02d 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -286,11 +286,6 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
286 if (!chip->base) 286 if (!chip->base)
287 return -ENOMEM; 287 return -ENOMEM;
288 288
289 chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR,
290 irq_base, &pl061_domain_ops, chip);
291 if (!chip->domain)
292 return -ENODEV;
293
294 spin_lock_init(&chip->lock); 289 spin_lock_init(&chip->lock);
295 290
296 chip->gc.request = pl061_gpio_request; 291 chip->gc.request = pl061_gpio_request;
@@ -320,6 +315,11 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
320 irq_set_chained_handler(irq, pl061_irq_handler); 315 irq_set_chained_handler(irq, pl061_irq_handler);
321 irq_set_handler_data(irq, chip); 316 irq_set_handler_data(irq, chip);
322 317
318 chip->domain = irq_domain_add_simple(adev->dev.of_node, PL061_GPIO_NR,
319 irq_base, &pl061_domain_ops, chip);
320 if (!chip->domain)
321 return -ENODEV;
322
323 for (i = 0; i < PL061_GPIO_NR; i++) { 323 for (i = 0; i < PL061_GPIO_NR; i++) {
324 if (pdata) { 324 if (pdata) {
325 if (pdata->directions & (1 << i)) 325 if (pdata->directions & (1 << i))
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index d3f15ae93bd3..fe088a30567a 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -381,7 +381,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
381 if (!p->irq_domain) { 381 if (!p->irq_domain) {
382 ret = -ENXIO; 382 ret = -ENXIO;
383 dev_err(&pdev->dev, "cannot initialize irq domain\n"); 383 dev_err(&pdev->dev, "cannot initialize irq domain\n");
384 goto err1; 384 goto err0;
385 } 385 }
386 386
387 if (devm_request_irq(&pdev->dev, irq->start, 387 if (devm_request_irq(&pdev->dev, irq->start,
diff --git a/drivers/gpio/gpio-tb10x.c b/drivers/gpio/gpio-tb10x.c
index 0502b9a041a5..da071ddbad99 100644
--- a/drivers/gpio/gpio-tb10x.c
+++ b/drivers/gpio/gpio-tb10x.c
@@ -132,6 +132,7 @@ static int tb10x_gpio_direction_out(struct gpio_chip *chip,
132 int mask = BIT(offset); 132 int mask = BIT(offset);
133 int val = TB10X_GPIO_DIR_OUT << offset; 133 int val = TB10X_GPIO_DIR_OUT << offset;
134 134
135 tb10x_gpio_set(chip, offset, value);
135 tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val); 136 tb10x_set_bits(tb10x_gpio, OFFSET_TO_REG_DDR, mask, val);
136 137
137 return 0; 138 return 0;
diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c
index 1a605f2a0f55..06fb5cf99ded 100644
--- a/drivers/gpio/gpio-ucb1400.c
+++ b/drivers/gpio/gpio-ucb1400.c
@@ -105,3 +105,4 @@ module_platform_driver(ucb1400_gpio_driver);
105 105
106MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); 106MODULE_DESCRIPTION("Philips UCB1400 GPIO driver");
107MODULE_LICENSE("GPL"); 107MODULE_LICENSE("GPL");
108MODULE_ALIAS("platform:ucb1400_gpio");
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4e10b10d3ddd..ac53a9593662 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -14,6 +14,7 @@
14#include <linux/idr.h> 14#include <linux/idr.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/acpi.h> 16#include <linux/acpi.h>
17#include <linux/gpio/driver.h>
17 18
18#define CREATE_TRACE_POINTS 19#define CREATE_TRACE_POINTS
19#include <trace/events/gpio.h> 20#include <trace/events/gpio.h>
@@ -1308,6 +1309,18 @@ struct gpio_chip *gpiochip_find(void *data,
1308} 1309}
1309EXPORT_SYMBOL_GPL(gpiochip_find); 1310EXPORT_SYMBOL_GPL(gpiochip_find);
1310 1311
1312static int gpiochip_match_name(struct gpio_chip *chip, void *data)
1313{
1314 const char *name = data;
1315
1316 return !strcmp(chip->label, name);
1317}
1318
1319static struct gpio_chip *find_chip_by_name(const char *name)
1320{
1321 return gpiochip_find((void *)name, gpiochip_match_name);
1322}
1323
1311#ifdef CONFIG_PINCTRL 1324#ifdef CONFIG_PINCTRL
1312 1325
1313/** 1326/**
@@ -1341,8 +1354,10 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip,
1341 ret = pinctrl_get_group_pins(pctldev, pin_group, 1354 ret = pinctrl_get_group_pins(pctldev, pin_group,
1342 &pin_range->range.pins, 1355 &pin_range->range.pins,
1343 &pin_range->range.npins); 1356 &pin_range->range.npins);
1344 if (ret < 0) 1357 if (ret < 0) {
1358 kfree(pin_range);
1345 return ret; 1359 return ret;
1360 }
1346 1361
1347 pinctrl_add_gpio_range(pctldev, &pin_range->range); 1362 pinctrl_add_gpio_range(pctldev, &pin_range->range);
1348 1363
@@ -2260,26 +2275,10 @@ void gpiod_add_table(struct gpiod_lookup *table, size_t size)
2260 mutex_unlock(&gpio_lookup_lock); 2275 mutex_unlock(&gpio_lookup_lock);
2261} 2276}
2262 2277
2263/*
2264 * Caller must have a acquired gpio_lookup_lock
2265 */
2266static struct gpio_chip *find_chip_by_name(const char *name)
2267{
2268 struct gpio_chip *chip = NULL;
2269
2270 list_for_each_entry(chip, &gpio_lookup_list, list) {
2271 if (chip->label == NULL)
2272 continue;
2273 if (!strcmp(chip->label, name))
2274 break;
2275 }
2276
2277 return chip;
2278}
2279
2280#ifdef CONFIG_OF 2278#ifdef CONFIG_OF
2281static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 2279static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2282 unsigned int idx, unsigned long *flags) 2280 unsigned int idx,
2281 enum gpio_lookup_flags *flags)
2283{ 2282{
2284 char prop_name[32]; /* 32 is max size of property name */ 2283 char prop_name[32]; /* 32 is max size of property name */
2285 enum of_gpio_flags of_flags; 2284 enum of_gpio_flags of_flags;
@@ -2297,20 +2296,22 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2297 return desc; 2296 return desc;
2298 2297
2299 if (of_flags & OF_GPIO_ACTIVE_LOW) 2298 if (of_flags & OF_GPIO_ACTIVE_LOW)
2300 *flags |= GPIOF_ACTIVE_LOW; 2299 *flags |= GPIO_ACTIVE_LOW;
2301 2300
2302 return desc; 2301 return desc;
2303} 2302}
2304#else 2303#else
2305static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, 2304static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
2306 unsigned int idx, unsigned long *flags) 2305 unsigned int idx,
2306 enum gpio_lookup_flags *flags)
2307{ 2307{
2308 return ERR_PTR(-ENODEV); 2308 return ERR_PTR(-ENODEV);
2309} 2309}
2310#endif 2310#endif
2311 2311
2312static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, 2312static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
2313 unsigned int idx, unsigned long *flags) 2313 unsigned int idx,
2314 enum gpio_lookup_flags *flags)
2314{ 2315{
2315 struct acpi_gpio_info info; 2316 struct acpi_gpio_info info;
2316 struct gpio_desc *desc; 2317 struct gpio_desc *desc;
@@ -2320,13 +2321,14 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
2320 return desc; 2321 return desc;
2321 2322
2322 if (info.gpioint && info.active_low) 2323 if (info.gpioint && info.active_low)
2323 *flags |= GPIOF_ACTIVE_LOW; 2324 *flags |= GPIO_ACTIVE_LOW;
2324 2325
2325 return desc; 2326 return desc;
2326} 2327}
2327 2328
2328static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, 2329static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
2329 unsigned int idx, unsigned long *flags) 2330 unsigned int idx,
2331 enum gpio_lookup_flags *flags)
2330{ 2332{
2331 const char *dev_id = dev ? dev_name(dev) : NULL; 2333 const char *dev_id = dev ? dev_name(dev) : NULL;
2332 struct gpio_desc *desc = ERR_PTR(-ENODEV); 2334 struct gpio_desc *desc = ERR_PTR(-ENODEV);
@@ -2418,7 +2420,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2418{ 2420{
2419 struct gpio_desc *desc; 2421 struct gpio_desc *desc;
2420 int status; 2422 int status;
2421 unsigned long flags = 0; 2423 enum gpio_lookup_flags flags = 0;
2422 2424
2423 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id); 2425 dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
2424 2426
@@ -2444,8 +2446,12 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2444 if (status < 0) 2446 if (status < 0)
2445 return ERR_PTR(status); 2447 return ERR_PTR(status);
2446 2448
2447 if (flags & GPIOF_ACTIVE_LOW) 2449 if (flags & GPIO_ACTIVE_LOW)
2448 set_bit(FLAG_ACTIVE_LOW, &desc->flags); 2450 set_bit(FLAG_ACTIVE_LOW, &desc->flags);
2451 if (flags & GPIO_OPEN_DRAIN)
2452 set_bit(FLAG_OPEN_DRAIN, &desc->flags);
2453 if (flags & GPIO_OPEN_SOURCE)
2454 set_bit(FLAG_OPEN_SOURCE, &desc->flags);
2449 2455
2450 return desc; 2456 return desc;
2451} 2457}