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