From patchwork Thu Apr 11 17:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 788081 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 D968D2BB1C; Thu, 11 Apr 2024 17:26:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856403; cv=none; b=fsKFYvI/BHuXPKbBLRMSj9GSkuHYl6RKBM9Sln7YJsmw3DZkc8kqUzNPcEuId2GyDf/rZFtUNVy36p0BMOciptXXIR7PR+UyD2oEIPueMd+L29ZnK1AONWV94Mpsl6Niq9er8SyNj40tW6+80v6rn6ga51C6ePGV9itN1pGpIoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856403; c=relaxed/simple; bh=GCmd6EWyeSI61/ahtWxVMlmLMfAP5vYzOKp2NSFA8/I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mJRwNbflxCE4pfb2GRrrk8MsaCD8fQJCMRYFTVoO+BVdCSk0U3gmgqcupmYu4vfdcGWxkSdtRmKp1F6momeKD4X7X6lCUPkttTQs70qsrrAxZJhfFiW9URW21FCUFrLAjy0pZaLH2ZEJgI0QNvjTZI8T6OnSWQzJqGYz4XIH1Ms= 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=lXUpBEwj; arc=none smtp.client-ip=198.175.65.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lXUpBEwj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712856402; x=1744392402; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GCmd6EWyeSI61/ahtWxVMlmLMfAP5vYzOKp2NSFA8/I=; b=lXUpBEwju9hHwDYAjqGVNgAjmo0NkZOY1QhOmqvKWy6+UB4UqtjAIW67 AQdBo5iuUslUnKqawseAgZuhR+fQSLosCw0tLyVRfcMx6haf3KF0K4xBi x7D+wDCIQkTrvfYYYO1p8C8a76/MEhNg7tJi4sD3hBq81rkOZ9waJysEn w9ZSfkXMcGxN5AocoWMOVM1mYJHABf2vpdhXf0a16FjdyLg5l7nElXrzV r7D6q7lgYeckKGaKoOiU4r8MI//+82NKbK+HVeUj9J1nJSBqdW31nF+i/ HazS+1inMFLuE2YUiyaN9CFBi865HOAMvU3gfg3Jjfk8J0tTNj6ilfKta w==; X-CSE-ConnectionGUID: FNuNgM5kReSxgswtEStJpQ== X-CSE-MsgGUID: APbE3zVKSHmKWiPsliT4tQ== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="18844992" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="18844992" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 10:26:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="937097271" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="937097271" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Apr 2024 10:26:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0AE03161; Thu, 11 Apr 2024 20:26:33 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , David Thompson , Linus Walleij , Patrick Rudolph , "Rafael J. Wysocki" , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Bartosz Golaszewski , Mika Westerberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v1 1/4] gpiolib: acpi: Extract __acpi_find_gpio() helper Date: Thu, 11 Apr 2024 20:22:29 +0300 Message-ID: <20240411172540.4122581-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> References: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We want to reuse it later on in the code. In particular, it helps to clean up the users of acpi_dev_gpio_irq_wake_get_by(). Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c2a33beeec50..d47b22ac3ecb 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -945,14 +945,11 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev, return con_id == NULL; } -struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, - const char *con_id, - unsigned int idx, - enum gpiod_flags *dflags, - unsigned long *lookupflags) +static struct gpio_desc * +__acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, + struct acpi_gpio_info *info) { struct acpi_device *adev = to_acpi_device_node(fwnode); - struct acpi_gpio_info info; struct gpio_desc *desc; char propname[32]; int i; @@ -969,10 +966,10 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, if (adev) desc = acpi_get_gpiod_by_index(adev, - propname, idx, &info); + propname, idx, info); else desc = acpi_get_gpiod_from_data(fwnode, - propname, idx, &info); + propname, idx, info); if (PTR_ERR(desc) == -EPROBE_DEFER) return ERR_CAST(desc); @@ -985,11 +982,28 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, if (!adev || !acpi_can_fallback_to_crs(adev, con_id)) return ERR_PTR(-ENOENT); - desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info); + desc = acpi_get_gpiod_by_index(adev, NULL, idx, info); if (IS_ERR(desc)) return desc; } + return desc; +} + +struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, + const char *con_id, + unsigned int idx, + enum gpiod_flags *dflags, + unsigned long *lookupflags) +{ + struct acpi_device *adev = to_acpi_device_node(fwnode); + struct acpi_gpio_info info; + struct gpio_desc *desc; + + desc = __acpi_find_gpio(fwnode, con_id, idx, &info); + if (IS_ERR(desc)) + return desc; + if (info.gpioint && (*dflags == GPIOD_OUT_LOW || *dflags == GPIOD_OUT_HIGH)) { dev_dbg(&adev->dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n"); From patchwork Thu Apr 11 17:22:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 788080 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 696B650A77; Thu, 11 Apr 2024 17:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856404; cv=none; b=WtpiUiRD1ghXqCafy1Uq2rsuNytlDRiRhKftRzhYzXCoyNGnzzOwdomzSHamFaNq5LDjaH1LCSY61ZyIs/7TqM2YeTliz1RjMZP9iAR94iOd+s8CRX9OoqnC/kV/XqIZcjH5+8KzvLrmLsTFtCXNZ9TONhNnEGlsa6uejFDSMWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856404; c=relaxed/simple; bh=mkcaxfIAu8Shkk3u4f6ITrX0al+FrzCJ1eyBmzPJWoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dm+9auKEbcevnUrDUckQsvP1OdYzdeKrIgx1Xst5qAaLW8pAjMStVxrFW+/Ec7jvGGWGjHq/hIqk+QT2X7otHUNpImCk+RR2WPtpWYGl11XraAQXxorxHkwLXw8VGeu5ElAXogixXrRPJhKN/Y5Y/F4OvIfgf1IgHcAy+/KZBZ0= 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=cnnxGZNU; arc=none smtp.client-ip=198.175.65.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cnnxGZNU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712856404; x=1744392404; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mkcaxfIAu8Shkk3u4f6ITrX0al+FrzCJ1eyBmzPJWoo=; b=cnnxGZNU3xxMElhZGYp6aDVOvkVvxJQuFJr5mCZyhFdxwnZpi4stAGfG 8lQWbQFctO1NIyw8zioiChXAI+ZGKQ3Q+OGcfMaMpti+2WSaSt+Ju4vNo jotbmDysUT6u1GRrMBUhIgiacMuM+qiqBWOIM2vn8vhp0JSEbkvMU1PwM AmcwgTY7KzgncXO0jcoVcOqzkIs2ne4LBCCq7Dc8Po3Cetusa3LPJuWB6 lf3/oOB8dD174lmAk5jnwHRvMzdTIIAZIa2kqyvd3BAuUmzgnXjl97iu+ SmSkxlxunFKYs6ifrk/4wpZWu4R/ocJPOPI+NQNf8x0gHBfEiJMZ/YPye g==; X-CSE-ConnectionGUID: NRO8WPnCS+Sl99JdXQnPGA== X-CSE-MsgGUID: U/tu2Y4SSZmgBguKyKPF4w== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="18845023" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="18845023" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 10:26:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="937097276" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="937097276" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Apr 2024 10:26:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1C123374; Thu, 11 Apr 2024 20:26:34 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , David Thompson , Linus Walleij , Patrick Rudolph , "Rafael J. Wysocki" , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Bartosz Golaszewski , Mika Westerberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v1 2/4] gpiolib: acpi: Simplify error handling in __acpi_find_gpio() Date: Thu, 11 Apr 2024 20:22:30 +0300 Message-ID: <20240411172540.4122581-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> References: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that we don't perform anything on the GPIO descriptor, we may simplify the error path in newly introduced helper. Do it so. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index d47b22ac3ecb..fb2e14670b7a 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -974,20 +974,14 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int return ERR_CAST(desc); if (!IS_ERR(desc)) - break; - } - - /* Then from plain _CRS GPIOs */ - if (IS_ERR(desc)) { - if (!adev || !acpi_can_fallback_to_crs(adev, con_id)) - return ERR_PTR(-ENOENT); - - desc = acpi_get_gpiod_by_index(adev, NULL, idx, info); - if (IS_ERR(desc)) return desc; } - return desc; + /* Then from plain _CRS GPIOs */ + if (!adev || !acpi_can_fallback_to_crs(adev, con_id)) + return ERR_PTR(-ENOENT); + + return acpi_get_gpiod_by_index(adev, NULL, idx, info); } struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, From patchwork Thu Apr 11 17:22:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 788437 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 1B9DD18050; Thu, 11 Apr 2024 17:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856401; cv=none; b=lj0KHv+9Eo+e64KwQPfdrdYj67CJamqT0+eOjL8WVpCcsD08CjKna5rlH9QA6cr0XqsU2kAa9VuJBq4yqXEbL1aDGUVIzGQTufLjXA2QfqQTrpTXtRkdKQaWJIIaN6r4B3H0K0ZXxtlldxvYhKQrP/nXYfyWgAB2CwS56j750uE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856401; c=relaxed/simple; bh=A2+jXtS5g8HA0A8/2hmcMBqno1MQ7oBHc6IPFkKw3e8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=om549zUD831/F28DxPqXQ/WGvj6F6pYOHsUcqpNffHCddUbtt9qJwI65Q8yx9qq/C2tqB0VFt4CYW/JE+af4OnfE+5qG6VNRETcCrCvL0qNqI5MLcmRRnBY0tvsgyO052uWLOjOWYGHR0G02yu3NTngbpEl8Nkj+zatMkIvn6PA= 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=WC28LqO8; arc=none smtp.client-ip=198.175.65.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WC28LqO8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712856400; x=1744392400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=A2+jXtS5g8HA0A8/2hmcMBqno1MQ7oBHc6IPFkKw3e8=; b=WC28LqO886XPiO9g611lcP4THsUDjjmeQEAtQ19xypW59zlhD2FtatuK lwZGg7RpTQVLx5H5rfcyElOZqmjAiGpGT+g2GwmYb4L5pSIePuKa7jUQ3 g1KM+YD1MtRZlOjAmzXU1PgnHe+Fp+v+d19M8elF53Y1BnSzv6WMDKfID MW8Tv7j7gPnnWVn5Uacw8IobRJKfcbqDuUqgEtzZ16hAIDy1eQjV/8M0w AvEtAlR1kHaRB3AI2n+c3ey954VVGH1km7DpXzxco2DqQBcKBuyn4EFfC que0V9KNsVIG1m3q0UR+4CqPhArSv3k593JcTbqPMPURnQNQ5ENmiaXQQ Q==; X-CSE-ConnectionGUID: VQclX42vR0aiFqbXrUtmuA== X-CSE-MsgGUID: RNyzALCHRhyv78PLv4d8tQ== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="18844983" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="18844983" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 10:26:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="937097272" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="937097272" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Apr 2024 10:26:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2B32C4C5; Thu, 11 Apr 2024 20:26:34 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , David Thompson , Linus Walleij , Patrick Rudolph , "Rafael J. Wysocki" , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Bartosz Golaszewski , Mika Westerberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v1 3/4] gpiolib: acpi: Move acpi_can_fallback_to_crs() out of __acpi_find_gpio() Date: Thu, 11 Apr 2024 20:22:31 +0300 Message-ID: <20240411172540.4122581-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> References: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 New coming user may need to check for _CRS fallback slightly differently. Move the current check out of the helper function to allow that user to use it. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib-acpi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index fb2e14670b7a..2b3fd43b13fc 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -947,7 +947,7 @@ static bool acpi_can_fallback_to_crs(struct acpi_device *adev, static struct gpio_desc * __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int idx, - struct acpi_gpio_info *info) + bool can_fallback, struct acpi_gpio_info *info) { struct acpi_device *adev = to_acpi_device_node(fwnode); struct gpio_desc *desc; @@ -978,7 +978,7 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int } /* Then from plain _CRS GPIOs */ - if (!adev || !acpi_can_fallback_to_crs(adev, con_id)) + if (!adev || !can_fallback) return ERR_PTR(-ENOENT); return acpi_get_gpiod_by_index(adev, NULL, idx, info); @@ -991,10 +991,11 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, unsigned long *lookupflags) { struct acpi_device *adev = to_acpi_device_node(fwnode); + bool can_fallback = acpi_can_fallback_to_crs(adev, con_id); struct acpi_gpio_info info; struct gpio_desc *desc; - desc = __acpi_find_gpio(fwnode, con_id, idx, &info); + desc = __acpi_find_gpio(fwnode, con_id, idx, can_fallback, &info); if (IS_ERR(desc)) return desc; From patchwork Thu Apr 11 17:22:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 788436 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 4BA03481D0; Thu, 11 Apr 2024 17:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856403; cv=none; b=bMXZTxA6jGK54c7dBPSMdjd6cd0gwAximCRXYdhFARzEcv4FlqOMTqSshtE66rGEGwQKfD0OcKRFNo4vVMy+ezuvEUwl0XxLhwi9zKsb4FIct3EYpbGl6036JCvJI64tUDLBIwqZlYWi+bubcjDpdnnRqACF/oQV5aAhijmo4+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712856403; c=relaxed/simple; bh=u78Kx86bou/Qgx7a5ckaEBe5SvOXz81P3wk/GtmrwyA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F052B+bbmNlaz5JOMMEdokBC2shKZRDXNMFvg3lJSzawNCLfdTYz0HZ/Vfj155JcjlJVbfnMuCq35ivsx7skiEP3aF25/yQ9KluBZTumSQGDMRCSHQT8RntMaaxbfeoi6Yxwg2GCN+/m4qBmL/MvEJiSGBKuSGSutwrSvslimn0= 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=NsMKiE9v; arc=none smtp.client-ip=198.175.65.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NsMKiE9v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712856403; x=1744392403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u78Kx86bou/Qgx7a5ckaEBe5SvOXz81P3wk/GtmrwyA=; b=NsMKiE9v0ZMskQyoOA+EmvLlz5l4FuOiSqs/SYivkOprx4VitNH6c1nV MGaAC0/HWsvvoeUj99QjpltURYDltsuvMY40gb9WrQJIZvpCGTBqtNZ4F O1ZoK8AQSD3pHqVgNKN9kwx7P4Hay8stBiTUHcAASPfLf9Chen6wN+rFM Tcg5JB046WOA3iqp0CZNOWhqntbP8vTVavgWvvFBJy81MgHRN4RijucWW Kjww3v6okCwYdoqcu4aYSir+tXQIAzt79jmw6ZeQPgMIVZkVKDTSEIXh3 4+i40UHJwZaAEFaqpHoaNq7fEqgx9ZHTXSAEK53Y1XZZw2X/VJm0VH/CU A==; X-CSE-ConnectionGUID: +EvSGvfATAyX92W2M8vrGg== X-CSE-MsgGUID: Khutd0m1SuCm6l/2Sx5CMQ== X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="18845018" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="18845018" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2024 10:26:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11041"; a="937097274" X-IronPort-AV: E=Sophos;i="6.07,193,1708416000"; d="scan'208";a="937097274" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 11 Apr 2024 10:26:35 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3558B73E; Thu, 11 Apr 2024 20:26:34 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , David Thompson , Linus Walleij , Patrick Rudolph , "Rafael J. Wysocki" , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org Cc: Bartosz Golaszewski , Mika Westerberg , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Rafael J. Wysocki" , Len Brown Subject: [PATCH v1 4/4] gpiolib: acpi: Pass con_id instead of property into acpi_dev_gpio_irq_get_by() Date: Thu, 11 Apr 2024 20:22:32 +0300 Message-ID: <20240411172540.4122581-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> References: <20240411172540.4122581-2-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass the con_id instead of property so that callers won't repeat the GPIO suffixes to try. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-pca953x.c | 2 +- drivers/gpio/gpiolib-acpi.c | 11 +++++------ .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c | 2 +- drivers/pinctrl/pinctrl-cy8c95x0.c | 2 +- include/linux/acpi.h | 8 ++++---- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 00ffa168e405..77a2812f2974 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -144,7 +144,7 @@ static int pca953x_acpi_get_irq(struct device *dev) if (ret) dev_warn(dev, "can't add GPIO ACPI mapping\n"); - ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0); + ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq", 0); if (ret < 0) return ret; diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 2b3fd43b13fc..909113312a1b 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -1013,7 +1013,7 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, /** * acpi_dev_gpio_irq_wake_get_by() - Find GpioInt and translate it to Linux IRQ number * @adev: pointer to a ACPI device to get IRQ from - * @name: optional name of GpioInt resource + * @con_id: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) * @wake_capable: Set to true if the IRQ is wake capable * @@ -1024,15 +1024,15 @@ struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode, * The function is idempotent, though each time it runs it will configure GPIO * pin direction according to the flags in GpioInt resource. * - * The function takes optional @name parameter. If the resource has a property - * name, then only those will be taken into account. + * The function takes optional @con_id parameter. If the resource has + * a @con_id in a property, then only those will be taken into account. * * The GPIO is considered wake capable if the GpioInt resource specifies * SharedAndWake or ExclusiveAndWake. * * Return: Linux IRQ number (> %0) on success, negative errno on failure. */ -int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, int index, bool *wake_capable) { int idx, i; @@ -1043,9 +1043,8 @@ int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, in struct acpi_gpio_info info; struct gpio_desc *desc; - desc = acpi_get_gpiod_by_index(adev, name, i, &info); - /* Ignore -EPROBE_DEFER, it only matters if idx matches */ + desc = __acpi_find_gpio(acpi_fwnode_handle(adev), con_id, i, true, &info); if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) return PTR_ERR(desc); diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c index ba303868686a..b157f0f1c5a8 100644 --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_main.c @@ -436,7 +436,7 @@ static int mlxbf_gige_probe(struct platform_device *pdev) priv->rx_irq = platform_get_irq(pdev, MLXBF_GIGE_RECEIVE_PKT_INTR_IDX); priv->llu_plu_irq = platform_get_irq(pdev, MLXBF_GIGE_LLU_PLU_INTR_IDX); - phy_irq = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(&pdev->dev), "phy-gpios", 0); + phy_irq = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(&pdev->dev), "phy", 0); if (phy_irq < 0) { dev_err(&pdev->dev, "Error getting PHY irq. Use polling instead"); phy_irq = PHY_POLL; diff --git a/drivers/pinctrl/pinctrl-cy8c95x0.c b/drivers/pinctrl/pinctrl-cy8c95x0.c index 67b5d160c027..981c569bd671 100644 --- a/drivers/pinctrl/pinctrl-cy8c95x0.c +++ b/drivers/pinctrl/pinctrl-cy8c95x0.c @@ -95,7 +95,7 @@ static int cy8c95x0_acpi_get_irq(struct device *dev) if (ret) dev_warn(dev, "can't add GPIO ACPI mapping\n"); - ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq-gpios", 0); + ret = acpi_dev_gpio_irq_get_by(ACPI_COMPANION(dev), "irq", 0); if (ret < 0) return ret; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 34829f2c517a..35aff121f418 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1233,7 +1233,7 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); bool acpi_gpio_get_io_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); -int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, int index, +int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, int index, bool *wake_capable); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, @@ -1246,7 +1246,7 @@ static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, { return false; } -static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *name, +static inline int acpi_dev_gpio_irq_wake_get_by(struct acpi_device *adev, const char *con_id, int index, bool *wake_capable) { return -ENXIO; @@ -1259,10 +1259,10 @@ static inline int acpi_dev_gpio_irq_wake_get(struct acpi_device *adev, int index return acpi_dev_gpio_irq_wake_get_by(adev, NULL, index, wake_capable); } -static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *con_id, int index) { - return acpi_dev_gpio_irq_wake_get_by(adev, name, index, NULL); + return acpi_dev_gpio_irq_wake_get_by(adev, con_id, index, NULL); } static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)