Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp921257rdh; Fri, 24 Nov 2023 00:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2zIZDKCG6Io0pQQ5D9BdJ+2PWvfdQEfW2i0EI7cyWbYKRod5e24DmAuBzYWs1srdb6Lwy X-Received: by 2002:a05:622a:547:b0:423:75ce:288f with SMTP id m7-20020a05622a054700b0042375ce288fmr2240117qtx.57.1700815731119; Fri, 24 Nov 2023 00:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700815731; cv=none; d=google.com; s=arc-20160816; b=L8/IYlW0kk+m+mzKFdsg3E3D7Q2aYTr0K8T6JXJp6VL7J4BCcoRu3297qI0UbOqRLg FzZM0JKNbA36nymW4H0/m198xiiPEVGy+h8Aay8D4rTCL4CQMsqfyhyPeId2Cr4CfgDO fHNCAa7nsrQWkxCtrNJsvkelyYADhcNNl61ZrK2sjre4VGu79Gw8yuELvKHrgpFx+Kj0 wwXLVCnhNmISOVveKKHAf9Y2wf0HBrNYg2kIo+jYn58UhT0vwmrDCO2gvjq7jILyP0zb 1etSE0/INCckqC5d717nicJly0f5knHm3jjwQpTjpG36z5e3QJIu4HevwCgeOwUtfmtq 51Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9gcV0VhY2cTwuPzn08AIP2x7mwpQ1SQ0TADzgV/HG1w=; fh=W+eSkce8uvUdQ8A1Dj5F8klEXQy967eJmFo02igvYfU=; b=i9jxNC7k8UTWGOD1ZgJDagdyBRRJd1NqK29Q84j23TLpLwadKqchxFQph86THzsrA5 xQWoqqyX3BOjzJhYUR6S5dxG2HP2mfPVdKej44I4/Xij09bTL1yJx3JUC6tK7qMUgwAm Jmxm83x+AVicz0DNtBLHRwb3HZrysnjXSpogp63BSFIrE+R5F16T26Nc3QoLJKZzs8If U6DCq/eZpyjYD9bKE/hUtDRmHGPJelbgsvLpujuELDUPthOV6SxFAhjsqQo0TdvxhoP/ xa5XpAteY/Vjxi+rw7ApukSC3zNzCHKFvrz9YDK4KTxo35F9X7p6tCo1aZJf4HrQam7V J3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iCPg5cI3; spf=pass (google.com: domain of linux-wireless+bounces-42-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-42-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q3-20020a05622a030300b0042378d7dc5csi2992368qtw.754.2023.11.24.00.48.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 00:48:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-42-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iCPg5cI3; spf=pass (google.com: domain of linux-wireless+bounces-42-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-42-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B0BB61C209EC for ; Fri, 24 Nov 2023 08:48:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82491156C3; Fri, 24 Nov 2023 08:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iCPg5cI3" X-Original-To: linux-wireless@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A3A810FE; Fri, 24 Nov 2023 00:48:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700815724; x=1732351724; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cnRhqRHN/FCSPFyKVdYVH7cYpVC1KUyHAWcRs58SbBg=; b=iCPg5cI3BJ4bEttl+g8b/DLN0nmX+9ywudf7qfg10EGj1cw4RNs3IU5/ QZH2PDY9iB8gRKFGvaunG372c/tPEECq1wurqfsrarDv7w/iffGf4IkkV AdxmMUyPd7UXYWcjEmru/K8MenIL8UZd9TlVPnXPbi0glYSJrq5Ai+SXR 0tQwhOFtgVuN6TQ64e3gV1mTm9ZOgwBuOX6z+mxxA4LMX34oIZIbH/e2g D7rvsSbSfpByhU4E9We63oXwG4Ad8bKRrUWjkcGGIlQFmeEwYcFteUid4 8JI3/mfnQxuZCn/nmZgpaAxzajs+2fW2s9fI3RJSR2JZ2njIN7Bi5qs7J w==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="456728916" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="456728916" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 00:48:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="760900499" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="760900499" Received: from mvlasov-mobl1.ger.corp.intel.com (HELO localhost) ([10.251.220.89]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2023 00:48:40 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: "John W. Linville" , Kalle Valo , Larry Finger , linux-wireless@vger.kernel.org, Ping-Ke Shih , Bjorn Helgaas , linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 08/10] wifi: rtlwifi: rtl8821ae: Access full PMCS reg and use pci_regs.h Date: Fri, 24 Nov 2023 10:47:23 +0200 Message-Id: <20231124084725.12738-9-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231124084725.12738-1-ilpo.jarvinen@linux.intel.com> References: <20231124084725.12738-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _rtl8821ae_clear_pci_pme_status() accesses the upper byte of the Power Management Control/Status register (PMCS) with literal 5 offset. Access the entire PMCS register using defines from pci_regs.h to improve code readability. While at it, remove the obvious comment and tweak debug prints slightly to not sound misleading. Signed-off-by: Ilpo Järvinen --- .../wireless/realtek/rtlwifi/rtl8821ae/hw.c | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c index 7cc648d49f2d..f4b232f038a9 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c @@ -2271,7 +2271,7 @@ static void _rtl8821ae_clear_pci_pme_status(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); struct pci_dev *pdev = rtlpci->pdev; - u8 pmcs_reg; + u16 pmcs_reg; u8 pm_cap; pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); @@ -2281,23 +2281,16 @@ static void _rtl8821ae_clear_pci_pme_status(struct ieee80211_hw *hw) return; } - /* Get the PM CSR (Control/Status Register), - * The PME_Status is located at PM Capatibility offset 5, bit 7 - */ - pci_read_config_byte(pdev, pm_cap + 5, &pmcs_reg); - - if (pmcs_reg & BIT(7)) { + pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pmcs_reg); + if (pmcs_reg & PCI_PM_CTRL_PME_STATUS) { /* Clear PME_Status with write */ - pci_write_config_byte(pdev, pm_cap + 5, pmcs_reg); - /* Read it back to check */ - pci_read_config_byte(pdev, pm_cap + 5, &pmcs_reg); + pci_write_config_word(pdev, pm_cap + PCI_PM_CTRL, pmcs_reg); + pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pmcs_reg); rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, - "Clear PME status 0x%2x to 0x%2x\n", - pm_cap + 5, pmcs_reg); + "Cleared PME status, PMCS reg = 0x%4x\n", pmcs_reg); } else { rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, - "PME status(0x%2x) = 0x%2x\n", - pm_cap + 5, pmcs_reg); + "PMCS reg = 0x%4x\n", pmcs_reg); } } -- 2.30.2