Commit 3b2ae0be authored by Luca Risolia's avatar Luca Risolia Committed by Mauro Carvalho Chehab

V4L/DVB (5766): ET61x251 driver updates

- 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: default avatarLuca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 3770be34
config USB_ET61X251 config USB_ET61X251
tristate "USB ET61X[12]51 PC Camera Controller support" tristate "USB ET61X[12]51 PC Camera Controller support"
depends on VIDEO_V4L1 depends on VIDEO_V4L2
---help--- ---help---
Say Y here if you want support for cameras based on Etoms ET61X151 Say Y here if you want support for cameras based on Etoms ET61X151
or ET61X251 PC Camera Controllers. or ET61X251 PC Camera Controllers.
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/kref.h>
#include "et61x251_sensor.h" #include "et61x251_sensor.h"
...@@ -134,7 +135,7 @@ struct et61x251_module_param { ...@@ -134,7 +135,7 @@ struct et61x251_module_param {
}; };
static DEFINE_MUTEX(et61x251_sysfs_lock); static DEFINE_MUTEX(et61x251_sysfs_lock);
static DECLARE_RWSEM(et61x251_disconnect); static DECLARE_RWSEM(et61x251_dev_lock);
struct et61x251_device { struct et61x251_device {
struct video_device* v4ldev; struct video_device* v4ldev;
...@@ -158,12 +159,14 @@ struct et61x251_device { ...@@ -158,12 +159,14 @@ struct et61x251_device {
struct et61x251_sysfs_attr sysfs; struct et61x251_sysfs_attr sysfs;
struct et61x251_module_param module_param; struct et61x251_module_param module_param;
struct kref kref;
enum et61x251_dev_state state; enum et61x251_dev_state state;
u8 users; u8 users;
struct mutex dev_mutex, fileop_mutex; struct completion probe;
struct mutex open_mutex, fileop_mutex;
spinlock_t queue_lock; spinlock_t queue_lock;
wait_queue_head_t open, wait_frame, wait_stream; wait_queue_head_t wait_open, wait_frame, wait_stream;
}; };
/*****************************************************************************/ /*****************************************************************************/
...@@ -177,7 +180,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id) ...@@ -177,7 +180,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id)
void void
et61x251_attach_sensor(struct et61x251_device* cam, et61x251_attach_sensor(struct et61x251_device* cam,
struct et61x251_sensor* sensor) const struct et61x251_sensor* sensor)
{ {
memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor)); memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
} }
...@@ -195,8 +198,8 @@ do { \ ...@@ -195,8 +198,8 @@ do { \
else if ((level) == 2) \ else if ((level) == 2) \
dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
else if ((level) >= 3) \ else if ((level) >= 3) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \
__FUNCTION__, __LINE__ , ## args); \ __FILE__, __FUNCTION__, __LINE__ , ## args); \
} \ } \
} while (0) } while (0)
# define KDBG(level, fmt, args...) \ # define KDBG(level, fmt, args...) \
...@@ -205,8 +208,8 @@ do { \ ...@@ -205,8 +208,8 @@ do { \
if ((level) == 1 || (level) == 2) \ if ((level) == 1 || (level) == 2) \
pr_info("et61x251: " fmt "\n", ## args); \ pr_info("et61x251: " fmt "\n", ## args); \
else if ((level) == 3) \ else if ((level) == 3) \
pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \ pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \
__LINE__ , ## args); \ __FUNCTION__, __LINE__ , ## args); \
} \ } \
} while (0) } while (0)
# define V4LDBG(level, name, cmd) \ # define V4LDBG(level, name, cmd) \
...@@ -222,8 +225,8 @@ do { \ ...@@ -222,8 +225,8 @@ do { \
#undef PDBG #undef PDBG
#define PDBG(fmt, args...) \ #define PDBG(fmt, args...) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __FUNCTION__, \
__FUNCTION__, __LINE__ , ## args) __LINE__ , ## args)
#undef PDBGG #undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */ #define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define _ET61X251_SENSOR_H_ #define _ET61X251_SENSOR_H_
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/videodev.h> #include <linux/videodev2.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/errno.h> #include <linux/errno.h>
...@@ -47,7 +47,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id); ...@@ -47,7 +47,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);
extern void extern void
et61x251_attach_sensor(struct et61x251_device* cam, et61x251_attach_sensor(struct et61x251_device* cam,
struct et61x251_sensor* sensor); const struct et61x251_sensor* sensor);
/*****************************************************************************/ /*****************************************************************************/
...@@ -56,10 +56,10 @@ extern int et61x251_read_reg(struct et61x251_device*, u16 index); ...@@ -56,10 +56,10 @@ extern int et61x251_read_reg(struct et61x251_device*, u16 index);
extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value); extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value);
extern int et61x251_i2c_read(struct et61x251_device*, u8 address); extern int et61x251_i2c_read(struct et61x251_device*, u8 address);
extern int et61x251_i2c_try_write(struct et61x251_device*, extern int et61x251_i2c_try_write(struct et61x251_device*,
struct et61x251_sensor*, u8 address, const struct et61x251_sensor*, u8 address,
u8 value); u8 value);
extern int et61x251_i2c_try_read(struct et61x251_device*, extern int et61x251_i2c_try_read(struct et61x251_device*,
struct et61x251_sensor*, u8 address); const struct et61x251_sensor*, u8 address);
extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1, extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
u8 data2, u8 data3, u8 data4, u8 data5, u8 data2, u8 data3, u8 data4, u8 data5,
u8 data6, u8 data7, u8 data8, u8 address); u8 data6, u8 data7, u8 data8, u8 address);
......
...@@ -69,7 +69,7 @@ static int tas5130d1b_set_ctrl(struct et61x251_device* cam, ...@@ -69,7 +69,7 @@ static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
} }
static struct et61x251_sensor tas5130d1b = { static const struct et61x251_sensor tas5130d1b = {
.name = "TAS5130D1B", .name = "TAS5130D1B",
.interface = ET61X251_I2C_3WIRES, .interface = ET61X251_I2C_3WIRES,
.rsta = ET61X251_I2C_RSTA_STOP, .rsta = ET61X251_I2C_RSTA_STOP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment