From patchwork Thu Apr 25 13:58:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?L=C3=A9o_DUBOIN?= X-Patchwork-Id: 792136 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 D33301494BB for ; Thu, 25 Apr 2024 13:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053589; cv=none; b=tMDnGmGvVERqmCJTPbos0pf31dkehIxJ4l8whEyHGX+pIvPbDgJaSwbPuR690SBlVscjdQf/LQD1ymgktmrCw81wPiHF0wRowJD2xPskJObw3YCt/HlGfzM4p6M94owFs4mKc6W6xom65CULNtaT/j6yOnS+L4yLvIXWnK/hegY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053589; c=relaxed/simple; bh=KbpZ8d+RgwRLaIMQKqSigv1pMFc5n3ynVMEzJAYBd0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Avq9HiJWmvaI4Dlvd40jB88CSKxgbs9aAgwPf9vFyyWZttsHvojPAH9Bd1UFfLl2Zg/8Y+IrS2bpPi2lAcaUQJ36VFQqoeWLUmlV7jJ4fffgNT1X6FQuDP7i+ewqBNz1DDxP+CA7tJUprl+vjy/chtfuDyn371hs576j9QIK5MY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freebox.fr; spf=pass smtp.mailfrom=freebox.fr; dkim=pass (2048-bit key) header.d=freebox-fr.20230601.gappssmtp.com header.i=@freebox-fr.20230601.gappssmtp.com header.b=NRgp8HGU; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freebox.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freebox.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freebox-fr.20230601.gappssmtp.com header.i=@freebox-fr.20230601.gappssmtp.com header.b="NRgp8HGU" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-41b56838250so4570685e9.2 for ; Thu, 25 Apr 2024 06:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebox-fr.20230601.gappssmtp.com; s=20230601; t=1714053585; x=1714658385; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LR5Th4rgsENBGC1XHGIaoOrv3KgiGLQWWbPFYgnaOZw=; b=NRgp8HGUleo4R2R34dIp8M961Lo6v72fpysxICs9WvOaGeFSK+YeZQUQYXpQq/qRBo KURk57Udb+3Jcntf8mGanubEU2y8KPx/3LVeq1vNXztSZ+T7wAf4p5/OMWd0wGjFv90x ZbIXAjSjacCrVG2AxDBKMRv7Kt2zbsZJtwtkko7f22tZHmueAHVedM35krXyCTVSwPoy oXbgJ8pGgwwDpnrf8cpCgM/fzwv696JYqII+biPcxq8zaLTKRZYJPqdZTISaMEiGdHe1 MjXke+uVRWdmySD9qeDjaVbphDFCUEMMRJCkopdsU949LUvaT6y+/dH9R+ZB+/nzRXEp qS0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714053585; x=1714658385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LR5Th4rgsENBGC1XHGIaoOrv3KgiGLQWWbPFYgnaOZw=; b=L6cVm7K2n0NB11v9c8/lKgRYvXr8RVDZXs4GqCTgf9nhQ8ZS/JkMReStVR53BhUtq9 KYE39BkbSnAywqKCPtTLUkzpLIzk2h0B8/uUd/oqjGH2VwUp6IzR1amofbQvgkR7rnx5 PFvYuXfW3Btfwju6Yx8EK0+jK409Fslxn/kyNiQwPtqJUhDRPQep8m1vaYXk+Lhb22YL uNnwpLsE8MbLmjLH+d9/H8LSw28T1x4PJGPMfeGgN77AVFdHXe8PHqrgoUeT/3pXlG7y E3OmzNO9yhQZYLqs1KF3QBEFGDxZdZZDQJZ/6HJ1BStITygKOIeo25iKYR1IjPqki9BD ytcw== X-Gm-Message-State: AOJu0YzJ9GoB96n7a1PKcX2xbSOyvsc+t3ucOORdUzurql2zYtfr1YtT onysuRoFUIYy6Z9FNnkr3Ekoz9srVixNNJCrKLWfL3AEIPaXZ9NQLk5Rzkav+jk= X-Google-Smtp-Source: AGHT+IHGaFhMe5yKL6F/+83lu4EV+Z0XaPXrPqBYQngm29el1FnXbXjw74hkSw+DvAhi+EO+LTBgaA== X-Received: by 2002:a05:600c:1d04:b0:418:ee1e:3445 with SMTP id l4-20020a05600c1d0400b00418ee1e3445mr5798812wms.26.1714053585319; Thu, 25 Apr 2024 06:59:45 -0700 (PDT) Received: from fbxleo.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.gmail.com with ESMTPSA id o12-20020a05600c4fcc00b00418a6d62ad0sm31479464wmq.34.2024.04.25.06.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:59:45 -0700 (PDT) From: =?utf-8?q?L=C3=A9o_DUBOIN?= To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?L?= =?utf-8?q?=C3=A9o_DUBOIN?= Subject: [PATCH 1/2] pinctrl: core: take into account the pins array in pinctrl_pins_show() Date: Thu, 25 Apr 2024 15:58:01 +0200 Message-ID: <6df39bd47942156be5713f8f4e317d2ad3e0ddeb.1714049455.git.lduboin@freebox.fr> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We previously only looked at the 'pin_base' of the pinctrl_gpio_ranges struct for determining if a pin matched a GPIO number. This value is present only if the 'pins' array is not NULL, and is 0 otherwise. This means that GPIO ranges declared using gpiochip_add_pingroup_range(), thus making use of pins, were always matched by the pins in the range [0-npins] even if they contained pins in a completely separate range. Signed-off-by: Léo DUBOIN --- drivers/pinctrl/core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 6649357637ff..901f2f9bf850 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1672,11 +1672,20 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) #ifdef CONFIG_GPIOLIB gpio_num = -1; list_for_each_entry(range, &pctldev->gpio_ranges, node) { - if ((pin >= range->pin_base) && - (pin < (range->pin_base + range->npins))) { - gpio_num = range->base + (pin - range->pin_base); - break; + if (range->pins != NULL) { + for (int i = 0; i < range->npins; ++i) { + if (range->pins[i] == pin) { + gpio_num = range->base + i; + break; + } + } + } else if ((pin >= range->pin_base) && + (pin < (range->pin_base + range->npins))) { + gpio_num = + range->base + (pin - range->pin_base); } + if (gpio_num != -1) + break; } if (gpio_num >= 0) /* From patchwork Fri May 10 16:25:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?L=C3=A9o_DUBOIN?= X-Patchwork-Id: 796793 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (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 78C19176FAB for ; Fri, 10 May 2024 16:26:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715358385; cv=none; b=HVWOZ02mFnKishm1OGjxRohNQ5HN46jRMCfr2LaFDPs2i/zji3z6u0YlmadUBW0cru7quh/YiP8OSNW1vfGzE5O8P2xU+xCpKT7EUVlyWNfyCGypnrHLWJOTaxISDjwbCnhd+C6LqAOmrUDTKrTLbh/fgvZvz2vQc74HLlaWvkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715358385; c=relaxed/simple; bh=mUZACTmIvN9VpSJnu+37t6kjVWpWjqK6pTbjUJgvM2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PPvRjGGEo3RivRFjKocBTgoas70v+L/67a5+ohcZus0LHIcDwRKP9ZhyKfcxi52osnkUA+R7SpX64WGLahZgh0dGB0U24D/4aTK+HUxDQhC3WaI0SGHNTCgKs4HWXIDpMBQtvI6yrTxFK2I+ymWqh2Y+2jSdfN43fen+l7B8piE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freebox.fr; spf=pass smtp.mailfrom=freebox.fr; dkim=pass (2048-bit key) header.d=freebox-fr.20230601.gappssmtp.com header.i=@freebox-fr.20230601.gappssmtp.com header.b=WjFSInR+; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=freebox.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=freebox.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=freebox-fr.20230601.gappssmtp.com header.i=@freebox-fr.20230601.gappssmtp.com header.b="WjFSInR+" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51f45104ef0so2308894e87.3 for ; Fri, 10 May 2024 09:26:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebox-fr.20230601.gappssmtp.com; s=20230601; t=1715358382; x=1715963182; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QyGh/Qwq5NmQyuXE/qEzsm92r8+stUz1K4JXovBXMG0=; b=WjFSInR+004w6lES0+Sqg96x+A0/oUCJiki5+9SVN0gyrruZSBj3408Vqg1dOOgtJr GIOkBovnH3X/SxyNGeCr7XtoXtydBSU4/m+w0jUvkEIihPxe9j7YAqFXm2Ouqw8Sap5M kw60olOuLghrLDjttCacq7Uz3h8KMprNoZ5TYG2xxJoQKthweA+Cd8qJsI2XNsfF1RS3 BXEgRb4DgE7fQza9KXZGscn6oJMboPbeFLm0vgbREYo3MXBD+xbzLD8yTLNXjabZc5Sk Y/fp7289weaEGP7neKAgR5rthEA6Yh2297aNDYclU3130+Ct72SkzoIv0SjvAC19dGJB 3nXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715358382; x=1715963182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QyGh/Qwq5NmQyuXE/qEzsm92r8+stUz1K4JXovBXMG0=; b=LWQ/Hf9Iddw2u2z70HQfFcsBQz5ZsXSVIZKWEG7gEuFOTNRio6OYU70Q6591kwNgwq Yrl0RpvsWIn3KSO7mxEzZ97gEDu2S2l2uS/I/2fqxryDzEUoBP8PIV1Ar8I+dwqdyJd/ jMCSvZT8Knm8SdmSEKmXQEcash9O8GvZGpqUoImX9nzOhoricoVv/VbjQEUDGCZvgcRV hKlCmwgXTV5utWqSEhnbKHL274osOeHLRg9Nbw8cQ2P1OllSxX5XQVz6P4k27epzqVEA 979mwp0AgDbnTImHs6JLmOMbtD9BAgpppq6WXRJlCirZwi4ahhoV7B+q5hl5wE6eQLyM TYMg== X-Gm-Message-State: AOJu0YwVxn6upPPRttmdQmSdSjOmiQUI8AIv2b1CxVwlK8GeJ0lHsu1I xe9YaEO46kG/DXS+oja146/s/bLjBgUbubTHLHfKz7aZAmB4R7VWC0wNOojjIp8= X-Google-Smtp-Source: AGHT+IE+Rh5byA5+4RfuhgVDmEQbOyg3w/YYGC/qD0xJW0Xl2arSt0vCilMQiRGox+uasSLbDvJ/1w== X-Received: by 2002:a05:6512:3283:b0:51f:1bf8:610e with SMTP id 2adb3069b0e04-5220fc6d559mr1885977e87.37.1715358381642; Fri, 10 May 2024 09:26:21 -0700 (PDT) Received: from fbxleo.iliad.local (freebox.vlq16.iliad.fr. [213.36.7.13]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b896aa5sm4952206f8f.34.2024.05.10.09.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 09:26:21 -0700 (PDT) From: =?utf-8?q?L=C3=A9o_DUBOIN?= To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?L?= =?utf-8?q?=C3=A9o_DUBOIN?= Subject: [PATCH RESEND 2/2] pinctrl: core: reset gpio_device in loop in pinctrl_pins_show() Date: Fri, 10 May 2024 18:25:39 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20240510162539.o6DNSbRmuA0ef_dn_clUEXs4PIJtcP-Wzjn-sXEF_mQ@z> We were not resetting the pointer to the associated gpio_device once we are done displaying a pin's information. This meant that once we reached the end of a gpio-range, if there were pins right after it that did not belong to any known range, they would be associated with the previous range's gpio device. This resulted in those pins appearing as <4294966783:old_gdev> instead of the expected <0:?> (due to gpio_num being -1). Signed-off-by: Léo DUBOIN --- drivers/pinctrl/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 901f2f9bf850..ad878196ada9 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1670,6 +1670,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) seq_printf(s, "pin %d (%s) ", pin, desc->name); #ifdef CONFIG_GPIOLIB + gdev = NULL; gpio_num = -1; list_for_each_entry(range, &pctldev->gpio_ranges, node) { if (range->pins != NULL) {