Commit 6a81c26f authored by Viresh Kumar's avatar Viresh Kumar Committed by Linus Torvalds

net/stmmac: remove conditional compilation of clk code

With addition of dummy clk_*() calls for non CONFIG_HAVE_CLK cases in
clk.h, there is no need to have clk code enclosed in #ifdef
CONFIG_HAVE_CLK, #endif macros.

This also fixes error paths of probe(), as a goto is required in this
patch.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@st.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: viresh kumar <viresh.linux@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2b1463dd
...@@ -82,9 +82,7 @@ struct stmmac_priv { ...@@ -82,9 +82,7 @@ struct stmmac_priv {
struct stmmac_counters mmc; struct stmmac_counters mmc;
struct dma_features dma_cap; struct dma_features dma_cap;
int hw_cap_support; int hw_cap_support;
#ifdef CONFIG_HAVE_CLK
struct clk *stmmac_clk; struct clk *stmmac_clk;
#endif
int clk_csr; int clk_csr;
int synopsys_id; int synopsys_id;
struct timer_list eee_ctrl_timer; struct timer_list eee_ctrl_timer;
...@@ -113,46 +111,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, ...@@ -113,46 +111,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
void stmmac_disable_eee_mode(struct stmmac_priv *priv); void stmmac_disable_eee_mode(struct stmmac_priv *priv);
bool stmmac_eee_init(struct stmmac_priv *priv); bool stmmac_eee_init(struct stmmac_priv *priv);
#ifdef CONFIG_HAVE_CLK
static inline int stmmac_clk_enable(struct stmmac_priv *priv)
{
if (!IS_ERR(priv->stmmac_clk))
return clk_prepare_enable(priv->stmmac_clk);
return 0;
}
static inline void stmmac_clk_disable(struct stmmac_priv *priv)
{
if (IS_ERR(priv->stmmac_clk))
return;
clk_disable_unprepare(priv->stmmac_clk);
}
static inline int stmmac_clk_get(struct stmmac_priv *priv)
{
priv->stmmac_clk = clk_get(priv->device, NULL);
if (IS_ERR(priv->stmmac_clk))
return PTR_ERR(priv->stmmac_clk);
return 0;
}
#else
static inline int stmmac_clk_enable(struct stmmac_priv *priv)
{
return 0;
}
static inline void stmmac_clk_disable(struct stmmac_priv *priv)
{
}
static inline int stmmac_clk_get(struct stmmac_priv *priv)
{
return 0;
}
#endif /* CONFIG_HAVE_CLK */
#ifdef CONFIG_STMMAC_PLATFORM #ifdef CONFIG_STMMAC_PLATFORM
extern struct platform_driver stmmac_pltfr_driver; extern struct platform_driver stmmac_pltfr_driver;
static inline int stmmac_register_platform(void) static inline int stmmac_register_platform(void)
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
https://bugzilla.stlinux.com/ https://bugzilla.stlinux.com/
*******************************************************************************/ *******************************************************************************/
#include <linux/clk.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ip.h> #include <linux/ip.h>
...@@ -173,12 +174,8 @@ static void stmmac_verify_args(void) ...@@ -173,12 +174,8 @@ static void stmmac_verify_args(void)
static void stmmac_clk_csr_set(struct stmmac_priv *priv) static void stmmac_clk_csr_set(struct stmmac_priv *priv)
{ {
#ifdef CONFIG_HAVE_CLK
u32 clk_rate; u32 clk_rate;
if (IS_ERR(priv->stmmac_clk))
return;
clk_rate = clk_get_rate(priv->stmmac_clk); clk_rate = clk_get_rate(priv->stmmac_clk);
/* Platform provided default clk_csr would be assumed valid /* Platform provided default clk_csr would be assumed valid
...@@ -200,7 +197,6 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) ...@@ -200,7 +197,6 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
* we can not estimate the proper divider as it is not known * we can not estimate the proper divider as it is not known
* the frequency of clk_csr_i. So we do not change the default * the frequency of clk_csr_i. So we do not change the default
* divider. */ * divider. */
#endif
} }
#if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG)
...@@ -1070,7 +1066,7 @@ static int stmmac_open(struct net_device *dev) ...@@ -1070,7 +1066,7 @@ static int stmmac_open(struct net_device *dev)
} else } else
priv->tm->enable = 1; priv->tm->enable = 1;
#endif #endif
stmmac_clk_enable(priv); clk_enable(priv->stmmac_clk);
stmmac_check_ether_addr(priv); stmmac_check_ether_addr(priv);
...@@ -1192,7 +1188,7 @@ static int stmmac_open(struct net_device *dev) ...@@ -1192,7 +1188,7 @@ static int stmmac_open(struct net_device *dev)
if (priv->phydev) if (priv->phydev)
phy_disconnect(priv->phydev); phy_disconnect(priv->phydev);
stmmac_clk_disable(priv); clk_disable(priv->stmmac_clk);
return ret; return ret;
} }
...@@ -1250,7 +1246,7 @@ static int stmmac_release(struct net_device *dev) ...@@ -1250,7 +1246,7 @@ static int stmmac_release(struct net_device *dev)
#ifdef CONFIG_STMMAC_DEBUG_FS #ifdef CONFIG_STMMAC_DEBUG_FS
stmmac_exit_fs(); stmmac_exit_fs();
#endif #endif
stmmac_clk_disable(priv); clk_disable(priv->stmmac_clk);
return 0; return 0;
} }
...@@ -2078,11 +2074,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, ...@@ -2078,11 +2074,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
ret = register_netdev(ndev); ret = register_netdev(ndev);
if (ret) { if (ret) {
pr_err("%s: ERROR %i registering the device\n", __func__, ret); pr_err("%s: ERROR %i registering the device\n", __func__, ret);
goto error; goto error_netdev_register;
} }
if (stmmac_clk_get(priv)) priv->stmmac_clk = clk_get(priv->device, NULL);
if (IS_ERR(priv->stmmac_clk)) {
pr_warning("%s: warning: cannot get CSR clock\n", __func__); pr_warning("%s: warning: cannot get CSR clock\n", __func__);
goto error_clk_get;
}
/* If a specific clk_csr value is passed from the platform /* If a specific clk_csr value is passed from the platform
* this means that the CSR Clock Range selection cannot be * this means that the CSR Clock Range selection cannot be
...@@ -2100,15 +2099,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, ...@@ -2100,15 +2099,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
if (ret < 0) { if (ret < 0) {
pr_debug("%s: MDIO bus (id: %d) registration failed", pr_debug("%s: MDIO bus (id: %d) registration failed",
__func__, priv->plat->bus_id); __func__, priv->plat->bus_id);
goto error; goto error_mdio_register;
} }
return priv; return priv;
error: error_mdio_register:
netif_napi_del(&priv->napi); clk_put(priv->stmmac_clk);
error_clk_get:
unregister_netdev(ndev); unregister_netdev(ndev);
error_netdev_register:
netif_napi_del(&priv->napi);
free_netdev(ndev); free_netdev(ndev);
return NULL; return NULL;
...@@ -2177,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev) ...@@ -2177,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev)
else { else {
stmmac_set_mac(priv->ioaddr, false); stmmac_set_mac(priv->ioaddr, false);
/* Disable clock in case of PWM is off */ /* Disable clock in case of PWM is off */
stmmac_clk_disable(priv); clk_disable(priv->stmmac_clk);
} }
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
return 0; return 0;
...@@ -2202,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev) ...@@ -2202,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev)
priv->hw->mac->pmt(priv->ioaddr, 0); priv->hw->mac->pmt(priv->ioaddr, 0);
else else
/* enable the clk prevously disabled */ /* enable the clk prevously disabled */
stmmac_clk_enable(priv); clk_enable(priv->stmmac_clk);
netif_device_attach(ndev); netif_device_attach(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment