Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp444307ybi; Thu, 30 May 2019 00:54:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFOhflqDpU4sVKpo9k3cmDaQreZ3mZAhT2sqCm3JGiqHDwpxQLFj683DCn4tQs5+83Zwwx X-Received: by 2002:a63:c30e:: with SMTP id c14mr2549592pgd.41.1559202851584; Thu, 30 May 2019 00:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559202851; cv=none; d=google.com; s=arc-20160816; b=FEGMkaKuT1CCbwnKU77tir4/2VjmoDHauSImEMJspaGWdQM0evwyp7FBI88z4yaeI3 Rl8/MCtmjTx7AqeCYxFjOtP9OoxojWZtWB5fPJNKkLUuYBius78OFD/0JOVNfVghm/6B cKeGN+TpDPCwYHKbRknvl9Igx1odkelmNNDaUQaSaKzUvuXAMtYxyP0WbKVX4Ex3d3Of O0kEmFxdsdhu067zSOv8kjau/obj0UkhMG6y/0DUHNcFPVrZQM4i58vkOCZNK+5CsXta 0JYU2TtNs8gKwHmUqMnJ6gIsdodojroIaj6XkSU/bDQOAJ2/XfZBS7IAMrwDJ8DHsEKX OS2Q== 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:message-id:date:cc:to:from; bh=kup1N25ywzCkpMzEyH0UrBukwtFOIY/khKgQIVEd+Mg=; b=y5PuuI1gLIN/7aUiqXzhrTc6y8H5vfkUN8Z6w5NhKhu6YLUwNLavzeNOxWrddvlJHs Hogj5ujjp+ZGwHnJ6aZ1+tQVntKlauQkpeDu4z0eDyr4xCNV2jr67QuQOApsN7Z3IMgI 8ZrdvO46JHELOtrY2prTEisHYHSGd/VSyQlhy5x//H0DwEhow4LmIp7NgvrlzxL4MS8i c4TcCieSO8HMi8bWny39E+phSsWN10eHjS8lXxUBUEGtJRfqJ2N6S8Omm/OgDzObrfQ+ m7ENY7s9TcSybsZ3dEiQwZ2puwam4pSC+7b4jjZoLL2Ws6R5FDy2r+oUEqXe1zWVo408 I0sQ== 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 z25si2563507pgv.418.2019.05.30.00.53.56; Thu, 30 May 2019 00:54:11 -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 S1727725AbfE3Hvb (ORCPT + 99 others); Thu, 30 May 2019 03:51:31 -0400 Received: from skyboo.net ([94.40.87.198]:50428 "EHLO skyboo.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726027AbfE3Hvb (ORCPT ); Thu, 30 May 2019 03:51:31 -0400 Received: from manio by skyboo.net with local (Exim 4.91) (envelope-from ) id 1hWFqR-0007Bw-Sv; Thu, 30 May 2019 09:51:28 +0200 From: Mariusz Bialonczyk To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Mariusz Bialonczyk , Dan Carpenter Date: Thu, 30 May 2019 09:51:25 +0200 Message-Id: <20190530075125.27379-1-manio@skyboo.net> X-Mailer: git-send-email 2.19.0.rc1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, greg@kroah.com, manio@skyboo.net, dan.carpenter@oracle.com 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] w1: ds2413: fix state byte comparision 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 This commit is fixing a smatch warning: drivers/w1/slaves/w1_ds2413.c:61 state_read() warn: impossible condition '(*buf == 255) => ((-128)-127 == 255)' by creating additional u8 variable for the bus reading and comparision Reported-by: kbuild test robot Reported-by: Dan Carpenter Cc: Dan Carpenter Fixes: 3856032a0628 ("w1: ds2413: when the slave is not responding during read, select it again") Signed-off-by: Mariusz Bialonczyk --- drivers/w1/slaves/w1_ds2413.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c index 21f08ac8a4e0..3364ad276b15 100644 --- a/drivers/w1/slaves/w1_ds2413.c +++ b/drivers/w1/slaves/w1_ds2413.c @@ -33,6 +33,7 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj, struct w1_slave *sl = kobj_to_w1_slave(kobj); unsigned int retries = W1_F3A_RETRIES; ssize_t bytes_read = -EIO; + u8 state; dev_dbg(&sl->dev, "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", @@ -53,12 +54,13 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj, while (retries--) { w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ); - *buf = w1_read_8(sl->master); - if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) { + state = w1_read_8(sl->master); + if ((state & 0x0F) == ((~state >> 4) & 0x0F)) { /* complement is correct */ + *buf = state; bytes_read = 1; goto out; - } else if (*buf == W1_F3A_INVALID_PIO_STATE) { + } else if (state == W1_F3A_INVALID_PIO_STATE) { /* slave didn't respond, try to select it again */ dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \ "reselecting, retries left: %d\n", retries); -- 2.19.0.rc1