From patchwork Tue Jul 5 15:08:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9214555 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 78D486048B for ; Tue, 5 Jul 2016 15:08:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B1F02624C for ; Tue, 5 Jul 2016 15:08:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F8E5262F2; Tue, 5 Jul 2016 15:08:52 +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 B53702624C for ; Tue, 5 Jul 2016 15:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755319AbcGEPIg (ORCPT ); Tue, 5 Jul 2016 11:08:36 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35426 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755311AbcGEPIb (ORCPT ); Tue, 5 Jul 2016 11:08:31 -0400 Received: by mail-oi0-f65.google.com with SMTP id d132so27968902oig.2 for ; Tue, 05 Jul 2016 08:08:31 -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=5Xy4Rl8/Da5CLX/SNXu8tjZ/XfuLdl0T/z7IQ3VnG7U=; b=jCSgoX14EfOQuJRb19CkEtEFktMBNFk9aNgLe+Ob3PzLXWJVcVTIXmp2ic1cstH6Ci xrMTfbM/ntNZLWXRNIjxrkLQPQdCvy8MIyH2o8Fu4VygCfDXckI0EmMaamLgL0CrLW+l J3Ju8nQY43uNKKI3RmUi15v84i7pInSS+fjkssWkS4UF4+oHyxHzeMbBzWR2WzfmaRfG /HeIedYW/CTUr24VcjHCydijLswE+fgX1gxRbhFX8UjcsCS7EVYHDXQiEKse232q9Ees 1fmUaG1+RS8lHNTMJTMaZc8r4iNvef6GDITtlniGsfvrB1atb88UNCr6AgC8rTX/h1LF RG8g== 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=5Xy4Rl8/Da5CLX/SNXu8tjZ/XfuLdl0T/z7IQ3VnG7U=; b=bL8Agq824LiHe09EE6mgbBAiBPeQKg37sTe70+RKsuKF6o8EugemUaWaS4fL4typB3 R2Y+s+1kfvpBMmeIvH5t3vDxEQ+BYKW+//skxWBvQQkWOr3rt8K5ZmCxXaBdFcEfn4va EXUTCM86H0oodqYe2DbnlRkMccA80D1E9Do2XnA++30QTFOWVRzWFHslVRn9z6KeuRIx 6ctsVa/M2fwExFfnnwGwo/iR/RCdE55fb1tMgs4c9NxCtKSk9WZqmttJVTr/BlYttJWQ psE3iCCyvqbv10ylu1GA+rHg5IVNxxPyZ1wXB6wEHyJ4BV2/vhtE/3T7a46NyjGIZvnn D7Gg== X-Gm-Message-State: ALyK8tLOXB/9aL6euGvq3XJ5GCybAJdTPbMtJVvpWOwszZnWRcrhZy564rIQkBrp0pc+Fg== X-Received: by 10.202.95.11 with SMTP id t11mr10653805oib.115.1467731310467; Tue, 05 Jul 2016 08:08:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jul 2016 08:08:29 -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 05/10] rtlwifi: rtl8192ee: Convert driver to use common hardware info routine Date: Tue, 5 Jul 2016 10:08:10 -0500 Message-Id: <1467731295-25850-6-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 RTL8192EE 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/rtl8192ee/hw.c | 73 ++++------------------ 1 file changed, 12 insertions(+), 61 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c index 9d1ecba..b07af8d 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c @@ -2098,75 +2098,24 @@ static void _rtl92ee_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]; - 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"); - return; - - default: - RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, - "boot from neither eeprom nor efuse, check it !!\n"); + int params[] = {RTL8192E_EEPROM_ID, EEPROM_VID, EEPROM_DID, + EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR, + EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID, + COUNTRY_CODE_WORLD_WIDE_13}; + u8 *hwinfo; + + hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL); + if (!hwinfo) return; - } - memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], HWSET_MAX_SIZE); - RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP\n", - hwinfo, HWSET_MAX_SIZE); + if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params)) + goto exit; - eeprom_id = *((u16 *)&hwinfo[0]); - if (eeprom_id != RTL8192E_EEPROM_ID) { - RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, - "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; - /*VID DID SVID SDID*/ - rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID]; - rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID]; - rtlefuse->eeprom_svid = *(u16 *)&hwinfo[EEPROM_SVID]; - rtlefuse->eeprom_smid = *(u16 *)&hwinfo[EEPROM_SMID]; - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROMId = 0x%4x\n", eeprom_id); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid); - RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, - "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid); - /*customer ID*/ - rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; if (rtlefuse->eeprom_oemid == 0xFF) rtlefuse->eeprom_oemid = 0; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid); - /*EEPROM version*/ - rtlefuse->eeprom_version = *(u8 *)&hwinfo[EEPROM_VERSION]; - /*mac address*/ - for (i = 0; i < 6; i += 2) { - usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR + i]; - *((u16 *)(&rtlefuse->dev_addr[i])) = usvalue; - } - - RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, - "dev_addr: %pM\n", rtlefuse->dev_addr); - /*channel plan */ - rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; /* set channel plan from efuse */ rtlefuse->channel_plan = rtlefuse->eeprom_channelplan; /*tx power*/ @@ -2208,6 +2157,8 @@ static void _rtl92ee_read_adapter_info(struct ieee80211_hw *hw) break; } } +exit: + kfree(hwinfo); } static void _rtl92ee_hal_customized_behavior(struct ieee80211_hw *hw)