Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp896584ima; Wed, 6 Feb 2019 10:05:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IbPOw05a4/yAu3ciuwAgYrhL4bk0/UQFlBtjO7LXLSO2Vi/MHqlHTS2Uowek98LO8RhyzGo X-Received: by 2002:a63:1061:: with SMTP id 33mr5337640pgq.108.1549476308897; Wed, 06 Feb 2019 10:05:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549476308; cv=none; d=google.com; s=arc-20160816; b=YHowFEndawQUXl2u1AeTjvOZ7kCT08ZWiG1MlEI/cxbxSfzqEd+ROnbKhOkD/8/xF+ WHvKvaI5iUjTR22zArZXX++J12o9wJ8UEB5f7ecdi7Y6sytHbZ4cwShQo3kcpDqCmpJQ iczxG5qCMxOh1NnbVy20oioBF3uS4BYm/J5U9BREsIh80eKrJsm1LCOYHg3lOknnLd9y +mNfvw9JSLhDChNfkWKHDy0iV/JdzOkGlqqwAUbRXn5FmyGb6DuB0s3Pqg+CxNqcIt3n uz2EV/NmQcI57TKfGWPgwILesYnPkH4j74ZdIGbVJLn1joOgS7wEIrmN4HM2Ka3JZ8hn th0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=TJBJymPX/RGQRihDyyMgKHXk8lwLQ/Q4fEPGRz4viOc=; b=aAD3I/aIHl9yEvMAXnWrqH1AGS2WyVgn6XdoqbOBtlurp5xL0gBYCOQDb8UtIJbFFh x58IeWs1C0VNK2Tdp5utno3G5v1/z/dTO26VeRXehnpiRpB8FqdPQyPrT4burEnjwd2O ti/jopUGXwxqNI8nwE2qA7A+U+x/k3XIH/wWPQxxlI2YsfWNiYWQWDps0SelJHppT2Du Ph9ZUf7WBvpnIctReRtFm0y5QV7ArF0i5ZVNsgbC7IXyOaoXS/nAVQ95tbGcu5WV2jCV ckG8mP5QxuRAwBXqsbwH4SZH2BwJ57RNJrp0FDDM9V9OZyE2tBDQj4wt5qG8wrvLtjUc /0ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j39si6640213plb.272.2019.02.06.10.04.45; Wed, 06 Feb 2019 10:05:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730231AbfBFRkN (ORCPT + 99 others); Wed, 6 Feb 2019 12:40:13 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46836 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730103AbfBFRkK (ORCPT ); Wed, 6 Feb 2019 12:40:10 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id CD87E27977F From: Enric Balletbo i Serra To: linux-kernel@vger.kernel.org Cc: groeck@chromium.org, lee.jones@linaro.org, gwendal@chromium.org, kernel@collabora.com, bleung@chromium.org, Guenter Roeck Subject: [PATCH v2] mfd: cros_ec_dev: Return number of bytes read with CROS_EC_DEV_IOCRDMEM Date: Wed, 6 Feb 2019 18:39:59 +0100 Message-Id: <20190206173959.23925-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guenter Roeck While ioctls normally return a negative error or 0 on success, this is not the case for CROS_EC_DEV_IOCXCMD in the cros_ec driver, which returns the number of bytes read instead. However, CROS_EC_DEV_IOCRDMEM in the same driver does not return the number of byte read on success. This is both inconsistent and problematic, since the amount of returned data can be dynamic. Have it return the number of data bytes for consistency. Signed-off-by: Guenter Roeck Signed-off-by: Enric Balletbo i Serra --- Hi, This patch was send long time ago and never landed to mainline [1]. This is a second attempt. Originally was made to apply on platform/chrome but after the recent changes we did it should go now throught the MFD subsystem. Without this patch userspace tools like ectool doesn't work as expected. Best regards, Enric [1] https://lore.kernel.org/patchwork/patch/665211/ Changes in v2: - Adapt and rebase to current mainline. drivers/mfd/cros_ec_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index ed809fc97df8..d275deaecb12 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -224,7 +224,7 @@ static long ec_device_ioctl_readmem(struct cros_ec_dev *ec, void __user *arg) if (copy_to_user((void __user *)arg, &s_mem, sizeof(s_mem))) return -EFAULT; - return 0; + return num; } static long ec_device_ioctl(struct file *filp, unsigned int cmd, -- 2.20.1