From patchwork Mon Mar 5 07:49:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10258301 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 00AE560134 for ; Mon, 5 Mar 2018 07:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3EC92896B for ; Mon, 5 Mar 2018 07:51:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D80A42896E; Mon, 5 Mar 2018 07:51:16 +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=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 7FC612896B for ; Mon, 5 Mar 2018 07:51:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933229AbeCEHue (ORCPT ); Mon, 5 Mar 2018 02:50:34 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:43926 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933008AbeCEHua (ORCPT ); Mon, 5 Mar 2018 02:50:30 -0500 Received: by mail-pg0-f67.google.com with SMTP id e9so6510606pgs.10; Sun, 04 Mar 2018 23:50:30 -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=EGCDau63+EqEJyB1KfD9OSG+sTSEwe4dxQr1MQzqa5A=; b=lZRE9kNWjWVPaznODg33KtBkLEF5NnqCcaMXdtpITOfiIrHNtYskXnvrh7cPpRxGiG h2gAeJBUEoP2WEWXKqy1oxF0HSBxkJnBY+BUswqJV67xGOM0GBZU9U5j9ZfjZtNsQ7CH cFEfCqlvfBSgLjliCmQ/3+FpgM77fzDHIGD1Kygemf9lTLVPI1JS9PUS9524WkMPT6Jd T3KSpZ2ZCUZG5ruvdITFP/uVlqN1r6+vUDRFOb0ncXltLq4ezvuOfcZH120FM41iKOat zcaCqTUw4SG7k38zJ2K7tXiHuXwbMzatIV5OEbcqe/5mgHIHROXQhT044/NQdbZlqyV4 Xcjw== 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=EGCDau63+EqEJyB1KfD9OSG+sTSEwe4dxQr1MQzqa5A=; b=tagtgqi1g0tvnGTO4Z9NVeYOB/TZjYIH841ODD1GlasR2p8m/xHN4CYVnOfa/bnIlu z1x2FoqI21AH+840bVQgxylvl1g833XgKRGQE5MQptwTZrm81qPK0ddSLXvEq8vxvIHK VSWru3EyTlkgtybkDjkB1ScSvkE9lvNg/aB58Gvrvx1d2jfWozp89yfRQe37iT7xz1sk 34gAlXuAt/ToXKJtcMJys2T3SigoZ/gPZS9FX/Z99ZN/v/p+M6GPqvvhDem7hGzPEl9i OxLce+wziU4ii2ozg1MTRxihKqvPsyKjC0mXiVKNcJR3EQMTeACL6NhaX03HZ7Y4CI+r qvZA== X-Gm-Message-State: APf1xPAiwTdvWjRtUxTaAuIeeW+taysTCc0yKQMfy1xf15ntgKvOwz0s 48g3YD+Tovr1XWxJWoJrYHI= X-Google-Smtp-Source: AG47ELt1SZrzkHLz6eefA5a7nUoRajGF+yv7glSVD+hLrU+Y+C7ncr05a/w+LKrlAGrUY9g75xy+kg== X-Received: by 10.98.200.131 with SMTP id i3mr14601934pfk.40.1520236230066; Sun, 04 Mar 2018 23:50:30 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id 125sm21674256pff.114.2018.03.04.23.50.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Mar 2018 23:50:29 -0800 (PST) From: Himanshu Jha To: jic23@kernel.org 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, Himanshu Jha Subject: [PATCH 09/11] Staging: iio: accel: Use sign_extend32 function Date: Mon, 5 Mar 2018 13:19:28 +0530 Message-Id: <1520236170-14668-10-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520236170-14668-1-git-send-email-himanshujha199640@gmail.com> References: <1520236170-14668-1-git-send-email-himanshujha199640@gmail.com> 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_extned32() for 32 bit sign extending rather than hard coding the same. Signed-off-by: Himanshu Jha --- drivers/staging/iio/accel/adis16201.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c index 307d4ab..8d795e2 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -159,9 +159,8 @@ static int adis16201_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; }