Message ID | 20240823161131.94305-3-marex@denx.de (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v2,1/4] dt-bindings: wireless: wilc1000: Document WILC3000 compatible string | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 8/23/24 18:08, Marek Vasut wrote: > 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(). > > Signed-off-by: Marek Vasut <marex@denx.de> > --- > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Adham Abozaeid <adham.abozaeid@microchip.com> > Cc: Ajay Singh <ajay.kathat@microchip.com> > Cc: Alexis Lothoré <alexis.lothore@bootlin.com> > Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev> > Cc: Conor Dooley <conor+dt@kernel.org> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Kalle Valo <kvalo@kernel.org> > Cc: Krzysztof Kozlowski <krzk+dt@kernel.org> > Cc: Marek Vasut <marex@denx.de> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: Rob Herring <robh@kernel.org> > Cc: devicetree@vger.kernel.org > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > --- > V2: New patch > --- > .../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 1aab2f2dc159f..5fbba6876bd07 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; Forwarding error codes sounds like a good idea, but neither this patch nor the next one is reading the return value from any chip_allow_sleep[XXX] function, so it does not bring much value. Alexis
On 8/27/24 10:14 AM, Alexis Lothoré wrote: > On 8/23/24 18:08, Marek Vasut wrote: >> 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(). >> >> Signed-off-by: Marek Vasut <marex@denx.de> >> --- >> Cc: "David S. Miller" <davem@davemloft.net> >> Cc: Adham Abozaeid <adham.abozaeid@microchip.com> >> Cc: Ajay Singh <ajay.kathat@microchip.com> >> Cc: Alexis Lothoré <alexis.lothore@bootlin.com> >> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev> >> Cc: Conor Dooley <conor+dt@kernel.org> >> Cc: Eric Dumazet <edumazet@google.com> >> Cc: Jakub Kicinski <kuba@kernel.org> >> Cc: Kalle Valo <kvalo@kernel.org> >> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org> >> Cc: Marek Vasut <marex@denx.de> >> Cc: Paolo Abeni <pabeni@redhat.com> >> Cc: Rob Herring <robh@kernel.org> >> Cc: devicetree@vger.kernel.org >> Cc: linux-wireless@vger.kernel.org >> Cc: netdev@vger.kernel.org >> --- >> V2: New patch >> --- >> .../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 1aab2f2dc159f..5fbba6876bd07 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; > > Forwarding error codes sounds like a good idea, but neither this patch nor the > next one is reading the return value from any chip_allow_sleep[XXX] function, so > it does not bring much value. I will add a follow up patch to this one which adds the error handling, since there is a lot of it to propagate the errors through. It will be in V3.
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 1aab2f2dc159f..5fbba6876bd07 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 ae187192a79c6..e75a5c8aaecec 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);
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(). Signed-off-by: Marek Vasut <marex@denx.de> --- Cc: "David S. Miller" <davem@davemloft.net> Cc: Adham Abozaeid <adham.abozaeid@microchip.com> Cc: Ajay Singh <ajay.kathat@microchip.com> Cc: Alexis Lothoré <alexis.lothore@bootlin.com> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev> Cc: Conor Dooley <conor+dt@kernel.org> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Kalle Valo <kvalo@kernel.org> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org> Cc: Marek Vasut <marex@denx.de> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Rob Herring <robh@kernel.org> Cc: devicetree@vger.kernel.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- V2: New patch --- .../net/wireless/microchip/wilc1000/wlan.c | 47 +++++++++---------- .../net/wireless/microchip/wilc1000/wlan.h | 2 - 2 files changed, 23 insertions(+), 26 deletions(-)