Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp120014rbe; Wed, 28 Feb 2024 14:21:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcn5twwvn1L7HZtNbzvATOE+1AbypkjrMkEAXhmZvA40+AMYrCa6CQTM63cegPuge7QeGEpHt9PlSzjrK21Q3IzGIUmyGIM/wLh4uorg== X-Google-Smtp-Source: AGHT+IHel837KwMzIstqSaEXRgHOIqTy+u+Kd1YQsJWgP1A4dzQRZj84UOuipZRwCqOqbklpuUSA X-Received: by 2002:a50:8d86:0:b0:565:f90c:1263 with SMTP id r6-20020a508d86000000b00565f90c1263mr189923edh.9.1709158918890; Wed, 28 Feb 2024 14:21:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709158918; cv=pass; d=google.com; s=arc-20160816; b=BAXTnfikhP2kE/xDRSbNFS6zemEsvjQXL0VZgAi++jEHjihuG/ofYhopRSpHR2REet KCiJIYhcRGZbctLTcEUdzDXEiM0i3WMWEtAcqfON6oK8H3EuNUCMQ3UXa9KPMIKIb9Xw QtUnl2ht+rgbEATx4XYOzp9E/jYg67qKRDscq2B3KS0ewwEH9dhiYPsZBEAwWCFv+4SR ONIvlCnfd2eiUXIKfSMlKkXYyV8r397REpA/tC4nDhO6CC0UUmZMrx61xh1Nhiy6E9xr cKK7novMkYNZsDR2swrYXwJHjehjUrXvzzCWONK6AXiro0WbCvNj9nP6puS97uG8lx7J LjZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TbOEerxNC6U36RNOelpyKwchqC5ejCqY7AEaQMpiV8I=; fh=/yQ0WMMU6iSfCOURJxcAcuvBWf4Rti7xY+fCKCJGOV0=; b=a3HLGD9aZCm2tNvOavcULEH41zilQ/pX8jadtGS9sL7xuLxyeBPhrqmBY9NghZWx3P gD0YDoDWCCoLqim9qbAFtHphMNos6lDjFXW3+1ToYPREX8JhpR1aUJUGxGPB6/Zv2jc5 2IVZJhfBbS7zEQwCW8ow+0VHL6l2tgcRnm6AXMtqe9lS1OAV2FETzr/xQfYfwzKmCBqT sHt4FWBUz+rUZP8MJoFgE9naYZnU+8iC42NuL6uRVgf0pzjTUVpj2NVHX4rF9i5lTJtj gQUvPtp9w/ax0gRDlVxNxeYCQ9TtMh9qU0be86RNH71+UMc9Y9SFkmjS6lAi30DdhLbo ysFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fM8uzBi0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g32-20020a056402322000b0056661146d91si1167509eda.291.2024.02.28.14.21.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 14:21:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fM8uzBi0; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-85545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85545-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4764A1F27579 for ; Wed, 28 Feb 2024 18:44:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2362E74416; Wed, 28 Feb 2024 18:44:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fM8uzBi0" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FFE71EC4; Wed, 28 Feb 2024 18:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709145862; cv=none; b=NT3Rq8dE4QsufYb+SFFGpHyMfKUkL1hBhaY6leAsAXBQ8nHrP46hzrrktoHF6fG4bXlpNqYGMOwn4lNdxjswVUW2/skeoxwtcR77TPR/K04O77HF5DTGTVCa3UixcPsXollKlcl4uvushmOQd6Fdd5z7D4ZiC9PMP36Y8tPxBLU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709145862; c=relaxed/simple; bh=xSiXX6AESAZ90Y56jbiUou7HsIyzjfLMjTWugNAhrBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A8K9xo1vbwqA3EUMS/yvphAE1TCf3CBtFSRiLP823KVWz93fxnDZPBjCCRxZ2Krzmq8O1wVwgN6FRDzgwZjSp6/PhpmLHI4ov6uKMysgHZisMuk3mermf6WxH/cv5erhEE2r/9mepecVrv+38mvagqCtwcpGkxZUqyFaRbgqVZg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fM8uzBi0; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709145860; x=1740681860; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xSiXX6AESAZ90Y56jbiUou7HsIyzjfLMjTWugNAhrBg=; b=fM8uzBi0p95/NvqrQertqOfsbUwAf9QDV3tOdrURwDHF5ydH1431YCBh n4Fib6OaZc3mU/fK60IHK7wHBQjCDs2pFVE+ttAEcqeOhe26NNewWlYEA tF6ZfChup3R/yAwnwG8hxqTVr3tclh7qFBzqq/QUJz7/+o7QeXTUZGCFV qdVPpLKSOnVxZvIZP0fU6pC7O8EBkRTBJVywuP7q2hlPNidUnlqFiW0Sy /tn9+ibk9xxNursBTmqN3uUYNGT+rqX7yW8pSXkPu8igB3WBBuaSpersc 5O8sYl5cRYCnVecOjK2VHMMOrc/1Bse+DjdLwqlXZdehMufNAMFSeUdB+ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="21023737" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="21023737" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2024 10:44:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937034566" X-IronPort-AV: E=Sophos;i="6.06,191,1705392000"; d="scan'208";a="937034566" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 28 Feb 2024 10:44:15 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 19F7D192; Wed, 28 Feb 2024 20:44:14 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Chris Packham Subject: [PATCH v1 1/2] gpiolib-of: Make of_gpio_get_count() take firmware node as a parameter Date: Wed, 28 Feb 2024 20:40:46 +0200 Message-ID: <20240228184412.3591847-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240228184412.3591847-1-andriy.shevchenko@linux.intel.com> References: <20240228184412.3591847-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Make of_gpio_get_count() take firmware node as a parameter in order to be aligned with other functions and decouple form unused device pointer. The latter helps to create a common fwnode_gpio_count() in the future. While at it, rename to be of_gpio_count() to be aligned with the others. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-of.c | 13 ++++++------- drivers/gpio/gpiolib-of.h | 5 +++-- drivers/gpio/gpiolib.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index e35a9c7da4ee..c0eae8924074 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -68,7 +68,7 @@ static int of_gpio_named_count(const struct device_node *np, /** * of_gpio_spi_cs_get_count() - special GPIO counting for SPI - * @dev: Consuming device + * @np: Consuming device node * @con_id: Function within the GPIO consumer * * Some elder GPIO controllers need special quirks. Currently we handle @@ -78,10 +78,8 @@ static int of_gpio_named_count(const struct device_node *np, * the counting of "cs-gpios" to count "gpios" transparent to the * driver. */ -static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id) +static int of_gpio_spi_cs_get_count(const struct device_node *np, const char *con_id) { - struct device_node *np = dev->of_node; - if (!IS_ENABLED(CONFIG_SPI_MASTER)) return 0; if (!con_id || strcmp(con_id, "cs")) @@ -93,13 +91,14 @@ static int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id) return of_gpio_named_count(np, "gpios"); } -int of_gpio_get_count(struct device *dev, const char *con_id) +int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) { + const struct device_node *np = to_of_node(fwnode); int ret; char propname[32]; unsigned int i; - ret = of_gpio_spi_cs_get_count(dev, con_id); + ret = of_gpio_spi_cs_get_count(np, con_id); if (ret > 0) return ret; @@ -111,7 +110,7 @@ int of_gpio_get_count(struct device *dev, const char *con_id) snprintf(propname, sizeof(propname), "%s", gpio_suffixes[i]); - ret = of_gpio_named_count(dev->of_node, propname); + ret = of_gpio_named_count(np, propname); if (ret > 0) break; } diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h index 6b3a5347c5d9..19988c1354fa 100644 --- a/drivers/gpio/gpiolib-of.h +++ b/drivers/gpio/gpiolib-of.h @@ -9,6 +9,7 @@ #include struct device; +struct fwnode_handle; struct gpio_chip; struct gpio_desc; @@ -21,7 +22,7 @@ struct gpio_desc *of_find_gpio(struct device_node *np, unsigned long *lookupflags); int of_gpiochip_add(struct gpio_chip *gc); void of_gpiochip_remove(struct gpio_chip *gc); -int of_gpio_get_count(struct device *dev, const char *con_id); +int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); #else static inline struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id, @@ -32,7 +33,7 @@ static inline struct gpio_desc *of_find_gpio(struct device_node *np, } static inline int of_gpiochip_add(struct gpio_chip *gc) { return 0; } static inline void of_gpiochip_remove(struct gpio_chip *gc) { } -static inline int of_gpio_get_count(struct device *dev, const char *con_id) +static inline int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) { return 0; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5fa3bf7b55bd..a93271b3d538 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4285,7 +4285,7 @@ int gpiod_count(struct device *dev, const char *con_id) int count = -ENOENT; if (is_of_node(fwnode)) - count = of_gpio_get_count(dev, con_id); + count = of_gpio_count(fwnode, con_id); else if (is_acpi_node(fwnode)) count = acpi_gpio_count(dev, con_id); else if (is_software_node(fwnode)) -- 2.43.0.rc1.1.gbec44491f096