diff mbox series

[04/11] net: dwc_eth_qos: Scrub ifdeffery

Message ID 20240309021831.264018-5-marex@denx.de
State Superseded
Delegated to: Patrice Chotard
Headers show
Series net: dwc_eth_qos: Clean up STM32 glue code and add STM32MP13xx support | expand

Commit Message

Marek Vasut March 9, 2024, 2:11 a.m. UTC
Replace ifdef CONFIG_CLK with if (CONFIG_IS_ENABLED(CLK)) to improve code
build coverage. Some of the functions printed debug("%s: OK\n", __func__);
on exit with and without CLK enabled, some did not, make it consistent and
print nothing if CLK is disabled.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Christophe Roullier <christophe.roullier@st.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: u-boot@dh-electronics.com
Cc: uboot-stm32@st-md-mailman.stormreply.com
---
 drivers/net/dwc_eth_qos_stm32.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

Comments

Patrice CHOTARD March 12, 2024, 12:36 p.m. UTC | #1
On 3/9/24 03:11, Marek Vasut wrote:
> Replace ifdef CONFIG_CLK with if (CONFIG_IS_ENABLED(CLK)) to improve code
> build coverage. Some of the functions printed debug("%s: OK\n", __func__);
> on exit with and without CLK enabled, some did not, make it consistent and
> print nothing if CLK is disabled.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Christophe Roullier <christophe.roullier@st.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Ramon Fried <rfried.dev@gmail.com>
> Cc: u-boot@dh-electronics.com
> Cc: uboot-stm32@st-md-mailman.stormreply.com
> ---
>  drivers/net/dwc_eth_qos_stm32.c | 25 ++++++++++++-------------
>  1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/net/dwc_eth_qos_stm32.c b/drivers/net/dwc_eth_qos_stm32.c
> index 7520a136ed0..d7ec0c9be36 100644
> --- a/drivers/net/dwc_eth_qos_stm32.c
> +++ b/drivers/net/dwc_eth_qos_stm32.c
> @@ -46,21 +46,22 @@
>  
>  static ulong eqos_get_tick_clk_rate_stm32(struct udevice *dev)
>  {
> -#ifdef CONFIG_CLK
> -	struct eqos_priv *eqos = dev_get_priv(dev);
> +	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
> +
> +	if (!CONFIG_IS_ENABLED(CLK))
> +		return 0;
>  
>  	return clk_get_rate(&eqos->clk_master_bus);
> -#else
> -	return 0;
> -#endif
>  }
>  
>  static int eqos_start_clks_stm32(struct udevice *dev)
>  {
> -#ifdef CONFIG_CLK
> -	struct eqos_priv *eqos = dev_get_priv(dev);
> +	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
>  	int ret;
>  
> +	if (!CONFIG_IS_ENABLED(CLK))
> +		return 0;
> +
>  	debug("%s(dev=%p):\n", __func__, dev);
>  
>  	ret = clk_enable(&eqos->clk_master_bus);
> @@ -89,12 +90,10 @@ static int eqos_start_clks_stm32(struct udevice *dev)
>  		}
>  		eqos->clk_ck_enabled = true;
>  	}
> -#endif
>  
>  	debug("%s: OK\n", __func__);
>  	return 0;
>  
> -#ifdef CONFIG_CLK
>  err_disable_clk_tx:
>  	clk_disable(&eqos->clk_tx);
>  err_disable_clk_rx:
> @@ -104,20 +103,20 @@ err_disable_clk_master_bus:
>  err:
>  	debug("%s: FAILED: %d\n", __func__, ret);
>  	return ret;
> -#endif
>  }
>  
>  static int eqos_stop_clks_stm32(struct udevice *dev)
>  {
> -#ifdef CONFIG_CLK
> -	struct eqos_priv *eqos = dev_get_priv(dev);
> +	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
> +
> +	if (!CONFIG_IS_ENABLED(CLK))
> +		return 0;
>  
>  	debug("%s(dev=%p):\n", __func__, dev);
>  
>  	clk_disable(&eqos->clk_tx);
>  	clk_disable(&eqos->clk_rx);
>  	clk_disable(&eqos->clk_master_bus);
> -#endif
>  
>  	debug("%s: OK\n", __func__);
>  	return 0;


Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Christophe Roullier April 5, 2024, 2:47 p.m. UTC | #2
> On 3/9/24 03:11, Marek Vasut wrote:
>> Replace ifdef CONFIG_CLK with if (CONFIG_IS_ENABLED(CLK)) to improve
>> code build coverage. Some of the functions printed debug("%s: OK\n",
>> __func__); on exit with and without CLK enabled, some did not, make it
>> consistent and print nothing if CLK is disabled.
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> ---
>> Cc: Christophe Roullier <christophe.roullier@st.com>
>> Cc: Joe Hershberger <joe.hershberger@ni.com>
>> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
>> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> Cc: Ramon Fried <rfried.dev@gmail.com>
>> Cc: u-boot@dh-electronics.com
>> Cc: uboot-stm32@st-md-mailman.stormreply.com
>> ---
>>   drivers/net/dwc_eth_qos_stm32.c | 25 ++++++++++++-------------
>>   1 file changed, 12 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/net/dwc_eth_qos_stm32.c
>> b/drivers/net/dwc_eth_qos_stm32.c index 7520a136ed0..d7ec0c9be36
>> 100644
>> --- a/drivers/net/dwc_eth_qos_stm32.c
>> +++ b/drivers/net/dwc_eth_qos_stm32.c
>> @@ -46,21 +46,22 @@
>>
>>   static ulong eqos_get_tick_clk_rate_stm32(struct udevice *dev)  {
>> -#ifdef CONFIG_CLK
>> -     struct eqos_priv *eqos = dev_get_priv(dev);
>> +     struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
>> +
>> +     if (!CONFIG_IS_ENABLED(CLK))
>> +             return 0;
>>
>>        return clk_get_rate(&eqos->clk_master_bus);
>> -#else
>> -     return 0;
>> -#endif
>>   }
>>
>>   static int eqos_start_clks_stm32(struct udevice *dev)  { -#ifdef
>> CONFIG_CLK
>> -     struct eqos_priv *eqos = dev_get_priv(dev);
>> +     struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
>>        int ret;
>>
>> +     if (!CONFIG_IS_ENABLED(CLK))
>> +             return 0;
>> +
>>        debug("%s(dev=%p):\n", __func__, dev);
>>
>>        ret = clk_enable(&eqos->clk_master_bus);
>> @@ -89,12 +90,10 @@ static int eqos_start_clks_stm32(struct udevice *dev)
>>                }
>>                eqos->clk_ck_enabled = true;
>>        }
>> -#endif
>>
>>        debug("%s: OK\n", __func__);
>>        return 0;
>>
>> -#ifdef CONFIG_CLK
>>   err_disable_clk_tx:
>>        clk_disable(&eqos->clk_tx);
>>   err_disable_clk_rx:
>> @@ -104,20 +103,20 @@ err_disable_clk_master_bus:
>>   err:
>>        debug("%s: FAILED: %d\n", __func__, ret);
>>        return ret;
>> -#endif
>>   }
>>
>>   static int eqos_stop_clks_stm32(struct udevice *dev)  { -#ifdef
>> CONFIG_CLK
>> -     struct eqos_priv *eqos = dev_get_priv(dev);
>> +     struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
>> +
>> +     if (!CONFIG_IS_ENABLED(CLK))
>> +             return 0;
>>
>>        debug("%s(dev=%p):\n", __func__, dev);
>>
>>        clk_disable(&eqos->clk_tx);
>>        clk_disable(&eqos->clk_rx);
>>        clk_disable(&eqos->clk_master_bus);
>> -#endif
>>
>>        debug("%s: OK\n", __func__);
>>        return 0;
>
> Reviewed-by: Christophe ROULLIER <christophe.roullier@foss.st.com>
>
diff mbox series

Patch

diff --git a/drivers/net/dwc_eth_qos_stm32.c b/drivers/net/dwc_eth_qos_stm32.c
index 7520a136ed0..d7ec0c9be36 100644
--- a/drivers/net/dwc_eth_qos_stm32.c
+++ b/drivers/net/dwc_eth_qos_stm32.c
@@ -46,21 +46,22 @@ 
 
 static ulong eqos_get_tick_clk_rate_stm32(struct udevice *dev)
 {
-#ifdef CONFIG_CLK
-	struct eqos_priv *eqos = dev_get_priv(dev);
+	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
+
+	if (!CONFIG_IS_ENABLED(CLK))
+		return 0;
 
 	return clk_get_rate(&eqos->clk_master_bus);
-#else
-	return 0;
-#endif
 }
 
 static int eqos_start_clks_stm32(struct udevice *dev)
 {
-#ifdef CONFIG_CLK
-	struct eqos_priv *eqos = dev_get_priv(dev);
+	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
 	int ret;
 
+	if (!CONFIG_IS_ENABLED(CLK))
+		return 0;
+
 	debug("%s(dev=%p):\n", __func__, dev);
 
 	ret = clk_enable(&eqos->clk_master_bus);
@@ -89,12 +90,10 @@  static int eqos_start_clks_stm32(struct udevice *dev)
 		}
 		eqos->clk_ck_enabled = true;
 	}
-#endif
 
 	debug("%s: OK\n", __func__);
 	return 0;
 
-#ifdef CONFIG_CLK
 err_disable_clk_tx:
 	clk_disable(&eqos->clk_tx);
 err_disable_clk_rx:
@@ -104,20 +103,20 @@  err_disable_clk_master_bus:
 err:
 	debug("%s: FAILED: %d\n", __func__, ret);
 	return ret;
-#endif
 }
 
 static int eqos_stop_clks_stm32(struct udevice *dev)
 {
-#ifdef CONFIG_CLK
-	struct eqos_priv *eqos = dev_get_priv(dev);
+	struct eqos_priv __maybe_unused *eqos = dev_get_priv(dev);
+
+	if (!CONFIG_IS_ENABLED(CLK))
+		return 0;
 
 	debug("%s(dev=%p):\n", __func__, dev);
 
 	clk_disable(&eqos->clk_tx);
 	clk_disable(&eqos->clk_rx);
 	clk_disable(&eqos->clk_master_bus);
-#endif
 
 	debug("%s: OK\n", __func__);
 	return 0;