aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-08-28 09:28:26 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-10-31 02:31:30 -0400
commitcf326dfebe612bf56c83d8fca7a7c1d1584c061f (patch)
tree0147f77a00da075c875c44b835b7eeb5502b5460 /drivers/media/v4l2-core
parentd3f884a70938b1776ba44c7b6c82f3c3fd54ccbd (diff)
[media] V4L2: add v4l2-clock helpers to register and unregister a fixed-rate clock
Many bridges and video host controllers supply fixed rate always on clocks to their I2C devices. This patch adds two simple helpers to register and unregister such a clock. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-clk.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-clk.c b/drivers/media/v4l2-core/v4l2-clk.c
index b67de8642b5a..e18cc0469cf8 100644
--- a/drivers/media/v4l2-core/v4l2-clk.c
+++ b/drivers/media/v4l2-core/v4l2-clk.c
@@ -240,3 +240,42 @@ void v4l2_clk_unregister(struct v4l2_clk *clk)
240 kfree(clk); 240 kfree(clk);
241} 241}
242EXPORT_SYMBOL(v4l2_clk_unregister); 242EXPORT_SYMBOL(v4l2_clk_unregister);
243
244struct v4l2_clk_fixed {
245 unsigned long rate;
246 struct v4l2_clk_ops ops;
247};
248
249static unsigned long fixed_get_rate(struct v4l2_clk *clk)
250{
251 struct v4l2_clk_fixed *priv = clk->priv;
252 return priv->rate;
253}
254
255struct v4l2_clk *__v4l2_clk_register_fixed(const char *dev_id,
256 const char *id, unsigned long rate, struct module *owner)
257{
258 struct v4l2_clk *clk;
259 struct v4l2_clk_fixed *priv = kzalloc(sizeof(*priv), GFP_KERNEL);
260
261 if (!priv)
262 return ERR_PTR(-ENOMEM);
263
264 priv->rate = rate;
265 priv->ops.get_rate = fixed_get_rate;
266 priv->ops.owner = owner;
267
268 clk = v4l2_clk_register(&priv->ops, dev_id, id, priv);
269 if (IS_ERR(clk))
270 kfree(priv);
271
272 return clk;
273}
274EXPORT_SYMBOL(__v4l2_clk_register_fixed);
275
276void v4l2_clk_unregister_fixed(struct v4l2_clk *clk)
277{
278 kfree(clk->priv);
279 v4l2_clk_unregister(clk);
280}
281EXPORT_SYMBOL(v4l2_clk_unregister_fixed);