aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2014-07-01 01:45:14 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-07-09 06:22:57 -0400
commit9c8318ff7041c8024e3afa22ce77e208138f1da5 (patch)
treef497d0096efe04e72777d5cec8f8f3e5143666d9 /drivers/gpio/gpiolib.c
parenta0e827c68d9c159bc028851061e21b4f73aeeef4 (diff)
gpio: always compile label support
Compiling out GPIO labels results in a space gain so small that it can hardly be justified. Labels can also be useful for printing debug messages, so always keep them around. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c27
1 files changed, 2 insertions, 25 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2ebc9071e354..8ba9dbedcfdf 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -66,9 +66,7 @@ struct gpio_desc {
66#define GPIO_FLAGS_MASK ((1 << ID_SHIFT) - 1) 66#define GPIO_FLAGS_MASK ((1 << ID_SHIFT) - 1)
67#define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE)) 67#define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE))
68 68
69#ifdef CONFIG_DEBUG_FS
70 const char *label; 69 const char *label;
71#endif
72}; 70};
73static struct gpio_desc gpio_desc[ARCH_NR_GPIOS]; 71static struct gpio_desc gpio_desc[ARCH_NR_GPIOS];
74 72
@@ -87,7 +85,6 @@ static void gpiod_free(struct gpio_desc *desc);
87 85
88/* With descriptor prefix */ 86/* With descriptor prefix */
89 87
90#ifdef CONFIG_DEBUG_FS
91#define gpiod_emerg(desc, fmt, ...) \ 88#define gpiod_emerg(desc, fmt, ...) \
92 pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ 89 pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
93 ##__VA_ARGS__) 90 ##__VA_ARGS__)
@@ -106,20 +103,6 @@ static void gpiod_free(struct gpio_desc *desc);
106#define gpiod_dbg(desc, fmt, ...) \ 103#define gpiod_dbg(desc, fmt, ...) \
107 pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ 104 pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
108 ##__VA_ARGS__) 105 ##__VA_ARGS__)
109#else
110#define gpiod_emerg(desc, fmt, ...) \
111 pr_emerg("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
112#define gpiod_crit(desc, fmt, ...) \
113 pr_crit("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
114#define gpiod_err(desc, fmt, ...) \
115 pr_err("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
116#define gpiod_warn(desc, fmt, ...) \
117 pr_warn("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
118#define gpiod_info(desc, fmt, ...) \
119 pr_info("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
120#define gpiod_dbg(desc, fmt, ...) \
121 pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
122#endif
123 106
124/* With chip prefix */ 107/* With chip prefix */
125 108
@@ -138,9 +121,7 @@ static void gpiod_free(struct gpio_desc *desc);
138 121
139static inline void desc_set_label(struct gpio_desc *d, const char *label) 122static inline void desc_set_label(struct gpio_desc *d, const char *label)
140{ 123{
141#ifdef CONFIG_DEBUG_FS
142 d->label = label; 124 d->label = label;
143#endif
144} 125}
145 126
146/* 127/*
@@ -1906,8 +1887,8 @@ EXPORT_SYMBOL_GPL(gpio_free_array);
1906 * @offset: of signal within controller's 0..(ngpio - 1) range 1887 * @offset: of signal within controller's 0..(ngpio - 1) range
1907 * 1888 *
1908 * Returns NULL if the GPIO is not currently requested, else a string. 1889 * Returns NULL if the GPIO is not currently requested, else a string.
1909 * If debugfs support is enabled, the string returned is the label passed 1890 * The string returned is the label passed to gpio_request(); if none has been
1910 * to gpio_request(); otherwise it is a meaningless constant. 1891 * passed it is a meaningless, non-NULL constant.
1911 * 1892 *
1912 * This function is for use by GPIO controller drivers. The label can 1893 * This function is for use by GPIO controller drivers. The label can
1913 * help with diagnostics, and knowing that the signal is used as a GPIO 1894 * help with diagnostics, and knowing that the signal is used as a GPIO
@@ -1924,11 +1905,7 @@ const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
1924 1905
1925 if (test_bit(FLAG_REQUESTED, &desc->flags) == 0) 1906 if (test_bit(FLAG_REQUESTED, &desc->flags) == 0)
1926 return NULL; 1907 return NULL;
1927#ifdef CONFIG_DEBUG_FS
1928 return desc->label; 1908 return desc->label;
1929#else
1930 return "?";
1931#endif
1932} 1909}
1933EXPORT_SYMBOL_GPL(gpiochip_is_requested); 1910EXPORT_SYMBOL_GPL(gpiochip_is_requested);
1934 1911