Skip to content

Commit ef7080b

Browse files
Jinjie RuanKAGA-KOKO
authored andcommitted
irqchip/riscv-aplic: Simplify the initialization code
The initialization code has an is_of_node() check and invokes to_of_node() for every of_property_*() invocation. to_of_node() has a is_of_node() check already, so simplify the code by invoking to_of_node() and checking that for NULL. If not NULL hand in the node pointer to of_property_*(). The same applies to of_property_*() which fails when invoked with a NULL node pointer. [ tglx: Massaged change log ] Signed-off-by: Jinjie Ruan <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent 760d7e7 commit ef7080b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/irqchip/irq-riscv-aplic-main.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,23 @@ static void aplic_init_hw_irqs(struct aplic_priv *priv)
127127

128128
int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs)
129129
{
130+
struct device_node *np = to_of_node(dev->fwnode);
130131
struct of_phandle_args parent;
131132
int rc;
132133

133134
/*
134135
* Currently, only OF fwnode is supported so extend this
135136
* function for ACPI support.
136137
*/
137-
if (!is_of_node(dev->fwnode))
138+
if (!np)
138139
return -EINVAL;
139140

140141
/* Save device pointer and register base */
141142
priv->dev = dev;
142143
priv->regs = regs;
143144

144145
/* Find out number of interrupt sources */
145-
rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources",
146-
&priv->nr_irqs);
146+
rc = of_property_read_u32(np, "riscv,num-sources", &priv->nr_irqs);
147147
if (rc) {
148148
dev_err(dev, "failed to get number of interrupt sources\n");
149149
return rc;
@@ -155,8 +155,8 @@ int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *
155155
* If "msi-parent" property is present then we ignore the
156156
* APLIC IDCs which forces the APLIC driver to use MSI mode.
157157
*/
158-
if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) {
159-
while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent))
158+
if (!of_property_present(np, "msi-parent")) {
159+
while (!of_irq_parse_one(np, priv->nr_idcs, &parent))
160160
priv->nr_idcs++;
161161
}
162162

@@ -184,8 +184,7 @@ static int aplic_probe(struct platform_device *pdev)
184184
* If msi-parent property is present then setup APLIC MSI
185185
* mode otherwise setup APLIC direct mode.
186186
*/
187-
if (is_of_node(dev->fwnode))
188-
msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent");
187+
msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent");
189188
if (msi_mode)
190189
rc = aplic_msi_setup(dev, regs);
191190
else

0 commit comments

Comments
 (0)