From nobody Sun Nov 10 09:45:52 2024 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25834199CB for ; Tue, 26 Dec 2023 19:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hNDoIHpw" Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-7bb0af58166so2864239f.1 for ; Tue, 26 Dec 2023 11:22:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703618540; x=1704223340; 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=X62kSUMdAd2TsFVgmakpOFBG3rZ/IiZ8YTHPEgONzYQ=; b=hNDoIHpwFE5bZVAbjzQfmsTmFtUMZrVxHmdYD8J6ZIRE/HSu63C+OGq+pNIuci8MIg uI4VGzx/OpA7RffB2fNi4aA2fxhFA/jeAX2BmSLa6v9NMVxhEKuYyn8EcqhKdGwE6eqk prbRv1TFM1k/PB7IxzLoGLKKyCUMm7Jk/4uGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703618540; x=1704223340; 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=X62kSUMdAd2TsFVgmakpOFBG3rZ/IiZ8YTHPEgONzYQ=; b=c2uv0mFLh0tKNR7UbuPNtQqpK2YjAWLmy/ITXRO6OZSqJ88WbmBm5M26XGKQ7Ht4Uu paswjcd33bsbM7M42OKJh6Yo0ABqiAT50MuCXSeXjX4SIphGHtxAj00Z/kwO7R+6shrv A+UkkOVxA8Z/mkBq5TykVJjHGwkP1iu4nKhqXII8XszvVz56gV0ccs2GiGy4lzT+YFwM +I66LMMhvMGYGhRKpzgY2vg8RxOBkaYf9ifB6ABNEqDlWfnLT2j7Bx6a6/hS26fgj1fJ 33hiHC8Lk3qk/cJDtn2BNPlivIEFfUIdTeNxLfdTqVka6O74pNdFUJEaol4Ov4d1atHR 4W6w== X-Gm-Message-State: AOJu0Yy0ppWtlqXtuPMQf+Id//zNvh9JNO+9qgD/mGm1+t4t5I9cMyPn APGSFFs3A9b5VGnbMWIbmh7yuH+SAepfpp9eeeNj5dO0ABnW X-Google-Smtp-Source: AGHT+IFcEJNCoiiMo8Qg++YCcAfKZRPQPBres6GJ9EPuoiGHGo0ZyDEn4ctqFj/q1mAJJoPuqiqTBg== X-Received: by 2002:a05:6602:1b86:b0:7ba:bd87:5404 with SMTP id dq6-20020a0566021b8600b007babd875404mr3390061iob.14.1703618540260; Tue, 26 Dec 2023 11:22:20 -0800 (PST) Received: from markhas1.lan (71-218-50-136.hlrn.qwest.net. [71.218.50.136]) by smtp.gmail.com with ESMTPSA id gw3-20020a0566381ee300b0046b692e719esm3207609jab.150.2023.12.26.11.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 11:22:20 -0800 (PST) From: Mark Hasemeyer To: LKML Cc: AngeloGioacchino Del Regno , Krzysztof Kozlowski , Rob Herring , Konrad Dybcio , Sudeep Holla , Andy Shevchenko , Raul Rangel , Tzung-Bi Shih , Mark Hasemeyer , Andy Shevchenko , Daniel Scally , Frank Rowand , Greg Kroah-Hartman , Heikki Krogerus , Len Brown , "Rafael J. Wysocki" , Rob Herring , Sakari Ailus , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org Subject: [PATCH v3 21/24] device property: Modify fwnode irq_get() to use resource Date: Tue, 26 Dec 2023 12:21:25 -0700 Message-ID: <20231226122113.v3.21.I38ac58ab04985a404ed6551eb5813fa7841ef410@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231226192149.1830592-1-markhas@chromium.org> References: <20231226192149.1830592-1-markhas@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The underlying ACPI and OF subsystems provide their own APIs which provide IRQ information as a struct resource. This allows callers to get more information about the IRQ by looking at the resource flags. For example, whether or not an IRQ is wake capable. Suggested-by: Andy Shevchenko Signed-off-by: Mark Hasemeyer --- Changes in v3: -Add Suggested-by tag -Initialize struct resource to 0 on stack -EXPORT_SYMBOL()->EXPORT_SYMBOL_GPL() -Remove extra space in commit message -Reformat fwnode_irq_get_resource() declaration Changes in v2: -New patch drivers/acpi/property.c | 11 +++++------ drivers/base/property.c | 24 +++++++++++++++++++++--- drivers/of/property.c | 8 ++++---- include/linux/fwnode.h | 8 +++++--- include/linux/property.h | 2 ++ 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index a6ead5204046b..891fff5a16797 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1627,17 +1627,16 @@ static int acpi_fwnode_graph_parse_endpoint(const s= truct fwnode_handle *fwnode, return 0; } =20 -static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, - unsigned int index) +static int acpi_fwnode_irq_get_resource(const struct fwnode_handle *fwnode= , unsigned int index, + struct resource *r) { - struct resource res; int ret; =20 - ret =3D acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res); + ret =3D acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, r); if (ret) return ret; =20 - return res.start; + return r->start; } =20 #define DECLARE_ACPI_FWNODE_OPS(ops) \ @@ -1664,7 +1663,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_ha= ndle *fwnode, acpi_graph_get_remote_endpoint, \ .graph_get_port_parent =3D acpi_fwnode_get_parent, \ .graph_parse_endpoint =3D acpi_fwnode_graph_parse_endpoint, \ - .irq_get =3D acpi_fwnode_irq_get, \ + .irq_get_resource =3D acpi_fwnode_irq_get_resource, \ }; \ EXPORT_SYMBOL_GPL(ops) =20 diff --git a/drivers/base/property.c b/drivers/base/property.c index a1b01ab420528..441899171d19d 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1047,23 +1047,41 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fw= node, int index) EXPORT_SYMBOL(fwnode_iomap); =20 /** - * fwnode_irq_get - Get IRQ directly from a fwnode + * fwnode_irq_get_resource - Get IRQ directly from a fwnode and populate + * the resource struct * @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ + * @r: Pointer to resource to populate with IRQ information. * * Return: Linux IRQ number on success. Negative errno on failure. */ -int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) +int fwnode_irq_get_resource(const struct fwnode_handle *fwnode, unsigned i= nt index, + struct resource *r) { int ret; =20 - ret =3D fwnode_call_int_op(fwnode, irq_get, index); + ret =3D fwnode_call_int_op(fwnode, irq_get_resource, index, r); /* We treat mapping errors as invalid case */ if (ret =3D=3D 0) return -EINVAL; =20 return ret; } +EXPORT_SYMBOL_GPL(fwnode_irq_get_resource); + +/** + * fwnode_irq_get - Get IRQ directly from a fwnode + * @fwnode: Pointer to the firmware node + * @index: Zero-based index of the IRQ + * + * Return: Linux IRQ number on success. Negative errno on failure. + */ +int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index) +{ + struct resource r =3D {}; + + return fwnode_irq_get_resource(fwnode, index, &r); +} EXPORT_SYMBOL(fwnode_irq_get); =20 /** diff --git a/drivers/of/property.c b/drivers/of/property.c index afdaefbd03f61..864ea5fa5702b 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1425,10 +1425,10 @@ static void __iomem *of_fwnode_iomap(struct fwnode_= handle *fwnode, int index) #endif } =20 -static int of_fwnode_irq_get(const struct fwnode_handle *fwnode, - unsigned int index) +static int of_fwnode_irq_get_resource(const struct fwnode_handle *fwnode, + unsigned int index, struct resource *r) { - return of_irq_get(to_of_node(fwnode), index); + return of_irq_to_resource(to_of_node(fwnode), index, r); } =20 static int of_fwnode_add_links(struct fwnode_handle *fwnode) @@ -1469,7 +1469,7 @@ const struct fwnode_operations of_fwnode_ops =3D { .graph_get_port_parent =3D of_fwnode_graph_get_port_parent, .graph_parse_endpoint =3D of_fwnode_graph_parse_endpoint, .iomap =3D of_fwnode_iomap, - .irq_get =3D of_fwnode_irq_get, + .irq_get_resource =3D of_fwnode_irq_get_resource, .add_links =3D of_fwnode_add_links, }; EXPORT_SYMBOL_GPL(of_fwnode_ops); diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 2a72f55d26eb8..716ed863acde0 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -9,10 +9,11 @@ #ifndef _LINUX_FWNODE_H_ #define _LINUX_FWNODE_H_ =20 -#include -#include #include #include +#include +#include +#include =20 struct fwnode_operations; struct device; @@ -164,7 +165,8 @@ struct fwnode_operations { int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); void __iomem *(*iomap)(struct fwnode_handle *fwnode, int index); - int (*irq_get)(const struct fwnode_handle *fwnode, unsigned int index); + int (*irq_get_resource)(const struct fwnode_handle *fwnode, + unsigned int index, struct resource *r); int (*add_links)(struct fwnode_handle *fwnode); }; =20 diff --git a/include/linux/property.h b/include/linux/property.h index e6516d0b7d52a..685ba72a8ce9e 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -190,6 +190,8 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_h= andle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); =20 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); +int fwnode_irq_get_resource(const struct fwnode_handle *fwnode, + unsigned int index, struct resource *r); int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *= name); =20 unsigned int device_get_child_node_count(const struct device *dev); --=20 2.43.0.472.g3155946c3a-goog