From patchwork Tue Jul 5 15:08:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9214553 X-Patchwork-Delegate: kvalo@adurom.com 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 B280D6048B for ; Tue, 5 Jul 2016 15:08:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3C012624C for ; Tue, 5 Jul 2016 15:08:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 986FA26252; Tue, 5 Jul 2016 15:08:39 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 4DD012624C for ; Tue, 5 Jul 2016 15:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755307AbcGEPId (ORCPT ); Tue, 5 Jul 2016 11:08:33 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34163 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755305AbcGEPIa (ORCPT ); Tue, 5 Jul 2016 11:08:30 -0400 Received: by mail-oi0-f65.google.com with SMTP id s17so28015506oih.1 for ; Tue, 05 Jul 2016 08:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GmQUOPDvLMPk82xchdYNlV4FJjB9+NMkkCgQdO+j+MY=; b=yD3MTppVUwUbhvikoGRch6CjSmsaay2MIdWtL+uzKy4uQQRFZlGktcg40SykL6zoOZ NFB8oL56VTjiFgmtctpgr43F4mDdG3o4IwmjzJMxnVVJ2RIbSW+Bm2ApnOaB1gRyLP+j Gb14lPycxljuOoXDVVRVHp49sdUoONqzRvjUhF1U+tCh+RDRL6EgxNZARPpnT1Y8jXDw tiTGSKJR22nurZj5zJcQcziu9QPjbVWoV8bkeospg+t2RZfPFVfyTAatdqLmFocaFHNl TCkVtlh9rNzkx0ZL3A5sIcli8tkmN5XlCTdvprewHlWpKCmqDypF98TDIMenlDCmaSep FL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GmQUOPDvLMPk82xchdYNlV4FJjB9+NMkkCgQdO+j+MY=; b=efX6iXEPT1zKJJmQ1K5ILv5AI1h6T6CxRAb2NVyPscuIjIeeKBQEZhmBH+lSXpKqEM 218WvqL7GI4rijf6/BcWbxz48v8I+ToVax4aMs9dlyr4ddcUeZ0Q5bf6OBI915Nh8l/p EcvOswmX1KJxDhJbe/NHW9Q+QoX81kdCsv6z46ZxvAGtlmAZS3x+gX0wYWiLKBX1smjp M7SLr/Gr1AT8FDnNA3uDs3Cq40UbTXyd16F6ZXJpLmO5jtmSWYOQ2mCvUm+Rs0Kb5Vq3 E5/ooYJY7F9ETp4PImL73bZ3BnfdVfI1VhaWCDarTXAuv23C8yr1cZF8aJ278+3IKFee 7a2Q== X-Gm-Message-State: ALyK8tJ5d2c7GmQWOH6avsbFvRrHfLw50IKDUrHaQrwmVZt1oY3DM1//M3wC81ctLp/D2g== X-Received: by 10.202.87.5 with SMTP id l5mr10136468oib.15.1467731308634; Tue, 05 Jul 2016 08:08:28 -0700 (PDT) Received: from linux-1t8h.suse (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id f184sm5680027oih.18.2016.07.05.08.08.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jul 2016 08:08:28 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, Larry Finger , Arnd Bergmann Subject: [PATCH v3 03/10] rtlwifi: rtl8192cu: Convert driver to use common hardware info routine Date: Tue, 5 Jul 2016 10:08:08 -0500 Message-Id: <1467731295-25850-4-git-send-email-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1467731295-25850-1-git-send-email-Larry.Finger@lwfinger.net> References: <1467731295-25850-1-git-send-email-Larry.Finger@lwfinger.net> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The driver for RTL8192CU chips is converted to use the common routine for getting the hardware information. Reported-by: Arnd Bergmann Signed-off-by: Larry Finger Cc: Arnd Bergmann --- V2 - Fixes bug found after V1 was submitted. V3 - No changes. This patch requires ("rtlwifi: Add missing newlines to RT_TRACE calls") submitted by Joe Perches. --- .../net/wireless/realtek/rtlwifi/rtl8192cu/hw.c | 61 ++++++---------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c index ae1129f..8789752 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c @@ -347,56 +347,24 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - u16 i, usvalue; - u8 hwinfo[HWSET_MAX_SIZE] = {0}; - u16 eeprom_id; - - switch (rtlefuse->epromtype) { - case EEPROM_BOOT_EFUSE: - rtl_efuse_shadow_map_update(hw); - break; - - case EEPROM_93C46: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "RTL819X Not boot from eeprom, check it !!\n"); + int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID, + EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR, + EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID, + 0}; + u8 *hwinfo; + + hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL); + if (!hwinfo) return; - default: - pr_warn("rtl92cu: no efuse data\n\n"); - return; - } - memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE); - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, "MAP", - hwinfo, HWSET_MAX_SIZE); - eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0])); - if (eeprom_id != RTL8190_EEPROM_ID) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "EEPROM ID(%#x) is invalid!!\n", eeprom_id); - rtlefuse->autoload_failflag = true; - } else { - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); - rtlefuse->autoload_failflag = false; - } - if (rtlefuse->autoload_failflag) - return; - for (i = 0; i < 6; i += 2) { - usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; - *((u16 *) (&rtlefuse->dev_addr[i])) = usvalue; - } - pr_info("MAC address: %pM\n", rtlefuse->dev_addr); + if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params)) + goto exit; + _rtl92cu_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag, hwinfo); - rtlefuse->eeprom_vid = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VID]); - rtlefuse->eeprom_did = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_DID]); - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, " VID = 0x%02x PID = 0x%02x\n", - rtlefuse->eeprom_vid, rtlefuse->eeprom_did); - rtlefuse->eeprom_channelplan = hwinfo[EEPROM_CHANNELPLAN]; - rtlefuse->eeprom_version = - le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VERSION]); + _rtl92cu_read_board_type(hw, hwinfo); + rtlefuse->txpwr_fromeprom = true; - rtlefuse->eeprom_oemid = hwinfo[EEPROM_CUSTOMER_ID]; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x\n", - rtlefuse->eeprom_oemid); if (rtlhal->oem_id == RT_CID_DEFAULT) { switch (rtlefuse->eeprom_oemid) { case EEPROM_CID_DEFAULT: @@ -422,7 +390,8 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) break; } } - _rtl92cu_read_board_type(hw, hwinfo); +exit: + kfree(hwinfo); } static void _rtl92cu_hal_customized_behavior(struct ieee80211_hw *hw)