All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/riscv-aplic: Simplify the to_of_node code
@ 2024-05-27 12:50 Jinjie Ruan
  2024-06-03 10:31 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Jinjie Ruan @ 2024-05-27 12:50 UTC (permalink / raw)
  To: anup, tglx, paul.walmsley, palmer, aou, linux-riscv; +Cc: ruanjinjie

The to_of_node has is_of_node check, so there is no need to repeat the
is_of_node and to_of_node. And if is_of_node is false, the to_of_node will
return NULL, the of_property_present will also return NULL, so remove the
redundant check.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/irqchip/irq-riscv-aplic-main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/irqchip/irq-riscv-aplic-main.c b/drivers/irqchip/irq-riscv-aplic-main.c
index 774a0c97fdab..28dd175b5764 100644
--- a/drivers/irqchip/irq-riscv-aplic-main.c
+++ b/drivers/irqchip/irq-riscv-aplic-main.c
@@ -127,6 +127,7 @@ static void aplic_init_hw_irqs(struct aplic_priv *priv)
 
 int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *regs)
 {
+	struct device_node *np = to_of_node(dev->fwnode);
 	struct of_phandle_args parent;
 	int rc;
 
@@ -134,7 +135,7 @@ int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *
 	 * Currently, only OF fwnode is supported so extend this
 	 * function for ACPI support.
 	 */
-	if (!is_of_node(dev->fwnode))
+	if (!np)
 		return -EINVAL;
 
 	/* Save device pointer and register base */
@@ -142,8 +143,7 @@ int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *
 	priv->regs = regs;
 
 	/* Find out number of interrupt sources */
-	rc = of_property_read_u32(to_of_node(dev->fwnode), "riscv,num-sources",
-				  &priv->nr_irqs);
+	rc = of_property_read_u32(np, "riscv,num-sources", &priv->nr_irqs);
 	if (rc) {
 		dev_err(dev, "failed to get number of interrupt sources\n");
 		return rc;
@@ -155,8 +155,8 @@ int aplic_setup_priv(struct aplic_priv *priv, struct device *dev, void __iomem *
 	 * If "msi-parent" property is present then we ignore the
 	 * APLIC IDCs which forces the APLIC driver to use MSI mode.
 	 */
-	if (!of_property_present(to_of_node(dev->fwnode), "msi-parent")) {
-		while (!of_irq_parse_one(to_of_node(dev->fwnode), priv->nr_idcs, &parent))
+	if (!of_property_present(np, "msi-parent")) {
+		while (!of_irq_parse_one(np, priv->nr_idcs, &parent))
 			priv->nr_idcs++;
 	}
 
@@ -184,8 +184,7 @@ static int aplic_probe(struct platform_device *pdev)
 	 * If msi-parent property is present then setup APLIC MSI
 	 * mode otherwise setup APLIC direct mode.
 	 */
-	if (is_of_node(dev->fwnode))
-		msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent");
+	msi_mode = of_property_present(to_of_node(dev->fwnode), "msi-parent");
 	if (msi_mode)
 		rc = aplic_msi_setup(dev, regs);
 	else
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] irqchip/riscv-aplic: Simplify the to_of_node code
  2024-05-27 12:50 [PATCH] irqchip/riscv-aplic: Simplify the to_of_node code Jinjie Ruan
@ 2024-06-03 10:31 ` Thomas Gleixner
  2024-06-03 11:16   ` Jinjie Ruan
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2024-06-03 10:31 UTC (permalink / raw)
  To: Jinjie Ruan, anup, paul.walmsley, palmer, aou, linux-riscv; +Cc: ruanjinjie

On Mon, May 27 2024 at 12:50, Jinjie Ruan wrote:
> The to_of_node has is_of_node check, so there is no need to repeat the
> is_of_node and to_of_node. And if is_of_node is false, the to_of_node will
> return NULL, the of_property_present will also return NULL, so remove the
> redundant check.

Please read:

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#function-references-in-changelogs

Thanks,

        tglx

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] irqchip/riscv-aplic: Simplify the to_of_node code
  2024-06-03 10:31 ` Thomas Gleixner
@ 2024-06-03 11:16   ` Jinjie Ruan
  0 siblings, 0 replies; 3+ messages in thread
From: Jinjie Ruan @ 2024-06-03 11:16 UTC (permalink / raw)
  To: Thomas Gleixner, anup, paul.walmsley, palmer, aou, linux-riscv



On 2024/6/3 18:31, Thomas Gleixner wrote:
> On Mon, May 27 2024 at 12:50, Jinjie Ruan wrote:
>> The to_of_node has is_of_node check, so there is no need to repeat the
>> is_of_node and to_of_node. And if is_of_node is false, the to_of_node will
>> return NULL, the of_property_present will also return NULL, so remove the
>> redundant check.
> 
> Please read:
> 
> https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#function-references-in-changelogs

Thank you, I will read the documentation carefully and change the commit
message as requested.

> 
> Thanks,
> 
>         tglx

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-03 11:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 12:50 [PATCH] irqchip/riscv-aplic: Simplify the to_of_node code Jinjie Ruan
2024-06-03 10:31 ` Thomas Gleixner
2024-06-03 11:16   ` Jinjie Ruan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.