irqdomain: Introduce is_fwnode_irqchip helper
authorSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Thu, 10 Dec 2015 16:55:28 +0000 (08:55 -0800)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 21 Dec 2015 13:49:49 +0000 (13:49 +0000)
Since there will be several places checking if fwnode.type
is equal FWNODE_IRQCHIP, this patch adds a convenient function
for this purpose.

Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
drivers/irqchip/irq-gic.c
include/linux/irqdomain.h
kernel/irq/irqdomain.c

index abf2ffaed392270c97d14c7fdc2ab247e63a58e1..fcd327f49e8e3e5417575787b3113843a52b58e0 100644 (file)
@@ -972,7 +972,7 @@ static int gic_irq_domain_translate(struct irq_domain *d,
                return 0;
        }
 
                return 0;
        }
 
-       if (fwspec->fwnode->type == FWNODE_IRQCHIP) {
+       if (is_fwnode_irqchip(fwspec->fwnode)) {
                if(fwspec->param_count != 2)
                        return -EINVAL;
 
                if(fwspec->param_count != 2)
                        return -EINVAL;
 
index a06fedacd9557f9065b6ee849e0ad7669623d449..d72fabc04437bd54ecb3cdb0e62b2f1ce0dcb62f 100644 (file)
@@ -211,6 +211,11 @@ static inline struct fwnode_handle *of_node_to_fwnode(struct device_node *node)
        return node ? &node->fwnode : NULL;
 }
 
        return node ? &node->fwnode : NULL;
 }
 
+static inline bool is_fwnode_irqchip(struct fwnode_handle *fwnode)
+{
+       return fwnode && fwnode->type == FWNODE_IRQCHIP;
+}
+
 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
                                                        enum irq_domain_bus_token bus_token)
 {
 static inline struct irq_domain *irq_find_matching_host(struct device_node *node,
                                                        enum irq_domain_bus_token bus_token)
 {
index 22aa9612ef7ca98cd8796188a7021810cc86d05a..7f34d98ebfc45742e7c21d53dd0727fe6652aedf 100644 (file)
@@ -70,7 +70,7 @@ void irq_domain_free_fwnode(struct fwnode_handle *fwnode)
 {
        struct irqchip_fwid *fwid;
 
 {
        struct irqchip_fwid *fwid;
 
-       if (WARN_ON(fwnode->type != FWNODE_IRQCHIP))
+       if (WARN_ON(!is_fwnode_irqchip(fwnode)))
                return;
 
        fwid = container_of(fwnode, struct irqchip_fwid, fwnode);
                return;
 
        fwid = container_of(fwnode, struct irqchip_fwid, fwnode);