From patchwork Fri Mar 16 20:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10290059 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 BD47C601A0 for ; Fri, 16 Mar 2018 20:08:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABFC828E0F for ; Fri, 16 Mar 2018 20:08:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CF2728F90; Fri, 16 Mar 2018 20:08:35 +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=-2.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS, RCVD_IN_SORBS_WEB, T_DKIM_INVALID autolearn=no 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 41D1D28E0F for ; Fri, 16 Mar 2018 20:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbeCPUHW (ORCPT ); Fri, 16 Mar 2018 16:07:22 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36366 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752519AbeCPUHU (ORCPT ); Fri, 16 Mar 2018 16:07:20 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so6550370plf.3; Fri, 16 Mar 2018 13:07:20 -0700 (PDT) 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=8iOK8Apf2CyFy1XJuAKVGjcjVq1AJw/TysWBpvUStNk=; b=X43zco3hu40ABtiewGXmEtpbkFAi4E/IkBp4egt51iPwQ7XPdUWWGVKH3fKojh4xib CcHY6ZZt32vaPLVLNJCrzCrtFsI5yX+lhSVVyAXhW8B1PjQ2ak5pH6IEaA1np2+LHcle 8x4aTF9+EaW8N4sU9sC/sHmKoLJZzFM7b/KA8/Ld2DCJGkZ1NGIz8/kbC9YtgLz3/pqC NwqAmX3SER0Wa1imzDVAZaixczsOvA4hrIHFmRGjMY+XLEOJhEL5uMDqF4eIJ7D1aEJY mqW3LcT+nxKNF7k/YzoWYgW7PVqsnMeWDIVstuPeoHtzFdawvrk+fi7ESev14d4Xe9Os T11Q== 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=8iOK8Apf2CyFy1XJuAKVGjcjVq1AJw/TysWBpvUStNk=; b=ZzeZg/IURmVZllfa9oh2omBZgWLEsC61ibFqJ0TVLukfMNHimHY+ZHfsFIBCuHgkXG MPgCydoSic5/IJdaAxwrs3CqY3bPFFX8oRrVUc0VtXASh1sJCmlKDY7937HPqHs8/Hhv M4UooTmOPijkqryf1UhPrABwhje2IQuYbQcNnOI/4uDVk23Aj5Grp62pJllm9qPGpcma 1PF/V9R0lwrdx+sy15Xob68shb4NQ3Zt2qeifd09Q45Dt0PFcMLerhOJodD5ZcBWtpJm rN2OmLus3frrXkcpCNz/Q2Q3IfbL6qMVTg4J7kgAbkjR2P5baZVYdNh5kJ4+BZAsUFmr o1tw== X-Gm-Message-State: AElRT7EvJoiqht/Nkk+rj63rBYilcG172wA4MPibfXiMcGump9oQ/G+N Nq1aLI3KmvC+WhNrKetDoWs= X-Google-Smtp-Source: AG47ELsUvDeesyn6zaKF4wORo7/LjsT1qELJe+2UM7i0taSqEcncO+6OYAFvygj5xFi6g73BxBq82Q== X-Received: by 2002:a17:902:678f:: with SMTP id g15-v6mr3503320plk.120.1521230839450; Fri, 16 Mar 2018 13:07:19 -0700 (PDT) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id s9sm15605347pfm.39.2018.03.16.13.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Mar 2018 13:07:19 -0700 (PDT) From: Himanshu Jha To: jic23@kernel.org Cc: lars@metafoo.de, Michael.Hennerich@analog.com, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, daniel.baluta@gmail.com, 21cnbao@gmail.com, Himanshu Jha Subject: [PATCH v2 6/9] Staging: iio: accel: adis16201: Use sign_extend32 function Date: Sat, 17 Mar 2018 01:36:23 +0530 Message-Id: <1521230786-18155-7-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521230786-18155-1-git-send-email-himanshujha199640@gmail.com> References: <1521230786-18155-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. Signed-off-by: Himanshu Jha --- v2: -no change in this patch. 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 97150ea..298bf90 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -173,9 +173,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; }