aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-08-17 00:49:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-26 16:39:39 -0400
commit31c1d17b3edeae51b7726ef39184017e02b23604 (patch)
tree2defffe4dca847fa578e73a464cd3bcb27c7d492 /drivers/media/i2c
parent8b99312b7214f1976ebb54071b01968536af53c9 (diff)
[media] smiapp: Use devm_* functions in smiapp-core.c file
devm_* functions are device managed functions and make code a bit smaller and cleaner. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 1cf914d11345..4f1c8d6eb19a 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2355,20 +2355,19 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2355 unsigned int i; 2355 unsigned int i;
2356 int rval; 2356 int rval;
2357 2357
2358 sensor->vana = regulator_get(&client->dev, "VANA"); 2358 sensor->vana = devm_regulator_get(&client->dev, "VANA");
2359 if (IS_ERR(sensor->vana)) { 2359 if (IS_ERR(sensor->vana)) {
2360 dev_err(&client->dev, "could not get regulator for vana\n"); 2360 dev_err(&client->dev, "could not get regulator for vana\n");
2361 return -ENODEV; 2361 return -ENODEV;
2362 } 2362 }
2363 2363
2364 if (!sensor->platform_data->set_xclk) { 2364 if (!sensor->platform_data->set_xclk) {
2365 sensor->ext_clk = clk_get(&client->dev, 2365 sensor->ext_clk = devm_clk_get(&client->dev,
2366 sensor->platform_data->ext_clk_name); 2366 sensor->platform_data->ext_clk_name);
2367 if (IS_ERR(sensor->ext_clk)) { 2367 if (IS_ERR(sensor->ext_clk)) {
2368 dev_err(&client->dev, "could not get clock %s\n", 2368 dev_err(&client->dev, "could not get clock %s\n",
2369 sensor->platform_data->ext_clk_name); 2369 sensor->platform_data->ext_clk_name);
2370 rval = -ENODEV; 2370 return -ENODEV;
2371 goto out_clk_get;
2372 } 2371 }
2373 2372
2374 rval = clk_set_rate(sensor->ext_clk, 2373 rval = clk_set_rate(sensor->ext_clk,
@@ -2378,8 +2377,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2378 "unable to set clock %s freq to %u\n", 2377 "unable to set clock %s freq to %u\n",
2379 sensor->platform_data->ext_clk_name, 2378 sensor->platform_data->ext_clk_name,
2380 sensor->platform_data->ext_clk); 2379 sensor->platform_data->ext_clk);
2381 rval = -ENODEV; 2380 return -ENODEV;
2382 goto out_clk_set_rate;
2383 } 2381 }
2384 } 2382 }
2385 2383
@@ -2389,8 +2387,7 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2389 dev_err(&client->dev, 2387 dev_err(&client->dev,
2390 "unable to acquire reset gpio %d\n", 2388 "unable to acquire reset gpio %d\n",
2391 sensor->platform_data->xshutdown); 2389 sensor->platform_data->xshutdown);
2392 rval = -ENODEV; 2390 return -ENODEV;
2393 goto out_clk_set_rate;
2394 } 2391 }
2395 } 2392 }
2396 2393
@@ -2470,8 +2467,8 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
2470 * when it is first requested by userspace. 2467 * when it is first requested by userspace.
2471 */ 2468 */
2472 if (sensor->minfo.smiapp_version && sensor->platform_data->nvm_size) { 2469 if (sensor->minfo.smiapp_version && sensor->platform_data->nvm_size) {
2473 sensor->nvm = kzalloc(sensor->platform_data->nvm_size, 2470 sensor->nvm = devm_kzalloc(&client->dev,
2474 GFP_KERNEL); 2471 sensor->platform_data->nvm_size, GFP_KERNEL);
2475 if (sensor->nvm == NULL) { 2472 if (sensor->nvm == NULL) {
2476 dev_err(&client->dev, "nvm buf allocation failed\n"); 2473 dev_err(&client->dev, "nvm buf allocation failed\n");
2477 rval = -ENOMEM; 2474 rval = -ENOMEM;
@@ -2637,21 +2634,12 @@ out_nvm_release:
2637 device_remove_file(&client->dev, &dev_attr_nvm); 2634 device_remove_file(&client->dev, &dev_attr_nvm);
2638 2635
2639out_power_off: 2636out_power_off:
2640 kfree(sensor->nvm);
2641 sensor->nvm = NULL;
2642 smiapp_power_off(sensor); 2637 smiapp_power_off(sensor);
2643 2638
2644out_smiapp_power_on: 2639out_smiapp_power_on:
2645 if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) 2640 if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
2646 gpio_free(sensor->platform_data->xshutdown); 2641 gpio_free(sensor->platform_data->xshutdown);
2647 2642
2648out_clk_set_rate:
2649 clk_put(sensor->ext_clk);
2650 sensor->ext_clk = NULL;
2651
2652out_clk_get:
2653 regulator_put(sensor->vana);
2654 sensor->vana = NULL;
2655 return rval; 2643 return rval;
2656} 2644}
2657 2645
@@ -2801,12 +2789,11 @@ static int smiapp_probe(struct i2c_client *client,
2801 const struct i2c_device_id *devid) 2789 const struct i2c_device_id *devid)
2802{ 2790{
2803 struct smiapp_sensor *sensor; 2791 struct smiapp_sensor *sensor;
2804 int rval;
2805 2792
2806 if (client->dev.platform_data == NULL) 2793 if (client->dev.platform_data == NULL)
2807 return -ENODEV; 2794 return -ENODEV;
2808 2795
2809 sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); 2796 sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
2810 if (sensor == NULL) 2797 if (sensor == NULL)
2811 return -ENOMEM; 2798 return -ENOMEM;
2812 2799
@@ -2821,12 +2808,8 @@ static int smiapp_probe(struct i2c_client *client,
2821 sensor->src->sensor = sensor; 2808 sensor->src->sensor = sensor;
2822 2809
2823 sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE; 2810 sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE;
2824 rval = media_entity_init(&sensor->src->sd.entity, 2, 2811 return media_entity_init(&sensor->src->sd.entity, 2,
2825 sensor->src->pads, 0); 2812 sensor->src->pads, 0);
2826 if (rval < 0)
2827 kfree(sensor);
2828
2829 return rval;
2830} 2813}
2831 2814
2832static int __exit smiapp_remove(struct i2c_client *client) 2815static int __exit smiapp_remove(struct i2c_client *client)
@@ -2845,10 +2828,8 @@ static int __exit smiapp_remove(struct i2c_client *client)
2845 sensor->power_count = 0; 2828 sensor->power_count = 0;
2846 } 2829 }
2847 2830
2848 if (sensor->nvm) { 2831 if (sensor->nvm)
2849 device_remove_file(&client->dev, &dev_attr_nvm); 2832 device_remove_file(&client->dev, &dev_attr_nvm);
2850 kfree(sensor->nvm);
2851 }
2852 2833
2853 for (i = 0; i < sensor->ssds_used; i++) { 2834 for (i = 0; i < sensor->ssds_used; i++) {
2854 media_entity_cleanup(&sensor->ssds[i].sd.entity); 2835 media_entity_cleanup(&sensor->ssds[i].sd.entity);
@@ -2857,12 +2838,6 @@ static int __exit smiapp_remove(struct i2c_client *client)
2857 smiapp_free_controls(sensor); 2838 smiapp_free_controls(sensor);
2858 if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN) 2839 if (sensor->platform_data->xshutdown != SMIAPP_NO_XSHUTDOWN)
2859 gpio_free(sensor->platform_data->xshutdown); 2840 gpio_free(sensor->platform_data->xshutdown);
2860 if (sensor->ext_clk)
2861 clk_put(sensor->ext_clk);
2862 if (sensor->vana)
2863 regulator_put(sensor->vana);
2864
2865 kfree(sensor);
2866 2841
2867 return 0; 2842 return 0;
2868} 2843}