aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-05-20 02:40:19 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-05-20 02:40:19 -0400
commit3f397c2144e46d9127662fdb6314f21960d8563d (patch)
treeef3401a6ac7e3b394ec10a1c586f5c1949b23edb /drivers/gpio
parentcc300d9ead66235e23c674babb8a4ae4ad4c9db8 (diff)
gpio: add trace events for setting direction and value
This patch allows to trace gpio operations using ftrace Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c27e52b56d6..137a8ca6782 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 *
@@ -1405,6 +1407,8 @@ int gpio_direction_input(unsigned gpio)
1405 status = chip->direction_input(chip, gpio); 1407 status = chip->direction_input(chip, gpio);
1406 if (status == 0) 1408 if (status == 0)
1407 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);
1408lose: 1412lose:
1409 return status; 1413 return status;
1410fail: 1414fail:
@@ -1458,6 +1462,8 @@ int gpio_direction_output(unsigned gpio, int value)
1458 status = chip->direction_output(chip, gpio, value); 1462 status = chip->direction_output(chip, gpio, value);
1459 if (status == 0) 1463 if (status == 0)
1460 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);
1461lose: 1467lose:
1462 return status; 1468 return status;
1463fail: 1469fail:
@@ -1547,10 +1553,13 @@ EXPORT_SYMBOL_GPL(gpio_set_debounce);
1547int __gpio_get_value(unsigned gpio) 1553int __gpio_get_value(unsigned gpio)
1548{ 1554{
1549 struct gpio_chip *chip; 1555 struct gpio_chip *chip;
1556 int value;
1550 1557
1551 chip = gpio_to_chip(gpio); 1558 chip = gpio_to_chip(gpio);
1552 WARN_ON(chip->can_sleep); 1559 WARN_ON(chip->can_sleep);
1553 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;
1554} 1563}
1555EXPORT_SYMBOL_GPL(__gpio_get_value); 1564EXPORT_SYMBOL_GPL(__gpio_get_value);
1556 1565
@@ -1569,6 +1578,7 @@ void __gpio_set_value(unsigned gpio, int value)
1569 1578
1570 chip = gpio_to_chip(gpio); 1579 chip = gpio_to_chip(gpio);
1571 WARN_ON(chip->can_sleep); 1580 WARN_ON(chip->can_sleep);
1581 trace_gpio_value(gpio, 0, value);
1572 chip->set(chip, gpio - chip->base, value); 1582 chip->set(chip, gpio - chip->base, value);
1573} 1583}
1574EXPORT_SYMBOL_GPL(__gpio_set_value); 1584EXPORT_SYMBOL_GPL(__gpio_set_value);
@@ -1619,10 +1629,13 @@ EXPORT_SYMBOL_GPL(__gpio_to_irq);
1619int gpio_get_value_cansleep(unsigned gpio) 1629int gpio_get_value_cansleep(unsigned gpio)
1620{ 1630{
1621 struct gpio_chip *chip; 1631 struct gpio_chip *chip;
1632 int value;
1622 1633
1623 might_sleep_if(extra_checks); 1634 might_sleep_if(extra_checks);
1624 chip = gpio_to_chip(gpio); 1635 chip = gpio_to_chip(gpio);
1625 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;
1626} 1639}
1627EXPORT_SYMBOL_GPL(gpio_get_value_cansleep); 1640EXPORT_SYMBOL_GPL(gpio_get_value_cansleep);
1628 1641
@@ -1632,6 +1645,7 @@ void gpio_set_value_cansleep(unsigned gpio, int value)
1632 1645
1633 might_sleep_if(extra_checks); 1646 might_sleep_if(extra_checks);
1634 chip = gpio_to_chip(gpio); 1647 chip = gpio_to_chip(gpio);
1648 trace_gpio_value(gpio, 0, value);
1635 chip->set(chip, gpio - chip->base, value); 1649 chip->set(chip, gpio - chip->base, value);
1636} 1650}
1637EXPORT_SYMBOL_GPL(gpio_set_value_cansleep); 1651EXPORT_SYMBOL_GPL(gpio_set_value_cansleep);