From nobody Sun Feb 8 22:07:45 2026 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 EC5ADC4167B for ; Tue, 27 Dec 2022 14:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231743AbiL0Oct (ORCPT ); Tue, 27 Dec 2022 09:32:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230267AbiL0Ocp (ORCPT ); Tue, 27 Dec 2022 09:32:45 -0500 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955C763E7 for ; Tue, 27 Dec 2022 06:32:44 -0800 (PST) Received: by mail-oi1-x22e.google.com with SMTP id u204so12064876oib.7 for ; Tue, 27 Dec 2022 06:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=Ri0mZ2K/fUhEx8zLPRzENIukosBulaHGjs8vpkuOJm0=; b=FzsUiFWzBJpv2JmeTGUVSttBRVVcokZ01iBLWstsIaKIarGbhHdLV1eWQTjALe9WsZ ao99I0x39hdNKMhO08W1vKYeFDpvjnhPElDfw8mktYJIfFN+B1Why6P6g6nTaIKyFBEN 7x9EqwL+4A1mx/5F4BA5GcVi8QRvM+Bssn8Is/7xT6qBlMrdrEaa9WGXG3ElndaiuRpk 4/efYE43oJKDvOdnwvL5Y668pA4OGaH3q7gJsmAHMekeWzIUZnnfkB0/YTiu2KROtTB/ UPT0Z7n/FlLaAkHL2AaczxJycL5lFcy4VneFbp409c45Sq0vJ8K3ILSY3XQq/ijgqwWS jaww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Ri0mZ2K/fUhEx8zLPRzENIukosBulaHGjs8vpkuOJm0=; b=3YAQvU7pDr4rtCVQjdmeVZfZ5vhmWP40g42SFSzICexJdh+nM9xaQFOzuYuNMVucKq 2DTTf75Qr7k0z+Lh8o2s7bp6ht/g+rBV8KpzzBcqQXh7sTHWdy3wU8V0xk9wpH3M9h9d 6cBtJ8X0ZnQnAj3etHlZlnuZtGbkWSvVHsaPg6Qg54WaqK4Qvntsc/53/b60s7gYa9ej IR09H0DAI0nW+fAE9JdXyW5EKiVWnPbuUGkcgceuIp31Q0OF3F+XNv53fKMi4qJYN9BU gJacx32ZsiCRClqnu52mL2I7dLl0rLp+65K26fSbrB6UaVCutxDWrPbZyksVqxc53UDp RUQA== X-Gm-Message-State: AFqh2kpvZ78Cl5iD2WuFLVy6/RbJ9LjYcbcPRRoPf55aac0Qs8wdhmjM 4t2wJqTGyqCJNHzCRAfy3EgZn6/n1ah93z2v X-Google-Smtp-Source: AMrXdXsfa8XvWG+xNY9yQw9yxMAS5xYahVfrADa6LKlUY/J9RXyRtrdeXRtLB/UnWVQmd+WtgQcbLQ== X-Received: by 2002:a54:4081:0:b0:35a:d72:5505 with SMTP id i1-20020a544081000000b0035a0d725505mr17025178oii.12.1672151563943; Tue, 27 Dec 2022 06:32:43 -0800 (PST) Received: from fedora.attlocal.net (69-109-179-158.lightspeed.dybhfl.sbcglobal.net. [69.109.179.158]) by smtp.gmail.com with ESMTPSA id q205-20020acac0d6000000b0035bce2a39c7sm5864969oif.21.2022.12.27.06.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 06:32:43 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org, brgl@bgdev.pl Cc: andriy.shevchenko@linux.intel.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, michael@walle.cc, William Breathitt Gray Subject: [PATCH v5 1/8] gpio: regmap: Always set gpio_chip get_direction Date: Tue, 27 Dec 2022 09:09:39 -0500 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If you only have reg_dat_base set, then it is input-only; if you only have reg_set_base set, then it is output-only. Thus, we can always set gpio_chip get_direction to gpio_regmap_get_direction and return GPIO_LINE_DIRECTION_IN/GPIO_LINE_DIRECTION_OUT given the respective register base addresses configuration. Reviewed-by: Andy Shevchenko Acked-by: Michael Walle Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-regmap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 6383136cbe59..f907c9c19fce 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -111,6 +111,11 @@ static int gpio_regmap_get_direction(struct gpio_chip = *chip, unsigned int base, val, reg, mask; int invert, ret; =20 + if (gpio->reg_dat_base && !gpio->reg_set_base) + return GPIO_LINE_DIRECTION_IN; + if (gpio->reg_set_base && !gpio->reg_dat_base) + return GPIO_LINE_DIRECTION_OUT; + if (gpio->reg_dir_out_base) { base =3D gpio_regmap_addr(gpio->reg_dir_out_base); invert =3D 0; @@ -265,8 +270,8 @@ struct gpio_regmap *gpio_regmap_register(const struct g= pio_regmap_config *config else if (gpio->reg_set_base) chip->set =3D gpio_regmap_set; =20 + chip->get_direction =3D gpio_regmap_get_direction; if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) { - chip->get_direction =3D gpio_regmap_get_direction; chip->direction_input =3D gpio_regmap_direction_input; chip->direction_output =3D gpio_regmap_direction_output; } --=20 2.38.1