From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbdEBART (ORCPT ); Mon, 1 May 2017 20:17:19 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:36713 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbdEBARS (ORCPT ); Mon, 1 May 2017 20:17:18 -0400 From: Rob Herring To: Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Smirnov Subject: [PATCH] tty: serdev: fix serdev_device_write return value Date: Mon, 1 May 2017 19:17:14 -0500 Message-Id: <20170502001714.11576-1-robh@kernel.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 6fe729c4bdae ("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: 6fe729c4bdae ("serdev: Add serdev_device_write subroutine") Cc: Andrey Smirnov Cc: Greg Kroah-Hartman Signed-off-by: Rob Herring --- drivers/tty/serdev/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index 433de5ea9b02..ccfe56355c4f 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -127,7 +127,7 @@ int serdev_device_write(struct serdev_device *serdev, unsigned long timeout) { struct serdev_controller *ctrl = serdev->ctrl; - int ret; + int ret, wr_cnt = 0; if (!ctrl || !ctrl->ops->write_buf || (timeout && !serdev->ops->write_wakeup)) @@ -143,12 +143,13 @@ int serdev_device_write(struct serdev_device *serdev, buf += ret; count -= ret; + wr_cnt += ret; } while (count && (timeout = wait_for_completion_timeout(&serdev->write_comp, timeout))); mutex_unlock(&serdev->write_lock); - return ret < 0 ? ret : (count ? -ETIMEDOUT : 0); + return ret < 0 ? ret : (count ? -ETIMEDOUT : wr_cnt); } EXPORT_SYMBOL_GPL(serdev_device_write); -- 2.11.0