Received: by 10.223.185.116 with SMTP id b49csp815711wrg; Sat, 3 Mar 2018 08:06:56 -0800 (PST) X-Google-Smtp-Source: AG47ELst/zHCJ5oTqCmKx4t32og1G1xQK9RAQCufv3ytqCUUyuDn284l4asVG2tcxrLOkTknQKu1 X-Received: by 10.101.64.10 with SMTP id f10mr7388526pgp.171.1520093216709; Sat, 03 Mar 2018 08:06:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520093216; cv=none; d=google.com; s=arc-20160816; b=xAbC5O/PBDo3pmt3Jfemz+QYohNqAexc0qFhmKsqaD03XwMW7fF2Cfgt17vw0fnGKB H1aSUZye/2CSZYI3QPX63X+ytb8SmHOTo9F4c+0bMqtX0qfnWk79v9gZA2epX3/VVu/U TSxa6MCt24LfaqTF3TopHmLilG7YV2cMyrhlewf1jkFiFJdy7+VXg24O9YhYbHL/+xHj Md0p78GlLm8rhdHMURtdrLoerGCCwSKxHjMNjy+UoYjZYjwV0etpMzIiLuaXSnFfXmxu Y91XNm5XMrqIZxuU6NDm/0fEDXnLUSLDkUnJgcD1SVVZAXjuhwYQEEwgxOfNy/twNrRb zjKA== 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=F9l2n6SQMWBJAhBlaiZm3VDxWJPpPg5bfuBxH7GsKDI=; b=AIRsndZoh6o6hbghUVFqTsO8PbAeEJEVjmHmXjOWL8zKoPdY9ZlQNbiSK4HDrM9N24 oXB9/Fn4v9XcJLk5MahDxx1utcLR4OwqnwJbK1hDoQ3XK7GdLDy78fojvSyH1GiRGxvz roCD81wj/tRHxwpKJm4TLh9nmZj37b46+oVkHxJmSjBLf5Y7+juNsRQ9NW21ofkeI5Rt cp1ZDmgxhUuDG49NsNXLNN6+VcH3bPHQJnx3E6V6691GiPv9Bhsf86K833n0cCWEG3L1 PtXPqCsfVNDQ1Q6oHAtBfY9oZCoBizHeDPSvrtImUqufE8W7F43MjzEZk1FwO9L09rsM SOQw== 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 u6-v6si6595200pld.129.2018.03.03.08.06.42; Sat, 03 Mar 2018 08:06:56 -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 S1752164AbeCCQGD (ORCPT + 99 others); Sat, 3 Mar 2018 11:06:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:52882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbeCCQGC (ORCPT ); Sat, 3 Mar 2018 11:06:02 -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 E3A1C2133D; Sat, 3 Mar 2018 16:05:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3A1C2133D 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: Sat, 3 Mar 2018 16:05:57 +0000 From: Jonathan Cameron To: Shreeya Patel 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 6/6] Staging: iio: adis16209: Use sign_extend32 and adjust a switch statement Message-ID: <20180303160557.26462aa7@archlinux> In-Reply-To: <982b80d683b8c8e8c61cbc5b0864c265ea2ac768.1519995673.git.shreeya.patel23498@gmail.com> References: <982b80d683b8c8e8c61cbc5b0864c265ea2ac768.1519995673.git.shreeya.patel23498@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 Fri, 2 Mar 2018 19:04:49 +0530 Shreeya Patel wrote: > Use sign_extend32 function instead of manually coding it. > Also, adjust a switch block to explicitly match channels > and return -EINVAL as default case which makes the code > semantically more clear. > > Signed-off-by: Shreeya Patel Changes are fine, but 2 changes to different things should be in 2 patches. Please split. I'd probably have taken this anyway if it hadn't been queued behind the requested changes to the previous 2 patches anyway. Good work on this series though so looking forward to v3. Note please mark the set as [PATCH v3] to make it clear it is the 3rd version of some of this. > --- > drivers/staging/iio/accel/adis16209.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c > index 7363fd0..5ab44a4 100644 > --- a/drivers/staging/iio/accel/adis16209.c > +++ b/drivers/staging/iio/accel/adis16209.c > @@ -150,10 +150,16 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, > switch (chan->type) { > case IIO_VOLTAGE: > *val = 0; > - if (chan->channel == 0) > + switch (chan->channel) { > + case 0: > *val2 = 305180; /* 0.30518 mV */ > - else > + break; > + case 1: > *val2 = 610500; /* 0.6105 mV */ > + break; > + default: > + return -EINVAL; > + } > return IIO_VAL_INT_PLUS_MICRO; > case IIO_TEMP: > *val = -470; > @@ -197,9 +203,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, > ret = adis_read_reg_16(st, addr, &val16); > if (ret) > return ret; > - val16 &= (1 << bits) - 1; > - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); > - *val = val16; > + > + *val = sign_extend32(val16, bits - 1); > return IIO_VAL_INT; > } > return -EINVAL;