Commit 54bd5b66 authored by Kay Sievers's avatar Kay Sievers Committed by Mauro Carvalho Chehab

V4L/DVB (6293): V4L: convert struct class_device to struct device

The currently used "struct class_device" will be removed from the
kernel. Here is a patch that converts all users in drivers/media/video/
to struct device.
Reviewed-by: default avatarThierry Merle <thierry.merle@free.fr>
Reviewed-by: default avatarMike Isely <isely@pobox.com>
Reviewed-by: default avatarLuca Risolia <luca.risolia@studio.unibo.it>
Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent d4cae5a5
...@@ -154,13 +154,14 @@ MODULE_LICENSE("GPL"); ...@@ -154,13 +154,14 @@ MODULE_LICENSE("GPL");
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* sysfs */ /* sysfs */
static ssize_t show_card(struct class_device *cd, char *buf) static ssize_t show_card(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vfd = to_video_device(cd); struct video_device *vfd = to_video_device(cd);
struct bttv *btv = dev_get_drvdata(vfd->dev); struct bttv *btv = dev_get_drvdata(vfd->dev);
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
} }
static CLASS_DEVICE_ATTR(card, S_IRUGO, show_card, NULL); static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
/* dvb auto-load setup */ /* dvb auto-load setup */
...@@ -4615,9 +4616,9 @@ static int __devinit bttv_register_video(struct bttv *btv) ...@@ -4615,9 +4616,9 @@ static int __devinit bttv_register_video(struct bttv *btv)
goto err; goto err;
printk(KERN_INFO "bttv%d: registered device video%d\n", printk(KERN_INFO "bttv%d: registered device video%d\n",
btv->c.nr,btv->video_dev->minor & 0x1f); btv->c.nr,btv->video_dev->minor & 0x1f);
if (class_device_create_file(&btv->video_dev->class_dev, if (device_create_file(&btv->video_dev->class_dev,
&class_device_attr_card)<0) { &dev_attr_card)<0) {
printk(KERN_ERR "bttv%d: class_device_create_file 'card' " printk(KERN_ERR "bttv%d: device_create_file 'card' "
"failed\n", btv->c.nr); "failed\n", btv->c.nr);
goto err; goto err;
} }
......
...@@ -706,7 +706,8 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count) ...@@ -706,7 +706,8 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
NOTE 2: buffers are PAGE_SIZE long NOTE 2: buffers are PAGE_SIZE long
*/ */
static ssize_t et61x251_show_reg(struct class_device* cd, char* buf) static ssize_t et61x251_show_reg(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
ssize_t count; ssize_t count;
...@@ -729,7 +730,8 @@ static ssize_t et61x251_show_reg(struct class_device* cd, char* buf) ...@@ -729,7 +730,8 @@ static ssize_t et61x251_show_reg(struct class_device* cd, char* buf)
static ssize_t static ssize_t
et61x251_store_reg(struct class_device* cd, const char* buf, size_t len) et61x251_store_reg(struct device* cd,
struct device_attribute *attr, const char* buf, size_t len)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
u8 index; u8 index;
...@@ -761,7 +763,8 @@ et61x251_store_reg(struct class_device* cd, const char* buf, size_t len) ...@@ -761,7 +763,8 @@ et61x251_store_reg(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t et61x251_show_val(struct class_device* cd, char* buf) static ssize_t et61x251_show_val(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
ssize_t count; ssize_t count;
...@@ -792,7 +795,8 @@ static ssize_t et61x251_show_val(struct class_device* cd, char* buf) ...@@ -792,7 +795,8 @@ static ssize_t et61x251_show_val(struct class_device* cd, char* buf)
static ssize_t static ssize_t
et61x251_store_val(struct class_device* cd, const char* buf, size_t len) et61x251_store_val(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
u8 value; u8 value;
...@@ -830,7 +834,8 @@ et61x251_store_val(struct class_device* cd, const char* buf, size_t len) ...@@ -830,7 +834,8 @@ et61x251_store_val(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf) static ssize_t et61x251_show_i2c_reg(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
ssize_t count; ssize_t count;
...@@ -855,7 +860,8 @@ static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf) ...@@ -855,7 +860,8 @@ static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf)
static ssize_t static ssize_t
et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) et61x251_store_i2c_reg(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
u8 index; u8 index;
...@@ -887,7 +893,8 @@ et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) ...@@ -887,7 +893,8 @@ et61x251_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf) static ssize_t et61x251_show_i2c_val(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
ssize_t count; ssize_t count;
...@@ -923,7 +930,8 @@ static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf) ...@@ -923,7 +930,8 @@ static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf)
static ssize_t static ssize_t
et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len) et61x251_store_i2c_val(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct et61x251_device* cam; struct et61x251_device* cam;
u8 value; u8 value;
...@@ -966,42 +974,40 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len) ...@@ -966,42 +974,40 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
} }
static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, static DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
et61x251_show_reg, et61x251_store_reg); et61x251_show_reg, et61x251_store_reg);
static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, static DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
et61x251_show_val, et61x251_store_val); et61x251_show_val, et61x251_store_val);
static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, static DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
et61x251_show_i2c_reg, et61x251_store_i2c_reg); et61x251_show_i2c_reg, et61x251_store_i2c_reg);
static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
et61x251_show_i2c_val, et61x251_store_i2c_val); et61x251_show_i2c_val, et61x251_store_i2c_val);
static int et61x251_create_sysfs(struct et61x251_device* cam) static int et61x251_create_sysfs(struct et61x251_device* cam)
{ {
struct class_device *classdev = &(cam->v4ldev->class_dev); struct device *classdev = &(cam->v4ldev->class_dev);
int err = 0; int err = 0;
if ((err = class_device_create_file(classdev, &class_device_attr_reg))) if ((err = device_create_file(classdev, &dev_attr_reg)))
goto err_out; goto err_out;
if ((err = class_device_create_file(classdev, &class_device_attr_val))) if ((err = device_create_file(classdev, &dev_attr_val)))
goto err_reg; goto err_reg;
if (cam->sensor.sysfs_ops) { if (cam->sensor.sysfs_ops) {
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_i2c_reg)))
&class_device_attr_i2c_reg)))
goto err_val; goto err_val;
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_i2c_val)))
&class_device_attr_i2c_val)))
goto err_i2c_reg; goto err_i2c_reg;
} }
err_i2c_reg: err_i2c_reg:
if (cam->sensor.sysfs_ops) if (cam->sensor.sysfs_ops)
class_device_remove_file(classdev, &class_device_attr_i2c_reg); device_remove_file(classdev, &dev_attr_i2c_reg);
err_val: err_val:
class_device_remove_file(classdev, &class_device_attr_val); device_remove_file(classdev, &dev_attr_val);
err_reg: err_reg:
class_device_remove_file(classdev, &class_device_attr_reg); device_remove_file(classdev, &dev_attr_reg);
err_out: err_out:
return err; return err;
} }
......
...@@ -5554,41 +5554,46 @@ ov518_configure(struct usb_ov511 *ov) ...@@ -5554,41 +5554,46 @@ ov518_configure(struct usb_ov511 *ov)
* sysfs * sysfs
***************************************************************************/ ***************************************************************************/
static inline struct usb_ov511 *cd_to_ov(struct class_device *cd) static inline struct usb_ov511 *cd_to_ov(struct device *cd)
{ {
struct video_device *vdev = to_video_device(cd); struct video_device *vdev = to_video_device(cd);
return video_get_drvdata(vdev); return video_get_drvdata(vdev);
} }
static ssize_t show_custom_id(struct class_device *cd, char *buf) static ssize_t show_custom_id(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%d\n", ov->customid); return sprintf(buf, "%d\n", ov->customid);
} }
static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL); static DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
static ssize_t show_model(struct class_device *cd, char *buf) static ssize_t show_model(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", ov->desc); return sprintf(buf, "%s\n", ov->desc);
} }
static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
static ssize_t show_bridge(struct class_device *cd, char *buf) static ssize_t show_bridge(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge)); return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge));
} }
static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL); static DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
static ssize_t show_sensor(struct class_device *cd, char *buf) static ssize_t show_sensor(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor)); return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor));
} }
static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL); static DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
static ssize_t show_brightness(struct class_device *cd, char *buf) static ssize_t show_brightness(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
unsigned short x; unsigned short x;
...@@ -5598,9 +5603,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf) ...@@ -5598,9 +5603,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
sensor_get_brightness(ov, &x); sensor_get_brightness(ov, &x);
return sprintf(buf, "%d\n", x >> 8); return sprintf(buf, "%d\n", x >> 8);
} }
static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
static ssize_t show_saturation(struct class_device *cd, char *buf) static ssize_t show_saturation(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
unsigned short x; unsigned short x;
...@@ -5610,9 +5616,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf) ...@@ -5610,9 +5616,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
sensor_get_saturation(ov, &x); sensor_get_saturation(ov, &x);
return sprintf(buf, "%d\n", x >> 8); return sprintf(buf, "%d\n", x >> 8);
} }
static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
static ssize_t show_contrast(struct class_device *cd, char *buf) static ssize_t show_contrast(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
unsigned short x; unsigned short x;
...@@ -5622,9 +5629,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf) ...@@ -5622,9 +5629,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
sensor_get_contrast(ov, &x); sensor_get_contrast(ov, &x);
return sprintf(buf, "%d\n", x >> 8); return sprintf(buf, "%d\n", x >> 8);
} }
static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
static ssize_t show_hue(struct class_device *cd, char *buf) static ssize_t show_hue(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
unsigned short x; unsigned short x;
...@@ -5634,9 +5642,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf) ...@@ -5634,9 +5642,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
sensor_get_hue(ov, &x); sensor_get_hue(ov, &x);
return sprintf(buf, "%d\n", x >> 8); return sprintf(buf, "%d\n", x >> 8);
} }
static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
static ssize_t show_exposure(struct class_device *cd, char *buf) static ssize_t show_exposure(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct usb_ov511 *ov = cd_to_ov(cd); struct usb_ov511 *ov = cd_to_ov(cd);
unsigned char exp = 0; unsigned char exp = 0;
...@@ -5646,49 +5655,49 @@ static ssize_t show_exposure(struct class_device *cd, char *buf) ...@@ -5646,49 +5655,49 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
sensor_get_exposure(ov, &exp); sensor_get_exposure(ov, &exp);
return sprintf(buf, "%d\n", exp >> 8); return sprintf(buf, "%d\n", exp >> 8);
} }
static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
static int ov_create_sysfs(struct video_device *vdev) static int ov_create_sysfs(struct video_device *vdev)
{ {
int rc; int rc;
rc = video_device_create_file(vdev, &class_device_attr_custom_id); rc = video_device_create_file(vdev, &dev_attr_custom_id);
if (rc) goto err; if (rc) goto err;
rc = video_device_create_file(vdev, &class_device_attr_model); rc = video_device_create_file(vdev, &dev_attr_model);
if (rc) goto err_id; if (rc) goto err_id;
rc = video_device_create_file(vdev, &class_device_attr_bridge); rc = video_device_create_file(vdev, &dev_attr_bridge);
if (rc) goto err_model; if (rc) goto err_model;
rc = video_device_create_file(vdev, &class_device_attr_sensor); rc = video_device_create_file(vdev, &dev_attr_sensor);
if (rc) goto err_bridge; if (rc) goto err_bridge;
rc = video_device_create_file(vdev, &class_device_attr_brightness); rc = video_device_create_file(vdev, &dev_attr_brightness);
if (rc) goto err_sensor; if (rc) goto err_sensor;
rc = video_device_create_file(vdev, &class_device_attr_saturation); rc = video_device_create_file(vdev, &dev_attr_saturation);
if (rc) goto err_bright; if (rc) goto err_bright;
rc = video_device_create_file(vdev, &class_device_attr_contrast); rc = video_device_create_file(vdev, &dev_attr_contrast);
if (rc) goto err_sat; if (rc) goto err_sat;
rc = video_device_create_file(vdev, &class_device_attr_hue); rc = video_device_create_file(vdev, &dev_attr_hue);
if (rc) goto err_contrast; if (rc) goto err_contrast;
rc = video_device_create_file(vdev, &class_device_attr_exposure); rc = video_device_create_file(vdev, &dev_attr_exposure);
if (rc) goto err_hue; if (rc) goto err_hue;
return 0; return 0;
err_hue: err_hue:
video_device_remove_file(vdev, &class_device_attr_hue); video_device_remove_file(vdev, &dev_attr_hue);
err_contrast: err_contrast:
video_device_remove_file(vdev, &class_device_attr_contrast); video_device_remove_file(vdev, &dev_attr_contrast);
err_sat: err_sat:
video_device_remove_file(vdev, &class_device_attr_saturation); video_device_remove_file(vdev, &dev_attr_saturation);
err_bright: err_bright:
video_device_remove_file(vdev, &class_device_attr_brightness); video_device_remove_file(vdev, &dev_attr_brightness);
err_sensor: err_sensor:
video_device_remove_file(vdev, &class_device_attr_sensor); video_device_remove_file(vdev, &dev_attr_sensor);
err_bridge: err_bridge:
video_device_remove_file(vdev, &class_device_attr_bridge); video_device_remove_file(vdev, &dev_attr_bridge);
err_model: err_model:
video_device_remove_file(vdev, &class_device_attr_model); video_device_remove_file(vdev, &dev_attr_model);
err_id: err_id:
video_device_remove_file(vdev, &class_device_attr_custom_id); video_device_remove_file(vdev, &dev_attr_custom_id);
err: err:
return rc; return rc;
} }
......
This diff is collapsed.
...@@ -996,20 +996,22 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f ...@@ -996,20 +996,22 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f
/********* /*********
* sysfs * sysfs
*********/ *********/
static struct pwc_device *cd_to_pwc(struct class_device *cd) static struct pwc_device *cd_to_pwc(struct device *cd)
{ {
struct video_device *vdev = to_video_device(cd); struct video_device *vdev = to_video_device(cd);
return video_get_drvdata(vdev); return video_get_drvdata(vdev);
} }
static ssize_t show_pan_tilt(struct class_device *class_dev, char *buf) static ssize_t show_pan_tilt(struct device *class_dev,
struct device_attribute *attr, char *buf)
{ {
struct pwc_device *pdev = cd_to_pwc(class_dev); struct pwc_device *pdev = cd_to_pwc(class_dev);
return sprintf(buf, "%d %d\n", pdev->pan_angle, pdev->tilt_angle); return sprintf(buf, "%d %d\n", pdev->pan_angle, pdev->tilt_angle);
} }
static ssize_t store_pan_tilt(struct class_device *class_dev, const char *buf, static ssize_t store_pan_tilt(struct device *class_dev,
size_t count) struct device_attribute *attr,
const char *buf, size_t count)
{ {
struct pwc_device *pdev = cd_to_pwc(class_dev); struct pwc_device *pdev = cd_to_pwc(class_dev);
int pan, tilt; int pan, tilt;
...@@ -1025,10 +1027,11 @@ static ssize_t store_pan_tilt(struct class_device *class_dev, const char *buf, ...@@ -1025,10 +1027,11 @@ static ssize_t store_pan_tilt(struct class_device *class_dev, const char *buf,
return ret; return ret;
return strlen(buf); return strlen(buf);
} }
static CLASS_DEVICE_ATTR(pan_tilt, S_IRUGO | S_IWUSR, show_pan_tilt, static DEVICE_ATTR(pan_tilt, S_IRUGO | S_IWUSR, show_pan_tilt,
store_pan_tilt); store_pan_tilt);
static ssize_t show_snapshot_button_status(struct class_device *class_dev, char *buf) static ssize_t show_snapshot_button_status(struct device *class_dev,
struct device_attribute *attr, char *buf)
{ {
struct pwc_device *pdev = cd_to_pwc(class_dev); struct pwc_device *pdev = cd_to_pwc(class_dev);
int status = pdev->snapshot_button_status; int status = pdev->snapshot_button_status;
...@@ -1036,26 +1039,26 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char ...@@ -1036,26 +1039,26 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
return sprintf(buf, "%d\n", status); return sprintf(buf, "%d\n", status);
} }
static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, static DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status,
NULL); NULL);
static int pwc_create_sysfs_files(struct video_device *vdev) static int pwc_create_sysfs_files(struct video_device *vdev)
{ {
struct pwc_device *pdev = video_get_drvdata(vdev); struct pwc_device *pdev = video_get_drvdata(vdev);
int rc; int rc;
rc = video_device_create_file(vdev, &class_device_attr_button); rc = video_device_create_file(vdev, &dev_attr_button);
if (rc) if (rc)
goto err; goto err;
if (pdev->features & FEATURE_MOTOR_PANTILT) { if (pdev->features & FEATURE_MOTOR_PANTILT) {
rc = video_device_create_file(vdev,&class_device_attr_pan_tilt); rc = video_device_create_file(vdev, &dev_attr_pan_tilt);
if (rc) goto err_button; if (rc) goto err_button;
} }
return 0; return 0;
err_button: err_button:
video_device_remove_file(vdev, &class_device_attr_button); video_device_remove_file(vdev, &dev_attr_button);
err: err:
return rc; return rc;
} }
...@@ -1064,8 +1067,8 @@ static void pwc_remove_sysfs_files(struct video_device *vdev) ...@@ -1064,8 +1067,8 @@ static void pwc_remove_sysfs_files(struct video_device *vdev)
{ {
struct pwc_device *pdev = video_get_drvdata(vdev); struct pwc_device *pdev = video_get_drvdata(vdev);
if (pdev->features & FEATURE_MOTOR_PANTILT) if (pdev->features & FEATURE_MOTOR_PANTILT)
video_device_remove_file(vdev, &class_device_attr_pan_tilt); video_device_remove_file(vdev, &dev_attr_pan_tilt);
video_device_remove_file(vdev, &class_device_attr_button); video_device_remove_file(vdev, &dev_attr_button);
} }
#ifdef CONFIG_USB_PWC_DEBUG #ifdef CONFIG_USB_PWC_DEBUG
......
...@@ -1029,7 +1029,8 @@ static u16 sn9c102_strtou16(const char* buff, size_t len, ssize_t* count) ...@@ -1029,7 +1029,8 @@ static u16 sn9c102_strtou16(const char* buff, size_t len, ssize_t* count)
NOTE 2: buffers are PAGE_SIZE long NOTE 2: buffers are PAGE_SIZE long
*/ */
static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf) static ssize_t sn9c102_show_reg(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
ssize_t count; ssize_t count;
...@@ -1053,7 +1054,8 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf) ...@@ -1053,7 +1054,8 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf)
static ssize_t static ssize_t
sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) sn9c102_store_reg(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
u16 index; u16 index;
...@@ -1086,7 +1088,8 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) ...@@ -1086,7 +1088,8 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) static ssize_t sn9c102_show_val(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
ssize_t count; ssize_t count;
...@@ -1118,7 +1121,8 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) ...@@ -1118,7 +1121,8 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
static ssize_t static ssize_t
sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) sn9c102_store_val(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
u16 value; u16 value;
...@@ -1157,7 +1161,8 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) ...@@ -1157,7 +1161,8 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) static ssize_t sn9c102_show_i2c_reg(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
ssize_t count; ssize_t count;
...@@ -1183,7 +1188,8 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) ...@@ -1183,7 +1188,8 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
static ssize_t static ssize_t
sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) sn9c102_store_i2c_reg(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
u16 index; u16 index;
...@@ -1216,7 +1222,8 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) ...@@ -1216,7 +1222,8 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
} }
static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) static ssize_t sn9c102_show_i2c_val(struct device* cd,
struct device_attribute *attr, char* buf)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
ssize_t count; ssize_t count;
...@@ -1253,7 +1260,8 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) ...@@ -1253,7 +1260,8 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
static ssize_t static ssize_t
sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) sn9c102_store_i2c_val(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
u16 value; u16 value;
...@@ -1298,7 +1306,8 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) ...@@ -1298,7 +1306,8 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
static ssize_t static ssize_t
sn9c102_store_green(struct class_device* cd, const char* buf, size_t len) sn9c102_store_green(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
enum sn9c102_bridge bridge; enum sn9c102_bridge bridge;
...@@ -1329,16 +1338,16 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len) ...@@ -1329,16 +1338,16 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len)
case BRIDGE_SN9C102: case BRIDGE_SN9C102:
if (value > 0x0f) if (value > 0x0f)
return -EINVAL; return -EINVAL;
if ((res = sn9c102_store_reg(cd, "0x11", 4)) >= 0) if ((res = sn9c102_store_reg(cd, attr, "0x11", 4)) >= 0)
res = sn9c102_store_val(cd, buf, len); res = sn9c102_store_val(cd, attr, buf, len);
break; break;
case BRIDGE_SN9C103: case BRIDGE_SN9C103:
case BRIDGE_SN9C105: case BRIDGE_SN9C105:
case BRIDGE_SN9C120: case BRIDGE_SN9C120:
if (value > 0x7f) if (value > 0x7f)
return -EINVAL; return -EINVAL;
if ((res = sn9c102_store_reg(cd, "0x07", 4)) >= 0) if ((res = sn9c102_store_reg(cd, attr, "0x07", 4)) >= 0)
res = sn9c102_store_val(cd, buf, len); res = sn9c102_store_val(cd, attr, buf, len);
break; break;
} }
...@@ -1347,7 +1356,8 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len) ...@@ -1347,7 +1356,8 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len)
static ssize_t static ssize_t
sn9c102_store_blue(struct class_device* cd, const char* buf, size_t len) sn9c102_store_blue(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
ssize_t res = 0; ssize_t res = 0;
u16 value; u16 value;
...@@ -1357,15 +1367,16 @@ sn9c102_store_blue(struct class_device* cd, const char* buf, size_t len) ...@@ -1357,15 +1367,16 @@ sn9c102_store_blue(struct class_device* cd, const char* buf, size_t len)
if (!count || value > 0x7f) if (!count || value > 0x7f)
return -EINVAL; return -EINVAL;
if ((res = sn9c102_store_reg(cd, "0x06", 4)) >= 0) if ((res = sn9c102_store_reg(cd, attr, "0x06", 4)) >= 0)
res = sn9c102_store_val(cd, buf, len); res = sn9c102_store_val(cd, attr, buf, len);
return res; return res;
} }
static ssize_t static ssize_t
sn9c102_store_red(struct class_device* cd, const char* buf, size_t len) sn9c102_store_red(struct device* cd, struct device_attribute *attr,
const char* buf, size_t len)
{ {
ssize_t res = 0; ssize_t res = 0;
u16 value; u16 value;
...@@ -1375,14 +1386,16 @@ sn9c102_store_red(struct class_device* cd, const char* buf, size_t len) ...@@ -1375,14 +1386,16 @@ sn9c102_store_red(struct class_device* cd, const char* buf, size_t len)
if (!count || value > 0x7f) if (!count || value > 0x7f)
return -EINVAL; return -EINVAL;
if ((res = sn9c102_store_reg(cd, "0x05", 4)) >= 0) if ((res = sn9c102_store_reg(cd, attr, "0x05", 4)) >= 0)
res = sn9c102_store_val(cd, buf, len); res = sn9c102_store_val(cd, attr, buf, len);
return res; return res;
} }
static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf) static ssize_t sn9c102_show_frame_header(struct device* cd,
struct device_attribute *attr,
char* buf)
{ {
struct sn9c102_device* cam; struct sn9c102_device* cam;
ssize_t count; ssize_t count;
...@@ -1401,72 +1414,63 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf) ...@@ -1401,72 +1414,63 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
} }
static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, static DEVICE_ATTR(reg, S_IRUGO | S_IWUSR, sn9c102_show_reg, sn9c102_store_reg);
sn9c102_show_reg, sn9c102_store_reg); static DEVICE_ATTR(val, S_IRUGO | S_IWUSR, sn9c102_show_val, sn9c102_store_val);
static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR, static DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
sn9c102_show_val, sn9c102_store_val); sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR, static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
sn9c102_show_i2c_reg, sn9c102_store_i2c_reg); sn9c102_show_i2c_val, sn9c102_store_i2c_val);
static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR, static DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
sn9c102_show_i2c_val, sn9c102_store_i2c_val); static DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green); static DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue); static DEVICE_ATTR(frame_header, S_IRUGO, sn9c102_show_frame_header, NULL);
static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
sn9c102_show_frame_header, NULL);
static int sn9c102_create_sysfs(struct sn9c102_device* cam) static int sn9c102_create_sysfs(struct sn9c102_device* cam)
{ {
struct class_device *classdev = &(cam->v4ldev->class_dev); struct device *classdev = &(cam->v4ldev->class_dev);
int err = 0; int err = 0;
if ((err = class_device_create_file(classdev, &class_device_attr_reg))) if ((err = device_create_file(classdev, &dev_attr_reg)))
goto err_out; goto err_out;
if ((err = class_device_create_file(classdev, &class_device_attr_val))) if ((err = device_create_file(classdev, &dev_attr_val)))
goto err_reg; goto err_reg;
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_frame_header)))
&class_device_attr_frame_header)))
goto err_val; goto err_val;
if (cam->sensor.sysfs_ops) { if (cam->sensor.sysfs_ops) {
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_i2c_reg)))
&class_device_attr_i2c_reg)))
goto err_frame_header; goto err_frame_header;
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_i2c_val)))
&class_device_attr_i2c_val)))
goto err_i2c_reg; goto err_i2c_reg;
} }
if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) { if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_green)))
&class_device_attr_green)))
goto err_i2c_val; goto err_i2c_val;
} else { } else {
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_blue)))
&class_device_attr_blue)))
goto err_i2c_val; goto err_i2c_val;
if ((err = class_device_create_file(classdev, if ((err = device_create_file(classdev, &dev_attr_red)))
&class_device_attr_red)))
goto err_blue; goto err_blue;
} }
return 0; return 0;
err_blue: err_blue:
class_device_remove_file(classdev, &class_device_attr_blue); device_remove_file(classdev, &dev_attr_blue);
err_i2c_val: err_i2c_val:
if (cam->sensor.sysfs_ops) if (cam->sensor.sysfs_ops)
class_device_remove_file(classdev, &class_device_attr_i2c_val); device_remove_file(classdev, &dev_attr_i2c_val);
err_i2c_reg: err_i2c_reg:
if (cam->sensor.sysfs_ops) if (cam->sensor.sysfs_ops)
class_device_remove_file(classdev, &class_device_attr_i2c_reg); device_remove_file(classdev, &dev_attr_i2c_reg);
err_frame_header: err_frame_header:
class_device_remove_file(classdev, &class_device_attr_frame_header); device_remove_file(classdev, &dev_attr_frame_header);
err_val: err_val:
class_device_remove_file(classdev, &class_device_attr_val); device_remove_file(classdev, &dev_attr_val);
err_reg: err_reg:
class_device_remove_file(classdev, &class_device_attr_reg); device_remove_file(classdev, &dev_attr_reg);
err_out: err_out:
return err; return err;
} }
......
...@@ -499,13 +499,14 @@ static int stv_init (struct usb_stv *stv680) ...@@ -499,13 +499,14 @@ static int stv_init (struct usb_stv *stv680)
* sysfs * sysfs
***************************************************************************/ ***************************************************************************/
#define stv680_file(name, variable, field) \ #define stv680_file(name, variable, field) \
static ssize_t show_##name(struct class_device *class_dev, char *buf) \ static ssize_t show_##name(struct device *class_dev, \
struct device_attribute *attr, char *buf) \
{ \ { \
struct video_device *vdev = to_video_device(class_dev); \ struct video_device *vdev = to_video_device(class_dev); \
struct usb_stv *stv = video_get_drvdata(vdev); \ struct usb_stv *stv = video_get_drvdata(vdev); \
return sprintf(buf, field, stv->variable); \ return sprintf(buf, field, stv->variable); \
} \ } \
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL); static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
stv680_file(model, camera_name, "%s\n"); stv680_file(model, camera_name, "%s\n");
stv680_file(in_use, user, "%d\n"); stv680_file(in_use, user, "%d\n");
...@@ -520,53 +521,53 @@ static int stv680_create_sysfs_files(struct video_device *vdev) ...@@ -520,53 +521,53 @@ static int stv680_create_sysfs_files(struct video_device *vdev)
{ {
int rc; int rc;
rc = video_device_create_file(vdev, &class_device_attr_model); rc = video_device_create_file(vdev, &dev_attr_model);
if (rc) goto err; if (rc) goto err;
rc = video_device_create_file(vdev, &class_device_attr_in_use); rc = video_device_create_file(vdev, &dev_attr_in_use);
if (rc) goto err_model; if (rc) goto err_model;
rc = video_device_create_file(vdev, &class_device_attr_streaming); rc = video_device_create_file(vdev, &dev_attr_streaming);
if (rc) goto err_inuse; if (rc) goto err_inuse;
rc = video_device_create_file(vdev, &class_device_attr_palette); rc = video_device_create_file(vdev, &dev_attr_palette);
if (rc) goto err_stream; if (rc) goto err_stream;
rc = video_device_create_file(vdev, &class_device_attr_frames_total); rc = video_device_create_file(vdev, &dev_attr_frames_total);
if (rc) goto err_pal; if (rc) goto err_pal;
rc = video_device_create_file(vdev, &class_device_attr_frames_read); rc = video_device_create_file(vdev, &dev_attr_frames_read);
if (rc) goto err_framtot; if (rc) goto err_framtot;
rc = video_device_create_file(vdev, &class_device_attr_packets_dropped); rc = video_device_create_file(vdev, &dev_attr_packets_dropped);
if (rc) goto err_framread; if (rc) goto err_framread;
rc = video_device_create_file(vdev, &class_device_attr_decoding_errors); rc = video_device_create_file(vdev, &dev_attr_decoding_errors);
if (rc) goto err_dropped; if (rc) goto err_dropped;
return 0; return 0;
err_dropped: err_dropped:
video_device_remove_file(vdev, &class_device_attr_packets_dropped); video_device_remove_file(vdev, &dev_attr_packets_dropped);
err_framread: err_framread:
video_device_remove_file(vdev, &class_device_attr_frames_read); video_device_remove_file(vdev, &dev_attr_frames_read);
err_framtot: err_framtot:
video_device_remove_file(vdev, &class_device_attr_frames_total); video_device_remove_file(vdev, &dev_attr_frames_total);
err_pal: err_pal:
video_device_remove_file(vdev, &class_device_attr_palette); video_device_remove_file(vdev, &dev_attr_palette);
err_stream: err_stream:
video_device_remove_file(vdev, &class_device_attr_streaming); video_device_remove_file(vdev, &dev_attr_streaming);
err_inuse: err_inuse:
video_device_remove_file(vdev, &class_device_attr_in_use); video_device_remove_file(vdev, &dev_attr_in_use);
err_model: err_model:
video_device_remove_file(vdev, &class_device_attr_model); video_device_remove_file(vdev, &dev_attr_model);
err: err:
return rc; return rc;
} }
static void stv680_remove_sysfs_files(struct video_device *vdev) static void stv680_remove_sysfs_files(struct video_device *vdev)
{ {
video_device_remove_file(vdev, &class_device_attr_model); video_device_remove_file(vdev, &dev_attr_model);
video_device_remove_file(vdev, &class_device_attr_in_use); video_device_remove_file(vdev, &dev_attr_in_use);
video_device_remove_file(vdev, &class_device_attr_streaming); video_device_remove_file(vdev, &dev_attr_streaming);
video_device_remove_file(vdev, &class_device_attr_palette); video_device_remove_file(vdev, &dev_attr_palette);
video_device_remove_file(vdev, &class_device_attr_frames_total); video_device_remove_file(vdev, &dev_attr_frames_total);
video_device_remove_file(vdev, &class_device_attr_frames_read); video_device_remove_file(vdev, &dev_attr_frames_read);
video_device_remove_file(vdev, &class_device_attr_packets_dropped); video_device_remove_file(vdev, &dev_attr_packets_dropped);
video_device_remove_file(vdev, &class_device_attr_decoding_errors); video_device_remove_file(vdev, &dev_attr_decoding_errors);
} }
/******************************************************************** /********************************************************************
......
...@@ -182,20 +182,22 @@ MODULE_ALIAS(DRIVER_ALIAS); ...@@ -182,20 +182,22 @@ MODULE_ALIAS(DRIVER_ALIAS);
#define YES_NO(x) ((x) ? "Yes" : "No") #define YES_NO(x) ((x) ? "Yes" : "No")
static inline struct usb_usbvision *cd_to_usbvision(struct class_device *cd) static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
return video_get_drvdata(vdev); return video_get_drvdata(vdev);
} }
static ssize_t show_version(struct class_device *cd, char *buf) static ssize_t show_version(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%s\n", USBVISION_VERSION_STRING); return sprintf(buf, "%s\n", USBVISION_VERSION_STRING);
} }
static CLASS_DEVICE_ATTR(version, S_IRUGO, show_version, NULL); static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
static ssize_t show_model(struct class_device *cd, char *buf) static ssize_t show_model(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -203,9 +205,10 @@ static ssize_t show_model(struct class_device *cd, char *buf) ...@@ -203,9 +205,10 @@ static ssize_t show_model(struct class_device *cd, char *buf)
return sprintf(buf, "%s\n", return sprintf(buf, "%s\n",
usbvision_device_data[usbvision->DevModel].ModelString); usbvision_device_data[usbvision->DevModel].ModelString);
} }
static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL); static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
static ssize_t show_hue(struct class_device *cd, char *buf) static ssize_t show_hue(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -217,9 +220,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf) ...@@ -217,9 +220,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value); return sprintf(buf, "%d\n", ctrl.value);
} }
static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL); static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
static ssize_t show_contrast(struct class_device *cd, char *buf) static ssize_t show_contrast(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -231,9 +235,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf) ...@@ -231,9 +235,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value); return sprintf(buf, "%d\n", ctrl.value);
} }
static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL); static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
static ssize_t show_brightness(struct class_device *cd, char *buf) static ssize_t show_brightness(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -245,9 +250,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf) ...@@ -245,9 +250,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value); return sprintf(buf, "%d\n", ctrl.value);
} }
static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL); static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
static ssize_t show_saturation(struct class_device *cd, char *buf) static ssize_t show_saturation(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -259,9 +265,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf) ...@@ -259,9 +265,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl); call_i2c_clients(usbvision, VIDIOC_G_CTRL, &ctrl);
return sprintf(buf, "%d\n", ctrl.value); return sprintf(buf, "%d\n", ctrl.value);
} }
static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL); static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
static ssize_t show_streaming(struct class_device *cd, char *buf) static ssize_t show_streaming(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -269,9 +276,10 @@ static ssize_t show_streaming(struct class_device *cd, char *buf) ...@@ -269,9 +276,10 @@ static ssize_t show_streaming(struct class_device *cd, char *buf)
return sprintf(buf, "%s\n", return sprintf(buf, "%s\n",
YES_NO(usbvision->streaming==Stream_On?1:0)); YES_NO(usbvision->streaming==Stream_On?1:0));
} }
static CLASS_DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
static ssize_t show_compression(struct class_device *cd, char *buf) static ssize_t show_compression(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
...@@ -279,16 +287,17 @@ static ssize_t show_compression(struct class_device *cd, char *buf) ...@@ -279,16 +287,17 @@ static ssize_t show_compression(struct class_device *cd, char *buf)
return sprintf(buf, "%s\n", return sprintf(buf, "%s\n",
YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS)); YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
} }
static CLASS_DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
static ssize_t show_device_bridge(struct class_device *cd, char *buf) static ssize_t show_device_bridge(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vdev = struct video_device *vdev =
container_of(cd, struct video_device, class_dev); container_of(cd, struct video_device, class_dev);
struct usb_usbvision *usbvision = video_get_drvdata(vdev); struct usb_usbvision *usbvision = video_get_drvdata(vdev);
return sprintf(buf, "%d\n", usbvision->bridgeType); return sprintf(buf, "%d\n", usbvision->bridgeType);
} }
static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); static DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL);
static void usbvision_create_sysfs(struct video_device *vdev) static void usbvision_create_sysfs(struct video_device *vdev)
{ {
...@@ -296,40 +305,40 @@ static void usbvision_create_sysfs(struct video_device *vdev) ...@@ -296,40 +305,40 @@ static void usbvision_create_sysfs(struct video_device *vdev)
if (!vdev) if (!vdev)
return; return;
do { do {
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_version); &dev_attr_version);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_model); &dev_attr_model);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_hue); &dev_attr_hue);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_contrast); &dev_attr_contrast);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_brightness); &dev_attr_brightness);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_saturation); &dev_attr_saturation);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_streaming); &dev_attr_streaming);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_compression); &dev_attr_compression);
if (res<0) if (res<0)
break; break;
res=class_device_create_file(&vdev->class_dev, res = device_create_file(&vdev->class_dev,
&class_device_attr_bridge); &dev_attr_bridge);
if (res>=0) if (res>=0)
return; return;
} while (0); } while (0);
...@@ -340,24 +349,24 @@ static void usbvision_create_sysfs(struct video_device *vdev) ...@@ -340,24 +349,24 @@ static void usbvision_create_sysfs(struct video_device *vdev)
static void usbvision_remove_sysfs(struct video_device *vdev) static void usbvision_remove_sysfs(struct video_device *vdev)
{ {
if (vdev) { if (vdev) {
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_version); &dev_attr_version);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_model); &dev_attr_model);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_hue); &dev_attr_hue);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_contrast); &dev_attr_contrast);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_brightness); &dev_attr_brightness);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_saturation); &dev_attr_saturation);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_streaming); &dev_attr_streaming);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_compression); &dev_attr_compression);
class_device_remove_file(&vdev->class_dev, device_remove_file(&vdev->class_dev,
&class_device_attr_bridge); &dev_attr_bridge);
} }
} }
......
...@@ -54,15 +54,14 @@ ...@@ -54,15 +54,14 @@
* sysfs stuff * sysfs stuff
*/ */
static ssize_t show_name(struct class_device *cd, char *buf) static ssize_t show_name(struct device *cd,
struct device_attribute *attr, char *buf)
{ {
struct video_device *vfd = container_of(cd, struct video_device, struct video_device *vfd = container_of(cd, struct video_device,
class_dev); class_dev);
return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name); return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
} }
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
struct video_device *video_device_alloc(void) struct video_device *video_device_alloc(void)
{ {
struct video_device *vfd; struct video_device *vfd;
...@@ -76,10 +75,9 @@ void video_device_release(struct video_device *vfd) ...@@ -76,10 +75,9 @@ void video_device_release(struct video_device *vfd)
kfree(vfd); kfree(vfd);
} }
static void video_release(struct class_device *cd) static void video_release(struct device *cd)
{ {
struct video_device *vfd = container_of(cd, struct video_device, struct video_device *vfd = container_of(cd, struct video_device, class_dev);
class_dev);
#if 1 #if 1
/* needed until all drivers are fixed */ /* needed until all drivers are fixed */
...@@ -89,9 +87,15 @@ static void video_release(struct class_device *cd) ...@@ -89,9 +87,15 @@ static void video_release(struct class_device *cd)
vfd->release(vfd); vfd->release(vfd);
} }
static struct device_attribute video_device_attrs[] = {
__ATTR(name, S_IRUGO, show_name, NULL),
__ATTR_NULL
};
static struct class video_class = { static struct class video_class = {
.name = VIDEO_NAME, .name = VIDEO_NAME,
.release = video_release, .dev_attrs = video_device_attrs,
.dev_release = video_release,
}; };
/* /*
...@@ -1753,22 +1757,16 @@ int video_register_device(struct video_device *vfd, int type, int nr) ...@@ -1753,22 +1757,16 @@ int video_register_device(struct video_device *vfd, int type, int nr)
/* sysfs class */ /* sysfs class */
memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
if (vfd->dev) if (vfd->dev)
vfd->class_dev.dev = vfd->dev; vfd->class_dev.parent = vfd->dev;
vfd->class_dev.class = &video_class; vfd->class_dev.class = &video_class;
vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base); sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
ret = class_device_register(&vfd->class_dev); ret = device_register(&vfd->class_dev);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "%s: class_device_register failed\n", printk(KERN_ERR "%s: device_register failed\n",
__FUNCTION__); __FUNCTION__);
goto fail_minor; goto fail_minor;
} }
ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
if (ret < 0) {
printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
__FUNCTION__);
goto fail_classdev;
}
#if 1 #if 1
/* needed until all drivers are fixed */ /* needed until all drivers are fixed */
...@@ -1779,8 +1777,6 @@ int video_register_device(struct video_device *vfd, int type, int nr) ...@@ -1779,8 +1777,6 @@ int video_register_device(struct video_device *vfd, int type, int nr)
#endif #endif
return 0; return 0;
fail_classdev:
class_device_unregister(&vfd->class_dev);
fail_minor: fail_minor:
mutex_lock(&videodev_lock); mutex_lock(&videodev_lock);
video_device[vfd->minor] = NULL; video_device[vfd->minor] = NULL;
...@@ -1804,7 +1800,7 @@ void video_unregister_device(struct video_device *vfd) ...@@ -1804,7 +1800,7 @@ void video_unregister_device(struct video_device *vfd)
panic("videodev: bad unregister"); panic("videodev: bad unregister");
video_device[vfd->minor]=NULL; video_device[vfd->minor]=NULL;
class_device_unregister(&vfd->class_dev); device_unregister(&vfd->class_dev);
mutex_unlock(&videodev_lock); mutex_unlock(&videodev_lock);
} }
......
...@@ -86,8 +86,11 @@ struct video_device ...@@ -86,8 +86,11 @@ struct video_device
/* device ops */ /* device ops */
const struct file_operations *fops; const struct file_operations *fops;
/* sysfs */
struct device class_dev; /* v4l device */
struct device *dev; /* device parent */
/* device info */ /* device info */
struct device *dev;
char name[32]; char name[32];
int type; /* v4l1 */ int type; /* v4l1 */
int type2; /* v4l2 */ int type2; /* v4l2 */
...@@ -332,7 +335,6 @@ void *priv; ...@@ -332,7 +335,6 @@ void *priv;
/* for videodev.c intenal usage -- please don't touch */ /* for videodev.c intenal usage -- please don't touch */
int users; /* video_exclusive_{open|close} ... */ int users; /* video_exclusive_{open|close} ... */
struct mutex lock; /* ... helper function uses these */ struct mutex lock; /* ... helper function uses these */
struct class_device class_dev; /* sysfs */
}; };
/* Class-dev to video-device */ /* Class-dev to video-device */
...@@ -360,18 +362,18 @@ extern int video_usercopy(struct inode *inode, struct file *file, ...@@ -360,18 +362,18 @@ extern int video_usercopy(struct inode *inode, struct file *file,
static inline int __must_check static inline int __must_check
video_device_create_file(struct video_device *vfd, video_device_create_file(struct video_device *vfd,
struct class_device_attribute *attr) struct device_attribute *attr)
{ {
int ret = class_device_create_file(&vfd->class_dev, attr); int ret = device_create_file(&vfd->class_dev, attr);
if (ret < 0) if (ret < 0)
printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret); printk(KERN_WARNING "%s error: %d\n", __FUNCTION__, ret);
return ret; return ret;
} }
static inline void static inline void
video_device_remove_file(struct video_device *vfd, video_device_remove_file(struct video_device *vfd,
struct class_device_attribute *attr) struct device_attribute *attr)
{ {
class_device_remove_file(&vfd->class_dev, attr); device_remove_file(&vfd->class_dev, attr);
} }
#endif /* CONFIG_VIDEO_V4L1_COMPAT */ #endif /* CONFIG_VIDEO_V4L1_COMPAT */
......
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