diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-12-05 04:26:24 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-12-09 08:17:21 -0500 |
commit | 1a2a99c69eaea30da25dede555a3d70d7a412ae2 (patch) | |
tree | 112a51fa43253f2edd49c4a99554f44c2ff4f050 /drivers/gpio/gpiolib.c | |
parent | 7589e59fc0be799fed069591b83d0e57f11058cc (diff) |
gpiolib: introduce chip_* to print with chip->label prefix
In several places we are printing messages with prefix based on chip->label.
Introduced macros help us to do this easier and in uniform way.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-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.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 2dc3657e99ba..30ae38681fef 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -84,6 +84,8 @@ static DEFINE_IDR(dirent_idr); | |||
84 | static int gpiod_request(struct gpio_desc *desc, const char *label); | 84 | static int gpiod_request(struct gpio_desc *desc, const char *label); |
85 | static void gpiod_free(struct gpio_desc *desc); | 85 | static void gpiod_free(struct gpio_desc *desc); |
86 | 86 | ||
87 | /* With descriptor prefix */ | ||
88 | |||
87 | #ifdef CONFIG_DEBUG_FS | 89 | #ifdef CONFIG_DEBUG_FS |
88 | #define gpiod_emerg(desc, fmt, ...) \ | 90 | #define gpiod_emerg(desc, fmt, ...) \ |
89 | pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ | 91 | pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ |
@@ -118,6 +120,21 @@ static void gpiod_free(struct gpio_desc *desc); | |||
118 | pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) | 120 | pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) |
119 | #endif | 121 | #endif |
120 | 122 | ||
123 | /* With chip prefix */ | ||
124 | |||
125 | #define chip_emerg(chip, fmt, ...) \ | ||
126 | pr_emerg("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
127 | #define chip_crit(chip, fmt, ...) \ | ||
128 | pr_crit("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
129 | #define chip_err(chip, fmt, ...) \ | ||
130 | pr_err("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
131 | #define chip_warn(chip, fmt, ...) \ | ||
132 | pr_warn("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
133 | #define chip_info(chip, fmt, ...) \ | ||
134 | pr_info("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
135 | #define chip_dbg(chip, fmt, ...) \ | ||
136 | pr_debug("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__) | ||
137 | |||
121 | static inline void desc_set_label(struct gpio_desc *d, const char *label) | 138 | static inline void desc_set_label(struct gpio_desc *d, const char *label) |
122 | { | 139 | { |
123 | #ifdef CONFIG_DEBUG_FS | 140 | #ifdef CONFIG_DEBUG_FS |
@@ -1032,8 +1049,7 @@ static int gpiochip_export(struct gpio_chip *chip) | |||
1032 | chip->desc[gpio++].chip = NULL; | 1049 | chip->desc[gpio++].chip = NULL; |
1033 | spin_unlock_irqrestore(&gpio_lock, flags); | 1050 | spin_unlock_irqrestore(&gpio_lock, flags); |
1034 | 1051 | ||
1035 | pr_debug("%s: chip %s status %d\n", __func__, | 1052 | chip_dbg(chip, "%s: status %d\n", __func__, status); |
1036 | chip->label, status); | ||
1037 | } | 1053 | } |
1038 | 1054 | ||
1039 | return status; | 1055 | return status; |
@@ -1056,8 +1072,7 @@ static void gpiochip_unexport(struct gpio_chip *chip) | |||
1056 | mutex_unlock(&sysfs_lock); | 1072 | mutex_unlock(&sysfs_lock); |
1057 | 1073 | ||
1058 | if (status) | 1074 | if (status) |
1059 | pr_debug("%s: chip %s status %d\n", __func__, | 1075 | chip_dbg(chip, "%s: status %d\n", __func__, status); |
1060 | chip->label, status); | ||
1061 | } | 1076 | } |
1062 | 1077 | ||
1063 | static int __init gpiolib_sysfs_init(void) | 1078 | static int __init gpiolib_sysfs_init(void) |
@@ -1337,8 +1352,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, | |||
1337 | 1352 | ||
1338 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); | 1353 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); |
1339 | if (!pin_range) { | 1354 | if (!pin_range) { |
1340 | pr_err("%s: GPIO chip: failed to allocate pin ranges\n", | 1355 | chip_err(chip, "failed to allocate pin ranges\n"); |
1341 | chip->label); | ||
1342 | return -ENOMEM; | 1356 | return -ENOMEM; |
1343 | } | 1357 | } |
1344 | 1358 | ||
@@ -1359,9 +1373,8 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, | |||
1359 | 1373 | ||
1360 | pinctrl_add_gpio_range(pctldev, &pin_range->range); | 1374 | pinctrl_add_gpio_range(pctldev, &pin_range->range); |
1361 | 1375 | ||
1362 | pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PINGRP %s\n", | 1376 | chip_dbg(chip, "created GPIO range %d->%d ==> %s PINGRP %s\n", |
1363 | chip->label, gpio_offset, | 1377 | gpio_offset, gpio_offset + pin_range->range.npins - 1, |
1364 | gpio_offset + pin_range->range.npins - 1, | ||
1365 | pinctrl_dev_get_devname(pctldev), pin_group); | 1378 | pinctrl_dev_get_devname(pctldev), pin_group); |
1366 | 1379 | ||
1367 | list_add_tail(&pin_range->node, &chip->pin_ranges); | 1380 | list_add_tail(&pin_range->node, &chip->pin_ranges); |
@@ -1388,8 +1401,7 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | |||
1388 | 1401 | ||
1389 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); | 1402 | pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); |
1390 | if (!pin_range) { | 1403 | if (!pin_range) { |
1391 | pr_err("%s: GPIO chip: failed to allocate pin ranges\n", | 1404 | chip_err(chip, "failed to allocate pin ranges\n"); |
1392 | chip->label); | ||
1393 | return -ENOMEM; | 1405 | return -ENOMEM; |
1394 | } | 1406 | } |
1395 | 1407 | ||
@@ -1404,13 +1416,12 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | |||
1404 | &pin_range->range); | 1416 | &pin_range->range); |
1405 | if (IS_ERR(pin_range->pctldev)) { | 1417 | if (IS_ERR(pin_range->pctldev)) { |
1406 | ret = PTR_ERR(pin_range->pctldev); | 1418 | ret = PTR_ERR(pin_range->pctldev); |
1407 | pr_err("%s: GPIO chip: could not create pin range\n", | 1419 | chip_err(chip, "could not create pin range\n"); |
1408 | chip->label); | ||
1409 | kfree(pin_range); | 1420 | kfree(pin_range); |
1410 | return ret; | 1421 | return ret; |
1411 | } | 1422 | } |
1412 | pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PIN %d->%d\n", | 1423 | chip_dbg(chip, "created GPIO range %d->%d ==> %s PIN %d->%d\n", |
1413 | chip->label, gpio_offset, gpio_offset + npins - 1, | 1424 | gpio_offset, gpio_offset + npins - 1, |
1414 | pinctl_name, | 1425 | pinctl_name, |
1415 | pin_offset, pin_offset + npins - 1); | 1426 | pin_offset, pin_offset + npins - 1); |
1416 | 1427 | ||