Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp881473img; Fri, 22 Mar 2019 10:31:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzJKYfenzJugNotM3OhIGm4dI/8fAenKEbRejRZ9d28SvOHcSi9m7fuBAjrRZoFKrERD6f X-Received: by 2002:a17:902:26f:: with SMTP id 102mr10503421plc.175.1553275917092; Fri, 22 Mar 2019 10:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553275917; cv=none; d=google.com; s=arc-20160816; b=JAuDJreEfthBN4yITdVAvnzzAthGRMCZUZf5ugL2nf997sFtL09pifgangsMcBOofv /Cr/TAtwTjiDynvUTw6lc5/aLoBOm1ac6cOiqS93oMPLjFG/fw/BTM8+wBBEUNGkHVh/ by0p3/vNMKTTjeS7Rfl6xWoHVYut7VyUz38AM8SFRXxbz6bljn5+eUHAgQ8FJkx++X2y BMY9H1pxII6ATK4xNJIvS2d8k42/52cmbvQcLJUqYJc5YcJHI20VcdrZkNMOPztUQqQ6 wn8U8+b0SUv0m8LVYaGZAmT4aEDt7cua4b/3ejMubNjZKiIIGIIUmZUEDygzDnSVaTCW 377A== 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:dkim-signature; bh=n4+h1AwiYWbcvCo2SVfEpk4VI/pUxMw43QNPM3T3NW0=; b=yVwfC+/1NzAA5lLmLcAmhQ5PHHeNLng5gT8y3uojFMuRt1txFUTscwQPYHWUw5rQrr ahIV2pU4vWMrE/NHmHe++ZKQVKjMYUBXfBH6kvLlDJiOO37sYTQNYCH/HkE+ZEve7Yhm p9BPv5C+jelPUdVXJgmGABYxgJMel3ijubuLh3siIHPMQGAny5kDvE2aHsPHGckZ9Zmm adb66ExaQMpS6o5jlF+Ms7g7YJeWimJ5+SY41HdAsNdx/omXOhy3pR54sjMqZaP8uSu7 j91R/WWWwRzbWqYn3A/GJswTxnfXzrcEt+B/VmGIno/mGBQ4kNM5N1DFe29wMFSOElZ7 Q/Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=LoexckY1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si1349963pff.130.2019.03.22.10.31.38; Fri, 22 Mar 2019 10:31:57 -0700 (PDT) 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; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=LoexckY1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728286AbfCVRa6 (ORCPT + 99 others); Fri, 22 Mar 2019 13:30:58 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34239 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728214AbfCVRa6 (ORCPT ); Fri, 22 Mar 2019 13:30:58 -0400 Received: by mail-wr1-f67.google.com with SMTP id p10so3260108wrq.1 for ; Fri, 22 Mar 2019 10:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n4+h1AwiYWbcvCo2SVfEpk4VI/pUxMw43QNPM3T3NW0=; b=LoexckY1HPl6LUnZOzO7JF9845wgvNJsudAL0VUzOp2BQpHgi3RUA3UrI5RyQ0PCI5 pOBbLsyCX0RWHbXqshAbxggD4RRnf5D8LOeguN9cBEkBhwi1pAvAFslfk7OWzzSvfvzw 348Q7XsI1YSJi6bTMBt/XucjxoEqtjjOqpmpQJNUfTt1hBapSfhz/PlpmrgcUiWSvNxd bnmKGJpJaJ7DHEpxgiIG2T9I6j4wkp4LlTcjPzhDbgAOsXBoeEROvaTKVytpcAvAwONR /SN2VY6cqmaiQsoDmZ2J8HC+Be/uDtuJvFK6DNjVMYXJOwHdecALA3dAYN5FdPkbyOEz gmNg== 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:mime-version :content-transfer-encoding; bh=n4+h1AwiYWbcvCo2SVfEpk4VI/pUxMw43QNPM3T3NW0=; b=AvQmddN0WhxmAzqJyWbzDhyQpF/ME7FQy5D1bezlu/BeLKECF/Dbb6aQrW5TrY/Yvr PgZi5TvHsWN/RTOWPVxpJeUhzjsGZGCcV4ES9dwQaGsWqL3vHcuDFiNaKeBln+828eCS 2oqo/7OEjseEewDGSDwvDwqCbjTmTQ4rVN63m9FsTDV7KzTjsCnGNunIYlpCU3aoMuzY c2rtyzvh06/eOUrtttGei5/MYDckQ2GiUkr8ZVGWBH71EN5LakJ+UQQfP5PKqG1LQWkt eymBYcn4QBT4gKb8pTQKTaNmCmIhukzNVOh8iNAWuaBHRjV7luG4zSaKHfBOiHprHwbT l9BA== X-Gm-Message-State: APjAAAVNiU2gLbpRqfW2Kdb54+iWIA7PQyV+034GeJxrtrycdpXwohpJ RgXtrd0DkulHiPz7JtYk8YNANA== X-Received: by 2002:adf:b741:: with SMTP id n1mr7046736wre.287.1553275856356; Fri, 22 Mar 2019 10:30:56 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id z14sm11941881wrv.78.2019.03.22.10.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 10:30:55 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpio: mockup: fix debugfs read Date: Fri, 22 Mar 2019 18:30:52 +0100 Message-Id: <20190322173052.23763-1-brgl@bgdev.pl> 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: Bartosz Golaszewski The debugfs read callback must advance ppos or users using read() on the file descriptor will never get the EOL. This wasn't spotted before as I was using busybox cat for testing which uses sendfile() internally and only noticed it now when switched to cat from coreutils. Fixes: 2a9e27408e12 ("gpio: mockup: rework debugfs interface") Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 154d959e8993..74ba8b1d71d8 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -204,8 +204,9 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, struct gpio_mockup_chip *chip; struct seq_file *sfile; struct gpio_chip *gc; + int val, rv, cnt; char buf[3]; - int val, rv; + if (*ppos != 0) return 0; @@ -216,13 +217,14 @@ static ssize_t gpio_mockup_debugfs_read(struct file *file, gc = &chip->gc; val = gpio_mockup_get(gc, priv->offset); - snprintf(buf, sizeof(buf), "%d\n", val); + cnt = snprintf(buf, sizeof(buf), "%d\n", val); - rv = copy_to_user(usr_buf, buf, sizeof(buf)); + rv = copy_to_user(usr_buf, buf, cnt); if (rv) return rv; - return sizeof(buf) - 1; + *ppos += cnt; + return cnt; } static ssize_t gpio_mockup_debugfs_write(struct file *file, -- 2.20.1