OSDN Git Service

serdev: use zero to indicate infinite write timeout
authorJohan Hovold <johan@kernel.org>
Wed, 14 Nov 2018 15:09:01 +0000 (16:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Nov 2018 18:44:21 +0000 (19:44 +0100)
Use zero to indicate infinite timeout for the synchronous
serdev_device_write() helper.

This allows drivers to specify an infinite timeout without knowing about
serdev implementation details, while also allowing the same timeout
argument to be used for both serdev_device_write() and
serdev_device_wait_until_sent().

Note that passing zero to the current helper makes no sense; just call
the asynchronous serdev_device_write_buf() directly instead.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serdev/core.c

index 9db93f5..c7d637d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/sched.h>
 #include <linux/serdev.h>
 #include <linux/slab.h>
 
@@ -235,10 +236,12 @@ int serdev_device_write(struct serdev_device *serdev,
        struct serdev_controller *ctrl = serdev->ctrl;
        int ret;
 
-       if (!ctrl || !ctrl->ops->write_buf ||
-           (timeout && !serdev->ops->write_wakeup))
+       if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup)
                return -EINVAL;
 
+       if (timeout == 0)
+               timeout = MAX_SCHEDULE_TIMEOUT;
+
        mutex_lock(&serdev->write_lock);
        do {
                reinit_completion(&serdev->write_comp);