Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp260307img; Mon, 18 Mar 2019 02:29:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqylF+ABBjGqKCKsWUhHcVNyWDEuBUReZlWAIrA619gHbEsuEUwHwbNu0hYAjXtAVmhbPLIq X-Received: by 2002:a65:448b:: with SMTP id l11mr16666160pgq.450.1552901379250; Mon, 18 Mar 2019 02:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901379; cv=none; d=google.com; s=arc-20160816; b=DEhDsCh1HOyB5I3Tv/ordxMqQ15wh87r5ZoF7tP6oTDfOQOy3r/XL3lEiZ7exC9e9F H9qJdTu22hNQ32kwimWGXI0qzlwMLsu7PDEz4bsznjYoy7G58Rp3o6wNU7PTB9buUhf1 Eiv9Iv6iaqslVN2BF955wCMWytoOvBXsO/gdiDoPG7MuBS56CkEKeV7N0OFyr1PktY4P 2OVVKXAqGfTtqAZTrzSiTRahMnDI1DuZ70uXtUnUlhdJvdFb/9PFhDQGlaQhJRqRq6Fh SVniuyk0yUwpe4AlTGwkoqASOXKnSBMkibsW4pXflM/MWWpSLCIHFGJAoztdt+Xdy7ql dLOw== 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=9aC/QB5yAJyNxJPw0FQtXnhvo6hNKo0eDEFpMb2NYW8=; b=IwHWmi47lRNHuSdYstdOiIYIhkB62qMxOoVsStk5EPXRIggJSeHh1Zaate4Se0dV/x vze2ct7fOQ+FxffuWckeq20HIAZEB1lkfKRwKVHxgKX5tRuGNweww0X24hhFq4CxlLoY WGprn+P2wsDlsJFZkVNOpIDz6Pna72l9r9AsHdMAC2NwOVuu8WanMhZGOFge9NAY2LGu 278WYRx39+gItNL+i+Gc4xCMjvwdxOskjy77KgMdec9DzuDtHBKwWwPffn0jCbZWm+jq koddMx6CsSNI0R6FeNahda/DByP6ujXU2o1MqrGdbqyGztVcO6FbCB25y7RRGeKsSTkR b15w== 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 c5si8747793plr.243.2019.03.18.02.29.24; Mon, 18 Mar 2019 02:29:39 -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 S1727990AbfCRJ2F (ORCPT + 99 others); Mon, 18 Mar 2019 05:28:05 -0400 Received: from skyboo.net ([94.40.87.198]:39094 "EHLO skyboo.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbfCRJ2B (ORCPT ); Mon, 18 Mar 2019 05:28:01 -0400 Received: from manio by skyboo.net with local (Exim 4.91) (envelope-from ) id 1h5oYn-0002Ie-Gb; Mon, 18 Mar 2019 10:27:57 +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:37 +0100 Message-Id: <20190318092737.8170-3-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 2/2] w1: fix the resume command API 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 From the DS2408 datasheet [1]: "Resume Command function checks the status of the RC flag and, if it is set, directly transfers control to the control functions, similar to a Skip ROM command. The only way to set the RC flag is through successfully executing the Match ROM, Search ROM, Conditional Search ROM, or Overdrive-Match ROM command" The function currently works perfectly fine in a multidrop bus, but when we have only a single slave connected, then only a Skip ROM is used and Match ROM is not called at all. This is leading to problems e.g. with single one DS2408 connected, as the Resume Command is not working properly and the device is responding with failing results after the Resume Command. This commit is fixing this by using a Skip ROM instead in those cases. The bandwidth / performance advantage is exactly the same. Refs: [1] https://datasheets.maximintegrated.com/en/ds/DS2408.pdf Signed-off-by: Mariusz Bialonczyk Cc: Jean-Francois Dagenais --- drivers/w1/w1_io.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c index 0364d3329c52..4697136b9027 100644 --- a/drivers/w1/w1_io.c +++ b/drivers/w1/w1_io.c @@ -432,8 +432,15 @@ int w1_reset_resume_command(struct w1_master *dev) if (w1_reset_bus(dev)) return -1; - /* This will make only the last matched slave perform a skip ROM. */ - w1_write_8(dev, W1_RESUME_CMD); + if (dev->slave_count == 1) { + /* Resume Command has to be preceeded with e.g. Match ROM which is + * not happening on single-slave buses, just do a Skip ROM instead + */ + w1_write_8(dev, W1_SKIP_ROM); + } else { + /* This will make only the last matched slave perform a skip ROM. */ + w1_write_8(dev, W1_RESUME_CMD); + } return 0; } EXPORT_SYMBOL_GPL(w1_reset_resume_command); -- 2.19.0.rc1