dm_gpio_request() returns -EBUSY when the requested offset is already
claimed, but gives no indication of which label already holds it. Any
caller going through the uclass API directly, rather than the "gpio"
command, has no way to see this at all.

Log it at dev_dbg() level: silent by default, available when actively
debugging with this device's debug output enabled.

Signed-off-by: Pranav Sanwal <[email protected]>
---

Changes in v2:
- Downgraded dev_warn() to dev_dbg(); moved the user-facing warning to
  patch 2/5 instead. (Simon)

 drivers/gpio/gpio-uclass.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 7559b8dc7e2..9451b7db4af 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -391,8 +391,11 @@ int dm_gpio_request(struct gpio_desc *desc, const char 
*label)
        int ret;
 
        uc_priv = dev_get_uclass_priv(dev);
-       if (gpio_is_claimed(uc_priv, desc->offset))
+       if (gpio_is_claimed(uc_priv, desc->offset)) {
+               dev_dbg(dev, "gpio offset %u already claimed by '%s', requested 
label '%s'\n",
+                       desc->offset, uc_priv->name[desc->offset], label);
                return -EBUSY;
+       }
        str = strdup(label);
        if (!str)
                return -ENOMEM;
-- 
2.43.7

Reply via email to