Received: by 10.223.185.116 with SMTP id b49csp5496899wrg; Wed, 7 Mar 2018 12:49:19 -0800 (PST) X-Google-Smtp-Source: AG47ELv0ZJp6RWlScP/iEUxTD9q4szL+s4Gcuksj/43VzgQR2DfwLocSIuKFG4wQlDOYrNOc2yv+ X-Received: by 2002:a17:902:b192:: with SMTP id s18-v6mr21532544plr.243.1520455759851; Wed, 07 Mar 2018 12:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520455759; cv=none; d=google.com; s=arc-20160816; b=Af6FUx8MLGyRrwCsXNSlQ2xvlYfpfXnU/l0M0ezG2fC24V+NcI7KpvGvlZ5wVSlsga iuLUS1CPHYfNbdgmA0AO45nvzwGV1DLiAb2nJKlI6ctLs1tPXwl3gZQTPIWJNTWTrcJP 8xUTJVtw1c78ttaS5BEWpSjyENx7NgtbKqSHK8RfkBig2eyf6/Z7ouIl8rE7P4ERhhOw bxqPlGIzAfvBFXWElXf7/xLlLiOI7+uLoA6+pkZMWMZGO6OVCZ5xpPh9/GLg4RUGG4cC IdAfYtNc4FASb092/QUsKZWvMi65LKqrbw/zMK33Q9Z9tGBYWdXVhr58oitfzXBtHUrb 8yBA== 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:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=Jl2aazD5dnCP7wGxkw6Zq8ggW0URbd06HIc6o1HcurA=; b=GjT1n164JnWUK0/E8opx7nFAYVMPZYbVVV/5RE+Q9u07ZURYgDgXeXxULPI1tskyya r/WQ+FgqYd5o21XkVAjo1L/A3axSHrgdfiUEPeDH1Ugs3KeDiZ88PaUfBuHg/7Y9PjZV xZPnklrKZ/mUxjpAqeVplPjkZhNm2uW179bctL8FSXD3IJI9y1mvpSOaNicwhHwBVa7z bJibw8Ebof+MingBwdQRVHRq8glT0d07mlKcNqVuQ0/J9BfuGhjuX7akPZczu1cBOflN 8mkgWnuI7uZOiWajcbGd0Pjh0Rg/ahHq4dUAQyGcAlusk8ZNsR2kkhjE/I+1lslvKcKE eMsw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si11862629pgf.613.2018.03.07.12.49.05; Wed, 07 Mar 2018 12:49:19 -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; 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 S934575AbeCGUsN (ORCPT + 99 others); Wed, 7 Mar 2018 15:48:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:35834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934492AbeCGUsL (ORCPT ); Wed, 7 Mar 2018 15:48:11 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 C73222133D; Wed, 7 Mar 2018 20:48:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C73222133D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Wed, 7 Mar 2018 20:48:05 +0000 From: Jonathan Cameron To: Himanshu Jha Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, daniel.baluta@gmail.com Subject: Re: [PATCH 08/11] Staging: iio: accel: Use switch statement than if-else Message-ID: <20180307204805.44ae9eac@archlinux> In-Reply-To: <1520236170-14668-9-git-send-email-himanshujha199640@gmail.com> References: <1520236170-14668-1-git-send-email-himanshujha199640@gmail.com> <1520236170-14668-9-git-send-email-himanshujha199640@gmail.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 5 Mar 2018 13:19:27 +0530 Himanshu Jha wrote: > Use switch statement instead of if-else pair to explicitly match > the only two channels present. > > Signed-off-by: Himanshu Jha I think this is going to generate some warnings in the various static analysers as they will point out there are lots of values channel can take that aren't handled by the switch statement.. You should have a default. (This is what made Dan less than convinced of whether this was a good change when I originally suggested it) I still think it's a marginal improvement in making it explicit that we only have two valid choices though - and Dan didn't care strongly about it. Jonathan > --- > drivers/staging/iio/accel/adis16201.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c > index 1737708..307d4ab 100644 > --- a/drivers/staging/iio/accel/adis16201.c > +++ b/drivers/staging/iio/accel/adis16201.c > @@ -114,12 +114,15 @@ static int adis16201_read_raw(struct iio_dev *indio_dev, > case IIO_CHAN_INFO_SCALE: > switch (chan->type) { > case IIO_VOLTAGE: > - if (chan->channel == 0) { > + switch (chan->channel) { > + case 0: > *val = 1; > *val2 = 220000; > - } else { > + break; > + case 1: > *val = 0; > *val2 = 610000; > + break; > } > return IIO_VAL_INT_PLUS_MICRO; > case IIO_TEMP: