Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp901267imu; Fri, 7 Dec 2018 10:38:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOhDcCETkDUE7GfFKFc6upsOIqkIWku9WWzcnnivpMyl8p4YYckc9rNzRdgj3Krul0FcL8 X-Received: by 2002:a63:da45:: with SMTP id l5mr2953595pgj.111.1544207910548; Fri, 07 Dec 2018 10:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544207910; cv=none; d=google.com; s=arc-20160816; b=MWgHvkuVA7Vu8CiMHow/zL7F01epTKfS7zPmCRTWCBYg5lQ7b08+Avb8J26r5imuOh /PZrJK2WFruv1UQWECSjBQGmrz6uOjhtcbxUNqSdrn0sW80SOZnJRjRjeDVJievm9iG0 ANr3Mkl97mx4xCpUqdUKihk4kdeJaLM1tBMQ8nydkDmMg61GPg9WHv7ZIRN4PB1dn/ft QaIFF7CTKdyKqjlX+s8LaHFfcKcfn3HcdB/VJCb24JHE7dfuAaDyWNV5/BBgoAtoa8o+ NHmT4LOfELNSu7ob/6gJhPjJZfZMvZzqk7RryDgFAp8Yy93QEJ7CzCbZTQNMqciR6AbP SCAA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=TipxjuVTetJLdNenIgGqyzJK986c8b3z8SSjGt//NU8=; b=f6D/uq/t10kXU6TLhKpBtHsrjUlVWDd83HXVfYd7wlSz+aqxBDXKpZvz+qgnvfbO5A ZwMYuiU4i8fWNFKrGm1W2t8PmPzHXyXuK2ql4JXP/JzRQdM19XLexCZtEfUyWJae+tkj /1cquXRJrXIHpiqrV0wV1HI8gYjpt38NWTlkCKvh/lTq37cwhv2KoIIm2Wj2+xvsYKhV zitwR0WBkm/uqmYISBhysKCWz9sadZQMzrrNfXbSO/QZMjmlmO75nZt2OA9/0g8RBgav NA8GBtSaWYWmRKIa3BXOxJkpqqMhUDrjKLH0rys5deM+p3lk0hZiceEZZ1pLfPOQYixL 4JoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HG4NdIU+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si3924399pfj.183.2018.12.07.10.38.15; Fri, 07 Dec 2018 10:38:30 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HG4NdIU+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726238AbeLGSha (ORCPT + 99 others); Fri, 7 Dec 2018 13:37:30 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41144 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbeLGSh3 (ORCPT ); Fri, 7 Dec 2018 13:37:29 -0500 Received: by mail-pg1-f193.google.com with SMTP id 70so2077600pgh.8; Fri, 07 Dec 2018 10:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=TipxjuVTetJLdNenIgGqyzJK986c8b3z8SSjGt//NU8=; b=HG4NdIU+2AOGBg0HjvQlPBxcpJBbCAt33bd/X78GmzeDgOJaatawjkhdTkjxp7J+Pp eGalkiRrVrgWj7HKeqpqjb5v+D//LfcSfVSWvpiGoYWgm3z8adLml8JimmIy3uV40usz dY3ohSJcY/AHV8G+9kLXZCaRvZfPQ1PC96t8aWNuIOiOPHXlKs2BhCBtfjXlY5DcWhG3 6zF1eDjvhvWnG6LzzN7zfusMofXRoloJqBFHMmozX3Xlo/Pr+o2LcIAoShoNmSUdiLwJ RYpFXuyoElrgqUUu/oZMzm90eTNbLcClYfaCZPsfdO4nWgLwXoZE9VbadrbG2eg5A4Gj 5nmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=TipxjuVTetJLdNenIgGqyzJK986c8b3z8SSjGt//NU8=; b=MkwuND7a7gJ0X2/BjX5SUbuj2WgrMW3GsxLxzCNjKnWwZMgIghpp7+Y4bSnautm/VH sLKdlFggp4MMz2FmFzkkADDJm2l4dvWCotl6j9ddf3ijWYiWWUJDxxchvmUA4ZViU1su k8waDeMDigQbGM+VnFBp2neKcXgOuQs9kdA+KqmH5cnAsUdg1jjPbW3pdwSFy+aX1R1E nuWUDYcYwDFp4cv6fnUxdmcFfyl+eL8970CezGaQA28dCwnfcJrpV2dWCd3P/5dZujeH 7b7RGuHeoANOoQWRLw0bBDQY7AzJdrO/b22JKl1EA4xoIi3rarvxt2/9GINvJw+g5ufk +CSA== X-Gm-Message-State: AA+aEWYZIIHd3ILyxvrqamG/bJCf9i3LooNvNYd096dzYyq/KIs+xF6m DOAVcd1EoUxqFASg3osJN9M= X-Received: by 2002:a63:c64f:: with SMTP id x15mr2845480pgg.16.1544207847681; Fri, 07 Dec 2018 10:37:27 -0800 (PST) Received: from Shreeya-Patel ([103.212.140.150]) by smtp.googlemail.com with ESMTPSA id g15sm17915806pfj.131.2018.12.07.10.37.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 10:37:26 -0800 (PST) Message-ID: <90e3066edb0616cd20ee019e3f2a392fd3a3f285.camel@gmail.com> Subject: Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0" From: Shreeya Patel To: Dan Carpenter , Jeremy Fertic Cc: devel@driverdev.osuosl.org, lars@metafoo.de, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de, jic23@kernel.org Date: Sat, 08 Dec 2018 00:07:21 +0530 In-Reply-To: <20181206124047.GH3095@unbuntlaptop> References: <20181205014900.4827-1-jeremyfertic@gmail.com> <20181205215953.GA2365@r2700x.localdomain> <20181206124047.GH3095@unbuntlaptop> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-12-06 at 15:40 +0300, Dan Carpenter wrote: > On Wed, Dec 05, 2018 at 02:59:53PM -0700, Jeremy Fertic wrote: > > On Thu, Dec 06, 2018 at 01:25:55AM +0530, Shreeya Patel wrote: > > > On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > > > > This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. > > > > > > > > i2c_smbus_read_byte() returns 0 when a byte with the value 0 is > > > > read > > > > from > > > > the device. This is a valid read so revert the check for 0. > > > > > > > > Signed-off-by: Jeremy Fertic > > > > --- > > > > > > Hi Jeremy, > > > > > > As per my understanding, 0 value indicates no error but no data > > > read. > > > Then how can this be a valid case? > > > > > > Can you please make me understand that how can we consider this > > > as a > > > valid case even when no data has been read? > > It's not reading no data. It's reading one byte of data and > returning > it. > > > > > > > > > > Thanks > > > > I'm not sure I understand why the value 0 would indicate no data > > read. > > Doesn't that just mean a byte was read with the value 0. > > Yes. It does mean that. Please don't ask rhetorical > questions... :( > This list is full of people who can't resist answering every > question. > > > For instance, if the input to the adc is 0V. Can you point me to > > where > > you're seeing that this would indicate no data read? > > drivers/i2c/i2c-core-smbus.c > 88 /** > 89 * i2c_smbus_read_byte - SMBus "receive byte" protocol > 90 * @client: Handle to slave device > 91 * > 92 * This executes the SMBus "receive byte" protocol, returning > negative errno > 93 * else the byte received from the device. > 94 */ > 95 s32 i2c_smbus_read_byte(const struct i2c_client *client) > 96 { > 97 union i2c_smbus_data data; > 98 int status; > 99 > 100 status = i2c_smbus_xfer(client->adapter, client- > >addr, client->flags, > 101 I2C_SMBUS_READ, 0, > 102 I2C_SMBUS_BYTE, &data); > 103 return (status < 0) ? status : data.byte; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > 104 } > 105 EXPORT_SYMBOL(i2c_smbus_read_byte); Even I had sent the same code to Jonathan and we had a discussion on this. I asked him that this code clearly shows that there is an error condition only when status < 0 then why do we need a check for status = 0. Then he explained me that 0 isn't an error. The issue is the silliness of the i2c interface. Pretty much every other bus returns an error (negative) if less data is received than expected. Most i2c bus master's do as well but in theory it can return 0 to indicate no error but no data read (which doesn't make any sense) 0 doesn't ever happen in reality but it should be handled for correctness though. So we should wait for what Jonathan has to say on this :) Thanks > You are right. Commit 00426e997893 ("Staging: iio: adt7316: Add an > extra check for 'ret' equals to 0") needs to be reverted... > > regards, > dan carpenter > >