From patchwork Mon Sep 9 18:37:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 13797414 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A63F31898F7; Mon, 9 Sep 2024 18:38:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725907101; cv=none; b=t4HL7Srx1hc+xJjE0642TWVqTH6jXNYw4WOCq7aFNaZtfFLbX2oByKk8P1BJE714OfTSmjecDnf9VuLN5bKOhCnJSmkHmR4m+EAEyCp4ayrnSdS9Pe1OgpPwLbHaCrrmJMCENJVJkJsrwZf7AuYzzBvXrgQsudGvNbSu77oILRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725907101; c=relaxed/simple; bh=NADRXRk73DSEcKHQQvni0lrWb3AK/hH7vJ+xsFaEuFQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NPQop0By5Q6SrgcVgl09l8XymZx+iEVY7x2rJLscVCQw4sTdFsQ89i3g7isByhmcfpXf4SSKhykBaUKv4qMScPMvXA2Vzum9FMRmFJjEokneRPFq9yKuppDM3N+fT1nK22klEZ/eFZOUK/Ym2UzralLaDukRkMWZYkNCfGePbu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=MOyVqPcq; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="MOyVqPcq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1725907097; bh=NADRXRk73DSEcKHQQvni0lrWb3AK/hH7vJ+xsFaEuFQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MOyVqPcqOprLfzy/XadLU8XC5fbGGQO9ILN+44UJ7vdDvadezUBuxbfg6endteo2I 4ngJRt9Pe/psTrCGqbHs5Jj2yuzFUo6Z5VLW+i944LZy/tEylnfVCDx51TqCxoMHoX pZeE0h8ej9VzktzoGE66zSZKXLEOyrw9oyQNp7kDbRiq83xI3vHjXYpMqDZUnv7EUB MthblXGFoaEM8MTt7WanuicQ/DPHKMqNl3C1e7j+WFBtxMz6iuFyIUY/quSwqc9MEk /eDtiM8FfrvIAboZc8bdR5NjWZzSyrCTuUptoWQY6/8JtmwnBDhUHGdQzD5R9l6u57 Q2ALrQ9fqVriw== Received: from [192.168.1.95] (pool-100-2-116-133.nycmny.fios.verizon.net [100.2.116.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by bali.collaboradmins.com (Postfix) with ESMTPSA id 82F8917E35FF; Mon, 9 Sep 2024 20:38:15 +0200 (CEST) From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Date: Mon, 09 Sep 2024 14:37:33 -0400 Subject: [PATCH RFC 2/3] selftest: gpio: Add wait flag to gpio-mockup-cdev Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240909-kselftest-gpio-set-get-config-v1-2-16a065afc3c1@collabora.com> References: <20240909-kselftest-gpio-set-get-config-v1-0-16a065afc3c1@collabora.com> In-Reply-To: <20240909-kselftest-gpio-set-get-config-v1-0-16a065afc3c1@collabora.com> To: Sean Wang , Linus Walleij , Matthias Brugger , AngeloGioacchino Del Regno , Bamvor Jian Zhang , Shuah Khan Cc: kernel@collabora.com, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, kernelci@lists.linux.dev, =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Mailer: b4 0.14.1 Add a -w flag to the gpio-mockup-cdev utility that causes the program to wait until a signal is received before exiting, even when its behavior is to retrieve the GPIO value of the line. This allows using this utility to keep a GPIO line configured even when in input mode, which will be relied on in other tests. Signed-off-by: NĂ­colas F. R. A. Prado --- tools/testing/selftests/gpio/gpio-mockup-cdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/gpio/gpio-mockup-cdev.c b/tools/testing/selftests/gpio/gpio-mockup-cdev.c index d1640f44f8ac..f674dcafa60a 100644 --- a/tools/testing/selftests/gpio/gpio-mockup-cdev.c +++ b/tools/testing/selftests/gpio/gpio-mockup-cdev.c @@ -15,6 +15,7 @@ #include #include #include +#include #define CONSUMER "gpio-mockup-cdev" @@ -95,6 +96,7 @@ static void usage(char *prog) printf(" (default is to leave bias unchanged):\n"); printf(" -l: set line active low (default is active high)\n"); printf(" -s: set line value (default is to get line value)\n"); + printf(" -w: wait even in get mode\n"); printf(" -u: uAPI version to use (default is 2)\n"); exit(-1); } @@ -120,13 +122,14 @@ int main(int argc, char *argv[]) unsigned int offset, val = 0, abiv; uint32_t flags_v1; uint64_t flags_v2; + bool wait = false; abiv = 2; ret = 0; flags_v1 = GPIOHANDLE_REQUEST_INPUT; flags_v2 = GPIO_V2_LINE_FLAG_INPUT; - while ((opt = getopt(argc, argv, "lb:s:u:")) != -1) { + while ((opt = getopt(argc, argv, "lb:s:u:w")) != -1) { switch (opt) { case 'l': flags_v1 |= GPIOHANDLE_REQUEST_ACTIVE_LOW; @@ -150,10 +153,14 @@ int main(int argc, char *argv[]) flags_v1 |= GPIOHANDLE_REQUEST_OUTPUT; flags_v2 &= ~GPIO_V2_LINE_FLAG_INPUT; flags_v2 |= GPIO_V2_LINE_FLAG_OUTPUT; + wait = true; break; case 'u': abiv = atoi(optarg); break; + case 'w': + wait = true; + break; default: usage(argv[0]); } @@ -183,9 +190,10 @@ int main(int argc, char *argv[]) return lfd; } - if (flags_v2 & GPIO_V2_LINE_FLAG_OUTPUT) { + if (wait) wait_signal(); - } else { + + if (flags_v2 & GPIO_V2_LINE_FLAG_INPUT) { if (abiv == 1) ret = get_value_v1(lfd); else