From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91C0432B10E for ; Thu, 13 Aug 2026 19:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786649840; cv=none; b=haTtWBXTBFNqEX8xkKOZmi8Log9LaddtQg4N6EFJcgdtYVSMDc1sK4ePYy4jvlF1IppOHB3dIoCgTQcUVP+QqBrUb4o5ot5bpW6ipz6W9zGFgRRwvFYrxAJLQi4Y8LFpnDUrBeBtOLcJEFRZr3KexLj+gU9IIiARvam9dfVuecI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786649840; c=relaxed/simple; bh=M0G3UV1JbqiwQ650LFdITg4eH6f5K1JQWX3e8Dje1cE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H7WTR8CHfl3cAcPNkxqcrm9bLlX2tgYJXFUQCfdl+XWQeL5t3UWbvu2tpr6zD0u0/A7PJhyO3EgvQxrLOdVYmP0KOqWHycjnd5jGMCB4EE6uZQJ0v7EzhJGhtlFsct3OVDwy4/c/dJpTwtd19CwwJfnY/GyxQyPEq0jR3/YN5TI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=duPioNVi; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="duPioNVi" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-476a130c138so196265f8f.0 for ; Thu, 13 Aug 2026 12:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786649837; x=1787254637; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YFt1IecK8st5prTppevSftNtM7IlSZTpN3UQhYTd790=; b=duPioNVic68IjTR0fgW49SSKqpSiCzCpt1G4R8aCrhBsTHsGEl0ZGuqT7cVXOxtbX6 httzLj4y3wL73fwtLvAqIYxghe0s1eRtALUKQEe/w5V0AmDj7gmuBS9OZ1TPaaQvSl4U faArLFAuXpC7v6+/iCqtZfkuerx1ubjZbZpFgAanBZ06Je0St+VU02Zdtg++hSaNK2B7 +ZcbrCGWc8HJGjtTwiWtQRnYKFYqqzGNZ5kOpt1adwPFKUd3QE97a1bwjI0jGB1/I7aC ZrbyEtyG7FmePz5Xw6L9fPlAKhCAuUUrz9hK+3LsnhAzUPdSSgRyj+kOuPLFswYKZo67 GTCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786649837; x=1787254637; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YFt1IecK8st5prTppevSftNtM7IlSZTpN3UQhYTd790=; b=SC6cHMPmklR79V+zABh59plD2CSSt3hpH9sC6bcpKuHb1J8YHdfSGFI4o0UoegkGoH lU3HzidqLSvzqMIqtihcQQv7D3tC3lg+dL6FMb7XDdyTp6gGB3nk2dhtG1xoVG8aXWzz MwtX2N/TRmdn6XOLXMZFyeeddRaV+FoSZP/6BR/qTeqsVzdaaIW+EGFbljWwoEx25KX4 v2aTrqE619itC+n6W9gFg3ZZ7ApWpok37aOHQASLJ3XOPu1umpaZkFJFlUlJuatcxGbL hAOpCroBN0lAnenQEhCxCMBiNkYaF2ifKGEd3gpFdkDwiQOLfFwuRRqgHY/ezyCjspGL hdrg== X-Forwarded-Encrypted: i=1; AHgh+RqfPzSaWB6Ec+DH01S1FL7921YtEb6sbhIhosTaPqYFRLwFfOQg8EGnYWqXoNiUBcblheOo2NjJ4cSNArk=@vger.kernel.org X-Gm-Message-State: AOJu0YzkchpxvHFEPRc9dP3rDWuJQksuhKJIi7G1lp+3gDoriIKqItRM 8cz1o56IIar86HtjscgzvWH4s7x80xmHopMeZXVH8Pj15vYc++XN0PBD X-Gm-Gg: AR+sD12J0bk610mZziC4sKxWR143Rgi6aSYEzUm9fUK3+mhZ2vXhjtYxY2JNIIbGy7B TufMjZ2qna6kZERhqqBQjy43H11dRgrNYMr7e21xl3ag5gOZOzy0DWN2vJleROwA1W8rrzAziz8 RMs7d5/SgBXmfH4jHj4J7N6BpJukqjbeEg2KWV/knwtHWDCwG+Cj1IHKEmxk8a87Wg0MYsctno/ canrNzXBFvgU45K7YmBhbPYTzlXn4if/u6NMDWiFV87HwWPv96IP4vbugJKLzeTfBCuLnRHmrxK Xu+omMssF8zyk6QD0vSH+woWoj/33np8NNpFE31aLYisYApIOEZ7CmFTejO/+7Nd070WKeKWabh wLnje8LTzqKP+jxoau0SwCDUfTMOK4wvQgmr1iOnxxU0YdBmlSFVsrrypcFv/kQH/koZJ1hOGrc YTZ6QM/T2Ba/L5k9KQhZFscqB6BiMFoq+LTmU4+gK2Vd0z/Deenu0mv7OWyqSEMTgS8A== X-Received: by 2002:a05:6000:230f:b0:47f:f1ab:9075 with SMTP id ffacd0b85a97d-4816074ccd8mr713187f8f.20.1786649836773; Thu, 13 Aug 2026 12:37:16 -0700 (PDT) Received: from deb05.proceq.com ([213.160.61.66]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4815f20059asm1530370f8f.5.2026.08.13.12.37.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2026 12:37:16 -0700 (PDT) From: Mehmet Fide To: Bartosz Golaszewski , Linus Walleij Cc: Christophe Leroy , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Mehmet Fide Subject: [PATCH] gpiolib: return quietly from gpiod_get_direction() without .get_direction() Date: Thu, 13 Aug 2026 21:37:15 +0200 Message-ID: <20260813193715.2346477-1-mehmet.fide@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mehmet Fide Since commit 471e998c0e31 ("gpiolib: remove redundant callback check") gpiod_get_direction() lets gpiochip_get_direction() WARN when the controller does not implement .get_direction(). Callers of the public API have no way to check for the callback themselves, so any of them hitting such a controller now produces a backtrace. One reachable case is the i2c generic GPIO bus recovery: i2c_register_adapter() calls gpiod_get_direction() on the SDA line, and on a Vybrid VF500 (gpio-vf610 has no .get_direction(), the pad direction lives in the iomuxc, not in the GPIO block) every i2c adapter probe logs WARNING: drivers/gpio/gpiolib.c:431 at gpiod_get_direction+0x16c/0x19c ... gpiod_get_direction from i2c_register_adapter+0x5bc/0x7f4 i2c_register_adapter from i2c_imx_probe+0x3fc/0x6a0 Commit d761c7e38a00 ("gpiolib: Check gc->get_direction() before calling gpiod_get_direction()") already shields the debugfs dump the same way. Do it once inside gpiod_get_direction() instead, and return -EOPNOTSUPP quietly, which restores the pre-471e998c0e31 behavior for external callers. Tested on a Colibri VF50: the boot log goes from 21 identical backtraces to none, and the i2c recovery init degrades exactly as before, by skipping set_sda. Fixes: 471e998c0e31 ("gpiolib: remove redundant callback check") Signed-off-by: Mehmet Fide --- drivers/gpio/gpiolib.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c433a095907f..ad9740a3b42d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -464,6 +464,14 @@ int gpiod_get_direction(struct gpio_desc *desc) if (!guard.gc) return -ENODEV; + /* + * Callers of the public API cannot know whether the controller + * implements .get_direction(), so bail out quietly instead of + * letting gpiochip_get_direction() WARN on them. + */ + if (!guard.gc->get_direction) + return -EOPNOTSUPP; + offset = gpiod_hwgpio(desc); flags = READ_ONCE(desc->flags); -- 2.54.0