[RFC,2/2] serial: 8250_dw: support polling mode

Message ID 1519324923-196857-3-git-send-email-john.garry@huawei.com
State New
Headers show
Series
  • Untitled series #9303
Related show

Commit Message

John Garry Feb. 22, 2018, 6:42 p.m.
It would be useful to make this driver support some
8250-compatible devices which have no interrupt line.

For these, we allow for no interrupt, and will fallback on
polling mode.

Note: the 8250 dt bindings state that "interrupts"
is a required property:
"interrupts : should contain uart interrupt."

But the 8250_of.c driver can live without it. So
this patch is going this way also.

Signed-off-by: John Garry <john.garry@huawei.com>

---
 drivers/tty/serial/8250/8250_dw.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andy Shevchenko Feb. 23, 2018, 5:35 p.m. | #1
On Fri, 2018-02-23 at 02:42 +0800, John Garry wrote:
> It would be useful to make this driver support some

> 8250-compatible devices which have no interrupt line.

> 

> For these, we allow for no interrupt, and will fallback on

> polling mode.

> 

> Note: the 8250 dt bindings state that "interrupts"

> is a required property:

> "interrupts : should contain uart interrupt."

> 

> But the 8250_of.c driver can live without it. So

> this patch is going this way also.


It should be documented in the binding.

>  	if (irq < 0) {

> -		if (irq != -EPROBE_DEFER)

> -			dev_err(dev, "cannot get irq\n");

> -		return irq;

> +		if (irq == -EPROBE_DEFER)

> +			return irq;

> +		dev_warn(dev, "cannot get irq, using polling

> mode\n");

> +		irq = 0;


NO_IRQ _is_ 0. You need to do something like

if (irq < 0) }
 ... leave existing code ...
}

if (!irq)
 dev_warn(, "Use polling mode\n");

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
John Garry Feb. 26, 2018, 10:54 a.m. | #2
On 23/02/2018 17:35, Andy Shevchenko wrote:
> On Fri, 2018-02-23 at 02:42 +0800, John Garry wrote:

>> It would be useful to make this driver support some

>> 8250-compatible devices which have no interrupt line.

>>

>> For these, we allow for no interrupt, and will fallback on

>> polling mode.

>>

>> Note: the 8250 dt bindings state that "interrupts"

>> is a required property:

>> "interrupts : should contain uart interrupt."

>>

>> But the 8250_of.c driver can live without it. So

>> this patch is going this way also.

>

> It should be documented in the binding.


Agreed. I find the wording a bit ambigious in bindings/serial/8250.txt 
and snps-dw-apb-uart.txt:

Required properties:
[...]
- interrupts : should contain uart interrupt.

It uses the word "should", and not "must". Maybe "should" means "must"...

>

>>  	if (irq < 0) {

>> -		if (irq != -EPROBE_DEFER)

>> -			dev_err(dev, "cannot get irq\n");

>> -		return irq;

>> +		if (irq == -EPROBE_DEFER)

>> +			return irq;

>> +		dev_warn(dev, "cannot get irq, using polling

>> mode\n");

>> +		irq = 0;

>

> NO_IRQ _is_ 0. You need to do something like

>

> if (irq < 0) }

>  ... leave existing code ...

> }

>

> if (!irq)

>  dev_warn(, "Use polling mode\n");


OK

>


Thanks,
John


--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 28fbc8f..3154988 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -422,9 +422,10 @@  static int dw8250_probe(struct platform_device *pdev)
 	}
 
 	if (irq < 0) {
-		if (irq != -EPROBE_DEFER)
-			dev_err(dev, "cannot get irq\n");
-		return irq;
+		if (irq == -EPROBE_DEFER)
+			return irq;
+		dev_warn(dev, "cannot get irq, using polling mode\n");
+		irq = 0;
 	}
 
 	spin_lock_init(&p->lock);