camera: rockchip: camsys driver v0.0x21.0xf
authorzhangyunlong <dalon.zhang@rock-chips.com>
Tue, 9 May 2017 03:41:19 +0000 (11:41 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 10 May 2017 11:02:45 +0000 (19:02 +0800)
add reference count for marvin

Change-Id: Ic410da2524a8972d782ccfdcb121e1727b02e9d8
Signed-off-by: zhangyunlong <dalon.zhang@rock-chips.com>
drivers/media/video/rk_camsys/camsys_drv.c
drivers/media/video/rk_camsys/camsys_internal.h

index 8b74b7efd79c6ee4f814a99da2c5ce9d43da42e7..915f92154b34e3ba2fc43fc9be7cca068efc818e 100644 (file)
@@ -803,7 +803,12 @@ static int camsys_open(struct inode *inode, struct file *file)
                }
        }
        spin_unlock(&camsys_devs.lock);
-
+       if (atomic_read(&camsys_dev->refcount) >= 1) {
+               camsys_err("%s has been opened!",
+                       dev_name(camsys_dev->miscdev.this_device));
+               err = -EBUSY;
+               goto end;
+       }
        INIT_LIST_HEAD(&camsys_dev->extdevs.active);
 
        if (camsys_dev->mipiphy != NULL) {
@@ -822,6 +827,7 @@ static int camsys_open(struct inode *inode, struct file *file)
                err = -ENODEV;
                goto end;
        } else {
+               atomic_inc(&camsys_dev->refcount);
                camsys_trace(1,
                        "%s(%p) is opened!",
                        dev_name(camsys_dev->miscdev.this_device), camsys_dev);
@@ -847,7 +853,7 @@ static int camsys_release(struct inode *inode, struct file *file)
                        }
                }
        }
-
+       atomic_dec(&camsys_dev->refcount);
        camsys_trace(1,
                "%s(%p) is closed",
                dev_name(camsys_dev->miscdev.this_device),
index 2c1109bbc07516de87362685ea142c9e1a25fbc3..7bb1a2821b4b49576f449f3de88f9c09c03a39eb 100644 (file)
 *v0.0x21.0xe
        1) correct mipiphy_hsfreqrange of 3368.
        2) add csi-phy timing setting for 3368.
+*v0.0x21.0xf:
+       1) add reference count for marvin.
 */
-#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x21, 0xe)
+#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x21, 0xf)
 
 #define CAMSYS_PLATFORM_DRV_NAME                "RockChip-CamSys"
 #define CAMSYS_PLATFORM_MARVIN_NAME             "Platform_MarvinDev"
@@ -323,7 +325,7 @@ typedef struct camsys_dev_s {
        unsigned long         rk_grf_base;
        unsigned long         rk_cru_base;
        unsigned long         rk_isp_base;
-
+       atomic_t              refcount;
        struct iommu_domain *domain;
        camsys_dma_buf_t dma_buf[CAMSYS_DMA_BUF_MAX_NUM];
        int dma_buf_cnt;