diff mbox

[v2,1/3] serial: mctrl_gpio: restrict MCTRL initialization

Message ID 1501485203-13185-2-git-send-email-yegorslists@googlemail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yegor Yefremov July 31, 2017, 7:13 a.m. UTC
From: Yegor Yefremov <yegorslists@googlemail.com>

GPIOs specified for serial port can be used either as GPIO driven MCTRL
or as a wakeup-source. Use the latter property to abort the MCTRL
initialization.

Return -ENOSYS as this would just skip mctrl initialization in the
case of wakeup source usage and not disable the port completely due to
failed serial8250_register_8250_port().

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 drivers/tty/serial/serial_mctrl_gpio.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Uwe Kleine-König Aug. 2, 2017, 6:19 a.m. UTC | #1
Hello Yegor,

On Mon, Jul 31, 2017 at 09:13:21AM +0200, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> GPIOs specified for serial port can be used either as GPIO driven MCTRL
> or as a wakeup-source. Use the latter property to abort the MCTRL
> initialization.
> 
> Return -ENOSYS as this would just skip mctrl initialization in the
> case of wakeup source usage and not disable the port completely due to
> failed serial8250_register_8250_port().
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>

Did I miss the explanation in the last round why this is necessary? You
write "can be used either as GPIO driven MCTRL or as a wakeup-source",
I wonder why there is a conflict.

Can you show a dt that makes problems and describe it. I would guess
either your dt being broken or you want to extend mctrl-gpio instead of
restrict it.

Best regards
Uwe
diff mbox

Patch

diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c
index d2da6aa..dce661c 100644
--- a/drivers/tty/serial/serial_mctrl_gpio.c
+++ b/drivers/tty/serial/serial_mctrl_gpio.c
@@ -19,6 +19,7 @@ 
 #include <linux/irq.h>
 #include <linux/gpio/consumer.h>
 #include <linux/termios.h>
+#include <linux/property.h>
 #include <linux/serial_core.h>
 #include <linux/module.h>
 
@@ -118,6 +119,9 @@  struct mctrl_gpios *mctrl_gpio_init_noauto(struct device *dev, unsigned int idx)
 	struct mctrl_gpios *gpios;
 	enum mctrl_gpio_idx i;
 
+	if (device_property_present(dev, "wakeup-source"))
+		return ERR_PTR(-ENOSYS);
+
 	gpios = devm_kzalloc(dev, sizeof(*gpios), GFP_KERNEL);
 	if (!gpios)
 		return ERR_PTR(-ENOMEM);