From patchwork Thu Oct 3 11:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 832952 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FEF617CA1F; Thu, 3 Oct 2024 11:16:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727954172; cv=none; b=sI5bbxhH2YnDo+Mf2brFSupodGlkHMOScAE+CR70kDbPnm4nxpMcyWd7TdFKrBF+kYNZj2d7uEY04SQr2dLVJV5WYo+BoyE7QaI1+alAGotHglydQzu0LpvPKLBjleIA0PzQZE1pVmwQqVWe6qTpLqLjEDkaSR69ADq9OwnXBaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727954172; c=relaxed/simple; bh=jqPLftyTmhJF75rBy6YtngjCPks8pX299FqdQHmAJhg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GAkMEoZrtuvCmAkdVd/5gomN6agXsOo8wU5uSMYlxClmdnnIO3uWtqCjyXez9WA1DyzD2QSA3e4xVkCG0c9f49VhjtqgGvWix+6cbyp1OSXBKsDJliSg4QID1NqowIMIo27frEC8OAVU/aFphQPN0XkHedBSJXl1vAs77xKHyvU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=lteoHJyN; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="lteoHJyN" Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id DD32A88C24; Thu, 3 Oct 2024 13:16:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1727954163; bh=OEQUCd7LHmaw0l8lT0metx5Y7d4unWP/iPcIZ5uSIzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lteoHJyNfycnaD7P3Vhlb9W61Lp2UkOz2PAf1FnIRQVNDJAM7495ZlSPugydwc05W vb4yW92GKd0Tq9zmHKHLUHL9JMmHRAljM71QZwE26sk5+1YFllRdqV3sHDKw2rUdMn pEgtGLquVABQmvNlxUdYcu3nBwMBed8mhHBgtHO/NgepOk0p0nQ4y8dSe1s+q4LaYu wY7rKtEBRFJ+76JMC9WYd5JFr6+UpslXEVrHIGn//NY3FfME7TZtQcWObNa9jDjnMM cTVgxiu9hdF9OgX6hZYLq/5XzMoD1xwCvWCUddjwsPwtGLUSXGbwLdqzHUbd1vPoE8 Ma7qIhbeJQVrg== From: Marek Vasut To: linux-wireless@vger.kernel.org Cc: Marek Vasut , =?utf-8?q?Alexis_Lothor=C3=A9?= , "David S. Miller" , Adham Abozaeid , Ajay Singh , Claudiu Beznea , Conor Dooley , Eric Dumazet , Jakub Kicinski , Kalle Valo , Krzysztof Kozlowski , Paolo Abeni , Rob Herring , devicetree@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v7 3/7] wifi: wilc1000: Fold chip_allow_sleep()/chip_wakeup() into wlan.c Date: Thu, 3 Oct 2024 13:14:37 +0200 Message-ID: <20241003111529.41232-3-marex@denx.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003111529.41232-1-marex@denx.de> References: <20241003111529.41232-1-marex@denx.de> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Neither chip_allow_sleep()/chip_wakeup() is used outside of wlan.c . Make both functions static and remove both the exported symbol and entries from wlan.h . Make chip_allow_sleep() return error code in preparation for the follow up patches. Move acquire_bus() and release_bus() to avoid forward declaration of chip_allow_sleep()/chip_wakeup(). Reviewed-by: Alexis LothorĂ© Signed-off-by: Marek Vasut --- Cc: "David S. Miller" Cc: Adham Abozaeid Cc: Ajay Singh Cc: Alexis LothorĂ© Cc: Claudiu Beznea Cc: Conor Dooley Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Kalle Valo Cc: Krzysztof Kozlowski Cc: Paolo Abeni Cc: Rob Herring Cc: devicetree@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- V2: New patch V3: No change V4: Add RB from Alexis V5: No change V6: - Rebase on next-20240926 V7: - Rebase on next-20241003 / wireless-next/main 5a4d42c1688c with v2 wifi: wilc1000: Keep slot powered on during suspend/resume --- .../net/wireless/microchip/wilc1000/wlan.c | 47 +++++++++---------- .../net/wireless/microchip/wilc1000/wlan.h | 2 - 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 1f113a55ea6aa..6f4be21296029 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,20 +12,6 @@ #define WAKE_UP_TRIAL_RETRY 10000 -static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) -{ - mutex_lock(&wilc->hif_cs); - if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP && wilc->power_save_mode) - chip_wakeup(wilc); -} - -static inline void release_bus(struct wilc *wilc, enum bus_release release) -{ - if (release == WILC_BUS_RELEASE_ALLOW_SLEEP && wilc->power_save_mode) - chip_allow_sleep(wilc); - mutex_unlock(&wilc->hif_cs); -} - static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num, struct txq_entry_t *tqe) { @@ -555,7 +541,7 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) return rqe; } -void chip_allow_sleep(struct wilc *wilc) +static int chip_allow_sleep(struct wilc *wilc) { u32 reg = 0; const struct wilc_hif_func *hif_func = wilc->hif_func; @@ -584,7 +570,7 @@ void chip_allow_sleep(struct wilc *wilc) while (--trials) { ret = hif_func->hif_read_reg(wilc, to_host_from_fw_reg, ®); if (ret) - return; + return ret; if ((reg & to_host_from_fw_bit) == 0) break; } @@ -594,28 +580,28 @@ void chip_allow_sleep(struct wilc *wilc) /* Clear bit 1 */ ret = hif_func->hif_read_reg(wilc, wakeup_reg, ®); if (ret) - return; + return ret; if (reg & wakeup_bit) { reg &= ~wakeup_bit; ret = hif_func->hif_write_reg(wilc, wakeup_reg, reg); if (ret) - return; + return ret; } ret = hif_func->hif_read_reg(wilc, from_host_to_fw_reg, ®); if (ret) - return; + return ret; if (reg & from_host_to_fw_bit) { reg &= ~from_host_to_fw_bit; ret = hif_func->hif_write_reg(wilc, from_host_to_fw_reg, reg); if (ret) - return; - + return ret; } + + return 0; } -EXPORT_SYMBOL_GPL(chip_allow_sleep); -void chip_wakeup(struct wilc *wilc) +static void chip_wakeup(struct wilc *wilc) { u32 ret = 0; u32 clk_status_val = 0, trials = 0; @@ -674,7 +660,20 @@ void chip_wakeup(struct wilc *wilc) if (wilc->io_type == WILC_HIF_SPI) wilc->hif_func->hif_reset(wilc); } -EXPORT_SYMBOL_GPL(chip_wakeup); + +static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) +{ + mutex_lock(&wilc->hif_cs); + if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP && wilc->power_save_mode) + chip_wakeup(wilc); +} + +static inline void release_bus(struct wilc *wilc, enum bus_release release) +{ + if (release == WILC_BUS_RELEASE_ALLOW_SLEEP && wilc->power_save_mode) + chip_allow_sleep(wilc); + mutex_unlock(&wilc->hif_cs); +} void host_wakeup_notify(struct wilc *wilc) { diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 44dce53d24916..90ba76cf14dd1 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -438,8 +438,6 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); bool wilc_wfi_mgmt_frame_rx(struct wilc_vif *vif, u8 *buff, u32 size); void host_wakeup_notify(struct wilc *wilc); void host_sleep_notify(struct wilc *wilc); -void chip_allow_sleep(struct wilc *wilc); -void chip_wakeup(struct wilc *wilc); int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, u32 count); int wilc_wlan_init(struct net_device *dev);