From patchwork Thu Feb 29 14:51:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 208435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp550190dyb; Thu, 29 Feb 2024 09:16:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVNuoFy9cWXvG404YaXXmUCK1p32Q9Mmy/niEvvJqloZrb777SSvu/OewXDLu6qt161Tb8Ty+iATK6i9KLuVgocLZNH2g== X-Google-Smtp-Source: AGHT+IGRsKc4j058Kgo0GJPb1vE6YaN8XaeDPIopg1r6HNHVlYXblHb29lpiHc3B+KWRzAuWFJmF X-Received: by 2002:a05:6a00:2d97:b0:6e5:5849:1af0 with SMTP id fb23-20020a056a002d9700b006e558491af0mr3509334pfb.8.1709226995346; Thu, 29 Feb 2024 09:16:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709226995; cv=pass; d=google.com; s=arc-20160816; b=lDZkKOtAvyTDo1hNt/i0ABLqTp8S3hx3+z+2ohzEdAWkcEDQRV+QzS92wC29O5dtr9 TdKNag1azYjoEYVL63JSyh1dDGlWb241iBz+udliZ6EtVipbAFEbl6XTqbvjUwBo7mFE L457OU4NHeGBQ3nMuJ4IDO5TeOIYTIF6xDTuFvqFl5H+tzySDJVi9wzXThsqNPLukSMf +aDLEWlWKVEijs/yEPoC5KMT+AqoUJrsIcJtkZCJjcAEhx0kE0VdXj4u+8WBD9QwoIOp pJJMbve4n0eCQj55ME7Ss2sg/OircUY/VJ0Zyn2BfH8qibwOTUOKxIoxh6TUjAxklL6k 2LHw== 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=Ggq4zUnrvd0/CVICMiGjm+6PnkLJKYOKnA4ss8rKyGM=; fh=/yQ0WMMU6iSfCOURJxcAcuvBWf4Rti7xY+fCKCJGOV0=; b=Nm3xUTTq92+SKqdxPDHDYaGnE7neYndHzspReczB25eI/yK/nYCY1HlUZ0au1WAvrF 0ugBCj/H2lUf6EPG/zdU7xf/tFqZOopKQUcHDheD7S1WZv3rvhKNLi1bSBhzSM5kkt+2 1YAidY9VHyM9RN8RBuX4mz2a1PRWyBlQyWvH2+/19KQtu6dJJuEKvm3ln3B2BRl/02BD wTbDOCMZGOFhuIhfrggZTxC53qc+M4aDy9NnwulV3+0nqDHFRrepdCEacuVZwJ64Nm7e fTCnK1tNAdYRYu84xXlkVeRuDpxTI8rATtmwvVw88BHwVCJ4pFuEcj7ayrxkEtrXlcY6 FB+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LHQ4tyJt; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86876-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id le7-20020a056a004fc700b006e555989bc7si1757727pfb.340.2024.02.29.09.16.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:16:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LHQ4tyJt; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86876-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86876-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 38BDCB23178 for ; Thu, 29 Feb 2024 14:53:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6B3F13B281; Thu, 29 Feb 2024 14:53:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LHQ4tyJt" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 15C26137747; Thu, 29 Feb 2024 14:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709218390; cv=none; b=pAbPwFclxXzkYFYtsmZ2TEJpx65iF/21YbjpX+HW2O3Z0+SwqR6KiiewkG7JtLxIHE308jWE6F1yC5tFmHspgYDahAZBAfZNn1WmC31doPtj2CJsmkyQgnvew3W4RMBYWE9gWdmSPA406XtN2aUal/nyQaL53QsiVgep/RNvv8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709218390; c=relaxed/simple; bh=wWSgyr0hdjqLu+2X6KWDqneEgrO6SAcjS23aDbCvptw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LYnqHy5SkoO0B6nvdDLJcFuYqBjONnB/qSKXDzY1/PAdfM2EDG2TPHS1qYGnFM8xPMoZEdOxpzkgAr97giJ91darU+FVtWpkIxqvoW4fp9gXrZcxFB2AUQS19LSlamS5JMYdOjr6L8bvYHxAkhnJcw3E2qA/4S4LNI8e7jM5EvQ= 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=LHQ4tyJt; arc=none smtp.client-ip=192.198.163.11 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=1709218389; x=1740754389; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wWSgyr0hdjqLu+2X6KWDqneEgrO6SAcjS23aDbCvptw=; b=LHQ4tyJtQ54gHnskyX9RlFs7Ax2bVstc7zYnZ6CRdG5ABvNfA4Yt5lx4 X7g8dkxrRGeSYdQ05vHPI6/vetT4Jl4+SUICU5Dx1X+/ynE+z8RHi/v8i AEQA2dFVylhP0f6w7Lvtn6bYSXvCLC0mBPDClq537OqrhF5ibGbcl2ocq jLRUUYQqvyjgWuTSL2SZrTB+L7h3Ou7NE+XWAHbJi7+60RhvWFJqQ/dva 5Qkp+X0Shv05wYj4e4rw9xiuYwMhxIDucPR4udVeCDbek+C/5AWYe+jrF 3WBDlmcKLETnxlxIIE22a8hz7ArwsC6rK0Lls2sx4dCtphRJQ1AvE4jYB Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14326500" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14326500" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:53:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937036060" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="937036060" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 29 Feb 2024 06:53:06 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E458E19F; Thu, 29 Feb 2024 16:53:04 +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 v2 1/2] gpiolib-of: Make of_gpio_get_count() take firmware node as a parameter Date: Thu, 29 Feb 2024 16:51:38 +0200 Message-ID: <20240229145303.3801332-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240229145303.3801332-1-andriy.shevchenko@linux.intel.com> References: <20240229145303.3801332-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792246071500474933 X-GMAIL-MSGID: 1792254405892493849 Make of_gpio_get_count() take firmware node as a parameter in order to be aligned with other functions and decouple from 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. Reviewed-by: Linus Walleij 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)) From patchwork Thu Feb 29 14:51:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 208496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp636208dyb; Thu, 29 Feb 2024 11:41:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/Qe5TwQML5O8wqamo2/oT66AXBw6cERhs6E483elzv93L3ZtomUmxNMh+xedvwPNqfvTlzpSl3r10E9JDrLNtN/1WCw== X-Google-Smtp-Source: AGHT+IG27uNiGz3sS/XrRWtwS6TYk00UuNLhBp1ci3MbHWAwJ2W9iwAtl2q0+Tq6RvoXbOqVRaOe X-Received: by 2002:aa7:d950:0:b0:564:fe7c:2 with SMTP id l16-20020aa7d950000000b00564fe7c0002mr2228909eds.36.1709235711163; Thu, 29 Feb 2024 11:41:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709235711; cv=pass; d=google.com; s=arc-20160816; b=L5lf/pPtnejJc6i109RcaKvxAA9SsN2LgRK9g/md6XR9V1UFvwoLsvbq5QAmUCVVHP oqUJ7kGl+YbOFNJm3tz566aNcLnl4I+smCoo7Hq68L3EawS0TAUX1pGHhbhrfQP5gwuq pwVv3zQPNv6xNiTvT46J8Mcz9NrL5WMtDtWPykezcSymRmTqJ1IVAcAUnwPygMckY9// yFKBjpUAhovVGgmZlerG3ExI11z9DbjmDBfBtSOmaRVNctojYAeoI7uADh30z+Q2gVZD ncI0CLhYF4Y0fn8ujG9XQ6JuH+bSYF9KT8LDPuw9tN4ERuaDgVJI9C8zKF4r2uEAO1Ot Lxig== 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=sRncu8lCA0qLUcJ77uvg4BEbJqNAzYYYDrgwMA/eAwQ=; fh=/yQ0WMMU6iSfCOURJxcAcuvBWf4Rti7xY+fCKCJGOV0=; b=T8QOAXPbOSXndfPuC2/mXtzr7UQtxrMv1YtS+SstJyBFnJA6ec+nPLwtTS4WAPLQf6 /MqzcCvtX3bwon9GTppq0us26NCCt3+wGMvR2bhTaMgcxccHOeZ8DMqUsBP3GjqloZPL Q6PtRmz+yEoHpHTwrZdM1e7rVKfccQKdsmVujf1d55OEzwmsxpWdzqlzkCcKGsvwgMlz 2Nm1VPhEpBy5JrpBXMHDWBL30UDRt9P5wJK3/q/pPA+FTfQYMDut8KFj5D2xDfK1AjXN D7Lm6lVgnNWqzCd67w+1Mmj6yULDalF14/VEuseOZOB6VtAKpEXKKs8EHEeUyDqxRSr3 1g3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PomS4Fgj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86878-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86878-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a22-20020a05640213d600b005647770bee6si830291edx.444.2024.02.29.11.41.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 11:41:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86878-ouuuleilei=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=PomS4Fgj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-86878-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86878-ouuuleilei=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 4B6A91F25E95 for ; Thu, 29 Feb 2024 14:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF0311448FE; Thu, 29 Feb 2024 14:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PomS4Fgj" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 68A7D137772; Thu, 29 Feb 2024 14:53:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709218393; cv=none; b=Ckf+9XxtDjHsv579QFbdJXMHGqaavQKM5cPHw7O7qmVEtcNQbFtr7NNanMkQw0Ovxt+fqzUSgaAE1FiFQ/itDJ87Ai/dzu+Agj0KQ2CAB+kMXYHKTwztefO0GN+Oq4wn2oslc1ol8PPXJWx57Q5mS/7wGDXpFxIbjYWoLBp9HvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709218393; c=relaxed/simple; bh=auK5leopyHo3okmJBfzsjNCZk5qwdivKbIquaIizWuU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QQFRDPiIdZD2TmxNEbkr+BHZop6wrILxmV9mqhBK5pn0XmqIHulXAJkImHWIof7JHQSMGuiWIcsW4xUc0Qv/DEM8cM14WhrBzCvbb08M7TqQngjzgm/cwMnGKGsZju7cpAtdCs+9e7hCa4z86byJfS2ckAKR/zAowafr2cag96o= 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=PomS4Fgj; arc=none smtp.client-ip=192.198.163.11 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=1709218391; x=1740754391; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=auK5leopyHo3okmJBfzsjNCZk5qwdivKbIquaIizWuU=; b=PomS4FgjXJNS2At8RnBp2aKLF9NjIAbXfETJREgVJQHlwo6qLd2W6WF6 N9kETvBJM2yhf+H7hlB2dfuBS721DKBCYGFHMP+gGWmsh0Rc3hnmo+iQE XA6wLxMMpOKR9E382WM+Ca+FQ0xBDlH/+zyHPUVSEES2yKaHIzYdtmYFN 6dza119h1dpRnrut39S4qzO6kmNodXx0+hIrI+RIyZCmNSNE8YN/R5sLq Z5aAMg0w6qxvIuBPXqnYlSiY8uZUvbzXEBKjcKNE/FbCOnsMO6TRkdMgb J3IQYNFIJGKgB5qMiQKV9Mvn/0FrpgnistNdA+yDOruP19z2EVL5alAjD g==; X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="14326508" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="14326508" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Feb 2024 06:53:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10998"; a="937036062" X-IronPort-AV: E=Sophos;i="6.06,194,1705392000"; d="scan'208";a="937036062" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 29 Feb 2024 06:53:06 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id F3D4D476; Thu, 29 Feb 2024 16:53:04 +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 v2 2/2] gpiolib-acpi: Make acpi_gpio_count() take firmware node as a parameter Date: Thu, 29 Feb 2024 16:51:39 +0200 Message-ID: <20240229145303.3801332-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240229145303.3801332-1-andriy.shevchenko@linux.intel.com> References: <20240229145303.3801332-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792263545190347601 X-GMAIL-MSGID: 1792263545190347601 Make acpi_gpio_count() take firmware node as a parameter in order to be aligned with other functions and decouple from unused device pointer. The latter helps to create a common fwnode_gpio_count() in the future. Reviewed-by: Linus Walleij Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 13 ++++++------- drivers/gpio/gpiolib-acpi.h | 4 ++-- drivers/gpio/gpiolib.c | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 899cd505073e..7f140df40f35 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1402,17 +1402,17 @@ static int acpi_find_gpio_count(struct acpi_resource *ares, void *data) } /** - * acpi_gpio_count - count the GPIOs associated with a device / function - * @dev: GPIO consumer, can be %NULL for system-global GPIOs + * acpi_gpio_count - count the GPIOs associated with a firmware node / function + * @fwnode: firmware node of the GPIO consumer * @con_id: function within the GPIO consumer * * Return: - * The number of GPIOs associated with a device / function or %-ENOENT, + * The number of GPIOs associated with a firmware node / function or %-ENOENT, * if no GPIO has been assigned to the requested function. */ -int acpi_gpio_count(struct device *dev, const char *con_id) +int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) { - struct acpi_device *adev = ACPI_COMPANION(dev); + struct acpi_device *adev = to_acpi_device_node(fwnode); const union acpi_object *obj; const struct acpi_gpio_mapping *gm; int count = -ENOENT; @@ -1429,8 +1429,7 @@ int acpi_gpio_count(struct device *dev, const char *con_id) snprintf(propname, sizeof(propname), "%s", gpio_suffixes[i]); - ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, - &obj); + ret = acpi_dev_get_property(adev, propname, ACPI_TYPE_ANY, &obj); if (ret == 0) { if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) count = 1; diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h index 0fcd7e14d7f9..6f295ea580fe 100644 --- a/drivers/gpio/gpiolib-acpi.h +++ b/drivers/gpio/gpiolib-acpi.h @@ -33,7 +33,7 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, enum gpiod_flags *dflags, unsigned long *lookupflags); -int acpi_gpio_count(struct device *dev, const char *con_id); +int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id); #else static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } @@ -51,7 +51,7 @@ acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, { return ERR_PTR(-ENOENT); } -static inline int acpi_gpio_count(struct device *dev, const char *con_id) +static inline int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) { return -ENODEV; } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a93271b3d538..e6c5c7894553 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4287,7 +4287,7 @@ int gpiod_count(struct device *dev, const char *con_id) if (is_of_node(fwnode)) count = of_gpio_count(fwnode, con_id); else if (is_acpi_node(fwnode)) - count = acpi_gpio_count(dev, con_id); + count = acpi_gpio_count(fwnode, con_id); else if (is_software_node(fwnode)) count = swnode_gpio_count(fwnode, con_id);