Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4528648rdb; Fri, 29 Dec 2023 05:08:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrQa+zMWeLMdVbu8hVcthHf+ae/eRfni6CYm4i9eao8HhZDPpkSRqoZP1nwC0C7hsA8rZz X-Received: by 2002:a1f:7d0d:0:b0:4b6:c810:ab7e with SMTP id y13-20020a1f7d0d000000b004b6c810ab7emr4355932vkc.28.1703855302991; Fri, 29 Dec 2023 05:08:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703855302; cv=none; d=google.com; s=arc-20160816; b=MIvx2VLZqlPFn+ayKDZo3cJRlF6XfJ1HKZtbmu7wLdsHLAvgpRmeArLilQFZvkfRXX My+uY2tBnaqFrHiVx7BUAij2vkpKxCxBW0HdGvaMZxJmYYjfQDiStafxbG/5ml148VOo QcHIKg6eG5yD0xqhR8RqbUtjuTecv5NjHWsFftU3rZaGrGNx0rIOEb/3mH4XDnfEBxGR kHr557BYm+LNYgeuXN8NXxkD7VI800pzNN/PkPgtxdu7PHcJ70y/4e7XgzddKtAfF04f MUx4HCLc/MJAfhnHaxkN3xOtI0RNuqHaPEUb9DM/XJ4pDD282zsvS2IP/2LAd/cMb2xq 3iyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; fh=7+VlPjlvMh5BcTbJ3sN70/UW1WHuO1uZHVdSiAivbi0=; b=Vjj1Y6jb1V9MIBOIVOulvW7noK5UIdG+CN2CHxK92Sahb7VpdD24nu/uSKni3XLWvi GwGafMReHRhcPhtvYchAt4dBWgsGIgDRqLqyNSxErB0yuFR4qnRWV8szMhmv+KQk3uX+ fer9BlVMq5WHMHG4Y7inkZ6rTCwqZbquX4HydFnfrVofmaAdEU2O/2BvEHg72rUyVUk0 cVE95KzttIStq6LMUZZoQFOkyuJnCLxkpPsdHdqNaIX3+dG0W9nU9elNOEgPXRV3KA1w n97SAI5/uieDKAQGASaSWAZLzwIykrZpkybZzZUe1zOFXNtznkbYmJydoUNaVIyHRtCj sFtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=eK9NUZ75; spf=pass (google.com: domain of linux-kernel+bounces-13092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i4-20020a056122128400b004b72b4580f0si1541465vkp.162.2023.12.29.05.08.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 05:08:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=eK9NUZ75; spf=pass (google.com: domain of linux-kernel+bounces-13092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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 B8C001C2219D for ; Fri, 29 Dec 2023 13:08:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 409C2111B0; Fri, 29 Dec 2023 13:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="eK9NUZ75" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 21393111B5 for ; Fri, 29 Dec 2023 13:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 562D53F15B for ; Fri, 29 Dec 2023 13:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1703855290; bh=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eK9NUZ751EG8XuCqHJjBkaq+ncUXr6PzlYT+zrbvp2ACMCzKJpSx4DvkmFeKL5Q99 boW7ZeongFkRMzciT9OS9UVesrn+sn9vWQnNqoqVxpZrkXfiuPBZwd1Obr1yaMLyRt l9q0yqHBFXfz6fX95Tqa8yghJqsqxhTkfjWzizuQu25jyxrcQ1FEwxkvI6Yf4vIwgI oZQ0i+fW9PjPrZ1IKwLBgyaNGiQb/KhnUFAjqgOROalCparTY7u4BpRoxxNxtmOZMY XlBONN9+8eFY1gs8NFvzc5JTZIFxV4iv3n/APR4+1eVB6+HBGFT9KLfvVW3WQcLUbt PEXMMpXwW/ekw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5552470977aso1698378a12.0 for ; Fri, 29 Dec 2023 05:08:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703855290; x=1704460090; 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=R+U2uLziDgx+IP4bP4iaMKnlOMS40so+TR+KdlJRETI=; b=Znb+TRjziAMqOqLw/SSz+yegYrMco5Xb1RgLwEWIh1dIk41GSzcM9yS5a06ju6qy93 BvZ60t3vIQxJMFUmb/IOWSdiXGGGsczhN+pBsm56az88Wjri7WmRg2rRKcsDJABleQAB 3ZSRWustN3RFkx19eW6h7sPT26slrDtqS+Drg0tkGAoZn2F4+TFLzFCGqPB75/LMkUsv yuIvw/Ky4ZclosK9sDSIIdmEP1liXQEeWut3KK/tHo5daJBfu57FhBgGyuL78hCACYcY cG9PZijxvgX5MwizVWm4xd8NbNx+bep17/KebtnAeIm/p7AI6e/fFhOH+INY9gOQqk7a vg7g== X-Gm-Message-State: AOJu0YzvVK9NGvJZZYw5DQEfsZrthrWdY1izK6jE/QaPrN8712Voylqr ZnR0E725m+4fEbm0RPLOTMsORthnpS8I392VFyj+wwOOuf8hXqZsZU90PV5n+jsu0/huZ+u4adC Xbh1P8oxrufpDHWRljxVrY6dpqEfJYoRV91JMunFbubLeh6iP X-Received: by 2002:a17:907:1047:b0:a1f:7298:aa25 with SMTP id oy7-20020a170907104700b00a1f7298aa25mr5908865ejb.45.1703855290046; Fri, 29 Dec 2023 05:08:10 -0800 (PST) X-Received: by 2002:a17:907:1047:b0:a1f:7298:aa25 with SMTP id oy7-20020a170907104700b00a1f7298aa25mr5908860ejb.45.1703855289728; Fri, 29 Dec 2023 05:08:09 -0800 (PST) Received: from stitch.. ([2001:67c:20a1:1909:b62b:6d4a:f569:ad01]) by smtp.gmail.com with ESMTPSA id ex1-20020a170907954100b00a26f22dca5asm4359327ejc.0.2023.12.29.05.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 05:08:09 -0800 (PST) From: Emil Renner Berthing To: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hoan Tran , Serge Semin , Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Jisheng Zhang , Drew Fustini Subject: [PATCH v1] gpio: dwapb: Use generic request, free and set_config Date: Fri, 29 Dec 2023 14:07:51 +0100 Message-ID: <20231229130758.84214-1-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This way GPIO will be denied on pins already claimed by other devices and basic pin configuration (pull-up, pull-down etc.) can be done through the userspace GPIO API. Signed-off-by: Emil Renner Berthing --- drivers/gpio/gpio-dwapb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 8c59332429c2..798235791f70 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -416,11 +416,12 @@ static int dwapb_gpio_set_config(struct gpio_chip *gc, unsigned offset, { u32 debounce; - if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) - return -ENOTSUPP; + if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) { + debounce = pinconf_to_config_argument(config); + return dwapb_gpio_set_debounce(gc, offset, debounce); + } - debounce = pinconf_to_config_argument(config); - return dwapb_gpio_set_debounce(gc, offset, debounce); + return gpiochip_generic_config(gc, offset, config); } static int dwapb_convert_irqs(struct dwapb_gpio_port_irqchip *pirq, @@ -530,10 +531,14 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, port->gc.fwnode = pp->fwnode; port->gc.ngpio = pp->ngpio; port->gc.base = pp->gpio_base; + port->gc.request = gpiochip_generic_request; + port->gc.free = gpiochip_generic_free; /* Only port A support debounce */ if (pp->idx == 0) port->gc.set_config = dwapb_gpio_set_config; + else + port->gc.set_config = gpiochip_generic_config; /* Only port A can provide interrupts in all configurations of the IP */ if (pp->idx == 0) -- 2.43.0