Received: by 10.223.185.116 with SMTP id b49csp1555751wrg; Sun, 4 Mar 2018 04:46:29 -0800 (PST) X-Google-Smtp-Source: AG47ELu57YMFbbhzquruPh60Cl6qlJjTbI3wOeet22ebPzR9h3k7rv8m57xaUg3F2ONtJ1QBCdYx X-Received: by 10.101.97.139 with SMTP id c11mr9427286pgv.449.1520167589455; Sun, 04 Mar 2018 04:46:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520167589; cv=none; d=google.com; s=arc-20160816; b=SRKzemzvOKAwNomwuUfVLu5xZ6mDbTX9A6pMYD4QbGmE3dUfjB/3ngHc1vAZ3Sat1J 9XirCUpaIgcDN0X9PJi6UU6ZFWuVy4x7q4RstKP9xlS4Le2nUyZXCzm4nOmRk/5FD1ii KDmGoF4jAqHvy1iLizz2YrXhwV3NVayOlTb1uAguVcFatdZDWJA1xG3teMofR8k+cV+1 7J4Zfym7j9jOgDDy2xo1VW5QNmaGBlx+buOrKatyeONYjFKQoXSIcdHRyuy8NLnztrRl 4t2khtjLKhBUXX5ONHZ7D9CQ14Rjzl2N+hjMYrnPBgl3vX4WP2fr3D635kWLfqkMp9kb SJmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=GuHBQwFntj+DvO0RtKKAOaUSatjCtQHVHgeb8plZJ20=; b=NwJ+gIyTptw1Tm81ZoRtFDbLaMDylVGe3h9LsgLahotSl/46EBOb6PZzE1M5FLB5bg 016b5T6RNBTkhZ4Em61UCzGKp6KWv5J60bwFJlboec7nSvB7o6SWjnm6tzgkgNMIgH2X o/99eJldNP/n6eXsE6rRw603MeBq0vxFqQXI70zw+yNotp8JKMmW1E+rwkdOUvu6o9jm oVp8rTgrTBPOXHGp18KqQNzGK3MCXYg0Gb/GbdD9bNKanCfIteq3wdFNP/biorZsbzVI LVEybyFBL1FIdb6DmWRiz1bDep6nvoviCmeoqNaosLXAUiTirR+60y68MXD/TkhP0KAG sFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sHtOLwTd; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e71si8366427pfc.276.2018.03.04.04.46.14; Sun, 04 Mar 2018 04:46:29 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sHtOLwTd; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752757AbeCDMpN (ORCPT + 99 others); Sun, 4 Mar 2018 07:45:13 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:32770 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbeCDMpL (ORCPT ); Sun, 4 Mar 2018 07:45:11 -0500 Received: by mail-pg0-f67.google.com with SMTP id g12so5745500pgs.0; Sun, 04 Mar 2018 04:45:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GuHBQwFntj+DvO0RtKKAOaUSatjCtQHVHgeb8plZJ20=; b=sHtOLwTd/iO2Fj3ZbeDwvYpLoUJwyatS0QFh1RH6d9IfT74X74Bwj5tOiNd29cN7Gj oTbQVcFtm7HttM50r8MoPLPcMulvYalquMCLVnXFxg8J13BpkUNZbpU50e5yn5QHan/1 oe6AhZU2hK19NnkuhvYupsc8Ahx8f7KJMZmWs+ma4MY3x1XnoI+OaSGd4wg86aNSy4hM btwV06DoGpoaaHR9AX6VOodmDdI1Df8Q7WYyjm2K7jkXoGpXzia4HWXqxqHxRK8tuHnq jjlGrwoZjqvcFRob48K2lOhzWXL3txvqeRX3NLwV3D/O31WYINKQ4pe5R1AKzm7cGBgx 26ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GuHBQwFntj+DvO0RtKKAOaUSatjCtQHVHgeb8plZJ20=; b=oUm9/QvcI4S5rgcStBWP1g+1j9FfOJdKPiqVvyt+yTt7Xr+iOALey7FSUvo0n/sNj5 sj3UAn0CS3OvA66Lo6Hj+oM4Jt74wpWeZBMS/cM1g2hxObA/YDek2zI0L7V/QkRAR42x sc/sK307nub8jcY1fI6LJQDBmpDwKIXhzrhUfOm0MoIEJ5h5bPg6suRqy3+CyuGCBZLi amj5OMQApexjX0KhL/lY9hb7iQMULHLLPMq/DItUbnq81E+C8GUUaJsy8k5c9NG6LSsv egeLXAh65kCAL2Q5Tt9rw4z2tVuhZYcl8hOMh93iMGmGQzjeOXAtCLMFjD/8zZvPh8o8 +/rg== X-Gm-Message-State: APf1xPCI/WIe97uNnJ8fRrAAamrC7N/hKe6c8tg68n6fBXoS7Avb/3+3 v/xNZflrNJfxXFNWm4YrVNA= X-Received: by 10.99.5.197 with SMTP id 188mr9548747pgf.196.1520167510807; Sun, 04 Mar 2018 04:45:10 -0800 (PST) Received: from shreeya-VirtualBox ([103.212.140.139]) by smtp.gmail.com with ESMTPSA id z64sm16883668pfi.58.2018.03.04.04.45.09 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Mar 2018 04:45:10 -0800 (PST) From: Shreeya Patel To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, 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 Cc: Shreeya Patel Subject: [PATCH v3 4/4] Staging: iio: adis16209: Use sign_extend32 function Date: Sun, 4 Mar 2018 18:15:06 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use sign_extend32 function instead of manually coding it. Signed-off-by: Shreeya Patel --- Changes in v3 -After split patch. drivers/staging/iio/accel/adis16209.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 9cb1ce0..a8453bf 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -212,9 +212,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; -- 2.7.4