Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -154,13 +154,14 @@ MODULE_LICENSE("GPL");
/* ----------------------------------------------------------------------- */
/* 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 bttv *btv = dev_get_drvdata(vfd->dev);
	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                                                     */
@@ -4615,9 +4616,9 @@ static int __devinit bttv_register_video(struct bttv *btv)
		goto err;
	printk(KERN_INFO "bttv%d: registered device video%d\n",
	       btv->c.nr,btv->video_dev->minor & 0x1f);
	if (class_device_create_file(&btv->video_dev->class_dev,
				     &class_device_attr_card)<0) {
		printk(KERN_ERR "bttv%d: class_device_create_file 'card' "
	if (device_create_file(&btv->video_dev->class_dev,
				     &dev_attr_card)<0) {
		printk(KERN_ERR "bttv%d: device_create_file 'card' "
		       "failed\n", btv->c.nr);
		goto err;
	}
+32 −26
Original line number Diff line number Diff line
@@ -706,7 +706,8 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
   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;
	ssize_t count;
@@ -729,7 +730,8 @@ static ssize_t et61x251_show_reg(struct class_device* cd, char* buf)


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;
	u8 index;
@@ -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;
	ssize_t count;
@@ -792,7 +795,8 @@ static ssize_t et61x251_show_val(struct class_device* cd, char* buf)


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;
	u8 value;
@@ -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;
	ssize_t count;
@@ -855,7 +860,8 @@ static ssize_t et61x251_show_i2c_reg(struct class_device* cd, char* buf)


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;
	u8 index;
@@ -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;
	ssize_t count;
@@ -923,7 +930,8 @@ static ssize_t et61x251_show_i2c_val(struct class_device* cd, char* buf)


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;
	u8 value;
@@ -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);
static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
static DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
		   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);
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);


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;

	if ((err = class_device_create_file(classdev, &class_device_attr_reg)))
	if ((err = device_create_file(classdev, &dev_attr_reg)))
		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;

	if (cam->sensor.sysfs_ops) {
		if ((err = class_device_create_file(classdev,
						  &class_device_attr_i2c_reg)))
		if ((err = device_create_file(classdev, &dev_attr_i2c_reg)))
			goto err_val;
		if ((err = class_device_create_file(classdev,
						  &class_device_attr_i2c_val)))
		if ((err = device_create_file(classdev, &dev_attr_i2c_val)))
			goto err_i2c_reg;
	}

err_i2c_reg:
	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:
	class_device_remove_file(classdev, &class_device_attr_val);
	device_remove_file(classdev, &dev_attr_val);
err_reg:
	class_device_remove_file(classdev, &class_device_attr_reg);
	device_remove_file(classdev, &dev_attr_reg);
err_out:
	return err;
}
+45 −36
Original line number Diff line number Diff line
@@ -5554,41 +5554,46 @@ ov518_configure(struct usb_ov511 *ov)
 *  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);
	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);
	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);
	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);
	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);
	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);
	unsigned short x;
@@ -5598,9 +5603,10 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
	sensor_get_brightness(ov, &x);
	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);
	unsigned short x;
@@ -5610,9 +5616,10 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
	sensor_get_saturation(ov, &x);
	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);
	unsigned short x;
@@ -5622,9 +5629,10 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
	sensor_get_contrast(ov, &x);
	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);
	unsigned short x;
@@ -5634,9 +5642,10 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
	sensor_get_hue(ov, &x);
	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);
	unsigned char exp = 0;
@@ -5646,49 +5655,49 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
	sensor_get_exposure(ov, &exp);
	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)
{
	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;
	rc = video_device_create_file(vdev, &class_device_attr_model);
	rc = video_device_create_file(vdev, &dev_attr_model);
	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;
	rc = video_device_create_file(vdev, &class_device_attr_sensor);
	rc = video_device_create_file(vdev, &dev_attr_sensor);
	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;
	rc = video_device_create_file(vdev, &class_device_attr_saturation);
	rc = video_device_create_file(vdev, &dev_attr_saturation);
	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;
	rc = video_device_create_file(vdev, &class_device_attr_hue);
	rc = video_device_create_file(vdev, &dev_attr_hue);
	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;

	return 0;

err_hue:
	video_device_remove_file(vdev, &class_device_attr_hue);
	video_device_remove_file(vdev, &dev_attr_hue);
err_contrast:
	video_device_remove_file(vdev, &class_device_attr_contrast);
	video_device_remove_file(vdev, &dev_attr_contrast);
err_sat:
	video_device_remove_file(vdev, &class_device_attr_saturation);
	video_device_remove_file(vdev, &dev_attr_saturation);
err_bright:
	video_device_remove_file(vdev, &class_device_attr_brightness);
	video_device_remove_file(vdev, &dev_attr_brightness);
err_sensor:
	video_device_remove_file(vdev, &class_device_attr_sensor);
	video_device_remove_file(vdev, &dev_attr_sensor);
err_bridge:
	video_device_remove_file(vdev, &class_device_attr_bridge);
	video_device_remove_file(vdev, &dev_attr_bridge);
err_model:
	video_device_remove_file(vdev, &class_device_attr_model);
	video_device_remove_file(vdev, &dev_attr_model);
err_id:
	video_device_remove_file(vdev, &class_device_attr_custom_id);
	video_device_remove_file(vdev, &dev_attr_custom_id);
err:
	return rc;
}
+113 −97

File changed.

Preview size limit exceeded, changes collapsed.

+17 −14
Original line number Diff line number Diff line
@@ -996,20 +996,22 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f
/*********
 * 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);
	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);
	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,
			 size_t count)
static ssize_t store_pan_tilt(struct device *class_dev,
			      struct device_attribute *attr,
			      const char *buf, size_t count)
{
	struct pwc_device *pdev = cd_to_pwc(class_dev);
	int pan, tilt;
@@ -1025,10 +1027,11 @@ static ssize_t store_pan_tilt(struct class_device *class_dev, const char *buf,
		return ret;
	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);

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);
	int status = pdev->snapshot_button_status;
@@ -1036,7 +1039,7 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
	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);

static int pwc_create_sysfs_files(struct video_device *vdev)
@@ -1044,18 +1047,18 @@ static int pwc_create_sysfs_files(struct video_device *vdev)
	struct pwc_device *pdev = video_get_drvdata(vdev);
	int rc;

	rc = video_device_create_file(vdev, &class_device_attr_button);
	rc = video_device_create_file(vdev, &dev_attr_button);
	if (rc)
		goto err;
	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;
	}

	return 0;

err_button:
	video_device_remove_file(vdev, &class_device_attr_button);
	video_device_remove_file(vdev, &dev_attr_button);
err:
	return rc;
}
@@ -1064,8 +1067,8 @@ static void pwc_remove_sysfs_files(struct video_device *vdev)
{
	struct pwc_device *pdev = video_get_drvdata(vdev);
	if (pdev->features & FEATURE_MOTOR_PANTILT)
		video_device_remove_file(vdev, &class_device_attr_pan_tilt);
	video_device_remove_file(vdev, &class_device_attr_button);
		video_device_remove_file(vdev, &dev_attr_pan_tilt);
	video_device_remove_file(vdev, &dev_attr_button);
}

#ifdef CONFIG_USB_PWC_DEBUG
Loading