gpiolib: Provide helper macros for logging of GPIO events
Currently many but not all GPIO log messages log the GPIO number and the formats vary. Ensure that this is done consistently by defining logging helpers which take the GPIO descriptor. The will help people pattern matching on logs and providing the number makes the log messages that omitted it more useful. Signed-off-by: Mark Brown <broonie@linaro.org> Acked-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Родитель
c27769ef6e
Коммит
6424de5af1
|
@ -102,6 +102,18 @@ static int gpiod_export_link(struct device *dev, const char *name,
|
||||||
static int gpiod_sysfs_set_active_low(struct gpio_desc *desc, int value);
|
static int gpiod_sysfs_set_active_low(struct gpio_desc *desc, int value);
|
||||||
static void gpiod_unexport(struct gpio_desc *desc);
|
static void gpiod_unexport(struct gpio_desc *desc);
|
||||||
|
|
||||||
|
#define gpiod_emerg(desc, fmt, ...) \
|
||||||
|
pr_emerg("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
|
||||||
|
#define gpiod_crit(desc, fmt, ...) \
|
||||||
|
pr_crit("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
|
||||||
|
#define gpiod_err(desc, fmt, ...) \
|
||||||
|
pr_err("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
|
||||||
|
#define gpiod_warn(desc, fmt, ...) \
|
||||||
|
pr_warn("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
|
||||||
|
#define gpiod_info(desc, fmt, ...) \
|
||||||
|
pr_info("gpio-%d: " fmt, desc_to_gpio(desc), ##__VA_ARGS__)
|
||||||
|
#define gpiod_dbg(desc, fmt, ...) \
|
||||||
|
pr_debug("gpio-%d: " fmt, desc_to_gpio(desc), ##__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)
|
||||||
{
|
{
|
||||||
|
@ -1635,8 +1647,9 @@ static int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
|
|
||||||
chip = desc->chip;
|
chip = desc->chip;
|
||||||
if (!chip->get || !chip->direction_input) {
|
if (!chip->get || !chip->direction_input) {
|
||||||
pr_warn("%s: missing get() or direction_input() operations\n",
|
gpiod_warn(desc,
|
||||||
__func__);
|
"%s: missing get() or direction_input() operations\n",
|
||||||
|
__func__);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1656,8 +1669,7 @@ static int gpiod_direction_input(struct gpio_desc *desc)
|
||||||
if (status) {
|
if (status) {
|
||||||
status = chip->request(chip, offset);
|
status = chip->request(chip, offset);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
pr_debug("GPIO-%d: chip request fail, %d\n",
|
gpiod_dbg(desc, "chip request fail, %d\n", status);
|
||||||
desc_to_gpio(desc), status);
|
|
||||||
/* and it's not available to anyone else ...
|
/* and it's not available to anyone else ...
|
||||||
* gpio_request() is the fully clean solution.
|
* gpio_request() is the fully clean solution.
|
||||||
*/
|
*/
|
||||||
|
@ -1675,8 +1687,7 @@ lose:
|
||||||
fail:
|
fail:
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
if (status)
|
if (status)
|
||||||
pr_debug("%s: gpio-%d status %d\n", __func__,
|
gpiod_dbg(desc, "%s status %d\n", __func__, status);
|
||||||
desc_to_gpio(desc), status);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1708,8 +1719,9 @@ static int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||||
|
|
||||||
chip = desc->chip;
|
chip = desc->chip;
|
||||||
if (!chip->set || !chip->direction_output) {
|
if (!chip->set || !chip->direction_output) {
|
||||||
pr_warn("%s: missing set() or direction_output() operations\n",
|
gpiod_warn(desc,
|
||||||
__func__);
|
"%s: missing set() or direction_output() operations\n",
|
||||||
|
__func__);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1729,8 +1741,7 @@ static int gpiod_direction_output(struct gpio_desc *desc, int value)
|
||||||
if (status) {
|
if (status) {
|
||||||
status = chip->request(chip, offset);
|
status = chip->request(chip, offset);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
pr_debug("GPIO-%d: chip request fail, %d\n",
|
gpiod_dbg(desc, "chip request fail, %d\n", status);
|
||||||
desc_to_gpio(desc), status);
|
|
||||||
/* and it's not available to anyone else ...
|
/* and it's not available to anyone else ...
|
||||||
* gpio_request() is the fully clean solution.
|
* gpio_request() is the fully clean solution.
|
||||||
*/
|
*/
|
||||||
|
@ -1748,8 +1759,7 @@ lose:
|
||||||
fail:
|
fail:
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
if (status)
|
if (status)
|
||||||
pr_debug("%s: gpio-%d status %d\n", __func__,
|
gpiod_dbg(desc, "%s: gpio status %d\n", __func__, status);
|
||||||
desc_to_gpio(desc), status);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1781,8 +1791,9 @@ static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
|
||||||
|
|
||||||
chip = desc->chip;
|
chip = desc->chip;
|
||||||
if (!chip->set || !chip->set_debounce) {
|
if (!chip->set || !chip->set_debounce) {
|
||||||
pr_debug("%s: missing set() or set_debounce() operations\n",
|
gpiod_dbg(desc,
|
||||||
__func__);
|
"%s: missing set() or set_debounce() operations\n",
|
||||||
|
__func__);
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1804,8 +1815,7 @@ static int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce)
|
||||||
fail:
|
fail:
|
||||||
spin_unlock_irqrestore(&gpio_lock, flags);
|
spin_unlock_irqrestore(&gpio_lock, flags);
|
||||||
if (status)
|
if (status)
|
||||||
pr_debug("%s: gpio-%d status %d\n", __func__,
|
gpiod_dbg(desc, "%s: status %d\n", __func__, status);
|
||||||
desc_to_gpio(desc), status);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1893,8 +1903,9 @@ static void _gpio_set_open_drain_value(struct gpio_desc *desc, int value)
|
||||||
}
|
}
|
||||||
trace_gpio_direction(desc_to_gpio(desc), value, err);
|
trace_gpio_direction(desc_to_gpio(desc), value, err);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
pr_err("%s: Error in set_value for open drain gpio%d err %d\n",
|
gpiod_err(desc,
|
||||||
__func__, desc_to_gpio(desc), err);
|
"%s: Error in set_value for open drain err %d\n",
|
||||||
|
__func__, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1920,8 +1931,9 @@ static void _gpio_set_open_source_value(struct gpio_desc *desc, int value)
|
||||||
}
|
}
|
||||||
trace_gpio_direction(desc_to_gpio(desc), !value, err);
|
trace_gpio_direction(desc_to_gpio(desc), !value, err);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
pr_err("%s: Error in set_value for open source gpio%d err %d\n",
|
gpiod_err(desc,
|
||||||
__func__, desc_to_gpio(desc), err);
|
"%s: Error in set_value for open source err %d\n",
|
||||||
|
__func__, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Загрузка…
Ссылка в новой задаче