From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Pascal Terjan <pterjan@google.com>,
Kalle Valo <kvalo@codeaurora.org>,
Sasha Levin <sashal@kernel.org>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.12 112/160] rtl8xxxu: Fix device info for RTL8192EU devices
Date: Tue, 6 Jul 2021 07:17:38 -0400 [thread overview]
Message-ID: <20210706111827.2060499-112-sashal@kernel.org> (raw)
In-Reply-To: <20210706111827.2060499-1-sashal@kernel.org>
From: Pascal Terjan <pterjan@google.com>
[ Upstream commit c240b044edefa3c3af4014a4030e017dd95b59a1 ]
Based on 2001:3319 and 2357:0109 which I used to test the fix and
0bda:818b and 2357:0108 for which I found efuse dumps online.
== 2357:0109 ==
=== Before ===
Vendor: Realtek
Product: \x03802.11n NI
Serial:
=== After ===
Vendor: Realtek
Product: 802.11n NIC
Serial not available.
== 2001:3319 ==
=== Before ===
Vendor: Realtek
Product: Wireless N
Serial: no USB Adap
=== After ===
Vendor: Realtek
Product: Wireless N Nano USB Adapter
Serial not available.
Signed-off-by: Pascal Terjan <pterjan@google.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210424172959.1559890-1-pterjan@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 11 +---
.../realtek/rtl8xxxu/rtl8xxxu_8192e.c | 59 +++++++++++++++++--
2 files changed, 56 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
index d6d1be4169e5..acb6b0cd3667 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
@@ -853,15 +853,10 @@ struct rtl8192eu_efuse {
u8 usb_optional_function;
u8 res9[2];
u8 mac_addr[ETH_ALEN]; /* 0xd7 */
- u8 res10[2];
- u8 vendor_name[7];
- u8 res11[2];
- u8 device_name[0x0b]; /* 0xe8 */
- u8 res12[2];
- u8 serial[0x0b]; /* 0xf5 */
- u8 res13[0x30];
+ u8 device_info[80];
+ u8 res11[3];
u8 unknown[0x0d]; /* 0x130 */
- u8 res14[0xc3];
+ u8 res12[0xc3];
};
struct rtl8xxxu_reg8val {
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index cfe2dfdae928..b06508d0cdf8 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -554,9 +554,43 @@ rtl8192e_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40)
}
}
+static void rtl8192eu_log_next_device_info(struct rtl8xxxu_priv *priv,
+ char *record_name,
+ char *device_info,
+ unsigned int *record_offset)
+{
+ char *record = device_info + *record_offset;
+
+ /* A record is [ total length | 0x03 | value ] */
+ unsigned char l = record[0];
+
+ /*
+ * The whole device info section seems to be 80 characters, make sure
+ * we don't read further.
+ */
+ if (*record_offset + l > 80) {
+ dev_warn(&priv->udev->dev,
+ "invalid record length %d while parsing \"%s\" at offset %u.\n",
+ l, record_name, *record_offset);
+ return;
+ }
+
+ if (l >= 2) {
+ char value[80];
+
+ memcpy(value, &record[2], l - 2);
+ value[l - 2] = '\0';
+ dev_info(&priv->udev->dev, "%s: %s\n", record_name, value);
+ *record_offset = *record_offset + l;
+ } else {
+ dev_info(&priv->udev->dev, "%s not available.\n", record_name);
+ }
+}
+
static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv)
{
struct rtl8192eu_efuse *efuse = &priv->efuse_wifi.efuse8192eu;
+ unsigned int record_offset;
int i;
if (efuse->rtl_id != cpu_to_le16(0x8129))
@@ -604,12 +638,25 @@ static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv)
priv->has_xtalk = 1;
priv->xtalk = priv->efuse_wifi.efuse8192eu.xtal_k & 0x3f;
- dev_info(&priv->udev->dev, "Vendor: %.7s\n", efuse->vendor_name);
- dev_info(&priv->udev->dev, "Product: %.11s\n", efuse->device_name);
- if (memchr_inv(efuse->serial, 0xff, 11))
- dev_info(&priv->udev->dev, "Serial: %.11s\n", efuse->serial);
- else
- dev_info(&priv->udev->dev, "Serial not available.\n");
+ /*
+ * device_info section seems to be laid out as records
+ * [ total length | 0x03 | value ] so:
+ * - vendor length + 2
+ * - 0x03
+ * - vendor string (not null terminated)
+ * - product length + 2
+ * - 0x03
+ * - product string (not null terminated)
+ * Then there is one or 2 0x00 on all the 4 devices I own or found
+ * dumped online.
+ * As previous version of the code handled an optional serial
+ * string, I now assume there may be a third record if the
+ * length is not 0.
+ */
+ record_offset = 0;
+ rtl8192eu_log_next_device_info(priv, "Vendor", efuse->device_info, &record_offset);
+ rtl8192eu_log_next_device_info(priv, "Product", efuse->device_info, &record_offset);
+ rtl8192eu_log_next_device_info(priv, "Serial", efuse->device_info, &record_offset);
if (rtl8xxxu_debug & RTL8XXXU_DEBUG_EFUSE) {
unsigned char *raw = priv->efuse_wifi.raw;
--
2.30.2
next prev parent reply other threads:[~2021-07-06 11:28 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210706111827.2060499-1-sashal@kernel.org>
2021-07-06 11:15 ` [PATCH AUTOSEL 5.12 010/160] net: pch_gbe: Use proper accessors to BE data in pch_ptp_match() Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 016/160] atm: iphase: fix possible use-after-free in ia_module_exit() Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 017/160] mISDN: fix possible use-after-free in HFC_cleanup() Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 018/160] atm: nicstar: Fix possible use-after-free in nicstar_cleanup() Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 019/160] net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 021/160] net: mdio: ipq8064: add regmap config to disable REGCACHE Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 026/160] bpf: Check for BPF_F_ADJ_ROOM_FIXED_GSO when bpf_skb_change_proto Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 027/160] net: mdio: provide shim implementation of devm_of_mdiobus_register Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 028/160] net/sched: cls_api: increase max_reclassify_loop Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 033/160] net: xilinx_emaclite: Do not print real IOMEM pointer Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 036/160] e100: handle eeprom as little endian Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 037/160] igb: handle vlan types with checker enabled Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 038/160] igb: fix assignment on big endian machines Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 042/160] net/mlx5e: IPsec/rep_tc: Fix rep_tc_update_skb drops IPsec packet Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 043/160] net/mlx5: Fix lag port remapping logic Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 046/160] net: stmmac: the XPCS obscures a potential "PHY not found" error Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 051/160] virtio-net: Add validation for used length Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 052/160] ipv6: use prandom_u32() for ID generation Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 059/160] net: tcp better handling of reordering then loss cases Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 065/160] net: bridge: mrp: Update ring transitions Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 067/160] ice: set the value of global config lock timeout longer Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 068/160] ice: fix clang warning regarding deadcode.DeadStores Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 069/160] virtio_net: Remove BUG() to avoid machine dead Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 070/160] net: mscc: ocelot: check return value after calling platform_get_resource() Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 071/160] net: bcmgenet: " Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 072/160] net: mvpp2: " Sasha Levin
2021-07-06 11:16 ` [PATCH AUTOSEL 5.12 073/160] net: micrel: " Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 074/160] net: moxa: Use devm_platform_get_and_ioremap_resource() Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 081/160] net: phy: realtek: add delay to fix RXC generation issue Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 082/160] selftests: Clean forgotten resources as part of cleanup() Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 083/160] net: sgi: ioc3-eth: check return value after calling platform_get_resource() Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 085/160] fjes: " Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 087/160] r8169: avoid link-up interrupt issue on RTL8106e if user enables ASPM Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 089/160] ibmvnic: fix kernel build warnings in build_hdr_descs_arr Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 090/160] xfrm: Fix error reporting in xfrm_state_construct Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 092/160] wlcore/wl12xx: Fix wl12xx get_mac error if device is in ELP Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 093/160] wl1251: Fix possible buffer overflow in wl1251_cmd_scan Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 094/160] cw1200: add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 097/160] net: hsr: don't check sequence number if tag removal is offloaded Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 098/160] bpf: Fix up register-based shifts in interpreter to silence KUBSAN Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 099/160] ice: fix incorrect payload indicator on PTYPE Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 100/160] ice: mark PTYPE 2 as reserved Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 101/160] mt76: mt7615: fix fixed-rate tx status reporting Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 102/160] mt76: dma: use ieee80211_tx_status_ext to free packets when tx fails Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 104/160] net: ipa: Add missing of_node_put() in ipa_firmware_load() Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 105/160] net: sched: fix error return code in tcf_del_walker() Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 109/160] mt76: mt7915: fix tssi indication field of DBDC NICs Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 110/160] mt76: mt7915: fix IEEE80211_HE_PHY_CAP7_MAX_NC for station mode Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 111/160] mt76: fix iv and CCMP header insertion Sasha Levin
2021-07-06 11:17 ` Sasha Levin [this message]
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 114/160] net: fec: add FEC_QUIRK_HAS_MULTI_QUEUES represents i.MX6SX ENET IP Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 115/160] net: fec: add ndo_select_queue to fix TX bandwidth fluctuations Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 116/160] atm: nicstar: use 'dma_free_coherent' instead of 'kfree' Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 117/160] atm: nicstar: register the interrupt handler in the right place Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 118/160] vsock: notify server to shutdown when client has pending signal Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 121/160] iwlwifi: mvm: don't change band on bound PHY contexts Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 122/160] iwlwifi: mvm: apply RX diversity per PHY context Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 123/160] iwlwifi: mvm: fix error print when session protection ends Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 124/160] iwlwifi: mvm: support LONG_GROUP for WOWLAN_GET_STATUSES version Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 125/160] iwlwifi: pcie: free IML DMA memory allocation Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 126/160] iwlwifi: pcie: fix context info freeing Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 127/160] rtw88: 8822c: update RF parameter tables to v62 Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 128/160] rtw88: add quirks to disable pci capabilities Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 129/160] sfc: avoid double pci_remove of VFs Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 130/160] sfc: error code if SRIOV cannot be disabled Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 131/160] net: dsa: b53: Create default VLAN entry explicitly Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 132/160] wireless: wext-spy: Fix out-of-bounds warning Sasha Levin
2021-07-06 11:17 ` [PATCH AUTOSEL 5.12 133/160] cfg80211: fix default HE tx bitrate mask in 2G band Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 134/160] mac80211: consider per-CPU statistics if present Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 135/160] mac80211_hwsim: add concurrent channels scanning support over virtio Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 136/160] mac80211: Properly WARN on HW scan before restart Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 138/160] media, bpf: Do not copy more entries than user space requested Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 139/160] net: retrieve netns cookie via getsocketopt Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 140/160] net: ip: avoid OOM kills with large UDP sends over loopback Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 143/160] Bluetooth: Fix the HCI to MGMT status conversion table Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 144/160] Bluetooth: Fix alt settings for incoming SCO with transparent coding format Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 145/160] Bluetooth: Shutdown controller after workqueues are flushed or cancelled Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 147/160] Bluetooth: L2CAP: Fix invalid access if ECRED Reconfigure fails Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 148/160] Bluetooth: L2CAP: Fix invalid access on ECRED Connection response Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 150/160] Bluetooth: mgmt: Fix the command returns garbage parameter value Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 154/160] bpf: Fix false positive kmemleak report in bpf_ringbuf_area_alloc() Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 155/160] flow_offload: action should not be NULL when it is referenced Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 156/160] sctp: validate from_addr_param return Sasha Levin
2021-07-06 11:18 ` [PATCH AUTOSEL 5.12 157/160] sctp: add size validation when walking chunks Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210706111827.2060499-112-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pterjan@google.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).