Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3941726rwb; Sat, 12 Nov 2022 17:12:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lGumo33UBHcgXNedlnTOMy6M+HgD5IVx+q3B6g2+IzxXKV/Zxan13tJmkSi8uHGVOzh+3 X-Received: by 2002:a17:907:78cb:b0:78d:887f:c1 with SMTP id kv11-20020a17090778cb00b0078d887f00c1mr6538205ejc.209.1668301924961; Sat, 12 Nov 2022 17:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668301924; cv=none; d=google.com; s=arc-20160816; b=SsDyPmd4Y9NpbIax8sSyYsAtHhCQOno4iMlohcdFoumwvC0pncrMq00eIVv2lwULkV DgJrupZTgzba/+AeZWb5J0ea/hHE6IS1zdegt1LRubpI9/4Yfe2XngQjg1ljwQwLU3Uf H1KRuZOpVFJN6xPKTxD/qaRclLGficFEi7Sx/LPwM12m5r8nXyOGPeALJgL9zRFoLDIl GGQNuoD/p7C4LNhcW2w2leo61jzDLo1SvNpD1Qi5bI68d2nzjuRJuVInq+cMoGSifNAW 5LDaXw2Vr3UqNVhSiIscHxQquQv8ZnXxpYcg0AZcnh+CIbgqUnsmJ3smqT2lpH0U0Wh8 +yEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=y2DT+DwYAGhQmBgm02Hatyz4IgqEc7zsVJLAJJN9Ri0=; b=CshItBO0esYvXLHChrBYgX6L9XuQCjI0qawPV3OXLChyBJ901WEg8TChGu2LcjLxG9 +gLUNB8DtUN6WNAPrWbrTpI2j0NFDNJG7XHCLtRNHD7VfnZ5V/U6kxj6xdOciqVtFSBp Orh8J+is0OSN33IViDU9/oxSbhYr/M1BXApfmgKR8asLrW34U6AQuXw4JOIFiA6FV9kz abczrrhhL6Sl/5OLbhSJkfxwQf4wBjrasft83V8bXXo8/GxBa/8VA22QTq/wpUWb6VcG GD32AbFWkLqtDBFZ+/X8eJDZWRDwU3yAFXVNHkW8/OQQ858wMS9sV1FznY38F9JIPoWi 8U0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NazLy5nz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc7-20020a1709071c0700b007adc0d5ad94si6616965ejc.938.2022.11.12.17.11.43; Sat, 12 Nov 2022 17:12:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NazLy5nz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235136AbiKMBJs (ORCPT + 90 others); Sat, 12 Nov 2022 20:09:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235106AbiKMBJp (ORCPT ); Sat, 12 Nov 2022 20:09:45 -0500 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186CB13F1D for ; Sat, 12 Nov 2022 17:09:45 -0800 (PST) Received: by mail-qk1-x729.google.com with SMTP id x18so5520256qki.4 for ; Sat, 12 Nov 2022 17:09:45 -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=y2DT+DwYAGhQmBgm02Hatyz4IgqEc7zsVJLAJJN9Ri0=; b=NazLy5nzQlgW+6kjijqavW5qe2KAD2TLi2xDnZLX97WjnB444i4AJ0eTOg+ljoaaiB 4lhtqnfPwkdxNwPG+6gwN11mYQQCgoS1EgMxx1FgsvDq2wwQa4i+OeYxo0tA9baVeFIb f4M5v59OxUwG8cfhj//NxZOBqvFY4HxfnikrswndKvkqJr7KId7IeNcPnskg+Chffz3U CMTqI+decenIEgYGwLZ937ilUJbsSht0rkGXtHofnmatZ2NoYOAkO9lIOH/J6qNt0qE7 B46c3vEK0IWR/CjPOZS3BHVs/XGcF1g2eBRqP/79G+89/L/jfrwDIdD/VuNWkh2vDnjt sFYQ== 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=y2DT+DwYAGhQmBgm02Hatyz4IgqEc7zsVJLAJJN9Ri0=; b=n0CzMM7uUYEU09o/UOB58kTMZa6Nexoi13ZwIyCIIYronV6pr9awVH5sZjOwvnz7il wFjhwkSw00NfzPkkPJb7emD4DyuHOY//4L2IPdyVD2hxZ+tJenS/iSRpwgKjjGaRP5L3 NvhJaMzv9IvorqOIRsCCR1tPJDQCN3J37zs69iFqYXzIiNj+9CBpcE/faeCa1hxxpvLj HqWtV6/84863cXHT2U2BNJ8ySQ4D/odLVHhtn6epFFfwFm7zta1S0PHs9QtLcV9mlo9I Vxl/HEKrMnyLFN/kQKyD3PHa4tUnew20WPIHKemtUAOYAFlDi18nIol3q7wXNBU6RUNb tVnA== X-Gm-Message-State: ANoB5pkg4xxCFKJehRY9zuoBU25nJ9wJEkcGwIwCRPm9nEnBvjnlIGrd zRjDU4zEqYD65RXEwBUf43oa+A== X-Received: by 2002:a37:6c83:0:b0:6fa:19a4:ab6f with SMTP id h125-20020a376c83000000b006fa19a4ab6fmr6719620qkc.759.1668301784203; Sat, 12 Nov 2022 17:09:44 -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 t6-20020a05622a180600b00343057845f7sm3552498qtc.20.2022.11.12.17.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Nov 2022 17:09: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, broonie@kernel.org, William Breathitt Gray Subject: [PATCH v2 1/4] gpio: regmap: Always set gpio_chip get_direction Date: Thu, 10 Nov 2022 20:55:50 -0500 Message-Id: <1805d1ddb5bbce8e86164e66421ddde481cce4f9.1668129763.git.william.gray@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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; + 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 = gpio_regmap_addr(gpio->reg_dir_out_base); invert = 0; @@ -265,8 +270,8 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config else if (gpio->reg_set_base) chip->set = gpio_regmap_set; + chip->get_direction = gpio_regmap_get_direction; if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) { - chip->get_direction = gpio_regmap_get_direction; chip->direction_input = gpio_regmap_direction_input; chip->direction_output = gpio_regmap_direction_output; } -- 2.38.1