From patchwork Sun Mar 4 12:45:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreeya Patel X-Patchwork-Id: 10257651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 275DF602BD for ; Sun, 4 Mar 2018 12:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D0F0287DC for ; Sun, 4 Mar 2018 12:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01639287E5; Sun, 4 Mar 2018 12:45:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5BFB287DC for ; Sun, 4 Mar 2018 12:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbeCDMpM (ORCPT ); Sun, 4 Mar 2018 07:45:12 -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-Google-Smtp-Source: AG47ELvHJjNKNUpmLlBCRkG26laPrA1kcDAT4epbPzq1gUmQYpwYlIeAQ/ruUQ2z+PW5fBOqleYiww== 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-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;