Skip to content

Commit 502abae

Browse files
robherringjnettlet
authored andcommitted
tty: serdev: fix serdev_device_write return value
Commit 6fe729c ("serdev: Add serdev_device_write subroutine") provides a compatibility wrapper for the existing serdev_device_write_buf, but it fails to return the number of bytes written causing users to timeout. Fixes: 6fe729c ("serdev: Add serdev_device_write subroutine") Cc: Andrey Smirnov <andrew.smirnov@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 57fdc98 commit 502abae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/tty/serdev/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int serdev_device_write(struct serdev_device *serdev,
139139
unsigned long timeout)
140140
{
141141
struct serdev_controller *ctrl = serdev->ctrl;
142-
int ret;
142+
int ret, wr_cnt = 0;
143143

144144
if (!ctrl || !ctrl->ops->write_buf ||
145145
(timeout && !serdev->ops->write_wakeup))
@@ -155,12 +155,13 @@ int serdev_device_write(struct serdev_device *serdev,
155155

156156
buf += ret;
157157
count -= ret;
158+
wr_cnt += ret;
158159

159160
} while (count &&
160161
(timeout = wait_for_completion_timeout(&serdev->write_comp,
161162
timeout)));
162163
mutex_unlock(&serdev->write_lock);
163-
return ret < 0 ? ret : (count ? -ETIMEDOUT : 0);
164+
return ret < 0 ? ret : (count ? -ETIMEDOUT : wr_cnt);
164165
}
165166
EXPORT_SYMBOL_GPL(serdev_device_write);
166167

0 commit comments

Comments
 (0)