From patchwork Sat Apr 16 14:54:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8861641 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 08D77BF29F for ; Sat, 16 Apr 2016 14:55:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24D9820212 for ; Sat, 16 Apr 2016 14:55:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 34FF920204 for ; Sat, 16 Apr 2016 14:55:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbcDPOzw (ORCPT ); Sat, 16 Apr 2016 10:55:52 -0400 Received: from mail-qg0-f49.google.com ([209.85.192.49]:32786 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349AbcDPOzv (ORCPT ); Sat, 16 Apr 2016 10:55:51 -0400 Received: by mail-qg0-f49.google.com with SMTP id v14so5573031qge.0 for ; Sat, 16 Apr 2016 07:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bobcopeland-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=YyBY20vAHIcccL8Q4V1qEtz2rjFT2kfY0UchwCR3iDw=; b=wdIQO4KVBsqwxdk852RKZyhN/PCY06oIRxrfOMfdgps9gt9qQZEGyB8NL0wmQWYm0h 4zLLhc8yJpX/48aDZTZBuNLjt6y/KZcQZjxZNsF5R3reBEnAiKeyK1qMxvFGnkse1TWe e9gUVVrGa9WWXspUqeqUn7g0Rk6szp441X61yurIxYNqEXQw9kwfNNHjxroT6CMXPx8u RMd/Wvi8Rm+WGrrnYZc83vuECuJ3LzC3+gqAhazZTaJhpaweBOwA0CAO4tOs4Ckx/OKv TRsyEgC/netlHL4Pt7OAAPD+jJGMQ2+yr1KLSah6Xo2mFp2SfTklcM00TKGW5CYCZaBJ lsNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YyBY20vAHIcccL8Q4V1qEtz2rjFT2kfY0UchwCR3iDw=; b=mGzmngAmKeQukOTZwUIawTG/J33/kRpThifXCTg6njwAlMaKBNEe002RX8KVUo7Q71 ut+L+0AHoSAqVoG4N77fjXX1Qo6DFLATMVGg/eNtMQ+C9pvsMY2/LCQjj1J1DiVFsOX5 Jk/K6bN+GsZDWmm/Aim7BTh2oDkiby+27lOgtbrEW0vTfKakWo2UEYnC83rnEEd6PyJ2 pwMVidQd2URi893cj+wV0jiab+YKEr0F7l6plJyTbMTi+WCcphEsnuoSATDqmjj/xp1u g2ZhUgks9Cm74EcMTFUJ7CPfTn0LOJJzxjsSaWRl1hSwmq3n96tfmk5ZE2/CPG1vjrrR fv4w== X-Gm-Message-State: AOPr4FXUiH8c4q1sNkrosJ442Krhl+q830RqS18w24hu2rch71wweS0kNWMiKlYUAQe8tA== X-Received: by 10.140.169.132 with SMTP id p126mr33181808qhp.71.1460818550758; Sat, 16 Apr 2016 07:55:50 -0700 (PDT) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id y123sm22804778qka.0.2016.04.16.07.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Apr 2016 07:55:50 -0700 (PDT) Received: from bob by hash with local (Exim 4.84_2) (envelope-from ) id 1arRdN-0005wx-3o; Sat, 16 Apr 2016 10:55:41 -0400 From: Bob Copeland To: linux-wireless@vger.kernel.org Cc: Oleksij Rempel , ath9k-devel@lists.ath9k.org, Bob Copeland Subject: [PATCH] ath9k: remove repetitions of mask array size Date: Sat, 16 Apr 2016 10:54:37 -0400 Message-Id: <1460818477-22785-1-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The constant "123", which is the number of elements in mask_m / mask_p, is repeated several times in this function. Replace memsets with array initialization, and replace a loop conditional with ARRAY_SIZE() so that we don't repeat ourselves. Signed-off-by: Bob Copeland Reviewed-by: Oleksij Rempel --- drivers/net/wireless/ath/ath9k/ar5008_phy.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar5008_phy.c b/drivers/net/wireless/ath/ath9k/ar5008_phy.c index 1b271b9..8eea8d2 100644 --- a/drivers/net/wireless/ath/ath9k/ar5008_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar5008_phy.c @@ -260,8 +260,8 @@ void ar5008_hw_cmn_spur_mitigate(struct ath_hw *ah, int cur_bin; int upper, lower, cur_vit_mask; int i; - int8_t mask_m[123]; - int8_t mask_p[123]; + int8_t mask_m[123] = {0}; + int8_t mask_p[123] = {0}; int8_t mask_amt; int tmp_mask; static const int pilot_mask_reg[4] = { @@ -274,9 +274,6 @@ void ar5008_hw_cmn_spur_mitigate(struct ath_hw *ah, }; static const int inc[4] = { 0, 100, 0, 0 }; - memset(&mask_m, 0, sizeof(int8_t) * 123); - memset(&mask_p, 0, sizeof(int8_t) * 123); - cur_bin = -6000; upper = bin + 100; lower = bin - 100; @@ -302,7 +299,7 @@ void ar5008_hw_cmn_spur_mitigate(struct ath_hw *ah, upper = bin + 120; lower = bin - 120; - for (i = 0; i < 123; i++) { + for (i = 0; i < ARRAY_SIZE(mask_m); i++) { if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) { /* workaround for gcc bug #37014 */ volatile int tmp_v = abs(cur_vit_mask - bin);