Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp773867rdg; Wed, 11 Oct 2023 05:20:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEik4/ADmUEfMDDb+sAN82B0aTo99y6M99vfL/1agMkZ4AaY8plkVWwK+WpGzVBO6zPMRrN X-Received: by 2002:a17:903:2348:b0:1c7:47ca:f07f with SMTP id c8-20020a170903234800b001c747caf07fmr19777407plh.21.1697026845516; Wed, 11 Oct 2023 05:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697026845; cv=none; d=google.com; s=arc-20160816; b=d7IZImuKSg2wBik8OqvXJjd92qPEliH24V9s+UDdd5iYlrKA7IZ3RWYqLP8rMOZIcv N4gU5sBBBHBd3Ji/Uw2leb8zQCMdzm1sY12jTsXtCJd6xwvg4IhHpn3yZ4iDOsmV5RJf N/x2mnzZM9nEwfe/7UH0L2iJ80G76SwWwBE0bRu3PeH2X1XN9jCQqOnxqLg36ni+cxvD 7jgJw8pKDH/nMmbzu9s46ZZd8vkE8VMfbq7nDu32Upisi50gva+4uD1zFOocYSBX0sGm LGV3O/6j+Y31UeIqF1/93Dk+Gy+BK3DP9+fPy6aypj/dldaPsIoMXhwjOGlkB1hREJkY gS0w== 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=PV4PS0wlUJUsPnHQ+15CSYkWjpePpNEtuLC0jO+O4fA=; fh=kOxmq+prcfKKX/dgMaMxTb6TRjzyc//QKXZBiaS/a94=; b=Ynz/ETcaLjW6Q7r6GRZ7+H1YKq/HnJXbN06ev2BRNWn7Ja/BvOXj01AyXyKCSkbCWN AHiZQM5Ev7UvrM0yih7Jb0zfstSHHjSMUTiBQz0nKnCG0wRhaNZWb0K+fXP53ifvX78q iXjq6Pvg99YWcvPHk505p39D3Ant8thiw4DgHxT/KH6LWqlMhRtmI7PIBcQtyZT3NYtd CqJq+QPeMhEMJdL95Nr/iXsEFm8Y8mMkwiP3HIgscBGpaxt60Jn59AXXAdMryqEkoTsv bPfgfhWrpe2lCQDVIjMxG1GdzkE/KItqU+Hlh4/AphU9nUJgoGWgMmEimHwv34WXM7i0 anxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SmIHmEHK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kn6-20020a170903078600b001c41515c4c7si13923344plb.115.2023.10.11.05.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=SmIHmEHK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 7B4728039EF1; Wed, 11 Oct 2023 05:20:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234978AbjJKMU1 (ORCPT + 99 others); Wed, 11 Oct 2023 08:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbjJKMUY (ORCPT ); Wed, 11 Oct 2023 08:20:24 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 025EE19A7 for ; Wed, 11 Oct 2023 05:10:20 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-405361bb94eso69192205e9.0 for ; Wed, 11 Oct 2023 05:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697026190; x=1697630990; 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=PV4PS0wlUJUsPnHQ+15CSYkWjpePpNEtuLC0jO+O4fA=; b=SmIHmEHKMnG2f/01uVvH1kD0bW639bRCf6KaJd2vlyfTV9XvDKyGtnaFBZS4txs77Q DIx8+KV6HWPDMFV1N7VvdlvR0mKtld+Wv/MfH7Vn6kP0r8mRUc0F6Fc8zO12p+X8g8an ZIO4WrKU1cBzw43RAsKlL1FLcf/lxCmht4NHZ0Odh47tvak9MMiHnd+igSq3c2ZCLaAx kLRddvtWUhv0Vo4crOkw6PDuLuUluY3q9m2ytcF5kLM2NNeXUdyTvAGrKVLmh64+2Hrb xsHxr8+ynKcMOQXOpRZ2brgtB4EeMOnUSjivFmm+pmiF38zfq/52AJbkuhUlmn/9YCeP 7M4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697026190; x=1697630990; 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=PV4PS0wlUJUsPnHQ+15CSYkWjpePpNEtuLC0jO+O4fA=; b=Ne3xhxun9nSAKfU+YfJMariuai4KaxcF9PbLYPTrojXpVk1Cx/P2/7+daEyaITO2by mPG3KafQn6BDE94co6vyR6vzh7cYNOFGJ85ZkmYLUKYfZzTxvMdiJY34Pwi0V2n0KNo7 vg+zQ6mcrgNXk+bCRVT5BZ32jjNuGqng2C0wutxWyfYcv6h5EXDoP8t74V73I3TA9iM2 3PH59PLJA2LUSkCummEdlxYGmpg+t0XrHA5EDfOsmMfJDuzOD9vwFuLpQrY6mBPYxsoD 7PkBD0ZBNADMoOdx8lXtIuPTUokaeBygydEukxpSkdtNHEIdrbynUm/d18vXXGrXT56F WElg== X-Gm-Message-State: AOJu0YyIoWk9DyfPgaSxybxjBkAR/sB4XrbbER/UcOJN2IdvdQXb5Gd9 Zk6Oox4S0Wm5VjGDD4MFnK0mvQ== X-Received: by 2002:a7b:c7c5:0:b0:404:4b6f:d70d with SMTP id z5-20020a7bc7c5000000b004044b6fd70dmr19405847wmk.17.1697026189872; 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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 05:09:49 -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 46/62] pinctrl: change the signature of pinctrl_ready_for_gpio_range() Date: Wed, 11 Oct 2023 14:08:14 +0200 Message-Id: <20231011120830.49324-47-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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 11 Oct 2023 05:20:40 -0700 (PDT) X-Spam-Level: ** From: Bartosz Golaszewski Modify pinctrl_ready_for_gpio_range() 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 | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 89df934d65bc..e3da8aeee01d 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -322,7 +322,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc, /** * pinctrl_ready_for_gpio_range() - check if other GPIO pins of * the same GPIO chip are in range - * @gpio: gpio pin to check taken from the global GPIO pin space + * @gc: GPIO chip structure from the GPIO subsystem + * @offset: hardware offset of the GPIO relative to the controller * * This function is complement of pinctrl_match_gpio_range(). If the return * value of pinctrl_match_gpio_range() is NULL, this function could be used @@ -333,19 +334,11 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, struct gpio_chip *gc, * is false, it means that pinctrl device may not be ready. */ #ifdef CONFIG_GPIOLIB -static bool pinctrl_ready_for_gpio_range(unsigned gpio) +static bool pinctrl_ready_for_gpio_range(struct gpio_chip *gc, + unsigned int offset) { struct pinctrl_dev *pctldev; struct pinctrl_gpio_range *range = NULL; - /* - * FIXME: "gpio" here is a number in the global GPIO numberspace. - * get rid of this from the ranges eventually and get the GPIO - * descriptor from the gpio_chip. - */ - struct gpio_chip *chip = gpiod_to_chip(gpio_to_desc(gpio)); - - if (WARN(!chip, "no gpio_chip for gpio%i?", gpio)) - return false; mutex_lock(&pinctrldev_list_mutex); @@ -355,8 +348,8 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio) mutex_lock(&pctldev->mutex); list_for_each_entry(range, &pctldev->gpio_ranges, node) { /* Check if any gpio range overlapped with gpio chip */ - if (range->base + range->npins - 1 < chip->base || - range->base > chip->base + chip->ngpio - 1) + if (range->base + range->npins - 1 < gc->base || + range->base > gc->base + gc->ngpio - 1) continue; mutex_unlock(&pctldev->mutex); mutex_unlock(&pinctrldev_list_mutex); @@ -370,7 +363,11 @@ static bool pinctrl_ready_for_gpio_range(unsigned gpio) return false; } #else -static bool pinctrl_ready_for_gpio_range(unsigned gpio) { return true; } +static inline bool +pinctrl_ready_for_gpio_range(struct gpio_chip *gc, unsigned int offset) +{ + return true; +} #endif /** @@ -805,7 +802,7 @@ int pinctrl_gpio_request(struct gpio_chip *gc, unsigned int offset) ret = pinctrl_get_device_gpio_range(gc, offset, &pctldev, &range); if (ret) { - if (pinctrl_ready_for_gpio_range(gc->base + offset)) + if (pinctrl_ready_for_gpio_range(gc, offset)) ret = 0; return ret; } -- 2.39.2