diff options
author | Ben Dooks <ben-linux@fluff.org> | 2009-11-30 20:24:37 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2010-01-15 03:10:10 -0500 |
commit | b3bf41be06634d69959a68a2b53e1ffc92f0d103 (patch) | |
tree | 7575fc3d60e9a2f99e74b2862e1b3a43b7df1f92 /arch/arm/plat-s3c | |
parent | 13bbd88504bfa0d205fa4121322869d8d7e083d0 (diff) |
ARM: SAMSUNG: Reduce size of struct clk.
Reduce the size of struct clk by 12 bytes and make defining clocks with
common implementation functions easier by moving the set_rate, get_rate,
round_rate and set_parent calls into a new structure called 'struct clk_ops'
and using that instead.
This change does make a few clocks larger as they need their own clk_ops,
but this is outweighed by the number of clocks with either no ops or having
a common set of ops.
Update all the users of this.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c')
-rw-r--r-- | arch/arm/plat-s3c/clock.c | 31 | ||||
-rw-r--r-- | arch/arm/plat-s3c/pwm-clock.c | 94 |
2 files changed, 65 insertions, 60 deletions
diff --git a/arch/arm/plat-s3c/clock.c b/arch/arm/plat-s3c/clock.c index 619cfa82dcab..fa91125c7e0e 100644 --- a/arch/arm/plat-s3c/clock.c +++ b/arch/arm/plat-s3c/clock.c | |||
@@ -150,8 +150,8 @@ unsigned long clk_get_rate(struct clk *clk) | |||
150 | if (clk->rate != 0) | 150 | if (clk->rate != 0) |
151 | return clk->rate; | 151 | return clk->rate; |
152 | 152 | ||
153 | if (clk->get_rate != NULL) | 153 | if (clk->ops != NULL && clk->ops->get_rate != NULL) |
154 | return (clk->get_rate)(clk); | 154 | return (clk->ops->get_rate)(clk); |
155 | 155 | ||
156 | if (clk->parent != NULL) | 156 | if (clk->parent != NULL) |
157 | return clk_get_rate(clk->parent); | 157 | return clk_get_rate(clk->parent); |
@@ -161,8 +161,8 @@ unsigned long clk_get_rate(struct clk *clk) | |||
161 | 161 | ||
162 | long clk_round_rate(struct clk *clk, unsigned long rate) | 162 | long clk_round_rate(struct clk *clk, unsigned long rate) |
163 | { | 163 | { |
164 | if (!IS_ERR(clk) && clk->round_rate) | 164 | if (!IS_ERR(clk) && clk->ops && clk->ops->round_rate) |
165 | return (clk->round_rate)(clk, rate); | 165 | return (clk->ops->round_rate)(clk, rate); |
166 | 166 | ||
167 | return rate; | 167 | return rate; |
168 | } | 168 | } |
@@ -178,13 +178,14 @@ int clk_set_rate(struct clk *clk, unsigned long rate) | |||
178 | * the clock may have been made this way by choice. | 178 | * the clock may have been made this way by choice. |
179 | */ | 179 | */ |
180 | 180 | ||
181 | WARN_ON(clk->set_rate == NULL); | 181 | WARN_ON(clk->ops == NULL); |
182 | WARN_ON(clk->ops && clk->ops->set_rate == NULL); | ||
182 | 183 | ||
183 | if (clk->set_rate == NULL) | 184 | if (clk->ops == NULL || clk->ops->set_rate == NULL) |
184 | return -EINVAL; | 185 | return -EINVAL; |
185 | 186 | ||
186 | spin_lock(&clocks_lock); | 187 | spin_lock(&clocks_lock); |
187 | ret = (clk->set_rate)(clk, rate); | 188 | ret = (clk->ops->set_rate)(clk, rate); |
188 | spin_unlock(&clocks_lock); | 189 | spin_unlock(&clocks_lock); |
189 | 190 | ||
190 | return ret; | 191 | return ret; |
@@ -204,8 +205,8 @@ int clk_set_parent(struct clk *clk, struct clk *parent) | |||
204 | 205 | ||
205 | spin_lock(&clocks_lock); | 206 | spin_lock(&clocks_lock); |
206 | 207 | ||
207 | if (clk->set_parent) | 208 | if (clk->ops && clk->ops->set_parent) |
208 | ret = (clk->set_parent)(clk, parent); | 209 | ret = (clk->ops->set_parent)(clk, parent); |
209 | 210 | ||
210 | spin_unlock(&clocks_lock); | 211 | spin_unlock(&clocks_lock); |
211 | 212 | ||
@@ -230,6 +231,10 @@ static int clk_default_setrate(struct clk *clk, unsigned long rate) | |||
230 | return 0; | 231 | return 0; |
231 | } | 232 | } |
232 | 233 | ||
234 | static struct clk_ops clk_ops_def_setrate = { | ||
235 | .set_rate = clk_default_setrate, | ||
236 | }; | ||
237 | |||
233 | struct clk clk_xtal = { | 238 | struct clk clk_xtal = { |
234 | .name = "xtal", | 239 | .name = "xtal", |
235 | .id = -1, | 240 | .id = -1, |
@@ -251,7 +256,7 @@ struct clk clk_epll = { | |||
251 | struct clk clk_mpll = { | 256 | struct clk clk_mpll = { |
252 | .name = "mpll", | 257 | .name = "mpll", |
253 | .id = -1, | 258 | .id = -1, |
254 | .set_rate = clk_default_setrate, | 259 | .ops = &clk_ops_def_setrate, |
255 | }; | 260 | }; |
256 | 261 | ||
257 | struct clk clk_upll = { | 262 | struct clk clk_upll = { |
@@ -267,7 +272,6 @@ struct clk clk_f = { | |||
267 | .rate = 0, | 272 | .rate = 0, |
268 | .parent = &clk_mpll, | 273 | .parent = &clk_mpll, |
269 | .ctrlbit = 0, | 274 | .ctrlbit = 0, |
270 | .set_rate = clk_default_setrate, | ||
271 | }; | 275 | }; |
272 | 276 | ||
273 | struct clk clk_h = { | 277 | struct clk clk_h = { |
@@ -276,7 +280,7 @@ struct clk clk_h = { | |||
276 | .rate = 0, | 280 | .rate = 0, |
277 | .parent = NULL, | 281 | .parent = NULL, |
278 | .ctrlbit = 0, | 282 | .ctrlbit = 0, |
279 | .set_rate = clk_default_setrate, | 283 | .ops = &clk_ops_def_setrate, |
280 | }; | 284 | }; |
281 | 285 | ||
282 | struct clk clk_p = { | 286 | struct clk clk_p = { |
@@ -285,7 +289,7 @@ struct clk clk_p = { | |||
285 | .rate = 0, | 289 | .rate = 0, |
286 | .parent = NULL, | 290 | .parent = NULL, |
287 | .ctrlbit = 0, | 291 | .ctrlbit = 0, |
288 | .set_rate = clk_default_setrate, | 292 | .ops = &clk_ops_def_setrate, |
289 | }; | 293 | }; |
290 | 294 | ||
291 | struct clk clk_usb_bus = { | 295 | struct clk clk_usb_bus = { |
@@ -296,7 +300,6 @@ struct clk clk_usb_bus = { | |||
296 | }; | 300 | }; |
297 | 301 | ||
298 | 302 | ||
299 | |||
300 | struct clk s3c24xx_uclk = { | 303 | struct clk s3c24xx_uclk = { |
301 | .name = "uclk", | 304 | .name = "uclk", |
302 | .id = -1, | 305 | .id = -1, |
diff --git a/arch/arm/plat-s3c/pwm-clock.c b/arch/arm/plat-s3c/pwm-clock.c index a318215ab535..1808fa88609a 100644 --- a/arch/arm/plat-s3c/pwm-clock.c +++ b/arch/arm/plat-s3c/pwm-clock.c | |||
@@ -130,20 +130,22 @@ static int clk_pwm_scaler_set_rate(struct clk *clk, unsigned long rate) | |||
130 | return 0; | 130 | return 0; |
131 | } | 131 | } |
132 | 132 | ||
133 | static struct clk_ops clk_pwm_scaler_ops = { | ||
134 | .get_rate = clk_pwm_scaler_get_rate, | ||
135 | .set_rate = clk_pwm_scaler_set_rate, | ||
136 | .round_rate = clk_pwm_scaler_round_rate, | ||
137 | }; | ||
138 | |||
133 | static struct clk clk_timer_scaler[] = { | 139 | static struct clk clk_timer_scaler[] = { |
134 | [0] = { | 140 | [0] = { |
135 | .name = "pwm-scaler0", | 141 | .name = "pwm-scaler0", |
136 | .id = -1, | 142 | .id = -1, |
137 | .get_rate = clk_pwm_scaler_get_rate, | 143 | .ops = &clk_pwm_scaler_ops, |
138 | .set_rate = clk_pwm_scaler_set_rate, | ||
139 | .round_rate = clk_pwm_scaler_round_rate, | ||
140 | }, | 144 | }, |
141 | [1] = { | 145 | [1] = { |
142 | .name = "pwm-scaler1", | 146 | .name = "pwm-scaler1", |
143 | .id = -1, | 147 | .id = -1, |
144 | .get_rate = clk_pwm_scaler_get_rate, | 148 | .ops = &clk_pwm_scaler_ops, |
145 | .set_rate = clk_pwm_scaler_set_rate, | ||
146 | .round_rate = clk_pwm_scaler_round_rate, | ||
147 | }, | 149 | }, |
148 | }; | 150 | }; |
149 | 151 | ||
@@ -256,50 +258,46 @@ static int clk_pwm_tdiv_set_rate(struct clk *clk, unsigned long rate) | |||
256 | return 0; | 258 | return 0; |
257 | } | 259 | } |
258 | 260 | ||
261 | static struct clk_ops clk_tdiv_ops = { | ||
262 | .get_rate = clk_pwm_tdiv_get_rate, | ||
263 | .set_rate = clk_pwm_tdiv_set_rate, | ||
264 | .round_rate = clk_pwm_tdiv_round_rate, | ||
265 | }; | ||
266 | |||
259 | static struct pwm_tdiv_clk clk_timer_tdiv[] = { | 267 | static struct pwm_tdiv_clk clk_timer_tdiv[] = { |
260 | [0] = { | 268 | [0] = { |
261 | .clk = { | 269 | .clk = { |
262 | .name = "pwm-tdiv", | 270 | .name = "pwm-tdiv", |
263 | .parent = &clk_timer_scaler[0], | 271 | .ops = &clk_tdiv_ops, |
264 | .get_rate = clk_pwm_tdiv_get_rate, | 272 | .parent = &clk_timer_scaler[0], |
265 | .set_rate = clk_pwm_tdiv_set_rate, | ||
266 | .round_rate = clk_pwm_tdiv_round_rate, | ||
267 | }, | 273 | }, |
268 | }, | 274 | }, |
269 | [1] = { | 275 | [1] = { |
270 | .clk = { | 276 | .clk = { |
271 | .name = "pwm-tdiv", | 277 | .name = "pwm-tdiv", |
272 | .parent = &clk_timer_scaler[0], | 278 | .ops = &clk_tdiv_ops, |
273 | .get_rate = clk_pwm_tdiv_get_rate, | 279 | .parent = &clk_timer_scaler[0], |
274 | .set_rate = clk_pwm_tdiv_set_rate, | ||
275 | .round_rate = clk_pwm_tdiv_round_rate, | ||
276 | } | 280 | } |
277 | }, | 281 | }, |
278 | [2] = { | 282 | [2] = { |
279 | .clk = { | 283 | .clk = { |
280 | .name = "pwm-tdiv", | 284 | .name = "pwm-tdiv", |
281 | .parent = &clk_timer_scaler[1], | 285 | .ops = &clk_tdiv_ops, |
282 | .get_rate = clk_pwm_tdiv_get_rate, | 286 | .parent = &clk_timer_scaler[1], |
283 | .set_rate = clk_pwm_tdiv_set_rate, | ||
284 | .round_rate = clk_pwm_tdiv_round_rate, | ||
285 | }, | 287 | }, |
286 | }, | 288 | }, |
287 | [3] = { | 289 | [3] = { |
288 | .clk = { | 290 | .clk = { |
289 | .name = "pwm-tdiv", | 291 | .name = "pwm-tdiv", |
290 | .parent = &clk_timer_scaler[1], | 292 | .ops = &clk_tdiv_ops, |
291 | .get_rate = clk_pwm_tdiv_get_rate, | 293 | .parent = &clk_timer_scaler[1], |
292 | .set_rate = clk_pwm_tdiv_set_rate, | ||
293 | .round_rate = clk_pwm_tdiv_round_rate, | ||
294 | }, | 294 | }, |
295 | }, | 295 | }, |
296 | [4] = { | 296 | [4] = { |
297 | .clk = { | 297 | .clk = { |
298 | .name = "pwm-tdiv", | 298 | .name = "pwm-tdiv", |
299 | .parent = &clk_timer_scaler[1], | 299 | .ops = &clk_tdiv_ops, |
300 | .get_rate = clk_pwm_tdiv_get_rate, | 300 | .parent = &clk_timer_scaler[1], |
301 | .set_rate = clk_pwm_tdiv_set_rate, | ||
302 | .round_rate = clk_pwm_tdiv_round_rate, | ||
303 | }, | 301 | }, |
304 | }, | 302 | }, |
305 | }; | 303 | }; |
@@ -356,31 +354,35 @@ static int clk_pwm_tin_set_parent(struct clk *clk, struct clk *parent) | |||
356 | return 0; | 354 | return 0; |
357 | } | 355 | } |
358 | 356 | ||
357 | static struct clk_ops clk_tin_ops = { | ||
358 | .set_parent = clk_pwm_tin_set_parent, | ||
359 | }; | ||
360 | |||
359 | static struct clk clk_tin[] = { | 361 | static struct clk clk_tin[] = { |
360 | [0] = { | 362 | [0] = { |
361 | .name = "pwm-tin", | 363 | .name = "pwm-tin", |
362 | .id = 0, | 364 | .id = 0, |
363 | .set_parent = clk_pwm_tin_set_parent, | 365 | .ops = &clk_tin_ops, |
364 | }, | 366 | }, |
365 | [1] = { | 367 | [1] = { |
366 | .name = "pwm-tin", | 368 | .name = "pwm-tin", |
367 | .id = 1, | 369 | .id = 1, |
368 | .set_parent = clk_pwm_tin_set_parent, | 370 | .ops = &clk_tin_ops, |
369 | }, | 371 | }, |
370 | [2] = { | 372 | [2] = { |
371 | .name = "pwm-tin", | 373 | .name = "pwm-tin", |
372 | .id = 2, | 374 | .id = 2, |
373 | .set_parent = clk_pwm_tin_set_parent, | 375 | .ops = &clk_tin_ops, |
374 | }, | 376 | }, |
375 | [3] = { | 377 | [3] = { |
376 | .name = "pwm-tin", | 378 | .name = "pwm-tin", |
377 | .id = 3, | 379 | .id = 3, |
378 | .set_parent = clk_pwm_tin_set_parent, | 380 | .ops = &clk_tin_ops, |
379 | }, | 381 | }, |
380 | [4] = { | 382 | [4] = { |
381 | .name = "pwm-tin", | 383 | .name = "pwm-tin", |
382 | .id = 4, | 384 | .id = 4, |
383 | .set_parent = clk_pwm_tin_set_parent, | 385 | .ops = &clk_tin_ops, |
384 | }, | 386 | }, |
385 | }; | 387 | }; |
386 | 388 | ||