diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2012-07-30 17:39:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:12 -0400 |
commit | 6a81c26f868b2fc5f88b9f78a6f82aeab1191e61 (patch) | |
tree | 2b800023f0401613a856650adcdaf5c3d85f5638 /drivers/net | |
parent | 2b1463ddde35a720de2fb4013057396e7f8011f0 (diff) |
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: Viresh Kumar <viresh.kumar@st.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Acked-by: David 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac.h | 42 | ||||
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 33 |
2 files changed, 17 insertions, 58 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index ab4c376cb276..f2d3665430ad 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h | |||
@@ -82,9 +82,7 @@ struct stmmac_priv { | |||
82 | struct stmmac_counters mmc; | 82 | struct stmmac_counters mmc; |
83 | struct dma_features dma_cap; | 83 | struct dma_features dma_cap; |
84 | int hw_cap_support; | 84 | int hw_cap_support; |
85 | #ifdef CONFIG_HAVE_CLK | ||
86 | struct clk *stmmac_clk; | 85 | struct clk *stmmac_clk; |
87 | #endif | ||
88 | int clk_csr; | 86 | int clk_csr; |
89 | int synopsys_id; | 87 | int synopsys_id; |
90 | struct timer_list eee_ctrl_timer; | 88 | struct timer_list eee_ctrl_timer; |
@@ -113,46 +111,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
113 | void stmmac_disable_eee_mode(struct stmmac_priv *priv); | 111 | void stmmac_disable_eee_mode(struct stmmac_priv *priv); |
114 | bool stmmac_eee_init(struct stmmac_priv *priv); | 112 | bool stmmac_eee_init(struct stmmac_priv *priv); |
115 | 113 | ||
116 | #ifdef CONFIG_HAVE_CLK | ||
117 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) | ||
118 | { | ||
119 | if (!IS_ERR(priv->stmmac_clk)) | ||
120 | return clk_prepare_enable(priv->stmmac_clk); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static inline void stmmac_clk_disable(struct stmmac_priv *priv) | ||
126 | { | ||
127 | if (IS_ERR(priv->stmmac_clk)) | ||
128 | return; | ||
129 | |||
130 | clk_disable_unprepare(priv->stmmac_clk); | ||
131 | } | ||
132 | static inline int stmmac_clk_get(struct stmmac_priv *priv) | ||
133 | { | ||
134 | priv->stmmac_clk = clk_get(priv->device, NULL); | ||
135 | |||
136 | if (IS_ERR(priv->stmmac_clk)) | ||
137 | return PTR_ERR(priv->stmmac_clk); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | #else | ||
142 | static inline int stmmac_clk_enable(struct stmmac_priv *priv) | ||
143 | { | ||
144 | return 0; | ||
145 | } | ||
146 | static inline void stmmac_clk_disable(struct stmmac_priv *priv) | ||
147 | { | ||
148 | } | ||
149 | static inline int stmmac_clk_get(struct stmmac_priv *priv) | ||
150 | { | ||
151 | return 0; | ||
152 | } | ||
153 | #endif /* CONFIG_HAVE_CLK */ | ||
154 | |||
155 | |||
156 | #ifdef CONFIG_STMMAC_PLATFORM | 114 | #ifdef CONFIG_STMMAC_PLATFORM |
157 | extern struct platform_driver stmmac_pltfr_driver; | 115 | extern struct platform_driver stmmac_pltfr_driver; |
158 | static inline int stmmac_register_platform(void) | 116 | static inline int stmmac_register_platform(void) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f6b04c1a3672..fd8882f9602a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -28,6 +28,7 @@ | |||
28 | https://bugzilla.stlinux.com/ | 28 | https://bugzilla.stlinux.com/ |
29 | *******************************************************************************/ | 29 | *******************************************************************************/ |
30 | 30 | ||
31 | #include <linux/clk.h> | ||
31 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
32 | #include <linux/interrupt.h> | 33 | #include <linux/interrupt.h> |
33 | #include <linux/ip.h> | 34 | #include <linux/ip.h> |
@@ -173,12 +174,8 @@ static void stmmac_verify_args(void) | |||
173 | 174 | ||
174 | static void stmmac_clk_csr_set(struct stmmac_priv *priv) | 175 | static void stmmac_clk_csr_set(struct stmmac_priv *priv) |
175 | { | 176 | { |
176 | #ifdef CONFIG_HAVE_CLK | ||
177 | u32 clk_rate; | 177 | u32 clk_rate; |
178 | 178 | ||
179 | if (IS_ERR(priv->stmmac_clk)) | ||
180 | return; | ||
181 | |||
182 | clk_rate = clk_get_rate(priv->stmmac_clk); | 179 | clk_rate = clk_get_rate(priv->stmmac_clk); |
183 | 180 | ||
184 | /* Platform provided default clk_csr would be assumed valid | 181 | /* Platform provided default clk_csr would be assumed valid |
@@ -200,7 +197,6 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) | |||
200 | * we can not estimate the proper divider as it is not known | 197 | * we can not estimate the proper divider as it is not known |
201 | * the frequency of clk_csr_i. So we do not change the default | 198 | * the frequency of clk_csr_i. So we do not change the default |
202 | * divider. */ | 199 | * divider. */ |
203 | #endif | ||
204 | } | 200 | } |
205 | 201 | ||
206 | #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) | 202 | #if defined(STMMAC_XMIT_DEBUG) || defined(STMMAC_RX_DEBUG) |
@@ -1070,7 +1066,7 @@ static int stmmac_open(struct net_device *dev) | |||
1070 | } else | 1066 | } else |
1071 | priv->tm->enable = 1; | 1067 | priv->tm->enable = 1; |
1072 | #endif | 1068 | #endif |
1073 | stmmac_clk_enable(priv); | 1069 | clk_enable(priv->stmmac_clk); |
1074 | 1070 | ||
1075 | stmmac_check_ether_addr(priv); | 1071 | stmmac_check_ether_addr(priv); |
1076 | 1072 | ||
@@ -1192,7 +1188,7 @@ open_error: | |||
1192 | if (priv->phydev) | 1188 | if (priv->phydev) |
1193 | phy_disconnect(priv->phydev); | 1189 | phy_disconnect(priv->phydev); |
1194 | 1190 | ||
1195 | stmmac_clk_disable(priv); | 1191 | clk_disable(priv->stmmac_clk); |
1196 | 1192 | ||
1197 | return ret; | 1193 | return ret; |
1198 | } | 1194 | } |
@@ -1250,7 +1246,7 @@ static int stmmac_release(struct net_device *dev) | |||
1250 | #ifdef CONFIG_STMMAC_DEBUG_FS | 1246 | #ifdef CONFIG_STMMAC_DEBUG_FS |
1251 | stmmac_exit_fs(); | 1247 | stmmac_exit_fs(); |
1252 | #endif | 1248 | #endif |
1253 | stmmac_clk_disable(priv); | 1249 | clk_disable(priv->stmmac_clk); |
1254 | 1250 | ||
1255 | return 0; | 1251 | return 0; |
1256 | } | 1252 | } |
@@ -2078,11 +2074,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
2078 | ret = register_netdev(ndev); | 2074 | ret = register_netdev(ndev); |
2079 | if (ret) { | 2075 | if (ret) { |
2080 | pr_err("%s: ERROR %i registering the device\n", __func__, ret); | 2076 | pr_err("%s: ERROR %i registering the device\n", __func__, ret); |
2081 | goto error; | 2077 | goto error_netdev_register; |
2082 | } | 2078 | } |
2083 | 2079 | ||
2084 | if (stmmac_clk_get(priv)) | 2080 | priv->stmmac_clk = clk_get(priv->device, NULL); |
2081 | if (IS_ERR(priv->stmmac_clk)) { | ||
2085 | pr_warning("%s: warning: cannot get CSR clock\n", __func__); | 2082 | pr_warning("%s: warning: cannot get CSR clock\n", __func__); |
2083 | goto error_clk_get; | ||
2084 | } | ||
2086 | 2085 | ||
2087 | /* If a specific clk_csr value is passed from the platform | 2086 | /* If a specific clk_csr value is passed from the platform |
2088 | * this means that the CSR Clock Range selection cannot be | 2087 | * this means that the CSR Clock Range selection cannot be |
@@ -2100,15 +2099,17 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, | |||
2100 | if (ret < 0) { | 2099 | if (ret < 0) { |
2101 | pr_debug("%s: MDIO bus (id: %d) registration failed", | 2100 | pr_debug("%s: MDIO bus (id: %d) registration failed", |
2102 | __func__, priv->plat->bus_id); | 2101 | __func__, priv->plat->bus_id); |
2103 | goto error; | 2102 | goto error_mdio_register; |
2104 | } | 2103 | } |
2105 | 2104 | ||
2106 | return priv; | 2105 | return priv; |
2107 | 2106 | ||
2108 | error: | 2107 | error_mdio_register: |
2109 | netif_napi_del(&priv->napi); | 2108 | clk_put(priv->stmmac_clk); |
2110 | 2109 | error_clk_get: | |
2111 | unregister_netdev(ndev); | 2110 | unregister_netdev(ndev); |
2111 | error_netdev_register: | ||
2112 | netif_napi_del(&priv->napi); | ||
2112 | free_netdev(ndev); | 2113 | free_netdev(ndev); |
2113 | 2114 | ||
2114 | return NULL; | 2115 | return NULL; |
@@ -2177,7 +2178,7 @@ int stmmac_suspend(struct net_device *ndev) | |||
2177 | else { | 2178 | else { |
2178 | stmmac_set_mac(priv->ioaddr, false); | 2179 | stmmac_set_mac(priv->ioaddr, false); |
2179 | /* Disable clock in case of PWM is off */ | 2180 | /* Disable clock in case of PWM is off */ |
2180 | stmmac_clk_disable(priv); | 2181 | clk_disable(priv->stmmac_clk); |
2181 | } | 2182 | } |
2182 | spin_unlock_irqrestore(&priv->lock, flags); | 2183 | spin_unlock_irqrestore(&priv->lock, flags); |
2183 | return 0; | 2184 | return 0; |
@@ -2202,7 +2203,7 @@ int stmmac_resume(struct net_device *ndev) | |||
2202 | priv->hw->mac->pmt(priv->ioaddr, 0); | 2203 | priv->hw->mac->pmt(priv->ioaddr, 0); |
2203 | else | 2204 | else |
2204 | /* enable the clk prevously disabled */ | 2205 | /* enable the clk prevously disabled */ |
2205 | stmmac_clk_enable(priv); | 2206 | clk_enable(priv->stmmac_clk); |
2206 | 2207 | ||
2207 | netif_device_attach(ndev); | 2208 | netif_device_attach(ndev); |
2208 | 2209 | ||