diff mbox series

[5/9] mtd: rawnand: brcmnand: Allow working without interrupts

Message ID 20211223002225.3738385-6-f.fainelli@gmail.com
State Superseded
Headers show
Series BCMA support for brcmnand | expand

Commit Message

Florian Fainelli Dec. 23, 2021, 12:22 a.m. UTC
The BCMA devices include the brcmnand controller but they do not wire up
any interrupt line, allow the main interrupt to be optional and update
the completion path to also check for the lack of an interrupt line.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 52 +++++++++++-------------
 1 file changed, 24 insertions(+), 28 deletions(-)

Comments

Andy Shevchenko Dec. 25, 2021, 5:45 p.m. UTC | #1
On Sat, Dec 25, 2021 at 1:41 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> The BCMA devices include the brcmnand controller but they do not wire up
> any interrupt line, allow the main interrupt to be optional and update
> the completion path to also check for the lack of an interrupt line.
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

> -       unsigned int            irq;
> +       int                     irq;

instead.,,

> +       ctrl->irq = platform_get_irq_optional(pdev, 0);
> +       if (ctrl->irq >= 0) {

ret = ...
if (ret > 0) {

And drop 0 from the equation, OF never uses 0 as valid vIRQ.
Florian Fainelli Dec. 27, 2021, 5:05 p.m. UTC | #2
On 12/25/2021 9:45 AM, Andy Shevchenko wrote:
> On Sat, Dec 25, 2021 at 1:41 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>> The BCMA devices include the brcmnand controller but they do not wire up
>> any interrupt line, allow the main interrupt to be optional and update
>> the completion path to also check for the lack of an interrupt line.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> 
>> -       unsigned int            irq;
>> +       int                     irq;
> 
> instead.,,
> 
>> +       ctrl->irq = platform_get_irq_optional(pdev, 0);
>> +       if (ctrl->irq >= 0) {
> 
> ret = ...
> if (ret > 0) {
> 
> And drop 0 from the equation, OF never uses 0 as valid vIRQ.

OK but the point of this patch series is to allow the use of the 
brcmnand driver in a configuration without OF. I don't really see the 
point in continuing to use unsigned int instead of just letting 
request_irq() play through and tell us if the interrupt descriptor was 
valid later on.
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 60a7f375df83..e7947cff4dd1 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -213,7 +213,7 @@  struct brcmnand_controller {
 	void __iomem		*nand_base;
 	void __iomem		*nand_fc; /* flash cache */
 	void __iomem		*flash_dma_base;
-	unsigned int		irq;
+	int			irq;
 	unsigned int		dma_irq;
 	int			nand_version;
 
@@ -1602,7 +1602,7 @@  static bool brcmstb_nand_wait_for_completion(struct nand_chip *chip)
 	bool err = false;
 	int sts;
 
-	if (mtd->oops_panic_write) {
+	if (mtd->oops_panic_write || ctrl->irq < 0) {
 		/* switch to interrupt polling and PIO mode */
 		disable_ctrl_irqs(ctrl);
 		sts = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY,
@@ -3130,33 +3130,29 @@  int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
 	}
 
 	/* IRQ */
-	ctrl->irq = platform_get_irq(pdev, 0);
-	if ((int)ctrl->irq < 0) {
-		dev_err(dev, "no IRQ defined\n");
-		ret = -ENODEV;
-		goto err;
-	}
-
-	/*
-	 * Some SoCs integrate this controller (e.g., its interrupt bits) in
-	 * interesting ways
-	 */
-	if (soc) {
-		ret = devm_request_irq(dev, ctrl->irq, brcmnand_irq, 0,
-				       DRV_NAME, ctrl);
+	ctrl->irq = platform_get_irq_optional(pdev, 0);
+	if (ctrl->irq >= 0) {
+		/*
+		 * Some SoCs integrate this controller (e.g., its interrupt bits) in
+		 * interesting ways
+		 */
+		if (soc) {
+			ret = devm_request_irq(dev, ctrl->irq, brcmnand_irq, 0,
+					       DRV_NAME, ctrl);
 
-		/* Enable interrupt */
-		ctrl->soc->ctlrdy_ack(ctrl->soc);
-		ctrl->soc->ctlrdy_set_enabled(ctrl->soc, true);
-	} else {
-		/* Use standard interrupt infrastructure */
-		ret = devm_request_irq(dev, ctrl->irq, brcmnand_ctlrdy_irq, 0,
-				       DRV_NAME, ctrl);
-	}
-	if (ret < 0) {
-		dev_err(dev, "can't allocate IRQ %d: error %d\n",
-			ctrl->irq, ret);
-		goto err;
+			/* Enable interrupt */
+			ctrl->soc->ctlrdy_ack(ctrl->soc);
+			ctrl->soc->ctlrdy_set_enabled(ctrl->soc, true);
+		} else {
+			/* Use standard interrupt infrastructure */
+			ret = devm_request_irq(dev, ctrl->irq, brcmnand_ctlrdy_irq, 0,
+					       DRV_NAME, ctrl);
+		}
+		if (ret < 0) {
+			dev_err(dev, "can't allocate IRQ %d: error %d\n",
+				ctrl->irq, ret);
+			goto err;
+		}
 	}
 
 	for_each_available_child_of_node(dn, child) {