Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp764633pxb; Thu, 15 Apr 2021 06:10:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA/O1IbeUEG9YXEDuHhki4/nDYkm7Tkg851eNuzCcOa38AXCx715jYf+x38Pz9wVeQWNEE X-Received: by 2002:a17:906:cb2:: with SMTP id k18mr3366332ejh.183.1618492234449; Thu, 15 Apr 2021 06:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618492234; cv=none; d=google.com; s=arc-20160816; b=oykLdMA2V171z3q74PXQzBtRPrFuaZ1lT6di9XjMZuM8GRp7ckV0LFidIoIRtMnkeV v7cxIyrZXtg09Nr4uWE/VXhUay6azOLIDxZO+nqe9gg1LDnbeJhl1U3kCDPtABnfj5Q3 P+sj4HIKiOngGIRJiWh8XKQCg9jy6YfhiAfW0QKOzFPkQjTepUCiVsaTVtatyGoUtuMO +YrFNdiK8BxNahHS0DEBIhqE/fT43U9b33XV+/qnxR25mTNNoQbvu/Wr8upVCwyGN25o nBaOCWTUQFrHD8yXT0VwNgzWpsuO0jcRCdlpAUGudyqn1O0Xf+QcUoRPjnlJbS3V3WpL Zdbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=Lf4Nm/6rilmOO2M5LbWS1BSMxj9LsEz7YMwQ7LIyVKI=; b=YXhJdPVrpCYNr1BPIq74vHJozzM4/QT4DRklrdV/vfGprW6lV4LtVXKJUVN9M8I+90 AxgsN8DsV0Tnbzu357f/JHCvU0WgmtcDeX5tQD2KLRGKogJz01MGr/M9KxAaEiXve4dC yCptO+QXgL7k2iyRFyRpkMsaVQL9dKWHaplVPV+GSRyI2rKMdZ1Sm7zvpSu8VmgJBj4p hfXcc3iabh/+sCz4gyZVuO8p3aITeDfmevttICC52jcPooSj3D0Qz+wYjVs2LUXgXHhL HKx2gm5/IhpdIMQ7V3oI5X1acdxvRbGnRoTIa4hDdrm6T95YLBjtFNOdanHobYqO1ptZ KQaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx20si2138197ejc.378.2021.04.15.06.10.10; Thu, 15 Apr 2021 06:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232959AbhDONGK (ORCPT + 99 others); Thu, 15 Apr 2021 09:06:10 -0400 Received: from mga05.intel.com ([192.55.52.43]:21249 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232655AbhDONGI (ORCPT ); Thu, 15 Apr 2021 09:06:08 -0400 IronPort-SDR: rUP6X/kABhgez+RKMWlW1a/O1Lb1ho87CmvdjEKI/rrYPe6Wo/5OU/OZ+xQP3tJ+Fz0+YW0y5O ru53mbR7se6Q== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="280162400" X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="280162400" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 06:03:43 -0700 IronPort-SDR: a1xlUfAK+Z4zpZkF642clCxXpiHmGJoPMBivoYCT1xBwK7GoljWI7xPHhHVZQ9yIGfX3M1YFmE c8+fZDCnB50w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,225,1613462400"; d="scan'208";a="452904048" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 15 Apr 2021 06:03:41 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7C1A612A; Thu, 15 Apr 2021 16:03:58 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Drew Fustini Subject: [PATCH v1 1/1] pinctrl: core: Show pin numbers for the controllers with base = 0 Date: Thu, 15 Apr 2021 16:03:56 +0300 Message-Id: <20210415130356.15885-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit f1b206cf7c57 ("pinctrl: core: print gpio in pins debugfs file") enabled GPIO pin number and label in debugfs for pin controller. However, it limited that feature to the chips where base is positive number. This, in particular, excluded chips where base is 0 for the historical or backward compatibility reasons. Refactor the code to include the latter as well. Fixes: f1b206cf7c57 ("pinctrl: core: print gpio in pins debugfs file") Cc: Drew Fustini Signed-off-by: Andy Shevchenko --- drivers/pinctrl/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index df7f5f049139..8ef24af88b75 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1604,8 +1604,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) unsigned i, pin; #ifdef CONFIG_GPIOLIB struct pinctrl_gpio_range *range; - unsigned int gpio_num; struct gpio_chip *chip; + int gpio_num; #endif seq_printf(s, "registered pins: %d\n", pctldev->desc->npins); @@ -1625,7 +1625,7 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) seq_printf(s, "pin %d (%s) ", pin, desc->name); #ifdef CONFIG_GPIOLIB - gpio_num = 0; + gpio_num = -1; list_for_each_entry(range, &pctldev->gpio_ranges, node) { if ((pin >= range->pin_base) && (pin < (range->pin_base + range->npins))) { @@ -1633,10 +1633,12 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) break; } } - chip = gpio_to_chip(gpio_num); - if (chip && chip->gpiodev && chip->gpiodev->base) - seq_printf(s, "%u:%s ", gpio_num - - chip->gpiodev->base, chip->label); + if (gpio_num >= 0) + chip = gpio_to_chip(gpio_num); + else + chip = NULL; + if (chip) + seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label); else seq_puts(s, "0:? "); #endif -- 2.30.2