Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5127767imm; Tue, 12 Jun 2018 03:03:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKID6TFfVwqE5PBSNks3MP6p8wzBUuB3FJy1QzqWr+f/SKNWt8H4j8W3/0XVvwpqlY+xpz9u X-Received: by 2002:a17:902:622:: with SMTP id 31-v6mr3276583plg.135.1528797806896; Tue, 12 Jun 2018 03:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528797806; cv=none; d=google.com; s=arc-20160816; b=tAOlAu697Q1MtJaZ2cW+omKi2oKxZj46SZGrLlAwAbeyhizj2OUyP897uPJmg1gGkk 0FBwlTvgDeVZr+4w8CorK2CfMikdHknVHy8rirPKyx6ZFt5DAIz2zEbelbfThcAhaJqs frAqMN0qMTWschldIYM47+3meGqqYRRrxzSH9eFZy1PGmPGqDC5wYHklk6SCORDIJCld WkmJ2SiMPuU2EOgo7NqpBKJLCyvDZ3S0or/tpM9rV92LW/Me8GjsbLDPP1qcIm29hTbX 1QG64vV9EvOMCQqWAeeW1QbMzgHH2w/B0TxDnw8WFvzJ6SGcH/VY62bDVQxZjVXoS6iR VZ7g== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=tJBD2O9DfugYzpQ3+RKfELo6jI1CAcg4/T1rtf/gDkY=; b=rkAexkK9BYfZz6Ea9Ly3ahanHkoPYppxujqjovcgPA99cZ3N3/oR6ZoHtenPYRTpDe /Zm7qjNsnQTHQYaPW/7p7ngwqV8LqIQgbWFLFgTq6vKpOTMEQb06vlsxadlb3BG3lDHr lB0YwUlUZViTCYSGODQ/Ic7K+Lx6AfW7icRTkF/Wf+qd/I0LIFsnOdJhBqO0Pske6rry yBld6HvppFFQPkItUp93otQkq+djbTtEPYt4o2KiFBhCsJuwuPXcHUJlFJutzGSmCP3/ sm1xKVPMyHjhDw5NZ6nznxoc0QsvjtkAiN5wsZDVnvbA7KyIgt2EVuvBbota8fauRdGI lweg== 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 f18-v6si442600pgt.283.2018.06.12.03.03.12; Tue, 12 Jun 2018 03:03:26 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753915AbeFLKBo (ORCPT + 99 others); Tue, 12 Jun 2018 06:01:44 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8658 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752659AbeFLKBm (ORCPT ); Tue, 12 Jun 2018 06:01:42 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 049AD92BF0550; Tue, 12 Jun 2018 18:01:28 +0800 (CST) Received: from localhost (10.206.48.115) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.382.0; Tue, 12 Jun 2018 18:01:25 +0800 Date: Tue, 12 Jun 2018 11:01:14 +0100 From: Jonathan Cameron To: Karim Eshapa CC: , , , , , , , , Subject: Re: [PATCH] staging:iio:accel:adis16240: sign extend function avoiding code duplication Message-ID: <20180612110114.00002303@huawei.com> In-Reply-To: <20180612005748.3546-1-karim.eshapa@gmail.com> References: <48143872d69d231273bd2c8ed835cbf0046a263d.camel@perches.com> <20180612005748.3546-1-karim.eshapa@gmail.com> Organization: Huawei X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.206.48.115] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Jun 2018 02:57:48 +0200 Karim Eshapa wrote: > Use sign_extend32 kernel function instead of code duplication. > Safe also for 16 bit. > > Signed-off-by: Karim Eshapa Please resend as a fresh patch marked at V2 with a change log below the --- so we can easily see what has changed. Thanks, Jonathan > --- > drivers/staging/iio/accel/adis16240.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c > index fff6d99089cc..24e525f1ef25 100644 > --- a/drivers/staging/iio/accel/adis16240.c > +++ b/drivers/staging/iio/accel/adis16240.c > @@ -250,7 +250,6 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, > { > struct adis *st = iio_priv(indio_dev); > int ret; > - int bits; > u8 addr; > s16 val16; > > @@ -287,24 +286,18 @@ static int adis16240_read_raw(struct iio_dev *indio_dev, > *val = 25000 / 244 - 0x133; /* 25 C = 0x133 */ > return IIO_VAL_INT; > case IIO_CHAN_INFO_CALIBBIAS: > - bits = 10; > addr = adis16240_addresses[chan->scan_index][0]; > 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, 9); > return IIO_VAL_INT; > case IIO_CHAN_INFO_PEAK: > - bits = 10; > addr = adis16240_addresses[chan->scan_index][1]; > 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, 9); > return IIO_VAL_INT; > } > return -EINVAL;