]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: camera: refactor isomgr interface
authorJihoon Bang <jbang@nvidia.com>
Wed, 8 May 2013 16:26:44 +0000 (09:26 -0700)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:13:11 +0000 (13:13 -0700)
Reduce #ifdef code by defining null function in function
defintion. This will increase readability of code.

Bug 1275691

Change-Id: If534566d0e84542f637fd38817cff66de120a9c4
Signed-off-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-on: http://git-master/r/226752
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/camera/camera.c
drivers/video/tegra/camera/camera_emc.c
drivers/video/tegra/camera/camera_emc.h

index 72ecf1591fc8a378d3300b49e0218e527e2fe0d5..90c392df6bdeb1f58796de13336602af64c08db2 100644 (file)
@@ -263,19 +263,9 @@ struct tegra_camera *tegra_camera_register(struct platform_device *ndev)
                        goto clk_get_fail;
        }
 
-#if defined(CONFIG_TEGRA_ISOMGR)
-       /* Dedicated bw is what VI could ask for at most */
-       camera->isomgr_handle = tegra_isomgr_register(TEGRA_ISO_CLIENT_VI_0,
-                                       /* dedicated bw, KBps*/
-                                       tegra_camera_get_max_bw(camera),
-                                       NULL,   /* tegra_isomgr_renegotiate */
-                                       NULL);  /* *priv */
-       if (!camera->isomgr_handle) {
-               dev_err(&ndev->dev, "%s: unable to register isomgr\n",
-                                       __func__);
+       ret = tegra_camera_isomgr_register(camera);
+       if (ret)
                goto clk_get_fail;
-       }
-#endif
 
        return camera;
 
@@ -300,25 +290,8 @@ int tegra_camera_unregister(struct tegra_camera *camera)
        for (i = 0; i < CAMERA_CLK_MAX; i++)
                clk_put(camera->clock[i].clk);
 
-#if defined(CONFIG_TEGRA_ISOMGR)
-       /*
-        * Return memory bandwidth to isomgr.
-        * If bandwidth is zero, then latency will be ignored
-        * in tegra_isomgr_reserve().
-        */
-       {
-               int ret = 0;
-
-               ret = tegra_isomgr_reserve(camera->isomgr_handle,
-                                       0,      /* KB/sec */
-                                       0);     /* usec */
-               if (!ret)
-                       return -ENOMEM;
+       tegra_camera_isomgr_unregister(camera);
 
-               tegra_isomgr_unregister(camera->isomgr_handle);
-               camera->isomgr_handle = NULL;
-       }
-#endif
        kfree(camera);
 
        return 0;
index 98101bb13139ceb66ce915f988f719b6fc0668b4..b5a5f1f3c33bb37164ea3905a2343a45c98274de 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/video/tegra/camera/camera_emc.c
  *
- * Copyright (C) 2013 Nvidia Corp
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -14,6 +14,7 @@
  *
  */
 
+#include "camera_clk.h"
 #include "camera_emc.h"
 
 int tegra_camera_enable_emc(struct tegra_camera *camera)
@@ -46,12 +47,37 @@ int tegra_camera_disable_emc(struct tegra_camera *camera)
                }
        }
 #endif
-
        return tegra_emc_enable_eack();
 }
 
-
 #if defined(CONFIG_TEGRA_ISOMGR)
+int tegra_camera_isomgr_register(struct tegra_camera *camera)
+{
+       dev_dbg(camera->dev, "%s++\n", __func__);
+
+       /* Dedicated bw is what VI could ask for at most */
+       camera->isomgr_handle = tegra_isomgr_register(TEGRA_ISO_CLIENT_VI_0,
+                                       /* dedicated bw, KBps*/
+                                       tegra_camera_get_max_bw(camera),
+                                       NULL,   /* tegra_isomgr_renegotiate */
+                                       NULL);  /* *priv */
+       if (!camera->isomgr_handle) {
+               dev_err(camera->dev, "%s: unable to register isomgr\n",
+                                       __func__);
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+int tegra_camera_isomgr_unregister(struct tegra_camera *camera)
+{
+       tegra_isomgr_unregister(camera->isomgr_handle);
+       camera->isomgr_handle = NULL;
+
+       return 0;
+}
+
 /*
  * bw: memory BW in KBps
  * lt: latency in usec
@@ -61,6 +87,8 @@ int tegra_camera_isomgr_request(struct tegra_camera *camera, unsigned long bw,
 {
        int ret = 0;
 
+       dev_dbg(camera->dev, "%s++ bw=%lu, lt=%lu\n", __func__, bw, lt);
+
        /* return value of tegra_isomgr_reserve is dvfs latency in usec */
        ret = tegra_isomgr_reserve(camera->isomgr_handle,
                                bw,     /* KB/sec */
@@ -84,4 +112,20 @@ int tegra_camera_isomgr_request(struct tegra_camera *camera, unsigned long bw,
 
        return 0;
 }
+#else
+int tegra_camera_isomgr_register(struct tegra_camera *camera)
+{
+       return 0;
+}
+
+int tegra_camera_isomgr_unregister(struct tegra_camera *camera)
+{
+       return 0;
+}
+
+int tegra_camera_isomgr_request(struct tegra_camera *camera, unsigned long bw,
+                               unsigned long lt)
+{
+       return 0;
+}
 #endif
index c1301315fbfa02a3ab89934e1b32618f6efe5adb..bc43f40dbb443c748a6c705cc1023525d2653d3e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * drivers/video/tegra/camera/camera_emc.h
  *
- * Copyright (C) 2013 Nvidia Corp
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -20,8 +20,9 @@
 
 int tegra_camera_enable_emc(struct tegra_camera *camera);
 int tegra_camera_disable_emc(struct tegra_camera *camera);
-#if defined(CONFIG_TEGRA_ISOMGR)
 int tegra_camera_isomgr_request(struct tegra_camera *camera, unsigned long bw,
                                unsigned long lt);
-#endif
+int tegra_camera_isomgr_register(struct tegra_camera *camera);
+int tegra_camera_isomgr_unregister(struct tegra_camera *camera);
+
 #endif