Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp775037rdg; Wed, 11 Oct 2023 05:22:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXpAXvcrs3Nxgt7kYsnLwXmcSQfJuxLP6J81Jt32Q92YNlx22lQmZnC4ZDixh9FS7VbXIA X-Received: by 2002:a17:90a:199d:b0:27d:1571:f683 with SMTP id 29-20020a17090a199d00b0027d1571f683mr9495pji.44.1697026968129; Wed, 11 Oct 2023 05:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697026968; cv=none; d=google.com; s=arc-20160816; b=odC8tAyYheJtkfiS3S0D75F/2fB+ObZSFmYcaFGYh6JD2ht9k22A/WyENbHGe/ZKmT AzbC2Ym0l+FY5fn0dDdAmxx7BIERTvqrSx72MIWH4XGx3h7Wh/PlLihbAdmEpZGmjhX/ 5wXD6D1ft+HMxZZ6zrFg7awYPL9s7HIB9DHzCOYhavJsKj8c7hLj6PSlA+umhVoQ9xNc 9gSeqo8E3z75GJA7YN1MMWOrWAcLUHTeMbcbo/i1NA28tS+uA0tb/Rdm2sGAGPnly6ya yB2NX/5Gsoa4HgyuhXjDvwFf4uEama4mn7tTaTvW5dMGeXd3b4VPAOywCT1v6bGLvrND 7gSw== 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=KvqkdE0pFC3rt0ALCPspH5t69Bx+kT0SWwFi+Jjq8JI=; fh=kOxmq+prcfKKX/dgMaMxTb6TRjzyc//QKXZBiaS/a94=; b=RsiJNOTFwdTBBzWtAj4c3PRvC9O/VFcHcWVpgeVpd1NSQdkHENb4id/uj+GJ3LIMYJ rq/579+444qE/KMtzDKhgtZjplnFCkdznPLAPeEnIVy0eJ4vFA5H0/zNlNpT0c15Uapm a9XXRzQ8rEg/FyuKWXk+xq9fKlp5+gpm8QYOgUQcbbaHTIDrJK74/A04FFnigaIGRSmY Qt8Ore/x+VTYL9Ipp2LvXE0y6OOEWh5fgZRElqZ2u12D4a2Ph7y76CpxrcHkTYcDGKDQ FwUJfJBohD15CKm5StLCr7eYUxcsg1d2ds2x4ZWTMqfjIenAo2U+Ytsea0Hj2oJ1DgRo dOhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=QZT2QNjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a22-20020a17090abe1600b00275cffed966si15599006pjs.57.2023.10.11.05.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:22:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=QZT2QNjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B5512813567C; Wed, 11 Oct 2023 05:22:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346960AbjJKMWb (ORCPT + 99 others); Wed, 11 Oct 2023 08:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232213AbjJKMWK (ORCPT ); Wed, 11 Oct 2023 08:22:10 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89B71199E for ; Wed, 11 Oct 2023 05:10:18 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40684f53bfcso62664555e9.0 for ; Wed, 11 Oct 2023 05:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697026189; x=1697630989; 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=KvqkdE0pFC3rt0ALCPspH5t69Bx+kT0SWwFi+Jjq8JI=; b=QZT2QNjmtsq4K2GdrJujpExlrFRrPGj3KERcfivGBjcMjq4lF4WxhrOuICYEB3xrBq RdIwARKiFOdjht488LPPwY7ntC3NrlkYtF3X+IZX2eMmaeKmxfhx6LxovjKwywQXBlUH uYEZFWhtRmVPupuj348uHMyPwZuJw0x++Jcxl0i3k/sA4VIva60/SImfOiArwX3QlgD0 ZQhf0UCUbEBcjWJe1A0XyWok3ZRtD5Rg8E9+tRh+ceN1PBrgN8w2b0FFxsgEPwL2xqM6 C2FqDD72WvUDh1d/QDK98nT5NBQlp2jg8pdybOqsoGC6nZbMFzURlbZe/1T5DcwfG9P5 JyRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697026189; x=1697630989; 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=KvqkdE0pFC3rt0ALCPspH5t69Bx+kT0SWwFi+Jjq8JI=; b=fwaEQRDos1l5+GXE/C4yIYQP2E3lY2vt4uvzLItfRgwT7BTiXeChnOJcGD04ND5Jnu L0ka7TA5GcA1GTogzENL73OTAnA3rHUqynD87wGmU7dpHm50sMz6nR2+gCAtKeiCUZIp GNSOwEUs4p/o3C179dKjuq+gFvjh0LeeIvanjxLLua2q9AjcwkMvZ3apNBZ8drkHszqB M88bhzB9E1FLFDiS5BLzeN4dzfefcmekPPJ6Xc+KFeREw9z5KkfOjn33l4w/qLfdvqRI p1UByX6hB4mUq/jfuqb9LbFIWOHsjDaTHKlYi812G4VafwfdtCVUtRKtMqDF+KMcyQ08 dyDA== X-Gm-Message-State: AOJu0YyZBBp54+naSlnaRr8lQbAff22VF3sROVevgPoy5z8s8bqUWmS1 plaCLm84oSORDzifxeNfBwVMsw== X-Received: by 2002:a7b:c4d6:0:b0:406:7074:301d with SMTP id g22-20020a7bc4d6000000b004067074301dmr19196089wmk.11.1697026189083; Wed, 11 Oct 2023 05:09:49 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:e551:3946:26fc:f94]) by smtp.gmail.com with ESMTPSA id w21-20020a05600c015500b0040652e8ca13sm19012253wmm.43.2023.10.11.05.09.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:09:48 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 45/62] pinctrl: change the signature of gpio_to_pin() Date: Wed, 11 Oct 2023 14:08:13 +0200 Message-Id: <20231011120830.49324-46-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231011120830.49324-1-brgl@bgdev.pl> References: <20231011120830.49324-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 05:22:43 -0700 (PDT) X-Spam-Level: ** From: Bartosz Golaszewski Modify gpio_to_pin() to be in line with public GPIO helpers and take a pair of GPIO chip & offset as arguments. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/core.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index dbc59e409439..89df934d65bc 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -269,7 +269,8 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev, /** * gpio_to_pin() - GPIO range GPIO number to pin number translation * @range: GPIO range used for the translation - * @gpio: gpio pin to translate to a pin number + * @gc: GPIO chip structure from the GPIO subsystem + * @offset: hardware offset of the GPIO relative to the controller * * Finds the pin number for a given GPIO using the specified GPIO range * as a base for translation. The distinction between linear GPIO ranges @@ -280,13 +281,13 @@ static int pinctrl_register_pins(struct pinctrl_dev *pctldev, * result of successful pinctrl_get_device_gpio_range calls)! */ static inline int gpio_to_pin(struct pinctrl_gpio_range *range, - unsigned int gpio) + struct gpio_chip *gc, unsigned int offset) { - unsigned int offset = gpio - range->base; + unsigned int pin = gc->base + offset - range->base; if (range->pins) - return range->pins[offset]; + return range->pins[pin]; else - return range->pin_base + offset; + return range->pin_base + pin; } /** @@ -777,7 +778,7 @@ bool pinctrl_gpio_can_use_line(struct gpio_chip *gc, unsigned int offset) mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ - pin = gpio_to_pin(range, gc->base + offset); + pin = gpio_to_pin(range, gc, offset); result = pinmux_can_be_used_for_gpio(pctldev, pin); @@ -812,7 +813,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset) mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ - pin = gpio_to_pin(range, gc->base + offset); + pin = gpio_to_pin(range, gc, offset); ret = pinmux_request_gpio(pctldev, range, pin, gc->base + offset); @@ -844,7 +845,7 @@ void pinctrl_gpio_free(struct gpio_chip *gc, unsigned int offset) mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ - pin = gpio_to_pin(range, gc->base + offset); + pin = gpio_to_pin(range, gc, offset); pinmux_free_gpio(pctldev, pin, range); @@ -868,7 +869,7 @@ static int pinctrl_gpio_direction(struct gpio_chip *gc, unsigned int offset, mutex_lock(&pctldev->mutex); /* Convert to the pin controllers number space */ - pin = gpio_to_pin(range, gc->base + offset); + pin = gpio_to_pin(range, gc, offset); ret = pinmux_gpio_direction(pctldev, range, pin, input); mutex_unlock(&pctldev->mutex); @@ -929,7 +930,7 @@ int pinctrl_gpio_set_config(struct gpio_chip *gc, unsigned int offset, return ret; mutex_lock(&pctldev->mutex); - pin = gpio_to_pin(range, gc->base + offset); + pin = gpio_to_pin(range, gc, offset); ret = pinconf_set_config(pctldev, pin, configs, ARRAY_SIZE(configs)); mutex_unlock(&pctldev->mutex); -- 2.39.2