From patchwork Mon Jun 3 09:15:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683392 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8A7974420 for ; Mon, 3 Jun 2024 09:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406151; cv=none; b=ENQEnTsg5+Mv+l0ZiJ565OtGyBi47EZz4E6V15Ll3vyklnMBJozpa1dX8MbJO0Cq2VRvqDpzXiyCj7P5psgkL6O4Yr107m/Lr0G2iD6X5SdTzzsq4mptWNbTeCGbPPbI693t5tdb1dWVbKm4l/BWfoe+iICwhEYInS4DuS2gUaM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406151; c=relaxed/simple; bh=PnSLEwaMRIhusLOj1H7+hLN1hV3Obq2sv6Ok+7+MTZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMoGTzkr0rCd+LMWQx4UInzPOOxq0HVHg+iAHkXtXURDpCpoRNPiRDH/hliBwhkzw+2jLX2mU8uduL+LIEPaKNQmLeneky8xieoOB0x9BT+b/UmJgVn1DtxKMGS2Uhziq1QzWIs6L57oGRn4LbSx/GPxaZqer2pMWOZZXTNqX+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=NGzWmaCV; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="NGzWmaCV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=LdfEPpYp2q55Lbd2/moAUzqffW0IB2tS5IgblPD0OA8=; b=NGzWma CVcolg6ZPrhBUwk1hNWstW5WslGXGh9X4xJVd+aOGNFRTOtgzHi77MTYd1szZseA pjQ/5aoNkBnm7yMiViL5bZf/RwXmeNX1D4MH30dmXReeZOax9ewXf0zIw9jDDbQQ +byec288G7tXebFyoMNuk/9U7Z7zgB3SwHo93MrGQssLsAHWawlWYsSLKsbLtH/N +d7s/0PbfaJn1MNRoj+l3p9cH7ZnK8MXY2roydMSCoXhL2VOqwWWVY1iDhhc95hx qH8eeJqOdEHkl77DLg/m98mnPN8jWld5wcttt0yq6C5S12vrdHys15Nndax2Qbad Aq5lFb08sx2QJhQA== Received: (qmail 1899265 invoked from network); 3 Jun 2024 11:15:45 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:45 +0200 X-UD-Smtp-Session: l3s3148p1@fPQ9x/gZ+oUgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Kalle Valo , Jeff Johnson , linux-wireless@vger.kernel.org, ath11k@lists.infradead.org Subject: [PATCH 1/6] wifi: ath11k: use 'time_left' variable with wait_event_timeout() Date: Mon, 3 Jun 2024 11:15:34 +0200 Message-ID: <20240603091541.8367-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_event_timeout() causing patterns like: timeout = wait_event_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Fix to the proper variable type 'long' while here. Signed-off-by: Wolfram Sang --- drivers/net/wireless/ath/ath11k/qmi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index d4a243b64f6c..2fe0ef660456 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -2859,7 +2859,7 @@ int ath11k_qmi_firmware_start(struct ath11k_base *ab, int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) { - int timeout; + long time_left; if (!ath11k_core_coldboot_cal_support(ab) || ab->hw_params.cbcal_restart_fw == 0) @@ -2867,11 +2867,11 @@ int ath11k_qmi_fwreset_from_cold_boot(struct ath11k_base *ab) ath11k_dbg(ab, ATH11K_DBG_QMI, "wait for cold boot done\n"); - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, - (ab->qmi.cal_done == 1), - ATH11K_COLD_BOOT_FW_RESET_DELAY); + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); - if (timeout <= 0) { + if (time_left <= 0) { ath11k_warn(ab, "Coldboot Calibration timed out\n"); return -ETIMEDOUT; } @@ -2886,7 +2886,7 @@ EXPORT_SYMBOL(ath11k_qmi_fwreset_from_cold_boot); static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) { - int timeout; + long time_left; int ret; ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT); @@ -2897,10 +2897,10 @@ static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab) ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n"); - timeout = wait_event_timeout(ab->qmi.cold_boot_waitq, - (ab->qmi.cal_done == 1), - ATH11K_COLD_BOOT_FW_RESET_DELAY); - if (timeout <= 0) { + time_left = wait_event_timeout(ab->qmi.cold_boot_waitq, + (ab->qmi.cal_done == 1), + ATH11K_COLD_BOOT_FW_RESET_DELAY); + if (time_left <= 0) { ath11k_warn(ab, "coldboot calibration timed out\n"); return 0; } From patchwork Mon Jun 3 09:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683391 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6B7576F17 for ; Mon, 3 Jun 2024 09:15:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406151; cv=none; b=QO58rHc9rYO9hvy2VXDwHdu+2uMqhWOspZOChU2/pji0h3hxHqrK1EQP0zaBcaTaYu4TyQsWY1Na1CL8AfLUcOwI/Ev2Em65/ErnyXOzFj+RYJT4Wwhx6t6Hvp9vm6kUUoB07Tb7XF+NGafTWWHY0YDmUEUEYNQFBg1fKwmiy5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406151; c=relaxed/simple; bh=RHq9CxtOVmMB6cXfYKhVGEaZuC37DAckfGOXb1IADxc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B+5/CpZkvXS5l0fs17Wkkv1XsalZY7az/zaPOJWOIHlAknZrydJBASYp3aWpjs8lgXG7KMohQXG/9DRUo93b2292xRoh5opf5DOncYOovTDsccTqJPc5iMz5k54olNP3jwUfaoq5O+mwNXJLfcYuY0v5zAtM73CqOh78RSZboqc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=BvW8w++s; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="BvW8w++s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=svASrHdCfX+q8u+/r9OQxM2ON1s7lrnJCs82vuq+Nu4=; b=BvW8w+ +sq17SSRw1A5hu3WKiAisuguJ/pteC4BYJt8khpG/uXA2vrX6Ao9CWdMt7/SEzLV sVLDYqGWhfKHH8fJGB6Tb50im3D3shTRrAclQ0SOtl/cgRt1ze4oQvVfSURKijKH jV5hmqNIXjQaVsrF3RKSkDqh7IWWMBpJ8HlmVqD2c9Mnfu1WCATNLnPelGDa0S0q bNx4KJZ57YaDYdfHPjrWR3Ucg/W3HHo+mMg2KkEAb0AYh4ZO1KHpOg4Zs1HiVhdl d6fz4hCkgI66lq6XT3rS9beMT/4W68VjwnNAOBl8u9J/7t6Cmae67jRDJqkFoUth /skn3/OXJcumo+Kw== Received: (qmail 1899305 invoked from network); 3 Jun 2024 11:15:46 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:46 +0200 X-UD-Smtp-Session: l3s3148p1@o5xMx/gZBIYgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Arend van Spriel , Kalle Valo , linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev, brcm80211-dev-list.pdl@broadcom.com Subject: [PATCH 2/6] wifi: brcmfmac: use 'time_left' variable with wait_event_timeout() Date: Mon, 3 Jun 2024 11:15:35 +0200 Message-ID: <20240603091541.8367-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_event_timeout() causing patterns like: timeout = wait_event_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Fix to the proper variable type 'long' while here. Signed-off-by: Wolfram Sang Acked-by: Arend van Spriel --- .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 5fe0e671ecb3..1585a5653ee4 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -4071,7 +4071,7 @@ static void brcmf_report_wowl_wakeind(struct wiphy *wiphy, struct brcmf_if *ifp) struct cfg80211_wowlan_wakeup *wakeup; u32 wakeind; s32 err; - int timeout; + long time_left; err = brcmf_fil_iovar_data_get(ifp, "wowl_wakeind", &wake_ind_le, sizeof(wake_ind_le)); @@ -4113,10 +4113,10 @@ static void brcmf_report_wowl_wakeind(struct wiphy *wiphy, struct brcmf_if *ifp) } if (wakeind & BRCMF_WOWL_PFN_FOUND) { brcmf_dbg(INFO, "WOWL Wake indicator: BRCMF_WOWL_PFN_FOUND\n"); - timeout = wait_event_timeout(cfg->wowl.nd_data_wait, - cfg->wowl.nd_data_completed, - BRCMF_ND_INFO_TIMEOUT); - if (!timeout) + time_left = wait_event_timeout(cfg->wowl.nd_data_wait, + cfg->wowl.nd_data_completed, + BRCMF_ND_INFO_TIMEOUT); + if (!time_left) bphy_err(drvr, "No result for wowl net detect\n"); else wakeup_data.net_detect = cfg->wowl.nd_info; From patchwork Mon Jun 3 09:15:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683394 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B5327E578 for ; Mon, 3 Jun 2024 09:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406153; cv=none; b=ua8ahbzCRCmxMPz6duQvw6OKDO+SoF280gsgk1GnWbvr07ap9vL9W7FmH4BdNixl5vbiusNTAtU6RvmggHXxmENxw3HoiXSYDJPSMS5B4omdTOS+t5+kKDhRede7Ng98nf9HD8Q9Wx61Bi9F0/+2TjQWijhnmBQgLK/DtlKyZso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406153; c=relaxed/simple; bh=zqhSOx9TEsK+ntdJ3WpSkCqHwe22qFXbYtLRZFiNxlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YQtsjKzzg6kaAFNab72Weu12lliVyOGBpbP2lvxWkCqJ8lX+9tLWpyqsywRToTWArs+5vQjFasU3+RkTWPpXe9fzh5aJlT1w2Q01Ieg6ARtNoiKgqIO5CJ4PeEM0X8HgCXdsPpchZs0rPMLCh4BfZg4FYBpNUCo3v1NCpbd2A0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=H5gTBkN3; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="H5gTBkN3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=CdJ6gRXs+1B22Jl+/VUs3m4FLJ6sLe4o/fPCvArtSI0=; b=H5gTBk N3AuM5oQ1fxOx4oqj1HgM/wZEvUkmqF+OTSqLBsMFDZkX7vd+ZOCL5sGkSsmfyML G1NZWTNQxa8GfY8sBgh/xma7jryPqVu0dO80B168RvqgYpnJX8YJLqo3jTtsMH0Y L14SxeIuzB5nzwg5h+fJ3WFJuBSmXn7RuWxBaJHlR1TAA7GTFZ+kCoXLuHq/3CtK SzRhqLWIriJkXy0ZhVoS3B0Bv4NWQt4pCYqrKF5kQu/oYvWM5v6JciND1GiFqQ68 UcgC8B1dmTgEg3th0sjs+h18MisPp5PQLt4piO/d/JvlVK1lx0cBtAZQda9QfkPt lp9jEGT4IKtbOLYQ== Received: (qmail 1899341 invoked from network); 3 Jun 2024 11:15:47 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:47 +0200 X-UD-Smtp-Session: l3s3148p1@861Xx/gZEoYgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 3/6] wifi: mac80211: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 3 Jun 2024 11:15:36 +0200 Message-ID: <20240603091541.8367-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Signed-off-by: Wolfram Sang --- drivers/net/wireless/marvell/mwl8k.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c index d3d07bb26335..241a02a0accd 100644 --- a/drivers/net/wireless/marvell/mwl8k.c +++ b/drivers/net/wireless/marvell/mwl8k.c @@ -2211,7 +2211,7 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt_hdr *cmd dma_addr_t dma_addr; unsigned int dma_size; int rc; - unsigned long timeout = 0; + unsigned long time_left = 0; u8 buf[32]; u32 bitmap = 0; @@ -2258,8 +2258,8 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt_hdr *cmd iowrite32(MWL8K_H2A_INT_DUMMY, regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS); - timeout = wait_for_completion_timeout(&cmd_wait, - msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS)); + time_left = wait_for_completion_timeout(&cmd_wait, + msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS)); priv->hostcmd_wait = NULL; @@ -2267,7 +2267,7 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt_hdr *cmd dma_unmap_single(&priv->pdev->dev, dma_addr, dma_size, DMA_BIDIRECTIONAL); - if (!timeout) { + if (!time_left) { wiphy_err(hw->wiphy, "Command %s timeout after %u ms\n", mwl8k_cmd_name(cmd->code, buf, sizeof(buf)), MWL8K_CMD_TIMEOUT_MS); @@ -2275,7 +2275,7 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt_hdr *cmd } else { int ms; - ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(timeout); + ms = MWL8K_CMD_TIMEOUT_MS - jiffies_to_msecs(time_left); rc = cmd->result ? -EINVAL : 0; if (rc) From patchwork Mon Jun 3 09:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683395 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D4B182860 for ; Mon, 3 Jun 2024 09:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; cv=none; b=QXwqmrZMZjf1eAPIODJpYTh23M/hhL2k3LkFlS/ZbaUopkQ6c74DA7cRgkrAnUm1KvzVEojqpZ0NrlH1qk0K1VJ+Tf17oO+zqkS20g68KNORwXKxQbBWDS2s+MWMWFHWQPOkvLSETMrXt31EX5MX6tC+erAGyPX2UTWyqNi2hqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; c=relaxed/simple; bh=HhBt6/7iPORMx5Kl1Z9ooKI2OQsHyjjVeOMZLg9WLBM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mK0UeXg67t3PgCEZwlCMNBWY6i5h3QWLBoFaDtx+G9rl+bjbiXcHyFPVJrbrA9R4t2NWrwW2Xeju33HhlhntWYqhY1pJiXzYPiFY3m59LN2wJpSgjL4SwGvrkk3uH0jxhzYLX7BHrwIEHxMR2oQEuejgGhK4jdP4xhMeSN23vK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=EvD5HKBD; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="EvD5HKBD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=9OJSdBKqUt1d4Vs+wHfk7HzuxjMx44r5nI8Q9nIvLBM=; b=EvD5HK BDgvJx56of1aDyIKNpwjw6wHq9xxahazmkblmjiw/RXovc5RWigo85Cxs68OYQ63 yK88U4RKeeMnliv5NAjtC3ljHYNh3Dnmk74bpipBrElhtnI3qxLhP+F7TTWG6HnV 2mjbm1sjwCuHbcXg2lO+Krkb60giVZ4vIF8eh9jbuecAeLTq4rNxwoRvoJcLwkQp YT7JTjLugYjBumkonA/TdeVYD572H2cRmAzuczTJ6MpWLfz0WFCqrSbYbr200i4K 2yzTvDSUD1pU/jhm84uewpv58Ghx4rzmsSsFafTfjwjziymdZ+GWkUwN8RjHHSu0 uV/MhEpw2/qsB13g== Received: (qmail 1899365 invoked from network); 3 Jun 2024 11:15:48 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:48 +0200 X-UD-Smtp-Session: l3s3148p1@A4Rmx/gZHIYgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Christian Lamparter , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 4/6] wifi: p54: use 'time_left' variable with wait_for_completion_interruptible_timeout() Date: Mon, 3 Jun 2024 11:15:37 +0200 Message-ID: <20240603091541.8367-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_interruptible_timeout() causing patterns like: timeout = wait_for_completion_interruptible_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Fix to the proper variable type 'long' while here. Signed-off-by: Wolfram Sang --- drivers/net/wireless/intersil/p54/fwio.c | 6 +++--- drivers/net/wireless/intersil/p54/p54pci.c | 8 ++++---- drivers/net/wireless/intersil/p54/p54spi.c | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/intersil/p54/fwio.c b/drivers/net/wireless/intersil/p54/fwio.c index c4fe70e05b9b..772084a9bd8d 100644 --- a/drivers/net/wireless/intersil/p54/fwio.c +++ b/drivers/net/wireless/intersil/p54/fwio.c @@ -216,7 +216,7 @@ int p54_download_eeprom(struct p54_common *priv, void *buf, struct sk_buff *skb; size_t eeprom_hdr_size; int ret = 0; - long timeout; + long time_left; if (priv->fw_var >= 0x509) eeprom_hdr_size = sizeof(*eeprom_hdr); @@ -245,9 +245,9 @@ int p54_download_eeprom(struct p54_common *priv, void *buf, p54_tx(priv, skb); - timeout = wait_for_completion_interruptible_timeout( + time_left = wait_for_completion_interruptible_timeout( &priv->eeprom_comp, HZ); - if (timeout <= 0) { + if (time_left <= 0) { wiphy_err(priv->hw->wiphy, "device does not respond or signal received!\n"); ret = -EBUSY; diff --git a/drivers/net/wireless/intersil/p54/p54pci.c b/drivers/net/wireless/intersil/p54/p54pci.c index e97ee547b9f3..6588f5477762 100644 --- a/drivers/net/wireless/intersil/p54/p54pci.c +++ b/drivers/net/wireless/intersil/p54/p54pci.c @@ -434,7 +434,7 @@ static int p54p_open(struct ieee80211_hw *dev) { struct p54p_priv *priv = dev->priv; int err; - long timeout; + long time_left; init_completion(&priv->boot_comp); err = request_irq(priv->pdev->irq, p54p_interrupt, @@ -472,12 +472,12 @@ static int p54p_open(struct ieee80211_hw *dev) P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET)); P54P_READ(dev_int); - timeout = wait_for_completion_interruptible_timeout( + time_left = wait_for_completion_interruptible_timeout( &priv->boot_comp, HZ); - if (timeout <= 0) { + if (time_left <= 0) { wiphy_err(dev->wiphy, "Cannot boot firmware!\n"); p54p_stop(dev); - return timeout ? -ERESTARTSYS : -ETIMEDOUT; + return time_left ? -ERESTARTSYS : -ETIMEDOUT; } P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE)); diff --git a/drivers/net/wireless/intersil/p54/p54spi.c b/drivers/net/wireless/intersil/p54/p54spi.c index 0073b5e0f9c9..d33a994906a7 100644 --- a/drivers/net/wireless/intersil/p54/p54spi.c +++ b/drivers/net/wireless/intersil/p54/p54spi.c @@ -518,7 +518,7 @@ static void p54spi_work(struct work_struct *work) static int p54spi_op_start(struct ieee80211_hw *dev) { struct p54s_priv *priv = dev->priv; - unsigned long timeout; + long time_left; int ret = 0; if (mutex_lock_interruptible(&priv->mutex)) { @@ -538,10 +538,10 @@ static int p54spi_op_start(struct ieee80211_hw *dev) mutex_unlock(&priv->mutex); - timeout = msecs_to_jiffies(2000); - timeout = wait_for_completion_interruptible_timeout(&priv->fw_comp, - timeout); - if (!timeout) { + time_left = msecs_to_jiffies(2000); + time_left = wait_for_completion_interruptible_timeout(&priv->fw_comp, + time_left); + if (!time_left) { dev_err(&priv->spi->dev, "firmware boot failed"); p54spi_power_off(priv); ret = -1; From patchwork Mon Jun 3 09:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683396 X-Patchwork-Delegate: pkshih@realtek.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEF6E82892 for ; Mon, 3 Jun 2024 09:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; cv=none; b=UbOTpBDTEZQUAq7NouS6cSH65ip/ba0h21k89p2DrJVsubvg95kVshHqoPYMVx76PVdkYFUEYyx5Yyfp8CQoMENXwRtjYpsUYALbElbsuF7kXcIfFel9M85xK7zukGe1iezsJhG8maoETT3ojqfAkiGc0MxqJHH0Rb5+H4Yj83s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; c=relaxed/simple; bh=Om8B2tw6oLgLo6pQmOUkw1WeVfy+tuh0XVXmWZ3xuSU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kVjOnulnud/a5R1m/zCa+jCTvkQwsgXeAoMPZxZYhJeE7zg4DCx+UK6KL9C0M5HOCGjCpgjJgFC1I4gTUMT4jadWMGBDb0PgwXmEtEk6QJvtfhgkl+oyww205wed+NQYxN/DIcgDLEX9qHhzcTwQvyqIsD+XYAEvohVEaZqunCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=f9nfNXnb; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="f9nfNXnb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=a2w0z/yBvhC10ZMyIkCZ0cl+k3B1H+tJUlvwth1QMmY=; b=f9nfNX nbl81Z6mr7AKzd/YPYUC3rxKgwfWsN67Lh8R2vqKYww5uOkClxOupq5mOozv4Ncy 1pJ60M+IMzpYeieGhlaGXdBjDrpKwA619I43dK7+Fy5G14qS0/hBv3LJQ087oMUr Ki97yUirYSNbCKgayUuIVcxga9yotwtYwITGVXZ38kMjKcm296ddweZChi1JjGrk +QbIZJJtZBs0SYSUnXwkgS9OLgAmjYIbwJz1S4A+LBvqtsJLqcYnRbYyESrlLjcz A2D8NnUInoF59lsSOEG0VqATUDw43Qy27RTDynx1rOjULt8NKpAfWF/62c72jOMl 1g6g8n+yQH5e3ayQ== Received: (qmail 1899381 invoked from network); 3 Jun 2024 11:15:49 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:49 +0200 X-UD-Smtp-Session: l3s3148p1@5Q1yx/gZIIYgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Ping-Ke Shih , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 5/6] wifi: rtw89: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 3 Jun 2024 11:15:38 +0200 Message-ID: <20240603091541.8367-6-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Signed-off-by: Wolfram Sang Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c index ddc390d24ec1..16ab834185b4 100644 --- a/drivers/net/wireless/realtek/rtw89/core.c +++ b/drivers/net/wireless/realtek/rtw89/core.c @@ -4022,15 +4022,15 @@ void rtw89_core_update_beacon_work(struct work_struct *work) int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond) { struct completion *cmpl = &wait->completion; - unsigned long timeout; + unsigned long time_left; unsigned int cur; cur = atomic_cmpxchg(&wait->cond, RTW89_WAIT_COND_IDLE, cond); if (cur != RTW89_WAIT_COND_IDLE) return -EBUSY; - timeout = wait_for_completion_timeout(cmpl, RTW89_WAIT_FOR_COND_TIMEOUT); - if (timeout == 0) { + time_left = wait_for_completion_timeout(cmpl, RTW89_WAIT_FOR_COND_TIMEOUT); + if (time_left == 0) { atomic_set(&wait->cond, RTW89_WAIT_COND_IDLE); return -ETIMEDOUT; } From patchwork Mon Jun 3 09:15:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13683397 X-Patchwork-Delegate: kvalo@adurom.com Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5B9982C63 for ; Mon, 3 Jun 2024 09:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; cv=none; b=Pa7ju6E5UkbhOg9JwokigGVKNFCgg/HFivy5g1QlhZuFGb1w6da5XhIUPc5ZdMHwAw9jrJTi/+cv+lKIdoXYHyAwt54GSXMNQH/vKkOxho/qutAba/nVHBP94kxJI+lwGADWObgBkaKohcMfuYSL7NkKtdY9oxbAPnaB+Tt3ljg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717406155; c=relaxed/simple; bh=KuYORB2sueIbIdV8ZkFX68NtUj8C7l8czDRU62n4XqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pz5YPnBllzmglpYCGV32Cz7ANy2BSLA0m/5ewQPSofzKjK9YQf91rewKtdhLzMVhOf9PeIM9fFk0MLnYCButsrYO2AUgbU2wF6qOSdn1z60s/s8T8u/0hD1kfIn6JIF780sZYauHferTNo7Rwk8g7PINbDPUsmV2DAXcF9oegZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=cehrddhk; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="cehrddhk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=vFiFwcvLEE/Pv747qc+Uul7awI7SHIx4wIkE2dTt7B4=; b=cehrdd hkCdJJ+YulpyRRPe+BHxQNyclUx7ZmMqKEZlM0MNlosr64dlYNqoV6T+D3QAlxw9 o+cNHHkoNrL+hQ7URTExVQW7lVGo/AEOUe97VsFiQiKTdv73AO2ijC17VT4N/9qj 80TLuzLJWn5TKvwLw95t2fvNbd+vj1qIWDCDi3BDcEJWrdHR2+CHxoeOM2q0OYPN Y2i8Jgs0ZFlOx/Bp0HzjNtvlIRR8eqaj73RRRCMO09ZXMoCI1S44VV+VusPchxzl /I4iy7M46YZx3TBAAim4Mdn3wmdyVLTW6Y6iLQIWwxQefifjaX45apTgDTdhTkQ1 l3zdCjVzOZZyBWMA== Received: (qmail 1899402 invoked from network); 3 Jun 2024 11:15:50 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 3 Jun 2024 11:15:50 +0200 X-UD-Smtp-Session: l3s3148p1@Wrp9x/gZKoYgAwDPXzLGAH1eNELjOc3g From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 6/6] wifi: zd1211rw: use 'time_left' variable with wait_for_completion_timeout() Date: Mon, 3 Jun 2024 11:15:39 +0200 Message-ID: <20240603091541.8367-7-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> References: <20240603091541.8367-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a confusing pattern in the kernel to use a variable named 'timeout' to store the result of wait_for_completion_timeout() causing patterns like: timeout = wait_for_completion_timeout(...) if (!timeout) return -ETIMEDOUT; with all kinds of permutations. Use 'time_left' as a variable to make the code self explaining. Signed-off-by: Wolfram Sang --- drivers/net/wireless/zydas/zd1211rw/zd_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c index f3b567a13ded..2ee4218da1c5 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c @@ -1698,7 +1698,7 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, int r, i, req_len, actual_req_len, try_count = 0; struct usb_device *udev; struct usb_req_read_regs *req = NULL; - unsigned long timeout; + unsigned long time_left; bool retry = false; if (count < 1) { @@ -1748,9 +1748,9 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values, goto error; } - timeout = wait_for_completion_timeout(&usb->intr.read_regs.completion, - msecs_to_jiffies(50)); - if (!timeout) { + time_left = wait_for_completion_timeout(&usb->intr.read_regs.completion, + msecs_to_jiffies(50)); + if (!time_left) { disable_read_regs_int(usb); dev_dbg_f(zd_usb_dev(usb), "read timed out\n"); r = -ETIMEDOUT;