Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1026865yba; Thu, 4 Apr 2019 02:44:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDuDdLgwt0nl0j/2Y33OsRedGKZrQmcPwnVnWaIS93WjA/t0f4z3aRankx9D7QF7Btw3pR X-Received: by 2002:a63:cc0c:: with SMTP id x12mr4841422pgf.336.1554371078645; Thu, 04 Apr 2019 02:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371078; cv=none; d=google.com; s=arc-20160816; b=gLoWF+8CKpT0YCQR38+yf4qbGuZGqxpq6KLlOABdrSCb1oTSZWNt5yOKDknile5V7M wZQBrwbl49tihbyIpYsMyFz2jR99617Qhp7o8jSrjNrPN3KuJ36ynZM1S733xhDrM8OT 6Jv/TlNovpWBPZbrpTwrqR+rbZ1Q/KyAAOsdCWhIXWBm++8x5tl6PxpgNT4Hv/ELo7kK JK3lunoZDQDKJGhgDMPgxIfKhOMcZRj7kUDFqGZS2cWc9tcBWa47/sH7snJmm5xmkbEu Bava6wHyO7mzoczMZ7uy3vMO3iUkqrqqjWqwMQeEWb76wgTudA4U2MLAn+cPphjudaa8 w0kQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7oVcy3yY/zCwJinb6QtrzKmkQbRC3uqTeHsn+lyk+Aw=; b=uYSGOVrvSuDH9PJ5n1hIsTMIfNwk5W0Obf0oHoo/X+8m5gkpYQeVL0XCZsfDArkEvX ol5x+G34GDRv619CNPntQnBxJyK5L7ZmkUHENcq7RMcwNWM8+A/sn27b7r84tb/RWRNT JAqgZyodjU+PfYfAxsDPcr8O/ye+MTUn/4v/WeZOp/sUAKlh3Y27RszlbfM/In7ZHi+D mnaxcaVbEHnB/shvMxc6aSTPIutT0WugEKogy9eeU5b/WPSZClJv29st45Cp8eNQO3QT tRMIxdGCs7kJ8oZwT7uHnOnGEiKiDpOODJcqpfC9BnZ5lSuHCQKGAvztwMcjtBqBGUH/ LLBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="L7cJv/Xw"; 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 91si16518634ply.258.2019.04.04.02.44.23; Thu, 04 Apr 2019 02:44:38 -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=@kernel.org header.s=default header.b="L7cJv/Xw"; 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 S1731272AbfDDJnr (ORCPT + 99 others); Thu, 4 Apr 2019 05:43:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:37148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730145AbfDDJA1 (ORCPT ); Thu, 4 Apr 2019 05:00:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BA33621741; Thu, 4 Apr 2019 09:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368426; bh=r8YHYRaqnoCraHtp30j9kJ1Qw0JOfqSxaEYILDaWKn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L7cJv/XwGkbrsoLJ9sOzXJPWcqaZNdewjfO8ip3XDZvM9S+w9Xe+MEKFLYqDkrStC ItfKf40aJJ/ilv91k1e5ey2qnYKivfZm3sB18SjsHCylWJMjAeDJ1T05/LQ9S/GpCV 19rej0j1HRT+vw1+1DMn6mss0sBTejmMjS3tFHQE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Perches , Andy Gross , David Brown , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 020/187] iio: adc: fix warning in Qualcomm PM8xxx HK/XOADC driver Date: Thu, 4 Apr 2019 10:45:57 +0200 Message-Id: <20190404084604.035618667@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e0f0ae838a25464179d37f355d763f9ec139fc15 ] The pm8xxx_get_channel() implementation is unclear, and causes gcc to suddenly generate odd warnings. The trigger for the warning (at least for me) was the entirely unrelated commit 79a4e91d1bb2 ("device.h: Add __cold to dev_ logging functions"), which apparently changes gcc code generation in the caller function enough to cause this: drivers/iio/adc/qcom-pm8xxx-xoadc.c: In function ‘pm8xxx_xoadc_probe’: drivers/iio/adc/qcom-pm8xxx-xoadc.c:633:8: warning: ‘ch’ may be used uninitialized in this function [-Wmaybe-uninitialized] ret = pm8xxx_read_channel_rsv(adc, ch, AMUX_RSV4, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ &read_nomux_rsv4, true); ~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/adc/qcom-pm8xxx-xoadc.c:426:27: note: ‘ch’ was declared here struct pm8xxx_chan_info *ch; ^~ because gcc for some reason then isn't able to see that the termination condition for the "for( )" loop in that function is also the condition for returning NULL. So it's not _actually_ uninitialized, but the function is admittedly just unnecessarily oddly written. Simplify and clarify the function, making gcc also see that it always returns a valid initialized value. Cc: Joe Perches Cc: Greg Kroah-Hartman Cc: Andy Gross Cc: David Brown Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- drivers/iio/adc/qcom-pm8xxx-xoadc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c index b093ecddf1a8..54db848f0bcd 100644 --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c @@ -423,18 +423,14 @@ static irqreturn_t pm8xxx_eoc_irq(int irq, void *d) static struct pm8xxx_chan_info * pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan) { - struct pm8xxx_chan_info *ch; int i; for (i = 0; i < adc->nchans; i++) { - ch = &adc->chans[i]; + struct pm8xxx_chan_info *ch = &adc->chans[i]; if (ch->hwchan->amux_channel == chan) - break; + return ch; } - if (i == adc->nchans) - return NULL; - - return ch; + return NULL; } static int pm8xxx_read_channel_rsv(struct pm8xxx_xoadc *adc, -- 2.19.1