Commit 1a2a99c6 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarAlexandre Courbot <acourbot@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 7589e59f
...@@ -84,6 +84,8 @@ static DEFINE_IDR(dirent_idr); ...@@ -84,6 +84,8 @@ static DEFINE_IDR(dirent_idr);
static int gpiod_request(struct gpio_desc *desc, const char *label); static int gpiod_request(struct gpio_desc *desc, const char *label);
static void gpiod_free(struct gpio_desc *desc); static void gpiod_free(struct gpio_desc *desc);
/* With descriptor prefix */
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
#define gpiod_emerg(desc, fmt, ...) \ #define gpiod_emerg(desc, fmt, ...) \
pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ 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,6 +120,21 @@ static void gpiod_free(struct gpio_desc *desc);
pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__) pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
#endif #endif
/* With chip prefix */
#define chip_emerg(chip, fmt, ...) \
pr_emerg("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
#define chip_crit(chip, fmt, ...) \
pr_crit("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
#define chip_err(chip, fmt, ...) \
pr_err("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
#define chip_warn(chip, fmt, ...) \
pr_warn("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
#define chip_info(chip, fmt, ...) \
pr_info("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
#define chip_dbg(chip, fmt, ...) \
pr_debug("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
static inline void desc_set_label(struct gpio_desc *d, const char *label) static inline void desc_set_label(struct gpio_desc *d, const char *label)
{ {
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -1032,8 +1049,7 @@ static int gpiochip_export(struct gpio_chip *chip) ...@@ -1032,8 +1049,7 @@ static int gpiochip_export(struct gpio_chip *chip)
chip->desc[gpio++].chip = NULL; chip->desc[gpio++].chip = NULL;
spin_unlock_irqrestore(&gpio_lock, flags); spin_unlock_irqrestore(&gpio_lock, flags);
pr_debug("%s: chip %s status %d\n", __func__, chip_dbg(chip, "%s: status %d\n", __func__, status);
chip->label, status);
} }
return status; return status;
...@@ -1056,8 +1072,7 @@ static void gpiochip_unexport(struct gpio_chip *chip) ...@@ -1056,8 +1072,7 @@ static void gpiochip_unexport(struct gpio_chip *chip)
mutex_unlock(&sysfs_lock); mutex_unlock(&sysfs_lock);
if (status) if (status)
pr_debug("%s: chip %s status %d\n", __func__, chip_dbg(chip, "%s: status %d\n", __func__, status);
chip->label, status);
} }
static int __init gpiolib_sysfs_init(void) static int __init gpiolib_sysfs_init(void)
...@@ -1337,8 +1352,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, ...@@ -1337,8 +1352,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip,
pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL);
if (!pin_range) { if (!pin_range) {
pr_err("%s: GPIO chip: failed to allocate pin ranges\n", chip_err(chip, "failed to allocate pin ranges\n");
chip->label);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1359,9 +1373,8 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, ...@@ -1359,9 +1373,8 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip,
pinctrl_add_gpio_range(pctldev, &pin_range->range); pinctrl_add_gpio_range(pctldev, &pin_range->range);
pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PINGRP %s\n", chip_dbg(chip, "created GPIO range %d->%d ==> %s PINGRP %s\n",
chip->label, gpio_offset, gpio_offset, gpio_offset + pin_range->range.npins - 1,
gpio_offset + pin_range->range.npins - 1,
pinctrl_dev_get_devname(pctldev), pin_group); pinctrl_dev_get_devname(pctldev), pin_group);
list_add_tail(&pin_range->node, &chip->pin_ranges); 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,8 +1401,7 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL); pin_range = kzalloc(sizeof(*pin_range), GFP_KERNEL);
if (!pin_range) { if (!pin_range) {
pr_err("%s: GPIO chip: failed to allocate pin ranges\n", chip_err(chip, "failed to allocate pin ranges\n");
chip->label);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1404,13 +1416,12 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, ...@@ -1404,13 +1416,12 @@ int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name,
&pin_range->range); &pin_range->range);
if (IS_ERR(pin_range->pctldev)) { if (IS_ERR(pin_range->pctldev)) {
ret = PTR_ERR(pin_range->pctldev); ret = PTR_ERR(pin_range->pctldev);
pr_err("%s: GPIO chip: could not create pin range\n", chip_err(chip, "could not create pin range\n");
chip->label);
kfree(pin_range); kfree(pin_range);
return ret; return ret;
} }
pr_debug("GPIO chip %s: created GPIO range %d->%d ==> %s PIN %d->%d\n", chip_dbg(chip, "created GPIO range %d->%d ==> %s PIN %d->%d\n",
chip->label, gpio_offset, gpio_offset + npins - 1, gpio_offset, gpio_offset + npins - 1,
pinctl_name, pinctl_name,
pin_offset, pin_offset + npins - 1); pin_offset, pin_offset + npins - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment