Skip to content

Commit

Permalink
V4L/DVB (5767): ZC0301 driver updates
Browse files Browse the repository at this point in the history
- Make the driver depend on V4L2 only (KConfig)
- Better and safe locking mechanism of the device structure on open(), close()
  and disconnect()
- Use kref for handling device deallocation
- Generic cleanups

Signed-off-by: Luca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Luca Risolia authored and Mauro Carvalho Chehab committed Jul 18, 2007
1 parent 3b2ae0b commit 4052fcc
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 83 deletions.
2 changes: 1 addition & 1 deletion drivers/media/video/zc0301/Kconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config USB_ZC0301
tristate "USB ZC0301[P] Image Processor and Control Chip support"
depends on VIDEO_V4L1
depends on VIDEO_V4L2
---help---
Say Y here if you want support for cameras based on the ZC0301 or
ZC0301P Image Processors and Control Chips.
Expand Down
21 changes: 12 additions & 9 deletions drivers/media/video/zc0301/zc0301.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/rwsem.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/kref.h>

#include "zc0301_sensor.h"

Expand Down Expand Up @@ -98,7 +99,7 @@ struct zc0301_module_param {
u16 frame_timeout;
};

static DECLARE_RWSEM(zc0301_disconnect);
static DECLARE_RWSEM(zc0301_dev_lock);

struct zc0301_device {
struct video_device* v4ldev;
Expand All @@ -121,12 +122,14 @@ struct zc0301_device {

struct zc0301_module_param module_param;

struct kref kref;
enum zc0301_dev_state state;
u8 users;

struct mutex dev_mutex, fileop_mutex;
struct completion probe;
struct mutex open_mutex, fileop_mutex;
spinlock_t queue_lock;
wait_queue_head_t open, wait_frame, wait_stream;
wait_queue_head_t wait_open, wait_frame, wait_stream;
};

/*****************************************************************************/
Expand Down Expand Up @@ -156,8 +159,8 @@ do { \
else if ((level) == 2) \
dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
else if ((level) >= 3) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
__FUNCTION__, __LINE__ , ## args); \
dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \
__FILE__, __FUNCTION__, __LINE__ , ## args); \
} \
} while (0)
# define KDBG(level, fmt, args...) \
Expand All @@ -166,8 +169,8 @@ do { \
if ((level) == 1 || (level) == 2) \
pr_info("zc0301: " fmt "\n", ## args); \
else if ((level) == 3) \
pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \
__LINE__ , ## args); \
pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \
__FUNCTION__, __LINE__ , ## args); \
} \
} while (0)
# define V4LDBG(level, name, cmd) \
Expand All @@ -183,8 +186,8 @@ do { \

#undef PDBG
#define PDBG(fmt, args...) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
__FUNCTION__, __LINE__ , ## args)
dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __FUNCTION__, \
__LINE__ , ## args)

#undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
Expand Down
Loading

0 comments on commit 4052fcc

Please sign in to comment.