Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] mt9v032: Use the common clock framework

Configure the device external clock using the common clock framework
instead of a board code callback function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
3300a8fd 4ab0620b

+11 -10
+11 -6
drivers/media/i2c/mt9v032.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 15 + #include <linux/clk.h> 15 16 #include <linux/delay.h> 16 17 #include <linux/i2c.h> 17 18 #include <linux/log2.h> ··· 136 135 struct mutex power_lock; 137 136 int power_count; 138 137 138 + struct clk *clk; 139 + 139 140 struct mt9v032_platform_data *pdata; 140 141 141 142 u32 sysclk; ··· 222 219 struct i2c_client *client = v4l2_get_subdevdata(&mt9v032->subdev); 223 220 int ret; 224 221 225 - if (mt9v032->pdata->set_clock) { 226 - mt9v032->pdata->set_clock(&mt9v032->subdev, mt9v032->sysclk); 227 - udelay(1); 228 - } 222 + clk_set_rate(mt9v032->clk, mt9v032->sysclk); 223 + clk_prepare_enable(mt9v032->clk); 224 + udelay(1); 229 225 230 226 /* Reset the chip and stop data read out */ 231 227 ret = mt9v032_write(client, MT9V032_RESET, 1); ··· 240 238 241 239 static void mt9v032_power_off(struct mt9v032 *mt9v032) 242 240 { 243 - if (mt9v032->pdata->set_clock) 244 - mt9v032->pdata->set_clock(&mt9v032->subdev, 0); 241 + clk_disable_unprepare(mt9v032->clk); 245 242 } 246 243 247 244 static int __mt9v032_set_power(struct mt9v032 *mt9v032, bool on) ··· 748 747 mt9v032 = devm_kzalloc(&client->dev, sizeof(*mt9v032), GFP_KERNEL); 749 748 if (!mt9v032) 750 749 return -ENOMEM; 750 + 751 + mt9v032->clk = devm_clk_get(&client->dev, NULL); 752 + if (IS_ERR(mt9v032->clk)) 753 + return PTR_ERR(mt9v032->clk); 751 754 752 755 mutex_init(&mt9v032->power_lock); 753 756 mt9v032->pdata = pdata;
-4
include/media/mt9v032.h
··· 1 1 #ifndef _MEDIA_MT9V032_H 2 2 #define _MEDIA_MT9V032_H 3 3 4 - struct v4l2_subdev; 5 - 6 4 struct mt9v032_platform_data { 7 5 unsigned int clk_pol:1; 8 - 9 - void (*set_clock)(struct v4l2_subdev *subdev, unsigned int rate); 10 6 11 7 const s64 *link_freqs; 12 8 s64 link_def_freq;