From patchwork Tue Sep 19 01:56:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haneen Mohammed X-Patchwork-Id: 9957993 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 5005B601E9 for ; Tue, 19 Sep 2017 01:56:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C8628CC6 for ; Tue, 19 Sep 2017 01:56:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26AB928D17; Tue, 19 Sep 2017 01:56:57 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 B68AB28CC6 for ; Tue, 19 Sep 2017 01:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750925AbdISB44 (ORCPT ); Mon, 18 Sep 2017 21:56:56 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34747 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbdISB4z (ORCPT ); Mon, 18 Sep 2017 21:56:55 -0400 Received: by mail-pg0-f66.google.com with SMTP id u18so1082458pgo.1 for ; Mon, 18 Sep 2017 18:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=7oiDR7lTD18C2Hqts7H0Gx3hb5VSU3yK4U1HSkXgx/o=; b=JFFS2uLsOo0g9/Fl/NzFNIsOLcvA9I0EeInJ3nPGJr8B/vRhHL82wU72RxV+RSrGVF Rc2jwpJIuYWshrxq65apyAqYx6Z1LdoWC402zbRVVom0Hxjl8Z48dE/4wNCgrUqsdwvp guKG44wjpISm+OSw8R+FWqwadJTEYe2mTr/hPCQ5It7pQ7HyYKCcA2MHHR/XSbYxQUXT CE35/yKT9Zx61hAm9RhYUJS4VHTrJeRWUXVuCKvI5p8hrow9hWwi0wrlT4YVX75PsE3A BD9gGDSy3n5HTsKfdGXZ3Fh6gblbBt94tXbd+4PD5EcQs+s2+O5KZ3BKz99YwN2sHfgz qPrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=7oiDR7lTD18C2Hqts7H0Gx3hb5VSU3yK4U1HSkXgx/o=; b=FdQxlLz0Pg2vFW4hbLkqIIsBrYgLhMHqJR63Lt4gEkhuV+3FNbKCK32iUrKCyI1ura NfNsQgXvbqGN0+nceVMYrYm+auNSb8/6BgbZ7fvk2oVNk9CSFsAI5n6PEa8WDO5qxAHw UC37HIZK6wUGUuDLb0Z/Eai9SXP3ipKWOhj6/o1HTnzkYjI7Pe6iB0cB+qPa47EyXvQO CQVZkuNXwKvgZm4tN4f2CodJypCyjFcSjmIpRLmR2uZS9410H8/Qo5J9yWmyVtp+PoOq YYatdokNixCRPHlE3UyylaBMYrdDwq+jensi209GvGJcCSRqM/+/s7wKrPeV7v2f2/yi SG/A== X-Gm-Message-State: AHPjjUjJ29DB/yysp+ep/bsGI00pQiGhWyLvw0Orw5e5qY6gW805HZ2c /4JFx2U2pgNbuA== X-Google-Smtp-Source: AOwi7QBSMRhHQR3GteO7hNK62L38o2snEyQbPiZbIfzdHuTsDzGfJdKobQLOLJDB9OlJGV5kK4ZmOA== X-Received: by 10.84.235.65 with SMTP id g1mr476727plt.353.1505786214744; Mon, 18 Sep 2017 18:56:54 -0700 (PDT) Received: from Haneen ([64.77.242.50]) by smtp.gmail.com with ESMTPSA id d18sm880094pfk.11.2017.09.18.18.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 18:56:53 -0700 (PDT) Date: Mon, 18 Sep 2017 19:56:51 -0600 From: Haneen Mohammed To: outreachy-kernel Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, hamohammed.sa@gmail.com Subject: [PATCH v2] staging: iio: Replace bit shifting with BIT macro Message-ID: <20170919015651.GA4554@Haneen> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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 This patch replace bit shifting on 1, and 3 with BIT(x) macro. Issue resolved with the following Coccinelle script: @r1@ identifier x; constant int g; @@ ( 0<<\(x\|g\) | 1<<\(x\|g\) | 2<<\(x\|g\) | 3<<\(x\|g\) ) @script:python b@ g2 < --- Changes in v2: - undo changes where it results in different styles mixed up - remove parenthesis aroun BIT(y) | BIT(g) drivers/staging/iio/impedance-analyzer/ad5933.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3d539ee..4cb418e 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -229,7 +229,7 @@ static int ad5933_set_freq(struct ad5933_state *st, u8 d8[4]; } dat; - freqreg = (u64) freq * (u64) (1 << 27); + freqreg = (u64)freq * (u64)BIT(27); do_div(freqreg, st->mclk_hz / 4); switch (reg) { @@ -318,7 +318,7 @@ static ssize_t ad5933_show_frequency(struct device *dev, freqreg = be32_to_cpu(dat.d32) & 0xFFFFFF; freqreg = (u64)freqreg * (u64)(st->mclk_hz / 4); - do_div(freqreg, 1 << 27); + do_div(freqreg, BIT(27)); return sprintf(buf, "%d\n", (int)freqreg); } @@ -452,9 +452,9 @@ static ssize_t ad5933_store(struct device *dev, /* 2x, 4x handling, see datasheet */ if (val > 1022) - val = (val >> 2) | (3 << 9); + val = (val >> 2) | BIT(10) | BIT(9); else if (val > 511) - val = (val >> 1) | (1 << 9); + val = (val >> 1) | BIT(9); dat = cpu_to_be16(val); ret = ad5933_i2c_write(st->client,