Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 1 | /* |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 2 | * drivers/clk/clkdev.c |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2008 Russell King. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * Helper for the clk API to assist looking up a struct clk. |
| 11 | */ |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/device.h> |
| 15 | #include <linux/list.h> |
| 16 | #include <linux/errno.h> |
| 17 | #include <linux/err.h> |
| 18 | #include <linux/string.h> |
| 19 | #include <linux/mutex.h> |
Hartley Sweeten | c0c60c4 | 2009-08-04 23:38:06 +0100 | [diff] [blame] | 20 | #include <linux/clk.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 21 | #include <linux/clkdev.h> |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 22 | #include <linux/clk-provider.h> |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 23 | #include <linux/of.h> |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 24 | |
Sylwester Nawrocki | 3a3d2b0 | 2013-08-23 17:03:44 +0200 | [diff] [blame] | 25 | #include "clk.h" |
| 26 | |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 27 | static LIST_HEAD(clocks); |
| 28 | static DEFINE_MUTEX(clocks_mutex); |
| 29 | |
Rob Herring | 137f8a7 | 2012-07-18 11:52:23 +0800 | [diff] [blame] | 30 | #if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) |
Sylwester Nawrocki | 7f05e28 | 2014-05-19 19:22:50 +0200 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * of_clk_get_by_clkspec() - Lookup a clock form a clock provider |
| 34 | * @clkspec: pointer to a clock specifier data structure |
| 35 | * |
| 36 | * This function looks up a struct clk from the registered list of clock |
| 37 | * providers, an input is a clock specifier data structure as returned |
| 38 | * from the of_parse_phandle_with_args() function call. |
| 39 | */ |
| 40 | struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec) |
| 41 | { |
| 42 | struct clk *clk; |
| 43 | |
| 44 | if (!clkspec) |
| 45 | return ERR_PTR(-EINVAL); |
| 46 | |
| 47 | of_clk_lock(); |
| 48 | clk = __of_clk_get_from_provider(clkspec); |
| 49 | |
| 50 | if (!IS_ERR(clk) && !__clk_get(clk)) |
| 51 | clk = ERR_PTR(-ENOENT); |
| 52 | |
| 53 | of_clk_unlock(); |
| 54 | return clk; |
| 55 | } |
| 56 | |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 57 | static struct clk *__of_clk_get(struct device_node *np, int index) |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 58 | { |
| 59 | struct of_phandle_args clkspec; |
| 60 | struct clk *clk; |
| 61 | int rc; |
| 62 | |
| 63 | if (index < 0) |
| 64 | return ERR_PTR(-EINVAL); |
| 65 | |
| 66 | rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, |
| 67 | &clkspec); |
| 68 | if (rc) |
| 69 | return ERR_PTR(rc); |
| 70 | |
Sylwester Nawrocki | 7f05e28 | 2014-05-19 19:22:50 +0200 | [diff] [blame] | 71 | clk = of_clk_get_by_clkspec(&clkspec); |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 72 | of_node_put(clkspec.np); |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 73 | |
| 74 | return clk; |
| 75 | } |
| 76 | |
| 77 | struct clk *of_clk_get(struct device_node *np, int index) |
| 78 | { |
| 79 | struct clk *clk = __of_clk_get(np, index); |
| 80 | |
| 81 | if (!IS_ERR(clk)) |
| 82 | clk = __clk_create_clk(__clk_get_hw(clk), np->full_name, NULL); |
| 83 | |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 84 | return clk; |
| 85 | } |
| 86 | EXPORT_SYMBOL(of_clk_get); |
| 87 | |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 88 | static struct clk *__of_clk_get_by_name(struct device_node *np, |
| 89 | const char *dev_id, |
| 90 | const char *name) |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 91 | { |
| 92 | struct clk *clk = ERR_PTR(-ENOENT); |
| 93 | |
| 94 | /* Walk up the tree of devices looking for a clock that matches */ |
| 95 | while (np) { |
| 96 | int index = 0; |
| 97 | |
| 98 | /* |
| 99 | * For named clocks, first look up the name in the |
| 100 | * "clock-names" property. If it cannot be found, then |
| 101 | * index will be an error code, and of_clk_get() will fail. |
| 102 | */ |
| 103 | if (name) |
| 104 | index = of_property_match_string(np, "clock-names", name); |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 105 | clk = __of_clk_get(np, index); |
| 106 | if (!IS_ERR(clk)) { |
| 107 | clk = __clk_create_clk(__clk_get_hw(clk), dev_id, name); |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 108 | break; |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 109 | } |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 110 | else if (name && index >= 0) { |
Stephen Boyd | d8e53c3 | 2014-06-13 16:36:31 -0700 | [diff] [blame] | 111 | if (PTR_ERR(clk) != -EPROBE_DEFER) |
| 112 | pr_err("ERROR: could not get clock %s:%s(%i)\n", |
| 113 | np->full_name, name ? name : "", index); |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 114 | return clk; |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * No matching clock found on this node. If the parent node |
| 119 | * has a "clock-ranges" property, then we can try one of its |
| 120 | * clocks. |
| 121 | */ |
| 122 | np = np->parent; |
| 123 | if (np && !of_get_property(np, "clock-ranges", NULL)) |
| 124 | break; |
| 125 | } |
| 126 | |
| 127 | return clk; |
| 128 | } |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node |
| 132 | * @np: pointer to clock consumer node |
| 133 | * @name: name of consumer's clock input, or NULL for the first clock reference |
| 134 | * |
| 135 | * This function parses the clocks and clock-names properties, |
| 136 | * and uses them to look up the struct clk from the registered list of clock |
| 137 | * providers. |
| 138 | */ |
| 139 | struct clk *of_clk_get_by_name(struct device_node *np, const char *name) |
| 140 | { |
| 141 | if (!np) |
| 142 | return ERR_PTR(-ENOENT); |
| 143 | |
| 144 | return __of_clk_get_by_name(np, np->full_name, name); |
| 145 | } |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 146 | EXPORT_SYMBOL(of_clk_get_by_name); |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 147 | |
| 148 | #else /* defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) */ |
| 149 | |
| 150 | static struct clk *__of_clk_get_by_name(struct device_node *np, |
| 151 | const char *dev_id, |
| 152 | const char *name) |
| 153 | { |
| 154 | return ERR_PTR(-ENOENT); |
| 155 | } |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 156 | #endif |
| 157 | |
Russell King | 409dc36 | 2009-01-24 10:14:37 +0000 | [diff] [blame] | 158 | /* |
| 159 | * Find the correct struct clk for the device and connection ID. |
| 160 | * We do slightly fuzzy matching here: |
| 161 | * An entry with a NULL ID is assumed to be a wildcard. |
| 162 | * If an entry has a device ID, it must match |
| 163 | * If an entry has a connection ID, it must match |
| 164 | * Then we take the most specific entry - with the following |
Uwe Kleine-König | 659431f | 2010-01-18 16:02:48 +0100 | [diff] [blame] | 165 | * order of precedence: dev+con > dev only > con only. |
Russell King | 409dc36 | 2009-01-24 10:14:37 +0000 | [diff] [blame] | 166 | */ |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 167 | static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 168 | { |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 169 | struct clk_lookup *p, *cl = NULL; |
viresh kumar | 67b5087 | 2012-04-19 04:23:25 +0100 | [diff] [blame] | 170 | int match, best_found = 0, best_possible = 0; |
| 171 | |
| 172 | if (dev_id) |
| 173 | best_possible += 2; |
| 174 | if (con_id) |
| 175 | best_possible += 1; |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 176 | |
| 177 | list_for_each_entry(p, &clocks, node) { |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 178 | match = 0; |
Russell King | 409dc36 | 2009-01-24 10:14:37 +0000 | [diff] [blame] | 179 | if (p->dev_id) { |
| 180 | if (!dev_id || strcmp(p->dev_id, dev_id)) |
| 181 | continue; |
| 182 | match += 2; |
| 183 | } |
| 184 | if (p->con_id) { |
| 185 | if (!con_id || strcmp(p->con_id, con_id)) |
| 186 | continue; |
| 187 | match += 1; |
| 188 | } |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 189 | |
viresh kumar | 67b5087 | 2012-04-19 04:23:25 +0100 | [diff] [blame] | 190 | if (match > best_found) { |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 191 | cl = p; |
viresh kumar | 67b5087 | 2012-04-19 04:23:25 +0100 | [diff] [blame] | 192 | if (match != best_possible) |
| 193 | best_found = match; |
viresh kumar | e4bf5be | 2010-03-09 11:54:30 +0100 | [diff] [blame] | 194 | else |
| 195 | break; |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 196 | } |
| 197 | } |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 198 | return cl; |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 199 | } |
| 200 | |
Sascha Hauer | 05fd8e73 | 2009-03-07 12:55:49 +0100 | [diff] [blame] | 201 | struct clk *clk_get_sys(const char *dev_id, const char *con_id) |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 202 | { |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 203 | struct clk_lookup *cl; |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 204 | struct clk *clk = NULL; |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 205 | |
| 206 | mutex_lock(&clocks_mutex); |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 207 | |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 208 | cl = clk_find(dev_id, con_id); |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 209 | if (!cl) |
| 210 | goto out; |
| 211 | |
| 212 | if (!__clk_get(cl->clk)) { |
Russell King | e8bf8df | 2011-04-30 10:14:08 +0100 | [diff] [blame] | 213 | cl = NULL; |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 214 | goto out; |
| 215 | } |
| 216 | |
| 217 | #if defined(CONFIG_COMMON_CLK) |
| 218 | clk = __clk_create_clk(__clk_get_hw(cl->clk), dev_id, con_id); |
| 219 | #else |
| 220 | clk = cl->clk; |
| 221 | #endif |
| 222 | |
| 223 | out: |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 224 | mutex_unlock(&clocks_mutex); |
| 225 | |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 226 | return cl ? clk : ERR_PTR(-ENOENT); |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 227 | } |
Sascha Hauer | 05fd8e73 | 2009-03-07 12:55:49 +0100 | [diff] [blame] | 228 | EXPORT_SYMBOL(clk_get_sys); |
| 229 | |
| 230 | struct clk *clk_get(struct device *dev, const char *con_id) |
| 231 | { |
| 232 | const char *dev_id = dev ? dev_name(dev) : NULL; |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 233 | struct clk *clk; |
| 234 | |
| 235 | if (dev) { |
Tomeu Vizoso | 035a61c | 2015-01-23 12:03:30 +0100 | [diff] [blame] | 236 | clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id); |
| 237 | if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER) |
Jean-Francois Moine | a34cd46 | 2013-11-25 19:47:04 +0100 | [diff] [blame] | 238 | return clk; |
Grant Likely | 766e6a4 | 2012-04-09 14:50:06 -0500 | [diff] [blame] | 239 | } |
Sascha Hauer | 05fd8e73 | 2009-03-07 12:55:49 +0100 | [diff] [blame] | 240 | |
| 241 | return clk_get_sys(dev_id, con_id); |
| 242 | } |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 243 | EXPORT_SYMBOL(clk_get); |
| 244 | |
| 245 | void clk_put(struct clk *clk) |
| 246 | { |
| 247 | __clk_put(clk); |
| 248 | } |
| 249 | EXPORT_SYMBOL(clk_put); |
| 250 | |
| 251 | void clkdev_add(struct clk_lookup *cl) |
| 252 | { |
| 253 | mutex_lock(&clocks_mutex); |
| 254 | list_add_tail(&cl->node, &clocks); |
| 255 | mutex_unlock(&clocks_mutex); |
| 256 | } |
| 257 | EXPORT_SYMBOL(clkdev_add); |
| 258 | |
Russell King | 0a0300d | 2010-01-12 12:28:00 +0000 | [diff] [blame] | 259 | void __init clkdev_add_table(struct clk_lookup *cl, size_t num) |
| 260 | { |
| 261 | mutex_lock(&clocks_mutex); |
| 262 | while (num--) { |
| 263 | list_add_tail(&cl->node, &clocks); |
| 264 | cl++; |
| 265 | } |
| 266 | mutex_unlock(&clocks_mutex); |
| 267 | } |
| 268 | |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 269 | #define MAX_DEV_ID 20 |
| 270 | #define MAX_CON_ID 16 |
| 271 | |
| 272 | struct clk_lookup_alloc { |
| 273 | struct clk_lookup cl; |
| 274 | char dev_id[MAX_DEV_ID]; |
| 275 | char con_id[MAX_CON_ID]; |
| 276 | }; |
| 277 | |
Russell King | e9d7f40 | 2012-05-02 09:30:32 +0100 | [diff] [blame] | 278 | static struct clk_lookup * __init_refok |
| 279 | vclkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, |
| 280 | va_list ap) |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 281 | { |
| 282 | struct clk_lookup_alloc *cla; |
| 283 | |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 284 | cla = __clkdev_alloc(sizeof(*cla)); |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 285 | if (!cla) |
| 286 | return NULL; |
| 287 | |
| 288 | cla->cl.clk = clk; |
| 289 | if (con_id) { |
| 290 | strlcpy(cla->con_id, con_id, sizeof(cla->con_id)); |
| 291 | cla->cl.con_id = cla->con_id; |
| 292 | } |
| 293 | |
| 294 | if (dev_fmt) { |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 295 | vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap); |
| 296 | cla->cl.dev_id = cla->dev_id; |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | return &cla->cl; |
| 300 | } |
Russell King | e9d7f40 | 2012-05-02 09:30:32 +0100 | [diff] [blame] | 301 | |
| 302 | struct clk_lookup * __init_refok |
| 303 | clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...) |
| 304 | { |
| 305 | struct clk_lookup *cl; |
| 306 | va_list ap; |
| 307 | |
| 308 | va_start(ap, dev_fmt); |
| 309 | cl = vclkdev_alloc(clk, con_id, dev_fmt, ap); |
| 310 | va_end(ap); |
| 311 | |
| 312 | return cl; |
| 313 | } |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 314 | EXPORT_SYMBOL(clkdev_alloc); |
| 315 | |
Tony Lindgren | c068303 | 2009-06-03 17:43:14 +0100 | [diff] [blame] | 316 | int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, |
| 317 | struct device *dev) |
| 318 | { |
| 319 | struct clk *r = clk_get(dev, id); |
| 320 | struct clk_lookup *l; |
| 321 | |
| 322 | if (IS_ERR(r)) |
| 323 | return PTR_ERR(r); |
| 324 | |
| 325 | l = clkdev_alloc(r, alias, alias_dev_name); |
| 326 | clk_put(r); |
| 327 | if (!l) |
| 328 | return -ENODEV; |
| 329 | clkdev_add(l); |
| 330 | return 0; |
| 331 | } |
| 332 | EXPORT_SYMBOL(clk_add_alias); |
| 333 | |
Russell King | 0318e69 | 2008-11-09 16:32:46 +0000 | [diff] [blame] | 334 | /* |
| 335 | * clkdev_drop - remove a clock dynamically allocated |
| 336 | */ |
| 337 | void clkdev_drop(struct clk_lookup *cl) |
| 338 | { |
| 339 | mutex_lock(&clocks_mutex); |
| 340 | list_del(&cl->node); |
| 341 | mutex_unlock(&clocks_mutex); |
| 342 | kfree(cl); |
| 343 | } |
| 344 | EXPORT_SYMBOL(clkdev_drop); |
Russell King | e9d7f40 | 2012-05-02 09:30:32 +0100 | [diff] [blame] | 345 | |
| 346 | /** |
| 347 | * clk_register_clkdev - register one clock lookup for a struct clk |
| 348 | * @clk: struct clk to associate with all clk_lookups |
| 349 | * @con_id: connection ID string on device |
| 350 | * @dev_id: format string describing device name |
| 351 | * |
| 352 | * con_id or dev_id may be NULL as a wildcard, just as in the rest of |
| 353 | * clkdev. |
| 354 | * |
| 355 | * To make things easier for mass registration, we detect error clks |
| 356 | * from a previous clk_register() call, and return the error code for |
| 357 | * those. This is to permit this function to be called immediately |
| 358 | * after clk_register(). |
| 359 | */ |
| 360 | int clk_register_clkdev(struct clk *clk, const char *con_id, |
| 361 | const char *dev_fmt, ...) |
| 362 | { |
| 363 | struct clk_lookup *cl; |
| 364 | va_list ap; |
| 365 | |
| 366 | if (IS_ERR(clk)) |
| 367 | return PTR_ERR(clk); |
| 368 | |
| 369 | va_start(ap, dev_fmt); |
| 370 | cl = vclkdev_alloc(clk, con_id, dev_fmt, ap); |
| 371 | va_end(ap); |
| 372 | |
| 373 | if (!cl) |
| 374 | return -ENOMEM; |
| 375 | |
| 376 | clkdev_add(cl); |
| 377 | |
| 378 | return 0; |
| 379 | } |
Tomeu Vizoso | a251361a | 2015-01-23 12:03:32 +0100 | [diff] [blame^] | 380 | EXPORT_SYMBOL(clk_register_clkdev); |
Russell King | e9d7f40 | 2012-05-02 09:30:32 +0100 | [diff] [blame] | 381 | |
| 382 | /** |
| 383 | * clk_register_clkdevs - register a set of clk_lookup for a struct clk |
| 384 | * @clk: struct clk to associate with all clk_lookups |
| 385 | * @cl: array of clk_lookup structures with con_id and dev_id pre-initialized |
| 386 | * @num: number of clk_lookup structures to register |
| 387 | * |
| 388 | * To make things easier for mass registration, we detect error clks |
| 389 | * from a previous clk_register() call, and return the error code for |
| 390 | * those. This is to permit this function to be called immediately |
| 391 | * after clk_register(). |
| 392 | */ |
| 393 | int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num) |
| 394 | { |
| 395 | unsigned i; |
| 396 | |
| 397 | if (IS_ERR(clk)) |
| 398 | return PTR_ERR(clk); |
| 399 | |
| 400 | for (i = 0; i < num; i++, cl++) { |
| 401 | cl->clk = clk; |
| 402 | clkdev_add(cl); |
| 403 | } |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | EXPORT_SYMBOL(clk_register_clkdevs); |