aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpio/gpiolib.c18
-rw-r--r--include/trace/events/gpio.h56
2 files changed, 72 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c27e52b56d66..137a8ca67822 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);
diff --git a/include/trace/events/gpio.h b/include/trace/events/gpio.h
new file mode 100644
index 000000000000..927a8ad9e51b
--- /dev/null
+++ b/include/trace/events/gpio.h
@@ -0,0 +1,56 @@
1#undef TRACE_SYSTEM
2#define TRACE_SYSTEM gpio
3
4#if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
5#define _TRACE_GPIO_H
6
7#include <linux/tracepoint.h>
8
9TRACE_EVENT(gpio_direction,
10
11 TP_PROTO(unsigned gpio, int in, int err),
12
13 TP_ARGS(gpio, in, err),
14
15 TP_STRUCT__entry(
16 __field(unsigned, gpio)
17 __field(int, in)
18 __field(int, err)
19 ),
20
21 TP_fast_assign(
22 __entry->gpio = gpio;
23 __entry->in = in;
24 __entry->err = err;
25 ),
26
27 TP_printk("%u %3s (%d)", __entry->gpio,
28 __entry->in ? "in" : "out", __entry->err)
29);
30
31TRACE_EVENT(gpio_value,
32
33 TP_PROTO(unsigned gpio, int get, int value),
34
35 TP_ARGS(gpio, get, value),
36
37 TP_STRUCT__entry(
38 __field(unsigned, gpio)
39 __field(int, get)
40 __field(int, value)
41 ),
42
43 TP_fast_assign(
44 __entry->gpio = gpio;
45 __entry->get = get;
46 __entry->value = value;
47 ),
48
49 TP_printk("%u %3s %d", __entry->gpio,
50 __entry->get ? "get" : "set", __entry->value)
51);
52
53#endif /* if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ) */
54
55/* This part must be outside protection */
56#include <trace/define_trace.h>