Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serdev: use zero to indicate infinite write timeout

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
22d66c85 dc93967b

+5 -2
+5 -2
drivers/tty/serdev/core.c
··· 15 15 #include <linux/of_device.h> 16 16 #include <linux/pm_domain.h> 17 17 #include <linux/pm_runtime.h> 18 + #include <linux/sched.h> 18 19 #include <linux/serdev.h> 19 20 #include <linux/slab.h> 20 21 ··· 236 235 struct serdev_controller *ctrl = serdev->ctrl; 237 236 int ret; 238 237 239 - if (!ctrl || !ctrl->ops->write_buf || 240 - (timeout && !serdev->ops->write_wakeup)) 238 + if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup) 241 239 return -EINVAL; 240 + 241 + if (timeout == 0) 242 + timeout = MAX_SCHEDULE_TIMEOUT; 242 243 243 244 mutex_lock(&serdev->write_lock); 244 245 do {