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

Commit 22a04f10 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (8429): videodev: renamed 'class_dev' to 'dev'



The class_dev field is a normal device, not a class device. This is very
confusing and now that the old 'dev' field has been renamed to 'parent'
we can rename 'class_dev' to just 'dev'.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 5e85e732
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ MODULE_LICENSE("GPL");
static ssize_t show_card(struct device *cd,
			 struct device_attribute *attr, char *buf)
{
	struct video_device *vfd = container_of(cd, struct video_device, class_dev);
	struct video_device *vfd = container_of(cd, struct video_device, dev);
	struct bttv *btv = dev_get_drvdata(vfd->parent);
	return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
}
@@ -4244,7 +4244,7 @@ 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 (device_create_file(&btv->video_dev->class_dev,
	if (device_create_file(&btv->video_dev->dev,
				     &dev_attr_card)<0) {
		printk(KERN_ERR "bttv%d: device_create_file 'card' "
		       "failed\n", btv->c.nr);
+1 −1
Original line number Diff line number Diff line
@@ -985,7 +985,7 @@ static DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,

static int et61x251_create_sysfs(struct et61x251_device* cam)
{
	struct device *classdev = &(cam->v4ldev->class_dev);
	struct device *classdev = &(cam->v4ldev->dev);
	int err = 0;

	if ((err = device_create_file(classdev, &dev_attr_reg)))
+25 −35
Original line number Diff line number Diff line
@@ -1038,8 +1038,7 @@ static ssize_t sn9c102_show_reg(struct device* cd,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1064,8 +1063,7 @@ sn9c102_store_reg(struct device* cd, struct device_attribute *attr,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1098,8 +1096,7 @@ static ssize_t sn9c102_show_val(struct device* cd,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1132,8 +1129,7 @@ sn9c102_store_val(struct device* cd, struct device_attribute *attr,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1170,8 +1166,7 @@ static ssize_t sn9c102_show_i2c_reg(struct device* cd,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1198,8 +1193,7 @@ sn9c102_store_i2c_reg(struct device* cd, struct device_attribute *attr,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1232,8 +1226,7 @@ static ssize_t sn9c102_show_i2c_val(struct device* cd,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1271,8 +1264,7 @@ sn9c102_store_i2c_val(struct device* cd, struct device_attribute *attr,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1318,8 +1310,7 @@ sn9c102_store_green(struct device* cd, struct device_attribute *attr,
	if (mutex_lock_interruptible(&sn9c102_sysfs_lock))
		return -ERESTARTSYS;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam) {
		mutex_unlock(&sn9c102_sysfs_lock);
		return -ENODEV;
@@ -1400,8 +1391,7 @@ static ssize_t sn9c102_show_frame_header(struct device* cd,
	struct sn9c102_device* cam;
	ssize_t count;

	cam = video_get_drvdata(container_of(cd, struct video_device,
					     class_dev));
	cam = video_get_drvdata(container_of(cd, struct video_device, dev));
	if (!cam)
		return -ENODEV;

@@ -1428,49 +1418,49 @@ static DEVICE_ATTR(frame_header, S_IRUGO, sn9c102_show_frame_header, NULL);

static int sn9c102_create_sysfs(struct sn9c102_device* cam)
{
	struct device *classdev = &(cam->v4ldev->class_dev);
	struct device *dev = &(cam->v4ldev->dev);
	int err = 0;

	if ((err = device_create_file(classdev, &dev_attr_reg)))
	if ((err = device_create_file(dev, &dev_attr_reg)))
		goto err_out;
	if ((err = device_create_file(classdev, &dev_attr_val)))
	if ((err = device_create_file(dev, &dev_attr_val)))
		goto err_reg;
	if ((err = device_create_file(classdev, &dev_attr_frame_header)))
	if ((err = device_create_file(dev, &dev_attr_frame_header)))
		goto err_val;

	if (cam->sensor.sysfs_ops) {
		if ((err = device_create_file(classdev, &dev_attr_i2c_reg)))
		if ((err = device_create_file(dev, &dev_attr_i2c_reg)))
			goto err_frame_header;
		if ((err = device_create_file(classdev, &dev_attr_i2c_val)))
		if ((err = device_create_file(dev, &dev_attr_i2c_val)))
			goto err_i2c_reg;
	}

	if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
		if ((err = device_create_file(classdev, &dev_attr_green)))
		if ((err = device_create_file(dev, &dev_attr_green)))
			goto err_i2c_val;
	} else {
		if ((err = device_create_file(classdev, &dev_attr_blue)))
		if ((err = device_create_file(dev, &dev_attr_blue)))
			goto err_i2c_val;
		if ((err = device_create_file(classdev, &dev_attr_red)))
		if ((err = device_create_file(dev, &dev_attr_red)))
			goto err_blue;
	}

	return 0;

err_blue:
	device_remove_file(classdev, &dev_attr_blue);
	device_remove_file(dev, &dev_attr_blue);
err_i2c_val:
	if (cam->sensor.sysfs_ops)
		device_remove_file(classdev, &dev_attr_i2c_val);
		device_remove_file(dev, &dev_attr_i2c_val);
err_i2c_reg:
	if (cam->sensor.sysfs_ops)
		device_remove_file(classdev, &dev_attr_i2c_reg);
		device_remove_file(dev, &dev_attr_i2c_reg);
err_frame_header:
	device_remove_file(classdev, &dev_attr_frame_header);
	device_remove_file(dev, &dev_attr_frame_header);
err_val:
	device_remove_file(classdev, &dev_attr_val);
	device_remove_file(dev, &dev_attr_val);
err_reg:
	device_remove_file(classdev, &dev_attr_reg);
	device_remove_file(dev, &dev_attr_reg);
err_out:
	return err;
}
+27 −45
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	return video_get_drvdata(vdev);
}

@@ -199,7 +199,7 @@ static ssize_t show_model(struct device *cd,
			  struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	return sprintf(buf, "%s\n",
		       usbvision_device_data[usbvision->DevModel].ModelString);
@@ -210,7 +210,7 @@ static ssize_t show_hue(struct device *cd,
			struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	struct v4l2_control ctrl;
	ctrl.id = V4L2_CID_HUE;
@@ -225,7 +225,7 @@ static ssize_t show_contrast(struct device *cd,
			     struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	struct v4l2_control ctrl;
	ctrl.id = V4L2_CID_CONTRAST;
@@ -240,7 +240,7 @@ static ssize_t show_brightness(struct device *cd,
			       struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	struct v4l2_control ctrl;
	ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -255,7 +255,7 @@ static ssize_t show_saturation(struct device *cd,
			       struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	struct v4l2_control ctrl;
	ctrl.id = V4L2_CID_SATURATION;
@@ -270,7 +270,7 @@ static ssize_t show_streaming(struct device *cd,
			      struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	return sprintf(buf, "%s\n",
		       YES_NO(usbvision->streaming==Stream_On?1:0));
@@ -281,7 +281,7 @@ static ssize_t show_compression(struct device *cd,
				struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	return sprintf(buf, "%s\n",
		       YES_NO(usbvision->isocMode==ISOC_MODE_COMPRESS));
@@ -292,7 +292,7 @@ static ssize_t show_device_bridge(struct device *cd,
				  struct device_attribute *attr, char *buf)
{
	struct video_device *vdev =
		container_of(cd, struct video_device, class_dev);
		container_of(cd, struct video_device, dev);
	struct usb_usbvision *usbvision = video_get_drvdata(vdev);
	return sprintf(buf, "%d\n", usbvision->bridgeType);
}
@@ -304,40 +304,31 @@ static void usbvision_create_sysfs(struct video_device *vdev)
	if (!vdev)
		return;
	do {
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_version);
		res = device_create_file(&vdev->dev, &dev_attr_version);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_model);
		res = device_create_file(&vdev->dev, &dev_attr_model);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_hue);
		res = device_create_file(&vdev->dev, &dev_attr_hue);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_contrast);
		res = device_create_file(&vdev->dev, &dev_attr_contrast);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_brightness);
		res = device_create_file(&vdev->dev, &dev_attr_brightness);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_saturation);
		res = device_create_file(&vdev->dev, &dev_attr_saturation);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_streaming);
		res = device_create_file(&vdev->dev, &dev_attr_streaming);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_compression);
		res = device_create_file(&vdev->dev, &dev_attr_compression);
		if (res<0)
			break;
		res = device_create_file(&vdev->class_dev,
					 &dev_attr_bridge);
		res = device_create_file(&vdev->dev, &dev_attr_bridge);
		if (res>=0)
			return;
	} while (0);
@@ -348,24 +339,15 @@ static void usbvision_create_sysfs(struct video_device *vdev)
static void usbvision_remove_sysfs(struct video_device *vdev)
{
	if (vdev) {
		device_remove_file(&vdev->class_dev,
					 &dev_attr_version);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_model);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_hue);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_contrast);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_brightness);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_saturation);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_streaming);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_compression);
		device_remove_file(&vdev->class_dev,
					 &dev_attr_bridge);
		device_remove_file(&vdev->dev, &dev_attr_version);
		device_remove_file(&vdev->dev, &dev_attr_model);
		device_remove_file(&vdev->dev, &dev_attr_hue);
		device_remove_file(&vdev->dev, &dev_attr_contrast);
		device_remove_file(&vdev->dev, &dev_attr_brightness);
		device_remove_file(&vdev->dev, &dev_attr_saturation);
		device_remove_file(&vdev->dev, &dev_attr_streaming);
		device_remove_file(&vdev->dev, &dev_attr_compression);
		device_remove_file(&vdev->dev, &dev_attr_bridge);
	}
}

+10 −13
Original line number Diff line number Diff line
@@ -41,16 +41,14 @@
static ssize_t show_index(struct device *cd,
			 struct device_attribute *attr, char *buf)
{
	struct video_device *vfd = container_of(cd, struct video_device,
						class_dev);
	struct video_device *vfd = container_of(cd, struct video_device, dev);
	return sprintf(buf, "%i\n", vfd->index);
}

static ssize_t show_name(struct device *cd,
			 struct device_attribute *attr, char *buf)
{
	struct video_device *vfd = container_of(cd, struct video_device,
						class_dev);
	struct video_device *vfd = container_of(cd, struct video_device, dev);
	return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name);
}

@@ -77,8 +75,7 @@ EXPORT_SYMBOL(video_device_release);

static void video_release(struct device *cd)
{
	struct video_device *vfd = container_of(cd, struct video_device,
								class_dev);
	struct video_device *vfd = container_of(cd, struct video_device, dev);

#if 1
	/* needed until all drivers are fixed */
@@ -320,13 +317,13 @@ int video_register_device_index(struct video_device *vfd, int type, int nr,
	mutex_init(&vfd->lock);

	/* sysfs class */
	memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
	vfd->class_dev.class = &video_class;
	vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
	memset(&vfd->dev, 0x00, sizeof(vfd->dev));
	vfd->dev.class = &video_class;
	vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
	if (vfd->parent)
		vfd->class_dev.parent = vfd->parent;
	sprintf(vfd->class_dev.bus_id, "%s%d", name_base, i - base);
	ret = device_register(&vfd->class_dev);
		vfd->dev.parent = vfd->parent;
	sprintf(vfd->dev.bus_id, "%s%d", name_base, i - base);
	ret = device_register(&vfd->dev);
	if (ret < 0) {
		printk(KERN_ERR "%s: device_register failed\n", __func__);
		goto fail_minor;
@@ -365,7 +362,7 @@ void video_unregister_device(struct video_device *vfd)
		panic("videodev: bad unregister");

	video_device[vfd->minor] = NULL;
	device_unregister(&vfd->class_dev);
	device_unregister(&vfd->dev);
	mutex_unlock(&videodev_lock);
}
EXPORT_SYMBOL(video_unregister_device);
Loading