From patchwork Tue May 2 00:17:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 98392 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1639371qgf; Mon, 1 May 2017 17:17:20 -0700 (PDT) X-Received: by 10.99.143.69 with SMTP id r5mr28895803pgn.77.1493684240532; Mon, 01 May 2017 17:17:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b126si1900744pga.105.2017.05.01.17.17.20; Mon, 01 May 2017 17:17:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750835AbdEBARS (ORCPT + 3 others); Mon, 1 May 2017 20:17:18 -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 Received: by mail-io0-f195.google.com with SMTP id x86so25449034ioe.3; Mon, 01 May 2017 17:17:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5GILDkpggMilXbQijDAYr+ucDtvbO9xEGlf/9lT0uQw=; b=E4RWupFEgWKZsDMuLDey/7iwrPLtIee3gR/+jqoGM6PW/qcnkGIbqvHqwCu7ppMbD2 IwsOYFqmIQGGcQV76pAKlZBCZnI5F9U1qYrejfjEFyoO0ParfDXJTI2w6Cm8RvVX2eJf UA7qFFJKyIZh9blNXMRa/BwjQ9W/cLLKYA8mVHKtEg01+FCgg/7O1181GbhrXeWMs4Mw 2T0Jpd0N5zSUTMTBuRtVUIsRzSNOUTAQMWcFIWz3KbELNT6Acfg3mx3zyEDb8donhZqU IOlGWbjh9ge6hS5hXoLH6HSR6ZoroK9DU+IzrJKmFE4G29YDHPD0PDxKVfzMUTs5y7Wr LLqw== X-Gm-Message-State: AN3rC/4PiiJXZ9fVUnzLRR9GDs61XrL+NiK4ExZacQDWXNl0bq3TCZGD RBsclvwAafODrePACmI= X-Received: by 10.202.224.6 with SMTP id x6mr10286970oig.186.1493684237425; Mon, 01 May 2017 17:17:17 -0700 (PDT) Received: from localhost.localdomain (66-90-148-125.dyn.grandenetworks.net. [66.90.148.125]) by smtp.googlemail.com with ESMTPSA id e191sm7838463oic.3.2017.05.01.17.17.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 May 2017 17:17:16 -0700 (PDT) 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-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@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(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);