Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp260268img; Mon, 18 Mar 2019 02:29:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqws1/+UjFc2GOqnSZid+7fwwoxXZgnLEU5NTQO16JIRCsnOaVGswM4IlesNAptkZkwnYdhO X-Received: by 2002:a65:64c3:: with SMTP id t3mr16850850pgv.14.1552901375240; Mon, 18 Mar 2019 02:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901375; cv=none; d=google.com; s=arc-20160816; b=NaG3XGhsiXt1irpkcyYVfEcsGZxwojgNKT34SXCBXDbgxKc0fz3p4Yoa7giufuYUzZ VicYUVKGpo36F65dDHPYRf1SH/YIrAuiPTZoou+uV5it010BRz0E3d3TxHSuii0LD1hW 1zMUoO1HWe8yZROSDMwBn7FaSUhwBA1mO9EQqmtHQw4Yrs8c27zWKNohX+dReqTnp/0j lw3Yae+1FDFQWBHYySi8FnB0OkbtPDURd/0eYx0sDYIntpHTEFVyz9dwuOUQFNnTc+fh Kvo5mnU7PKQDNp+XKqOHWR+tv/brdmnbena8BaZCBuJCucbVz3hUnS7x+dZ2UbRCtVWV LLGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=tUmvCBl3El+mORTBP+EMK3H/gJ2NgJ9cJ8lR+SMT0Hg=; b=JmyFbIg/Ir41b9hQLmxrKdwqtlQGp5HkGqqeu4+MvfIAP+55auux6oSGU115Sscqzn zSqAwR2+zTXXATwEFlvqo5UgNvdAAWNUKe4p4kZJdrCXF1+7Vka8yQOUcyTKmJDfaX7P sLLm7IAy62fg2CS5C35ouuMi/xI3fJSpr/oGJA2VsB78a4EoZcFr6WwIBHiZjOAZUG1r 6YKvacbkzDpL6X+LJWDSypPTM7XXMMZOC6z8mYNnvWW6YuCX8XfewGg0gzZCl1UW0FTW iy7ROGdHyaypqQJ23UHEw+ywWzRoRmZRXSRO2uFekjQvqPjRAnKL0Zc/TYqEzUNwkEKL TGaw== 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=REJECT dis=NONE) header.from=skyboo.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v17si9102899pff.214.2019.03.18.02.29.20; Mon, 18 Mar 2019 02:29:35 -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; 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=REJECT dis=NONE) header.from=skyboo.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727974AbfCRJ2C (ORCPT + 99 others); Mon, 18 Mar 2019 05:28:02 -0400 Received: from skyboo.net ([94.40.87.198]:39050 "EHLO skyboo.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727954AbfCRJ16 (ORCPT ); Mon, 18 Mar 2019 05:27:58 -0400 Received: from manio by skyboo.net with local (Exim 4.91) (envelope-from ) id 1h5oYl-0002IU-JA; Mon, 18 Mar 2019 10:27:56 +0100 From: Mariusz Bialonczyk To: linux-kernel@vger.kernel.org, Evgeniy Polyakov , Greg Kroah-Hartman , Jean-Francois Dagenais Cc: Mariusz Bialonczyk Date: Mon, 18 Mar 2019 10:27:36 +0100 Message-Id: <20190318092737.8170-2-manio@skyboo.net> X-Mailer: git-send-email 2.19.0.rc1 In-Reply-To: <20190318092737.8170-1-manio@skyboo.net> References: <20190318092737.8170-1-manio@skyboo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, zbr@ioremap.net, greg@kroah.com, jeff.dagenais@gmail.com, manio@skyboo.net X-SA-Exim-Mail-From: manio@skyboo.net X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nemesis.skyboo.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_RELAYS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH 1/2] w1: ds2408: add a missing reset when retrying in output_write() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on skyboo.net) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we have success in 'Channel Access Write' but reading back the latch state has failed, then the code continues but without doing a proper slave reset. This was leading to protocol errors as the slave treats the next 'Channel Access Write' as the continuation of previous command. This commit is fixing this, and because we have to reset no matter if the actual write or the readback checking is failing then the resetting is done on the beginning of the loop. Signed-off-by: Mariusz Bialonczyk Cc: Jean-Francois Dagenais --- drivers/w1/slaves/w1_ds2408.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c index b535d5ec35b6..562ee2d861e8 100644 --- a/drivers/w1/slaves/w1_ds2408.c +++ b/drivers/w1/slaves/w1_ds2408.c @@ -158,6 +158,13 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj, goto error; while (retries--) { + /* do a reset/resume on every new retry call + except the first one */ + if (retries < W1_F29_RETRIES - 1) { + if (w1_reset_resume_command(sl->master)) + goto error; + } + w1_buf[0] = W1_F29_FUNC_CHANN_ACCESS_WRITE; w1_buf[1] = *buf; w1_buf[2] = ~(*buf); @@ -165,12 +172,8 @@ static ssize_t output_write(struct file *filp, struct kobject *kobj, readBack = w1_read_8(sl->master); - if (readBack != W1_F29_SUCCESS_CONFIRM_BYTE) { - if (w1_reset_resume_command(sl->master)) - goto error; - /* try again, the slave is ready for a command */ + if (readBack != W1_F29_SUCCESS_CONFIRM_BYTE) continue; - } #ifdef CONFIG_W1_SLAVE_DS2408_READBACK /* here the master could read another byte which -- 2.19.0.rc1