aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/gpio/gpiolib.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c71
1 files changed, 22 insertions, 49 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 21da9c19a0cb..a971e3d043ba 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -12,6 +12,8 @@
12#include <linux/idr.h> 12#include <linux/idr.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14 14
15#define CREATE_TRACE_POINTS
16#include <trace/events/gpio.h>
15 17
16/* Optional implementation infrastructure for GPIO interfaces. 18/* Optional implementation infrastructure for GPIO interfaces.
17 * 19 *
@@ -1165,6 +1167,7 @@ struct gpio_chip *gpiochip_find(void *data,
1165 1167
1166 return chip; 1168 return chip;
1167} 1169}
1170EXPORT_SYMBOL_GPL(gpiochip_find);
1168 1171
1169/* These "optional" allocation calls help prevent drivers from stomping 1172/* These "optional" allocation calls help prevent drivers from stomping
1170 * on each other, and help provide better diagnostics in debugfs. 1173 * on each other, and help provide better diagnostics in debugfs.
@@ -1281,6 +1284,9 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
1281 err = gpio_direction_output(gpio, 1284 err = gpio_direction_output(gpio,
1282 (flags & GPIOF_INIT_HIGH) ? 1 : 0); 1285 (flags & GPIOF_INIT_HIGH) ? 1 : 0);
1283 1286
1287 if (err)
1288 gpio_free(gpio);
1289
1284 return err; 1290 return err;
1285} 1291}
1286EXPORT_SYMBOL_GPL(gpio_request_one); 1292EXPORT_SYMBOL_GPL(gpio_request_one);
@@ -1290,7 +1296,7 @@ EXPORT_SYMBOL_GPL(gpio_request_one);
1290 * @array: array of the 'struct gpio' 1296 * @array: array of the 'struct gpio'
1291 * @num: how many GPIOs in the array 1297 * @num: how many GPIOs in the array
1292 */ 1298 */
1293int gpio_request_array(struct gpio *array, size_t num) 1299int gpio_request_array(const struct gpio *array, size_t num)
1294{ 1300{
1295 int i, err; 1301 int i, err;
1296 1302
@@ -1313,7 +1319,7 @@ EXPORT_SYMBOL_GPL(gpio_request_array);
1313 * @array: array of the 'struct gpio' 1319 * @array: array of the 'struct gpio'
1314 * @num: how many GPIOs in the array 1320 * @num: how many GPIOs in the array
1315 */ 1321 */
1316void gpio_free_array(struct gpio *array, size_t num) 1322void gpio_free_array(const struct gpio *array, size_t num)
1317{ 1323{
1318 while (num--) 1324 while (num--)
1319 gpio_free((array++)->gpio); 1325 gpio_free((array++)->gpio);
@@ -1401,6 +1407,8 @@ int gpio_direction_input(unsigned gpio)
1401 status = chip->direction_input(chip, gpio); 1407 status = chip->direction_input(chip, gpio);
1402 if (status == 0) 1408 if (status == 0)
1403 clear_bit(FLAG_IS_OUT, &desc->flags); 1409 clear_bit(FLAG_IS_OUT, &desc->flags);
1410
1411 trace_gpio_direction(chip->base + gpio, 1, status);
1404lose: 1412lose:
1405 return status; 1413 return status;
1406fail: 1414fail:
@@ -1454,6 +1462,8 @@ int gpio_direction_output(unsigned gpio, int value)
1454 status = chip->direction_output(chip, gpio, value); 1462 status = chip->direction_output(chip, gpio, value);
1455 if (status == 0) 1463 if (status == 0)
1456 set_bit(FLAG_IS_OUT, &desc->flags); 1464 set_bit(FLAG_IS_OUT, &desc->flags);
1465 trace_gpio_value(chip->base + gpio, 0, value);
1466 trace_gpio_direction(chip->base + gpio, 0, status);
1457lose: 1467lose:
1458 return status; 1468 return status;
1459fail: 1469fail:
@@ -1543,10 +1553,13 @@ EXPORT_SYMBOL_GPL(gpio_set_debounce);
1543int __gpio_get_value(unsigned gpio) 1553int __gpio_get_value(unsigned gpio)
1544{ 1554{
1545 struct gpio_chip *chip; 1555 struct gpio_chip *chip;
1556 int value;
1546 1557
1547 chip = gpio_to_chip(gpio); 1558 chip = gpio_to_chip(gpio);
1548 WARN_ON(chip->can_sleep); 1559 WARN_ON(chip->can_sleep);
1549 return chip->get ? chip->get(chip, gpio - chip->base) : 0; 1560 value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
1561 trace_gpio_value(gpio, 1, value);
1562 return value;
1550} 1563}
1551EXPORT_SYMBOL_GPL(__gpio_get_value); 1564EXPORT_SYMBOL_GPL(__gpio_get_value);
1552 1565
@@ -1565,6 +1578,7 @@ void __gpio_set_value(unsigned gpio, int value)
1565 1578
1566 chip = gpio_to_chip(gpio); 1579 chip = gpio_to_chip(gpio);
1567 WARN_ON(chip->can_sleep); 1580 WARN_ON(chip->can_sleep);
1581 trace_gpio_value(gpio, 0, value);
1568 chip->set(chip, gpio - chip->base, value); 1582 chip->set(chip, gpio - chip->base, value);
1569} 1583}
1570EXPORT_SYMBOL_GPL(__gpio_set_value); 1584EXPORT_SYMBOL_GPL(__gpio_set_value);
@@ -1615,10 +1629,13 @@ EXPORT_SYMBOL_GPL(__gpio_to_irq);
1615int gpio_get_value_cansleep(unsigned gpio) 1629int gpio_get_value_cansleep(unsigned gpio)
1616{ 1630{
1617 struct gpio_chip *chip; 1631 struct gpio_chip *chip;
1632 int value;
1618 1633
1619 might_sleep_if(extra_checks); 1634 might_sleep_if(extra_checks);
1620 chip = gpio_to_chip(gpio); 1635 chip = gpio_to_chip(gpio);
1621 return chip->get ? chip->get(chip, gpio - chip->base) : 0; 1636 value = chip->get ? chip->get(chip, gpio - chip->base) : 0;
1637 trace_gpio_value(gpio, 1, value);
1638 return value;
1622} 1639}
1623EXPORT_SYMBOL_GPL(gpio_get_value_cansleep); 1640EXPORT_SYMBOL_GPL(gpio_get_value_cansleep);
1624 1641
@@ -1628,6 +1645,7 @@ void gpio_set_value_cansleep(unsigned gpio, int value)
1628 1645
1629 might_sleep_if(extra_checks); 1646 might_sleep_if(extra_checks);
1630 chip = gpio_to_chip(gpio); 1647 chip = gpio_to_chip(gpio);
1648 trace_gpio_value(gpio, 0, value);
1631 chip->set(chip, gpio - chip->base, value); 1649 chip->set(chip, gpio - chip->base, value);
1632} 1650}
1633EXPORT_SYMBOL_GPL(gpio_set_value_cansleep); 1651EXPORT_SYMBOL_GPL(gpio_set_value_cansleep);
@@ -1653,51 +1671,6 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
1653 chip->get 1671 chip->get
1654 ? (chip->get(chip, i) ? "hi" : "lo") 1672 ? (chip->get(chip, i) ? "hi" : "lo")
1655 : "? "); 1673 : "? ");
1656
1657 if (!is_out) {
1658 int irq = gpio_to_irq(gpio);
1659 struct irq_desc *desc = irq_to_desc(irq);
1660
1661 /* This races with request_irq(), set_irq_type(),
1662 * and set_irq_wake() ... but those are "rare".
1663 *
1664 * More significantly, trigger type flags aren't
1665 * currently maintained by genirq.
1666 */
1667 if (irq >= 0 && desc->action) {
1668 char *trigger;
1669
1670 switch (desc->status & IRQ_TYPE_SENSE_MASK) {
1671 case IRQ_TYPE_NONE:
1672 trigger = "(default)";
1673 break;
1674 case IRQ_TYPE_EDGE_FALLING:
1675 trigger = "edge-falling";
1676 break;
1677 case IRQ_TYPE_EDGE_RISING:
1678 trigger = "edge-rising";
1679 break;
1680 case IRQ_TYPE_EDGE_BOTH:
1681 trigger = "edge-both";
1682 break;
1683 case IRQ_TYPE_LEVEL_HIGH:
1684 trigger = "level-high";
1685 break;
1686 case IRQ_TYPE_LEVEL_LOW:
1687 trigger = "level-low";
1688 break;
1689 default:
1690 trigger = "?trigger?";
1691 break;
1692 }
1693
1694 seq_printf(s, " irq-%d %s%s",
1695 irq, trigger,
1696 (desc->status & IRQ_WAKEUP)
1697 ? " wakeup" : "");
1698 }
1699 }
1700
1701 seq_printf(s, "\n"); 1674 seq_printf(s, "\n");
1702 } 1675 }
1703} 1676}