Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3109649rdg; Tue, 17 Oct 2023 05:08:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsmfLT1bicAKafEG9edMyTsc2l/duybXPTIYje03JX5cKTaOdI+Yn6i6f7cJlGXNaUPwpd X-Received: by 2002:a17:902:760d:b0:1c9:e072:3398 with SMTP id k13-20020a170902760d00b001c9e0723398mr1815939pll.41.1697544538218; Tue, 17 Oct 2023 05:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697544538; cv=none; d=google.com; s=arc-20160816; b=xpqShn3EALbD1nnN7NlTUrxzWBcdunsrp2+wsPUIcFjpKlEEWUGU6MSb1s6CoJEDD9 oRGcY4weXju79WdL5ES+zMvBiR2j+5uoDT5vF8dKjkGIehnkTMAY1DxxCy/f77wjC4G3 UQuekPJy5htnBh5dHRjvpm1NUnDL8J78pqGqXpFi/96pz/T6+emzKWiWlWaYwO0uFl5X lvBI6BLUk+wfuasToBD9J2DanrwWHnfI1bn5iQZDM50+noBYW6l0nYDZftf5axKXshfc gc8bnpJCUg7ygzt0Bthcw3sacg1q1LsxiwI4iVHs6e9NqThDEFfG2DhJNmfSVcSoDdOc c8ww== 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=eJlmvjClNYUGDO9zWdiE9QW26eZ74vwLTwImlwEqdgA=; fh=kOxmq+prcfKKX/dgMaMxTb6TRjzyc//QKXZBiaS/a94=; b=uOlesNkhs23cv3q+E/ZE37xdnUkVRYtrGbHwI0mQqXbpT/bv+fA7Fo/7Dg/rtdDrtu ecCgJa5Z1fTcZkxK/aooj5yp31rifaQiuP4usRucR2cLJOV6DAFf3GfLIh2Rcj3KGARH I0Z8qwM4thCxocdGaEIotj7vKxXTbGDBaf/a3ybX5y0b7Wi63CHaDlU2I02M90PDCLPy YHCwqgGHCTcCzn2Wiu9ELDKP9svWDtOzMngGto1z5iCng62GEFiC+hShU1dyXNKgcfgn OsnCgb0bGJ29t7B1jJxz0Ncfo7r2q58vykCbTqC5zrZqCCXthAADQ5DauuC8lShgDDUZ pOxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=CEpZd2qV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q13-20020a17090311cd00b001bdd35033efsi1643002plh.374.2023.10.17.05.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:08:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=CEpZd2qV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id A503C801B6C5; Tue, 17 Oct 2023 05:08:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235035AbjJQMIq (ORCPT + 99 others); Tue, 17 Oct 2023 08:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234889AbjJQMHd (ORCPT ); Tue, 17 Oct 2023 08:07:33 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8014211C for ; Tue, 17 Oct 2023 05:05:40 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4065dea9a33so52640915e9.3 for ; Tue, 17 Oct 2023 05:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1697544339; x=1698149139; 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=eJlmvjClNYUGDO9zWdiE9QW26eZ74vwLTwImlwEqdgA=; b=CEpZd2qVeeMGuYMjOwPiJPAW0Ucq1BhxbN69wfZllsr9FsELlxC3P5AtIqpc481wzz +DdGfPoflsAxAxOsSnudjvwD/Lh/CndCpsngPznGhSNV0dIEfefbtTMaFYWHaD8Zl5T0 NJOKEqzSBAIg2orALZczMnzvK8Kq63auYE3Kj8Uvc/fWm3lO28drBVz0BbqHN3JPN7nY CaJieTgK0RmTWqKJY4786UVs4JF2PumlGCbGSsEQwQWhEtDahId9kS7DIHY+lrnP8g+J QxCA5iEG37+M3IMkp8xRt3qps5clCaf498pHJ03efq7N2ER9Zs9cPct4zqArd0XMdO0k Grug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697544339; x=1698149139; 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=eJlmvjClNYUGDO9zWdiE9QW26eZ74vwLTwImlwEqdgA=; b=LA0CJW0jMrt+wPPcqIppgcNG/Nk1uJSJBnQ2XGJiBqe7l5gCZmpfp3Fti+KI0940Iv a8FuprtJ82jdTJAxYal+AXfMkqCRBsxzQnfgj4jl/4whxkmn0FFZvBxNycFVAoO/5z+X xH1RfiBJBRotCByj165iwidn9Ef6QFwuPQk7xR2YudR1ZogGB+Bigva21ZYpCy5TICfc pY7WTgZkookHKJwzxZyG74oPj4yaeOV4na/2e53kbpDQcyroxjM6Zv6IKAj/QYlX741l d3nxAPnjX9Gp3JLLffg/TRrvq9mRlH1tlR6ld0l2auJabKiwSzFsr7e4PACCj0ktL7OH jtnw== X-Gm-Message-State: AOJu0YzG8yjJ5Yz8r3QmhWFdSR3/wpdmhTILsf+rsPPyeGSn0WYVubjb CSjICjgN8q90pXoHKunMW45Cnw== X-Received: by 2002:a05:600c:511b:b0:403:272:4414 with SMTP id o27-20020a05600c511b00b0040302724414mr1672045wms.0.1697544339037; Tue, 17 Oct 2023 05:05:39 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:f1ee:b000:ce90:ed14]) by smtp.gmail.com with ESMTPSA id a2-20020a05600c224200b00405442edc69sm1353859wmm.14.2023.10.17.05.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:05:38 -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 v3 52/73] pinctrl: change the signature of pinctrl_ready_for_gpio_range() Date: Tue, 17 Oct 2023 14:04:10 +0200 Message-Id: <20231017120431.68847-53-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231017120431.68847-1-brgl@bgdev.pl> References: <20231017120431.68847-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 05:08:56 -0700 (PDT) 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 Reviewed-by: Andy Shevchenko --- 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 da5d716f154d..932bbcdc0eb1 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