From patchwork Tue Feb 2 15:48:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byeoungwook Kim X-Patchwork-Id: 8191551 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5C5F39F3CD for ; Tue, 2 Feb 2016 15:49:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83C66202E9 for ; Tue, 2 Feb 2016 15:49:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B89720295 for ; Tue, 2 Feb 2016 15:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933373AbcBBPtE (ORCPT ); Tue, 2 Feb 2016 10:49:04 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:34308 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933093AbcBBPtB (ORCPT ); Tue, 2 Feb 2016 10:49:01 -0500 Received: by mail-pf0-f173.google.com with SMTP id o185so102282521pfb.1; Tue, 02 Feb 2016 07:49:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=/NaAyuwIuIR4zytSnC5+8aAtJyJM7dUUvn5iSZWmpiA=; b=wQwLPrXXBPO5qHsr+bavLL4AjU9Jp4iZldeVKsTDQo2qKwEzcFYpDwWaehCb+n4shj h39p1rE19F9rzVSPAc37PDWX2RXbGrtxcnKDYjhBklBWl0Wn+O1Vh7cvt1hDOLOfHbwt XnkACMXSrBxo/81uvvDDM8SNOSmOkS8OBhTXwRvmRLVqIrtDAVTJ5zxyYFP6UYYQvvpv yzwOMYjl3KmlKXQvQwXocujY1eau+XeipNWCKDYc7eMnZxDYEPbV1hsZjYX8GRfoiXBl QlFvPeGMhE99lHlMEQHQLUFCkBeFOXDrAMuO0YQRlqb6gtu3LYRPl7ApPi9bRxyaYyoW YNHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=/NaAyuwIuIR4zytSnC5+8aAtJyJM7dUUvn5iSZWmpiA=; b=Ks0vAOIbbjYq7ZKbAa1G5oBq9sJjM1h79CtwA3KP0B4TAWIAD3xz8IhP81mI3DuQ/s THh8GfuZRktmunJVYVQSnUQa11oZi3LTH+I4fdMlmHpzDYQs5/+HKtt0UxHBCfrPo5on hh0F9MhKzI5zdCnnbQ9mH3WogQd8Q869VBTO+kSXchEoO7ebwKxH5NohTIAnbbkqM4w6 YBnW6eLQ1JUFT4bTUFv/e37fJrikM2QbfQAkBWzqyenBFTEcSHoQi68Az+l8L6sWOSNH h292cqjfboEdpT5VZHWonR3G4BsDPeKOLDUYqVwmlKOfjVSm7NRPspVsCF7RIFSgPe/1 +jtw== X-Gm-Message-State: AG10YOQu+R+LVbc8LN9sqpvNAf04AhoDOXy09bd3VMJIaqgWfimuFrWh6xyHlNXJq1fpCg== X-Received: by 10.98.44.195 with SMTP id s186mr48807498pfs.0.1454428140912; Tue, 02 Feb 2016 07:49:00 -0800 (PST) Received: from gmail.com ([210.118.75.116]) by smtp.gmail.com with ESMTPSA id q20sm3544862pfa.70.2016.02.02.07.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Feb 2016 07:49:00 -0800 (PST) Date: Wed, 3 Feb 2016 00:48:55 +0900 From: Byeoungwook Kim To: kvalo@codeaurora.org Cc: Larry.Finger@lwfinger.net, chaoming_li@realsil.com.cn, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rtlwifi: Fix reusable codes in core.c Message-ID: <20160202154855.GA8990@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FSL_HELO_FAKE, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 rtl_*_delay() functions were reused same codes about addr variable. So i have converted to rtl_addr_delay() from code about addr variable. Conditional codes in rtl_addr_delay() were improved in readability and performance by using switch codes. Signed-off-by: Byeoungwook Kim --- drivers/net/wireless/realtek/rtlwifi/core.c | 48 +++++++++++------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c index 4ae421e..c1193d1 100644 --- a/drivers/net/wireless/realtek/rtlwifi/core.c +++ b/drivers/net/wireless/realtek/rtlwifi/core.c @@ -37,36 +37,34 @@ void rtl_addr_delay(u32 addr) { - if (addr == 0xfe) + switch (addr) { + case 0xfe: mdelay(50); - else if (addr == 0xfd) + break; + case 0xfd: mdelay(5); - else if (addr == 0xfc) + break; + case 0xfc: mdelay(1); - else if (addr == 0xfb) + break; + case 0xfb: udelay(50); - else if (addr == 0xfa) + break; + case 0xfa: udelay(5); - else if (addr == 0xf9) + break; + case 0xf9: udelay(1); + break; + }; } EXPORT_SYMBOL(rtl_addr_delay); void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr, u32 mask, u32 data) { - if (addr == 0xfe) { - mdelay(50); - } else if (addr == 0xfd) { - mdelay(5); - } else if (addr == 0xfc) { - mdelay(1); - } else if (addr == 0xfb) { - udelay(50); - } else if (addr == 0xfa) { - udelay(5); - } else if (addr == 0xf9) { - udelay(1); + if (addr >= 0xf9 && addr <= 0xfe) { + rtl_addr_delay(addr); } else { rtl_set_rfreg(hw, rfpath, addr, mask, data); udelay(1); @@ -76,18 +74,8 @@ EXPORT_SYMBOL(rtl_rfreg_delay); void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data) { - if (addr == 0xfe) { - mdelay(50); - } else if (addr == 0xfd) { - mdelay(5); - } else if (addr == 0xfc) { - mdelay(1); - } else if (addr == 0xfb) { - udelay(50); - } else if (addr == 0xfa) { - udelay(5); - } else if (addr == 0xf9) { - udelay(1); + if (addr >= 0xf9 && addr <= 0xfe) { + rtl_addr_delay(addr); } else { rtl_set_bbreg(hw, addr, MASKDWORD, data); udelay(1);