From patchwork Sat May 31 16:29:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Merello X-Patchwork-Id: 4276231 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E75A9F30B for ; Sat, 31 May 2014 16:30:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 697D120270 for ; Sat, 31 May 2014 16:30:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 540F920268 for ; Sat, 31 May 2014 16:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751744AbaEaQaO (ORCPT ); Sat, 31 May 2014 12:30:14 -0400 Received: from mail-we0-f171.google.com ([74.125.82.171]:58345 "EHLO mail-we0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbaEaQaN (ORCPT ); Sat, 31 May 2014 12:30:13 -0400 Received: by mail-we0-f171.google.com with SMTP id w62so3349730wes.16 for ; Sat, 31 May 2014 09:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+cyTKjhMmMd9oDncC3L/t0n0yWArXOJeu+Zm8nfuTXA=; b=0smg7LCaurxi+0vP10dXgyfYve+h3siSSpWIopX4OgAvSvbN4dbN7zQjJRTft0VxWD zmjK0omcvDb13oQdQ8VF+xH5U5InXK+4eoojbj6dFG8nADE7TC3r/9my+Vy7c4PdLWWU P4o4USEZIQ9p1xvMfJdZ4pMLGGvbAS08LrlPwioBFK3Nm8OICKMvrXaUiQsCBoNkcXfb ZI/q0uOTSQsz9xI7/1+v3EDCREnEyfpZvCUnt+sLESQsPzfAldsxGgjqqHZsN0AdZU0B 7uYqj9jKhYg32EEFQGBl58sErRzUi+YD9g519aWt0mPle2X2qRkRKIWzFLI+MMML1ShS dNFQ== X-Received: by 10.194.205.8 with SMTP id lc8mr33281419wjc.81.1401553812200; Sat, 31 May 2014 09:30:12 -0700 (PDT) Received: from localhost.localdomain (host84-87-dynamic.7-79-r.retail.telecomitalia.it. [79.7.87.84]) by mx.google.com with ESMTPSA id u10sm5446828wjz.43.2014.05.31.09.30.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 May 2014 09:30:11 -0700 (PDT) From: Andrea Merello To: linville@tuxdriver.com Cc: linux-wireless@vger.kernel.org, Larry.Finger@lwfinger.net, bernhard@schiffner-limbach.de, dan.carpenter@oracle.com, Andrea Merello Subject: [PATCH 1/3] rtl818x_pci: make RSSI code more readable Date: Sat, 31 May 2014 18:29:46 +0200 Message-Id: <1401553786-7603-1-git-send-email-andrea.merello@gmail.com> X-Mailer: git-send-email 1.9.1 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 remove the if-else chains and use switch-case to make code more readable and avoiding long lines that broke in several lines Signed-off-by: Andrea Merello --- drivers/net/wireless/rtl818x/rtl8180/dev.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 2c1c02b..c2dd5e6 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -209,7 +209,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) struct rtl8180_priv *priv = dev->priv; struct rtl818x_rx_cmd_desc *cmd_desc; unsigned int count = 32; - u8 signal, agc, sq; + u8 agc, sq, signal = 1; dma_addr_t mapping; while (count--) { @@ -266,18 +266,21 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) rx_status.rate_idx = (flags >> 20) & 0xF; agc = (flags2 >> 17) & 0x7F; - if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8185) { + switch (priv->chip_family) { + case RTL818X_CHIP_FAMILY_RTL8185: if (rx_status.rate_idx > 3) signal = 90 - clamp_t(u8, agc, 25, 90); else signal = 95 - clamp_t(u8, agc, 30, 95); - } else if (priv->chip_family == - RTL818X_CHIP_FAMILY_RTL8180) { + break; + case RTL818X_CHIP_FAMILY_RTL8180: sq = flags2 & 0xff; signal = priv->rf->calc_rssi(agc, sq); - } else { + break; + case RTL818X_CHIP_FAMILY_RTL8187SE: /* TODO: rtl8187se rssi */ signal = 10; + break; } rx_status.signal = signal; rx_status.freq = dev->conf.chandef.chan->center_freq;