@@ -1627,17 +1627,16 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
return 0;
}
-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;
- ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
+ ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, r);
if (ret)
return ret;
- return res.start;
+ return r->start;
}
#define DECLARE_ACPI_FWNODE_OPS(ops) \
@@ -1664,7 +1663,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
acpi_graph_get_remote_endpoint, \
.graph_get_port_parent = acpi_fwnode_get_parent, \
.graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
- .irq_get = acpi_fwnode_irq_get, \
+ .irq_get_resource = acpi_fwnode_irq_get_resource, \
}; \
EXPORT_SYMBOL_GPL(ops)
@@ -1046,6 +1046,29 @@ void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index)
}
EXPORT_SYMBOL(fwnode_iomap);
+/**
+ * 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_resource(const struct fwnode_handle *fwnode, unsigned int index,
+ struct resource *r)
+{
+ int ret;
+
+ ret = fwnode_call_int_op(fwnode, irq_get_resource, index, r);
+ /* We treat mapping errors as invalid case */
+ if (ret == 0)
+ return -EINVAL;
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(fwnode_irq_get_resource);
+
/**
* fwnode_irq_get - Get IRQ directly from a fwnode
* @fwnode: Pointer to the firmware node
@@ -1055,14 +1078,9 @@ EXPORT_SYMBOL(fwnode_iomap);
*/
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
{
- int ret;
+ struct resource r = {};
- ret = fwnode_call_int_op(fwnode, irq_get, index);
- /* We treat mapping errors as invalid case */
- if (ret == 0)
- return -EINVAL;
-
- return ret;
+ return fwnode_irq_get_resource(fwnode, index, &r);
}
EXPORT_SYMBOL(fwnode_irq_get);
@@ -1425,10 +1425,10 @@ static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index)
#endif
}
-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);
}
static int of_fwnode_add_links(struct fwnode_handle *fwnode)
@@ -1469,7 +1469,7 @@ const struct fwnode_operations of_fwnode_ops = {
.graph_get_port_parent = of_fwnode_graph_get_port_parent,
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
.iomap = of_fwnode_iomap,
- .irq_get = of_fwnode_irq_get,
+ .irq_get_resource = of_fwnode_irq_get_resource,
.add_links = of_fwnode_add_links,
};
EXPORT_SYMBOL_GPL(of_fwnode_ops);
@@ -9,12 +9,13 @@
#ifndef _LINUX_FWNODE_H_
#define _LINUX_FWNODE_H_
-#include <linux/types.h>
-#include <linux/list.h>
#include <linux/bits.h>
#include <linux/err.h>
+#include <linux/list.h>
+#include <linux/types.h>
struct fwnode_operations;
+struct resource;
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);
};
@@ -190,6 +190,8 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode);
void fwnode_handle_put(struct fwnode_handle *fwnode);
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);
unsigned int device_get_child_node_count(const struct device *dev);