]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
driver: vi: tegra_camera: correct pdev->id for DT
authorBryan Wu <pengw@nvidia.com>
Fri, 21 Feb 2014 18:45:03 +0000 (10:45 -0800)
committerBryan Wu <pengw@nvidia.com>
Tue, 4 Mar 2014 22:54:16 +0000 (14:54 -0800)
DT will initialize the pdev->id as -1 for both vi.0 and vi.1. This
will cause several subtle issues since checking pdev->id is used a
in VI and Tegra V4L2 camera drivers.

Set the pdev->id as the right value during probing for DT case. Then
no change is need for others

Bug 1463966

Change-Id: I8adf124c4d3489e9c06abbecb6d3587437954c50
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/373000
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/media/platform/soc_camera/tegra_camera/common.c
drivers/media/platform/soc_camera/tegra_camera/vi2.c
drivers/video/tegra/host/vi/tegra_vi.c

index d257115258b941176a18b6d5d6129c5ab6dbfbc1..50ba778f6cef6fc95ed354ca80c22a4adb533659 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -802,6 +802,12 @@ static int tegra_camera_probe(struct platform_device *pdev)
                match = of_match_device(tegra_vi_of_match, &pdev->dev);
                if (match)
                        ndata = (struct nvhost_device_data *) match->data;
+
+               /*
+                * Device Tree will initialize this ID as -1
+                * Set it to the right value for future usage
+                */
+               pdev->id = pdev->dev.id;
        } else
                ndata = pdev->dev.platform_data;
 
@@ -823,7 +829,7 @@ static int tegra_camera_probe(struct platform_device *pdev)
 
        cam->ici.priv = cam;
        cam->ici.v4l2_dev.dev = &pdev->dev;
-       cam->ici.nr = pdev->dev.id;
+       cam->ici.nr = pdev->id;
        cam->ici.drv_name = dev_name(&pdev->dev);
        cam->ici.ops = &tegra_soc_camera_host_ops;
 
index f58c03bff8a5738fdc5173b0c80b3812aec1e840..60bdaa4dabc7e22270469cee74e350103d4410bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2014, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -329,20 +329,10 @@ static struct tegra_camera_clk vi2_clks1[] = {
 static int vi2_clks_init(struct tegra_camera_dev *cam)
 {
        struct platform_device *pdev = cam->ndev;
-       char devname[MAX_DEVID_LENGTH];
-       const char *pdev_name;
        struct tegra_camera_clk *clks;
-       int i, dev_id, ret;
-
-       pdev_name = dev_name(&pdev->dev);
-       ret = sscanf(pdev_name, "vi.%1d", &dev_id);
-       if (ret != 1) {
-               dev_err(&pdev->dev, "Read dev_id failed!\n");
-               return -ENODEV;
-       }
-       snprintf(devname, MAX_DEVID_LENGTH, "tegra_%s", pdev_name);
+       int i;
 
-       switch (dev_id) {
+       switch (pdev->id) {
        case 0:
                cam->num_clks = ARRAY_SIZE(vi2_clks0);
                cam->clks = vi2_clks0;
@@ -352,16 +342,19 @@ static int vi2_clks_init(struct tegra_camera_dev *cam)
                cam->clks = vi2_clks1;
                break;
        default:
-               dev_err(&pdev->dev, "Wrong device ID %d\n", dev_id);
+               dev_err(&pdev->dev, "Wrong device ID %d\n", pdev->id);
                return -ENODEV;
        }
 
        for (i = 0; i < cam->num_clks; i++) {
                clks = &cam->clks[i];
 
-               if (clks->use_devname)
+               if (clks->use_devname) {
+                       char devname[MAX_DEVID_LENGTH];
+                       snprintf(devname, MAX_DEVID_LENGTH,
+                                "tegra_%s", dev_name(&pdev->dev));
                        clks->clk = clk_get_sys(devname, clks->name);
-               else
+               else
                        clks->clk = clk_get(&pdev->dev, clks->name);
                if (IS_ERR_OR_NULL(clks->clk)) {
                        dev_err(&pdev->dev, "Failed to get clock %s.\n",
index d4f5c47ede6aaad0f22eb824f50ddb404168d292..9e2e14bd301c6aeb6768038e18b6f46caade04e1 100644 (file)
@@ -89,15 +89,8 @@ void nvhost_vi_deinit(struct platform_device *dev)
 
 int nvhost_vi_finalize_poweron(struct platform_device *dev)
 {
-       int ret = 0, dev_id;
+       int ret = 0;
        struct vi *tegra_vi;
-       const char *devname = dev_name(&dev->dev);
-
-       ret = sscanf(devname, "vi.%1d", &dev_id);
-       if (ret != 1) {
-               dev_err(&dev->dev, "Read dev_id failed!\n");
-               return -ENODEV;
-       }
 
        tegra_vi = (struct vi *)nvhost_get_private_data(dev);
        if (tegra_vi && tegra_vi->reg) {
@@ -111,7 +104,7 @@ int nvhost_vi_finalize_poweron(struct platform_device *dev)
        }
 
        /* Only do this for vi.0 not for slave device vi.1 */
-       if (dev_id == 0)
+       if (dev->id == 0)
                host1x_writel(dev, T12_VI_CFG_CG_CTRL, T12_CG_2ND_LEVEL_EN);
 
  fail: