From patchwork Thu Feb 15 08:33:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1899214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=rgiRJp+Q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-gpio+bounces-3330-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tb7dT2Ny9z23gM for ; Thu, 15 Feb 2024 19:34:05 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D0C6A1C21EA8 for ; Thu, 15 Feb 2024 08:34:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8F7013FE5; Thu, 15 Feb 2024 08:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="rgiRJp+Q" X-Original-To: linux-gpio@vger.kernel.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 E907413AEC for ; Thu, 15 Feb 2024 08:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707986020; cv=none; b=pmgbmuHSQhVqOk5zVsS4iVaSvBtjZQNLPFdH55KXaAgMbzbNsI9m4MY+MJAlYGuDpRG8J3bAH0jQBzJPRweGolD/4mv+AxNpZaWW8BvceDMgdCRgTHuSAaTtuI7z+QqiCVhH7lRXA8EIRXCMGXOFogp1e8eWRStMbwyDSOf3ubY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707986020; c=relaxed/simple; bh=xT5dfURtGIxff62raqt0jG+pcsjp7uhfEREhWd31PRw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZiT/dv0zmwnIMXAqLEDsDkgu6De27JqxtaH/yAkK6djwTUyabg+CsxVobvDUF4yB+0F4wzj1N8nU7AB1MWARMA22VZNt3XGOA9NIfG5cA4fKbd4fzbukn6qOgif5+pCb606Bb0nZ1Rq2Cl3FhvfUCQ6RBXSUwfAuQa/9lOUwRgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=rgiRJp+Q; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d11d17dddeso6697471fa.3 for ; Thu, 15 Feb 2024 00:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707986017; x=1708590817; 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; bh=Ez9xOpn3UTLsU+b3iGm2vmX6gqE6PZNq2Dof+USHQP0=; b=rgiRJp+Qem11c2HuaMFORjMJWUhH42bl3u6IkuCAVxIVmcHdhSrqrYI4ii3zb3yGjk 4Zgq6t+jLUt8A8cDulRb84EYI/N8iUT8gRr12o/3I3bF2T7mCiUXG4PvZQcOcK3khmRJ kZOC5kzYPOtiAdM3sNd0lf9iIaVCiTca/MCY97XxUFXy/L9gX6NNN9ByOBktVaLhQiWI iNRKfWCIQlHTKiFr2F90RC0ledaQfI5f50LU+BALeuPGkJa5ktf0EXlu6bCUdb6Tija9 wSvU5n2IH/yr9v1Uopaj281PKZODFMssAVI6lEr69ZXwx/4KYa+uinI6E5LuYKglssKS BDJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707986017; x=1708590817; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ez9xOpn3UTLsU+b3iGm2vmX6gqE6PZNq2Dof+USHQP0=; b=od36tp0u0IJJz4ZJybz5lLr4r1A6uBxhH8Nf7M+8l3CTyU+I83PWyQG93HYzgzGPGf 11Jp/97uiYHnXiF9yGHsAFOubjcuvhedwHf8ZxsNrTkKzTklf0uxQFnUyEoKhAj2xWcH zOvcUh/xUT1HZ2X+tmEEgpmz4JE33qiJB4bOup8D5xWOqNoTn9echml+CC2T5+98Juja +ZKo3o5hSqiLq1QkUsYNnJNedT2vpvhMD4ShYq7YaFosdh0yvurxcNr01VpwxGNhkcMR +rCcoKZAn841BJU/K6DEgeJN/SBeDuhkdUMMjkQGsbbfZ3+WnEwOJQl5ou/b+HwXogWD jyuA== X-Gm-Message-State: AOJu0YwW8p0A/XHOdQPfLAvP3gVvVJOvEQbrfrVH56+xPY973JTnMHxR jSPk8tnqJHOYv4VROftMC10MPaK7+9PgC8byQoDlwPhHa2SoAFnsJtmlUoJLPsM= X-Google-Smtp-Source: AGHT+IFQV7OKQsTQ/UxE3IWZlRvegLax6f9smfnoepWKpuD0SsrBm4RCPyfQCitdXEojv+hB5o6haQ== X-Received: by 2002:a2e:9c58:0:b0:2d0:a8fe:4263 with SMTP id t24-20020a2e9c58000000b002d0a8fe4263mr760447ljj.25.1707986016884; Thu, 15 Feb 2024 00:33:36 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:20b3:d902:bf8e:897]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c211600b0040fddaf9ff4sm4286906wml.40.2024.02.15.00.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:33:36 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] gpio: provide for_each_gpio() Date: Thu, 15 Feb 2024 09:33:27 +0100 Message-Id: <20240215083328.11464-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We only provide iterators for requested GPIOs to provider drivers. In order to allow them to display debug information about all GPIOs, let's provide a variant for iterating over all GPIOs. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- include/linux/gpio/driver.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 9d0023f83a57..5f915b653548 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -551,6 +551,21 @@ DEFINE_CLASS(_gpiochip_for_each_data, }), const char **label, int *i) +/** + * for_each_gpio - Iterates over all GPIOs for given chip. + * @_chip: Chip to iterate over. + * @_i: Loop counter. + * @_label: Place to store the address of the label if the GPIO is requested. + * Set to NULL for unused GPIOs. + */ +#define for_each_gpio(_chip, _i, _label) \ + for (CLASS(_gpiochip_for_each_data, _data)(&_label, &_i); \ + *_data.i < _chip->ngpio; \ + (*_data.i)++, kfree(*(_data.label)), *_data.label = NULL) \ + if (IS_ERR(*_data.label = \ + gpiochip_dup_line_label(_chip, *_data.i))) {} \ + else + /** * for_each_requested_gpio_in_range - iterates over requested GPIOs in a given range * @_chip: the chip to query From patchwork Thu Feb 15 08:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 1899216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=19GM6JXQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-gpio+bounces-3331-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tb7pJ6K2pz23hM for ; Thu, 15 Feb 2024 19:41:44 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C6BEB2F360 for ; Thu, 15 Feb 2024 08:34:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F15B813FE7; Thu, 15 Feb 2024 08:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="19GM6JXQ" X-Original-To: linux-gpio@vger.kernel.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 E305B13AFB for ; Thu, 15 Feb 2024 08:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707986022; cv=none; b=um2IEAbTGJXYAqvA1CGALmSf8oeHR70mM/TKU5DkjN3yNe0PqA59jeLrMqaC7yg4byYVrURoOt8UCsEGoFb38wjaczvXp4a3Jp5YIalpgbnznq2kbZ0C2YaiNw+NVdbiUX1xsh5MZ7GBKthMm02G1FLqXpTaECCwCKF8mX5NL68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707986022; c=relaxed/simple; bh=YT4/POV3M8MtyVT6SG3s3/ohDW0RzcPxhzts0DGQ55I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vDIVWeQzCJXA8mk53iwi33FFLBqIdLUcZf0MOpOmwH7XDKQNxWDUcUi5oLM3iwXsoyfmisd5+P15QdZH/1SOnBW8G2PPR60LdO734u9TOUJ4UaAzKVndPulRnRtZjXc7X0oI7LC9ceDpDUvZ+9D5mKWnzlv0B09WlWlijBOqAAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=19GM6JXQ; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-411fc61a03dso5034935e9.3 for ; Thu, 15 Feb 2024 00:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707986018; x=1708590818; 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=tuZqG0oYu5QXy6Hacy/4Gf0XYdpRrgU60aNFFSE8Nik=; b=19GM6JXQ7uXWi6QM1U6cEtDcSaD2fmUUDiwJ4QT6G9r8Y1G0LL4kbE0UsOZ/EaDNez ERP04bSBpbvIm/JceU405ry/8ic5rhBk+Pilmd5pFAmF5puNaUNyzg+z+iHRoz1R9Fm5 erC88b3UjcEbVI7nMWA9as3G2Q4mRZ8DNtaQY2pxPgFQypxzzX/x+Om2iMJhCxeMdnVK BicY9U3186pfCqd8ezGwl68U0FKAQ8SxUMi/Y/6lY+ihOg2resPRL6iaddTLrFllKSNs eBSW1DhDm3wyPrYGDDRC8HfSr4i4XPRdR7yiRCnIbN3HU8IJPYL2RE0GgCTw9ECX86RV gXGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707986018; x=1708590818; 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=tuZqG0oYu5QXy6Hacy/4Gf0XYdpRrgU60aNFFSE8Nik=; b=P5PaYLFKKViXvtrd5+xV/y8TL7OUYYqcA2Gl9xirhAzT/SHkYXwCpSdn7RLHOM4MVF XODaI+yanrh6iNoxAPksvE4acSFXqEyWHaFv5bA++CCXzKZnwcP8ro128W8UHlFirfku YJzhSTST+drREk9FLxpdB/TybwVsBz5++lPOQb1psUSc20V522+pyQDkV3gcFc5Ks5f5 54FBr6XxD2bSWS0WUJZKZyX8UqHztGzYOvoh9sz2c/SyHHdDMKAd6eohrqtfvcgDXpD1 IvRmT6CEe2EAryFGPfg4ofH2Nw0mKUGUJAo+VMkZqmPBp4T2IxGuR36M3pbyI58g3Yka 08Ow== X-Gm-Message-State: AOJu0Yw62HM02KnMlp2HjZBmKlmPmqGyIpzaT8N7ZcXAwidGe9FlQKFm b/FjPtjhWJt2pnqWywoJbPwkA/5BaDShw9Jp7tq/ha0GWeuZfLUrsO+Q4cAN3JdrfjTnxl8GvuM b X-Google-Smtp-Source: AGHT+IFTAcUrqBtlmisv2yuIw/iHEpKckPDhY5yHQ/h9rk+RRjXEGabSjPJGHca/XBvqOCxefHaWzA== X-Received: by 2002:a05:600c:1384:b0:410:c128:2bed with SMTP id u4-20020a05600c138400b00410c1282bedmr762104wmf.20.1707986017955; Thu, 15 Feb 2024 00:33:37 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:20b3:d902:bf8e:897]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c211600b0040fddaf9ff4sm4286906wml.40.2024.02.15.00.33.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:33:37 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/2] gpio: sim: use for_each_gpio() Date: Thu, 15 Feb 2024 09:33:28 +0100 Message-Id: <20240215083328.11464-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240215083328.11464-1-brgl@bgdev.pl> References: <20240215083328.11464-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Display debugfs information about all simulated GPIOs, not only the requested ones. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpio-sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index c4106e37e6db..1ebd6961ffba 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -234,10 +234,10 @@ static void gpio_sim_dbg_show(struct seq_file *seq, struct gpio_chip *gc) guard(mutex)(&chip->lock); - for_each_requested_gpio(gc, i, label) + for_each_gpio(gc, i, label) seq_printf(seq, " gpio-%-3d (%s) %s,%s\n", gc->base + i, - label, + label ?: "", test_bit(i, chip->direction_map) ? "input" : test_bit(i, chip->value_map) ? "output-high" : "output-low",