Skip to content

Commit 99c6370

Browse files
Sakari Ailusrafaeljw
authored andcommitted
device property: Add irq_get to fwnode operation
Add irq_get() fwnode operation to implement fwnode_irq_get() through fwnode operations, moving the code in fwnode_irq_get() to OF and ACPI frameworks. Signed-off-by: Sakari Ailus <[email protected]> Acked-by: Rob Herring <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 68b979d commit 99c6370

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

drivers/acpi/property.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,19 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
13941394
return 0;
13951395
}
13961396

1397+
static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
1398+
unsigned int index)
1399+
{
1400+
struct resource res;
1401+
int ret;
1402+
1403+
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
1404+
if (ret)
1405+
return ret;
1406+
1407+
return res.start;
1408+
}
1409+
13971410
#define DECLARE_ACPI_FWNODE_OPS(ops) \
13981411
const struct fwnode_operations ops = { \
13991412
.device_is_available = acpi_fwnode_device_is_available, \
@@ -1418,6 +1431,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
14181431
acpi_graph_get_remote_endpoint, \
14191432
.graph_get_port_parent = acpi_fwnode_get_parent, \
14201433
.graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \
1434+
.irq_get = acpi_fwnode_irq_get, \
14211435
}; \
14221436
EXPORT_SYMBOL_GPL(ops)
14231437

drivers/base/property.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -901,17 +901,7 @@ EXPORT_SYMBOL(fwnode_iomap);
901901
*/
902902
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
903903
{
904-
struct resource res;
905-
int ret;
906-
907-
if (is_of_node(fwnode))
908-
return of_irq_get(to_of_node(fwnode), index);
909-
910-
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), index, &res);
911-
if (ret)
912-
return ret;
913-
914-
return res.start;
904+
return fwnode_call_int_op(fwnode, irq_get, index);
915905
}
916906
EXPORT_SYMBOL(fwnode_irq_get);
917907

drivers/of/property.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,12 @@ static void __iomem *of_fwnode_iomap(struct fwnode_handle *fwnode, int index)
14741474
#endif
14751475
}
14761476

1477+
static int of_fwnode_irq_get(const struct fwnode_handle *fwnode,
1478+
unsigned int index)
1479+
{
1480+
return of_irq_get(to_of_node(fwnode), index);
1481+
}
1482+
14771483
static int of_fwnode_add_links(struct fwnode_handle *fwnode)
14781484
{
14791485
struct property *p;
@@ -1512,6 +1518,7 @@ const struct fwnode_operations of_fwnode_ops = {
15121518
.graph_get_port_parent = of_fwnode_graph_get_port_parent,
15131519
.graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
15141520
.iomap = of_fwnode_iomap,
1521+
.irq_get = of_fwnode_irq_get,
15151522
.add_links = of_fwnode_add_links,
15161523
};
15171524
EXPORT_SYMBOL_GPL(of_fwnode_ops);

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct fwnode_operations {
149149
int (*graph_parse_endpoint)(const struct fwnode_handle *fwnode,
150150
struct fwnode_endpoint *endpoint);
151151
void __iomem *(*iomap)(struct fwnode_handle *fwnode, int index);
152+
int (*irq_get)(const struct fwnode_handle *fwnode, unsigned int index);
152153
int (*add_links)(struct fwnode_handle *fwnode);
153154
};
154155

0 commit comments

Comments
 (0)