From patchwork Thu Sep 7 14:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 721196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9F92EC8742 for ; Thu, 7 Sep 2023 15:46:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232185AbjIGPqG (ORCPT ); Thu, 7 Sep 2023 11:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244841AbjIGPZw (ORCPT ); Thu, 7 Sep 2023 11:25:52 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBB45CF for ; Thu, 7 Sep 2023 08:25:29 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401d80f4ef8so12220715e9.1 for ; Thu, 07 Sep 2023 08:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694100321; x=1694705121; 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=HijaDWjtU9+MMMmQDH1Rm0HmHWsQfV4zHlVWc3shxSo=; b=NcimMccUpdcJOzDBrDiQHRJa+Pf5tShg/1Q82rRNAOVvxHvrMu6KRaQFu8JCyk2RZU aQSsS1wKcBAAhitatqxMJcp0OeSpdK5JYAASp5JpGdglVEZ6z8iTV1oaaQorB2YEkojD VW4u0778OKCnE3bQqiIdFJzUG6vq4paoHQ3gibyd5irs+WGiaA0mrGihkeuj3lbUIsLJ 5rqqdMcHElt4OhOFc5GkrUKULSDW9us7oNxLUk45bEe6aJcDmBRlziZ6iY5QkqcnnYn6 r+Qc5Jkk5tljZm4dRc0cTLuTPTyCYoMfBv/NKyO0FPWwL5Ka6lVa9cxiEH6mHN8SG7ib ZVWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694100321; x=1694705121; 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=HijaDWjtU9+MMMmQDH1Rm0HmHWsQfV4zHlVWc3shxSo=; b=TfGAz/l5V5NlKFvWUu1DtEn0DZWL19UC5gVf5l4+tzS8xHIHh6RwAOvqQNDsPWkiR/ n90scuMD5v9366ODofL9LHvQ2BofScNx1scgATAhcHyP5O4t8h2ZJDv2j2UtShOl5Ylx MwY4+UrNDIeUs3UCES8EKN0ZfJaaUIkWUz9LFTzhp3lsqQqYbJ3pkjoLrgORYD0eeeXq uthcNWOksLLeNcw8XTRx0yfMYbRazDEBVHCcEjyCtY0moiOxgmR9Mphpk0sNdfGvOv76 N8ia6CXT7NA7Dh5FlLmGDIygYSObqkjr6MnS6aYfcFWYuQnHab7TEfy/jiqm30qFDqdV Pgwg== X-Gm-Message-State: AOJu0Yy6ep4jvXIjp3yxrhh7s5Y1OMRnFi0oNqw5ZQtKimxZzTYDSsGn xCIoSE0pbr++QJkQbRRWvIV3VnmmkSda0HQUnwk= X-Google-Smtp-Source: AGHT+IGMfrd68cQiTItvDb+O04EvbhJPhzV/s88UZI49HyvK3RoNa7kYSWHBGxozNXZDNyvX7p4BiA== X-Received: by 2002:a05:600c:224e:b0:401:b2c7:349d with SMTP id a14-20020a05600c224e00b00401b2c7349dmr4904033wmm.29.1694098353082; Thu, 07 Sep 2023 07:52:33 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:56f5:e2d4:1e04:b28e]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003feef82bbefsm2757588wmi.29.2023.09.07.07.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:52:32 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/5] gpio: mockup: fix kerneldoc Date: Thu, 7 Sep 2023 16:52:26 +0200 Message-Id: <20230907145230.44085-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski The pull field of the line state struct is undocumented. Fix it. Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface") Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpio-mockup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index b32063ac845a..17d4d48524b7 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -39,6 +39,8 @@ * struct gpio_pin_status - structure describing a GPIO status * @dir: Configures direction of gpio as "in" or "out" * @value: Configures status of the gpio as 0(low) or 1(high) + * @pull: Configures the current pull of the GPIO as 0 (pull-down) or + * 1 (pull-up) */ struct gpio_mockup_line_status { int dir; From patchwork Thu Sep 7 14:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 721195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1B63EC8740 for ; Thu, 7 Sep 2023 15:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbjIGPqN (ORCPT ); Thu, 7 Sep 2023 11:46:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245435AbjIGP3a (ORCPT ); Thu, 7 Sep 2023 11:29:30 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4305B1FE9 for ; Thu, 7 Sep 2023 08:29:02 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-401bbfc05fcso12350065e9.3 for ; Thu, 07 Sep 2023 08:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694100490; x=1694705290; 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=NzpZWHat+ptY4i8T7d70uw7fEAXlmofiE9gJ/p0X22U=; b=lLFmQhX/6PTdTS5/V36fzyf4K8v/UUBciFnZZ6moSwWJHFMzMri0SGVDsxkeH+SmQa 76cwT8vOfJWWRWkyB8GL8kIL1qEv7tm5g64huvaNi7qpDy3i+okE8nhDNmHxve70E7Ts rO+nahpyr5vt+croe0OfraOS2tE6LKb4hLoFynjmdlfs1XZRj/72DzteF57WsHOfDgsO +ZvbbVVcxs5pO15ABOlfNBXnOJ8CaHl3ak02GGooB58hBca2qBOqjGZbN6BWHqPj3gwf 3nDNxRiRRmlNP5CAMxn9cd5r2O/95cOeihQrbWEt5nqYw5wIB0V0gbiv2Dl1ZdKZram8 S34g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694100490; x=1694705290; 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=NzpZWHat+ptY4i8T7d70uw7fEAXlmofiE9gJ/p0X22U=; b=l9nM4cnKQLkuYKGlAvAMCtG+bvEoqjXZv6E9D1Dvp8izHlyAL+DO6nZa2JQAuUPccF ljrQbQfJc7gu7rDNlEvZeRbwft2EhO0/PoifGZC5KGBfhqyrTRo0xzFqIQbJFZkGYNh7 /mj4UaMa8y0QbHdAS4VlT1A6/Ro4A6rVecFxImdbWVd5G4Y4JJW7LNFHQbKoNfCkMGvE Zi0k8X3GXKSXlHW+FY7thlqv/G/GU2/65dFxDQgvjjiUnGy10wXLqBn8+SkjWxQMLxut aF71KjJUse3T0V1a05u9jcYlhCtO1bR3xUZdNp1TTPDcdjBLaeGUTBGkPoLAioOucD5e ReJA== X-Gm-Message-State: AOJu0Yyn0ZTDxwiITpa/IsTHbLNDXY30lXpgjQ7qU8y4XjmEcYmKA6rL Dss5uFdBG8C9vFHJ44iTni3loQ== X-Google-Smtp-Source: AGHT+IEMrWqCe5xMabRBv863fM0ihgw8yV+E02Os/rx4rFHyiXrXdvVxp9K8Xsp3/xkyjEuBAAYEFQ== X-Received: by 2002:a05:600c:2a41:b0:401:be70:53b6 with SMTP id x1-20020a05600c2a4100b00401be7053b6mr4884675wme.15.1694098353959; Thu, 07 Sep 2023 07:52:33 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:56f5:e2d4:1e04:b28e]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003feef82bbefsm2757588wmi.29.2023.09.07.07.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:52:33 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/5] gpio: mockup: remove unused field Date: Thu, 7 Sep 2023 16:52:27 +0200 Message-Id: <20230907145230.44085-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230907145230.44085-1-brgl@bgdev.pl> References: <20230907145230.44085-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski The desc assigned to debugfs private structure is unused so remove it. Fixes: 9202ba2397d1 ("gpio: mockup: implement event injecting over debugfs") Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 17d4d48524b7..ff1a263f1b05 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -58,7 +58,6 @@ struct gpio_mockup_chip { struct gpio_mockup_dbgfs_private { struct gpio_mockup_chip *chip; - struct gpio_desc *desc; unsigned int offset; }; @@ -369,7 +368,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, priv->chip = chip; priv->offset = i; - priv->desc = gpiochip_get_desc(gc, i); debugfs_create_file(name, 0600, chip->dbg_dir, priv, &gpio_mockup_debugfs_ops); From patchwork Thu Sep 7 14:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 720706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4321DEC873E for ; Thu, 7 Sep 2023 15:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbjIGPqU (ORCPT ); Thu, 7 Sep 2023 11:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233506AbjIGPYd (ORCPT ); Thu, 7 Sep 2023 11:24:33 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6FF1724 for ; Thu, 7 Sep 2023 08:24:19 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2bcc4347d2dso18593821fa.0 for ; Thu, 07 Sep 2023 08:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694100257; x=1694705057; 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=X/2YQRFzw6VwClsyr++RExaQTGHU2Q9mZM8LcXjJixY=; b=AclUhgAyH1qJ9FuB+yQkbFOJ7UHPkdw529iFr5ldBmjwq1bkTXllN4ZBcKwgKHd+QB icuFj1bxfNhnDpcD/OCM8DDToQ2jwkNfCViGoWgg013TKwyHa5Z3EHxG2gPzaqH4L2Zt HG7uvSQpKhaebYTlLQ8Vxix/3kckHaqlFIx8tOraqNEX1w5y6pMAWJmzwofW/T6Pj3qv z56/5HbC53cCWhzukpIB5HOrcFYDgnUDD9QynBgzYur+WrGW5X72cN00bngOtNgsbF/4 8y7fOev7t4wjixQV8hfKMgsAP1WoU3Jotwq8tLFO9o8lvVdgPGAsxTMG+0FcShj3OIhA yEtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694100257; x=1694705057; 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=X/2YQRFzw6VwClsyr++RExaQTGHU2Q9mZM8LcXjJixY=; b=Kech0PX3Skps6T9P627SH5VXJgLlLgxXOAqi/sF5nj6nkeLP23cA2rPXeWzuz+NKyX bkawnYI9uSzFWc8u+40cHZllhZ6ZKhVMBIk2MAvjNfwviFu1Kb1YFir2IUQWuNTHoDLy 3HEOyHVSHp9hMvZLzLj8VTUYYd76Z37m2o3rY5BH5M2+TNaVRrTsmCwjg9AcQXDng3x1 jALFGLYn7X3bjT3CkkHP0QuAg4A2tzhE0fjO8VurmIEufBbAjlv84GbkrUhzE9viXpiw JZW3b7Lq/ao2UrqnQVxi1bULhnlD1RVDywaDXbJlG5aevPPEHuJTb/ciu7rdPHg4JcJI mqmQ== X-Gm-Message-State: AOJu0Yzf0DCsP3S7Qbl+Af8nN1G6vqCZ2a43eLaSVHEwoonYQ3W+0O9V PUO4lQAZz1yHdgCo8mIcDKuhQIzG456+G41LdO0= X-Google-Smtp-Source: AGHT+IFNnMZUCfIg0VmYtVkkHWQ56jupSQhxmu9VyxODnOTBsDUjstLbANCvb1NNvJCUxIP8YGRitw== X-Received: by 2002:a7b:ce94:0:b0:401:b204:3b85 with SMTP id q20-20020a7bce94000000b00401b2043b85mr5110118wmj.36.1694098354840; Thu, 07 Sep 2023 07:52:34 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:56f5:e2d4:1e04:b28e]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003feef82bbefsm2757588wmi.29.2023.09.07.07.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:52:34 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 3/5] gpio: mockup: deprecate the old testing module Date: Thu, 7 Sep 2023 16:52:28 +0200 Message-Id: <20230907145230.44085-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230907145230.44085-1-brgl@bgdev.pl> References: <20230907145230.44085-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski We have a much better alternative to the clunky old gpio-mockup. Don't remove it just yet (there are tests depending on it out there) but make Kconfig say that it should no longer be used in new projects. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 673bafb8be58..913948876c93 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1790,9 +1790,11 @@ config GPIO_LATCH connected to other GPIOs. config GPIO_MOCKUP - tristate "GPIO Testing Driver" + tristate "GPIO Testing Driver (DEPRECATED)" select IRQ_SIM help + This module is DEPRECATED. Please consider using gpio-sim instead. + This enables GPIO Testing driver, which provides a way to test GPIO subsystem through sysfs (or char device) and debugfs. User could use it through the script in From patchwork Thu Sep 7 14:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 720707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63C4FEC873A for ; Thu, 7 Sep 2023 15:46:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232783AbjIGPqO (ORCPT ); Thu, 7 Sep 2023 11:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245149AbjIGP3U (ORCPT ); Thu, 7 Sep 2023 11:29:20 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4401BFA for ; Thu, 7 Sep 2023 08:28:48 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-402d499580dso12295835e9.1 for ; Thu, 07 Sep 2023 08:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694100477; x=1694705277; 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=2ADDhL3Y9ChksGd5FuRK3cdw+MrzNNwwXAMmsBve8eY=; b=dt7li3pggFFC3EGjs1qK30kJrmwN0MKXFcHaZO3XthbniG/9SoNKH2Expe6zPhmPjf eXo0xq6p93XShe+ON7YxdolbRk1q2fRpuc3VL1YL4M3Yqo19J/2nwRX4YL78Z3j6k3zS HpP6HVXark72rB/HOT1UH0e0qdTz7mm9dnuejdNkCv3bKkms3VKJqjNq3JdUqHJoji3B ViP9T2ksnKubYt+SfhVjXCRkS907GdbZ4l5nfvkz+WyT1hHb0KoE1qzwWpQAk/lncSbt 7qTL5mLyaHkfiVJ0OoGqug/g8N7NsfCGiyDEI96bhE1qpQwzLeYHmDKtwkxO28Xn8k1b 4Ggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694100477; x=1694705277; 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=2ADDhL3Y9ChksGd5FuRK3cdw+MrzNNwwXAMmsBve8eY=; b=aOR30dBZ3cycRiB7P4xsWpr9hA26WBsafXukg1VKqV253Wrnwtgu0g/L6bZ4TxnRZT b2I9DBHVSfBrX1MQr9eQUH1UwJ3PIC1NOjqrEDy1b2YjS/+1HM4qrYeJdzsxmXt5wwZh ygiqkXj+fgPSqKACi/ZnB4YJN2gQViURFmiB7TyP5yN3ziaQLIav/xzUZBw76Yilhrai vY5ucCrx+3f0ULA7tUBio3aTB0CKVYur3EcWP6o/2e65gQhkaWpt5wDT+vGP9jQK3iOm F52mluhIYZeI4uMRDtexqSLradtQ77KDXp3FMpi7OjUbGlDi68NsIwCL6Qci+MzPv02o tc0g== X-Gm-Message-State: AOJu0YzYvNnYhEclBQB0qqEXCJN+djvpMJTgsC0jiFmT2vbzugUKh34d GXXlx43QI/N91av1q1JfN1/pUTaC3hflFU/4rWU= X-Google-Smtp-Source: AGHT+IGYRLf7GpXbSfX9yL4OLNbiYEdnhHMAnQCxOV6DjnXOpS1Z/JCpHYk+r7prOvveef7RE/lcMg== X-Received: by 2002:a05:600c:2809:b0:3fe:dcd0:2e10 with SMTP id m9-20020a05600c280900b003fedcd02e10mr5150331wmb.17.1694098355761; Thu, 07 Sep 2023 07:52:35 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:56f5:e2d4:1e04:b28e]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003feef82bbefsm2757588wmi.29.2023.09.07.07.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:52:35 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 4/5] gpio: mockup: simplify code by using cleanup helpers Date: Thu, 7 Sep 2023 16:52:29 +0200 Message-Id: <20230907145230.44085-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230907145230.44085-1-brgl@bgdev.pl> References: <20230907145230.44085-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Use lock from linux/cleanup.h and simplify locking paths. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 45 ++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index ff1a263f1b05..44684ff4462f 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -92,9 +93,8 @@ static int gpio_mockup_get(struct gpio_chip *gc, unsigned int offset) struct gpio_mockup_chip *chip = gpiochip_get_data(gc); int val; - mutex_lock(&chip->lock); - val = __gpio_mockup_get(chip, offset); - mutex_unlock(&chip->lock); + scoped_guard(mutex, &chip->lock) + val = __gpio_mockup_get(chip, offset); return val; } @@ -105,12 +105,12 @@ static int gpio_mockup_get_multiple(struct gpio_chip *gc, struct gpio_mockup_chip *chip = gpiochip_get_data(gc); unsigned int bit, val; - mutex_lock(&chip->lock); - for_each_set_bit(bit, mask, gc->ngpio) { - val = __gpio_mockup_get(chip, bit); - __assign_bit(bit, bits, val); + scoped_guard(mutex, &chip->lock) { + for_each_set_bit(bit, mask, gc->ngpio) { + val = __gpio_mockup_get(chip, bit); + __assign_bit(bit, bits, val); + } } - mutex_unlock(&chip->lock); return 0; } @@ -126,9 +126,9 @@ static void gpio_mockup_set(struct gpio_chip *gc, { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); + __gpio_mockup_set(chip, offset, value); - mutex_unlock(&chip->lock); } static void gpio_mockup_set_multiple(struct gpio_chip *gc, @@ -137,10 +137,10 @@ static void gpio_mockup_set_multiple(struct gpio_chip *gc, struct gpio_mockup_chip *chip = gpiochip_get_data(gc); unsigned int bit; - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); + for_each_set_bit(bit, mask, gc->ngpio) __gpio_mockup_set(chip, bit, test_bit(bit, bits)); - mutex_unlock(&chip->lock); } static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, @@ -150,7 +150,7 @@ static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, struct gpio_desc *desc = gpiochip_get_desc(gc, offset); int curr, irq, irq_type, ret = 0; - mutex_lock(&chip->lock); + guard(mutex)(&chip->lock); if (test_bit(FLAG_REQUESTED, &desc->flags) && !test_bit(FLAG_IS_OUT, &desc->flags)) { @@ -187,7 +187,6 @@ static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, out: chip->lines[offset].pull = value; - mutex_unlock(&chip->lock); return ret; } @@ -212,10 +211,10 @@ static int gpio_mockup_dirout(struct gpio_chip *gc, { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - mutex_lock(&chip->lock); - chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT; - __gpio_mockup_set(chip, offset, value); - mutex_unlock(&chip->lock); + scoped_guard(mutex, &chip->lock) { + chip->lines[offset].dir = GPIO_LINE_DIRECTION_OUT; + __gpio_mockup_set(chip, offset, value); + } return 0; } @@ -224,9 +223,8 @@ static int gpio_mockup_dirin(struct gpio_chip *gc, unsigned int offset) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); - mutex_lock(&chip->lock); - chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN; - mutex_unlock(&chip->lock); + scoped_guard(mutex, &chip->lock) + chip->lines[offset].dir = GPIO_LINE_DIRECTION_IN; return 0; } @@ -236,9 +234,8 @@ static int gpio_mockup_get_direction(struct gpio_chip *gc, unsigned int offset) struct gpio_mockup_chip *chip = gpiochip_get_data(gc); int direction; - mutex_lock(&chip->lock); - direction = chip->lines[offset].dir; - mutex_unlock(&chip->lock); + scoped_guard(mutex, &chip->lock) + direction = chip->lines[offset].dir; return direction; } From patchwork Thu Sep 7 14:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 720708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FF3EEC873E for ; Thu, 7 Sep 2023 15:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232684AbjIGPqK (ORCPT ); Thu, 7 Sep 2023 11:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237315AbjIGP2y (ORCPT ); Thu, 7 Sep 2023 11:28:54 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12BD21FE1 for ; Thu, 7 Sep 2023 08:28:28 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2bcc331f942so13076671fa.0 for ; Thu, 07 Sep 2023 08:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694100451; x=1694705251; 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=sWPps9q7CEJq96bHnOFu416k4mJ9kfxW5sLbFk5Yxo4=; b=u1Ju6CUQwXkoESOIhJNCrEwyr7jUWkcrOudadB6YSCzdOyfRClTElx1k1ZrVTOJHrq qohqcKoEeZXoIXPhyhovtl86rq2Ptz0gc7bH+lwTIC2S67KBYrBvFsiW6kG8RukGZM/0 Dj+StshCn+PyTht2w9hju37pwb4y5/Cs6UlggIY7iJxwC8znbIl5wvRTnHB9EHNf8/7+ ih6PXFjNVmYSNWpKTXob6Kd7Ln6atC8H6gzIpjC0Z6CK9KFCGefS1jsukKS8FM/OIFqw A8ogy/eUg88lZd1zxdNafYVN4Q7yO3zEx/HPmx7WZqIZLT+zoPft7NPF6KrFBEYKbT7J qtmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694100451; x=1694705251; 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=sWPps9q7CEJq96bHnOFu416k4mJ9kfxW5sLbFk5Yxo4=; b=BEvBTzBc+1yAExM7PdKKPj5501lRaSWMtbuQvWRbF5HHRlDwKBBTaYhB1qVzHsUMnt Q9OGjcZZWXNNWeStGBTp6d4+rt54YRazQn655iXGIVhoF0U3JbUlRKVI8ywMQqBA6/GG ViBFUjDrXo1r8mRcmAYpBRk+gzTueUqBdpN0x0ZONSZyQVeQ3dyegpcwDYXr/tPrFnaE gUN4lQ7QiDUodedf54fDgDnph4AiscTYR6LnMiHUXlMXc80aJ6gCGkrEkLB5lZz20Io0 yvkYInhfIF9Rnepu7FZ+PmkuUu6ry0UTOYEufS2x+YIqagHE01SImvpjHKOuv6KO/Csn zEcg== X-Gm-Message-State: AOJu0Yxzt/D9uN+kn+6850akTXKunjX2ZgeiUrNGejYVqnJGzoIsTpTp 65VoR0lM0IB3SUrUEOhuRBYBgJ0hQpB62bC3uas= X-Google-Smtp-Source: AGHT+IHSSQPay0nZxYl504c1/I5ZSMW+6yvqaJiKuZ+uWRiSAz+fxXCyqA+3MtRZRy/7Ggos7+QkOQ== X-Received: by 2002:adf:fd87:0:b0:318:416:a56a with SMTP id d7-20020adffd87000000b003180416a56amr2402815wrr.13.1694098356640; Thu, 07 Sep 2023 07:52:36 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:56f5:e2d4:1e04:b28e]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c020200b003feef82bbefsm2757588wmi.29.2023.09.07.07.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:52:36 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 5/5] gpio: mockup: don't access internal GPIOLIB structures Date: Thu, 7 Sep 2023 16:52:30 +0200 Message-Id: <20230907145230.44085-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230907145230.44085-1-brgl@bgdev.pl> References: <20230907145230.44085-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bartosz Golaszewski Don't include gpiolib.h. Track the request status of lines locally instead. In order to retrieve the device name use the fact that gpio-mockup supports only a single GPIO device per platform device and call device_find_any_child(). Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 39 +++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 44684ff4462f..4870e267a402 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -25,8 +26,6 @@ #include #include -#include "gpiolib.h" - #define GPIO_MOCKUP_MAX_GC 10 /* * We're storing two values per chip: the GPIO base and the number @@ -42,11 +41,13 @@ * @value: Configures status of the gpio as 0(low) or 1(high) * @pull: Configures the current pull of the GPIO as 0 (pull-down) or * 1 (pull-up) + * @requested: Request status of this GPIO */ struct gpio_mockup_line_status { int dir; int value; int pull; + bool requested; }; struct gpio_mockup_chip { @@ -146,14 +147,12 @@ static void gpio_mockup_set_multiple(struct gpio_chip *gc, static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, unsigned int offset, int value) { - struct gpio_chip *gc = &chip->gc; - struct gpio_desc *desc = gpiochip_get_desc(gc, offset); + struct gpio_mockup_line_status *line = &chip->lines[offset]; int curr, irq, irq_type, ret = 0; guard(mutex)(&chip->lock); - if (test_bit(FLAG_REQUESTED, &desc->flags) && - !test_bit(FLAG_IS_OUT, &desc->flags)) { + if (line->requested && line->dir == GPIO_LINE_DIRECTION_IN) { curr = __gpio_mockup_get(chip, offset); if (curr == value) goto out; @@ -181,8 +180,7 @@ static int gpio_mockup_apply_pull(struct gpio_mockup_chip *chip, set_value: /* Change the value unless we're actively driving the line. */ - if (!test_bit(FLAG_REQUESTED, &desc->flags) || - !test_bit(FLAG_IS_OUT, &desc->flags)) + if (!line->requested || line->dir == GPIO_LINE_DIRECTION_IN) __gpio_mockup_set(chip, offset, value); out: @@ -247,10 +245,23 @@ static int gpio_mockup_to_irq(struct gpio_chip *gc, unsigned int offset) return irq_create_mapping(chip->irq_sim_domain, offset); } +static int gpio_mockup_request(struct gpio_chip *gc, unsigned int offset) +{ + struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + + scoped_guard(mutex, &chip->lock) + chip->lines[offset].requested = true; + + return 0; +} + static void gpio_mockup_free(struct gpio_chip *gc, unsigned int offset) { struct gpio_mockup_chip *chip = gpiochip_get_data(gc); + guard(mutex)(&chip->lock); + + chip->lines[offset].requested = false; __gpio_mockup_set(chip, offset, chip->lines[offset].pull); } @@ -343,6 +354,7 @@ static const struct file_operations gpio_mockup_debugfs_ops = { static void gpio_mockup_debugfs_setup(struct device *dev, struct gpio_mockup_chip *chip) { + struct device *child __free(put_device) = NULL; struct gpio_mockup_dbgfs_private *priv; struct gpio_chip *gc; const char *devname; @@ -350,8 +362,16 @@ static void gpio_mockup_debugfs_setup(struct device *dev, int i; gc = &chip->gc; - devname = dev_name(&gc->gpiodev->dev); + /* + * There can only be a single GPIO device per platform device in + * gpio-mockup so using device_find_any_child() is OK. + */ + child = device_find_any_child(dev); + if (!child) + return; + + devname = dev_name(child); chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); for (i = 0; i < gc->ngpio; i++) { @@ -435,6 +455,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) gc->get_direction = gpio_mockup_get_direction; gc->set_config = gpio_mockup_set_config; gc->to_irq = gpio_mockup_to_irq; + gc->request = gpio_mockup_request; gc->free = gpio_mockup_free; chip->lines = devm_kcalloc(dev, gc->ngpio,