Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 39577
b: refs/heads/master
c: c12e3be
h: refs/heads/master
i:
  39575: 329d76c
v: v3
  • Loading branch information
Jeff Garzik authored and Mauro Carvalho Chehab committed Oct 14, 2006
1 parent 8de9444 commit ad23a8c
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2444a2fca488fa8e362895a4ca9fdc51f497282a
refs/heads/master: c12e3be0860652ed1e15c9442adcba44317211d1
37 changes: 31 additions & 6 deletions trunk/drivers/media/video/et61x251/et61x251_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,16 +973,32 @@ static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
et61x251_show_i2c_val, et61x251_store_i2c_val);


static void et61x251_create_sysfs(struct et61x251_device* cam)
static int et61x251_create_sysfs(struct et61x251_device* cam)
{
struct video_device *v4ldev = cam->v4ldev;
int rc;

video_device_create_file(v4ldev, &class_device_attr_reg);
video_device_create_file(v4ldev, &class_device_attr_val);
rc = video_device_create_file(v4ldev, &class_device_attr_reg);
if (rc) goto err;
rc = video_device_create_file(v4ldev, &class_device_attr_val);
if (rc) goto err_reg;
if (cam->sensor.sysfs_ops) {
video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
video_device_create_file(v4ldev, &class_device_attr_i2c_val);
rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
if (rc) goto err_val;
rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
if (rc) goto err_i2c_reg;
}

return 0;

err_i2c_reg:
video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
err_val:
video_device_remove_file(v4ldev, &class_device_attr_val);
err_reg:
video_device_remove_file(v4ldev, &class_device_attr_reg);
err:
return rc;
}
#endif /* CONFIG_VIDEO_ADV_DEBUG */

Expand Down Expand Up @@ -2534,7 +2550,9 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;

#ifdef CONFIG_VIDEO_ADV_DEBUG
et61x251_create_sysfs(cam);
err = et61x251_create_sysfs(cam);
if (err)
goto fail2;
DBG(2, "Optional device control through 'sysfs' interface ready");
#endif

Expand All @@ -2544,6 +2562,13 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)

return 0;

#ifdef CONFIG_VIDEO_ADV_DEBUG
fail2:
video_nr[dev_nr] = -1;
dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
mutex_unlock(&cam->dev_mutex);
video_unregister_device(cam->v4ldev);
#endif
fail:
if (cam) {
kfree(cam->control_buffer);
Expand Down
41 changes: 32 additions & 9 deletions trunk/drivers/media/video/pwc/pwc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,12 +1024,25 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status,
NULL);

static void 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);
if (pdev->features & FEATURE_MOTOR_PANTILT)
video_device_create_file(vdev, &class_device_attr_pan_tilt);
video_device_create_file(vdev, &class_device_attr_button);
int rc;

rc = video_device_create_file(vdev, &class_device_attr_button);
if (rc)
goto err;
if (pdev->features & FEATURE_MOTOR_PANTILT) {
rc = video_device_create_file(vdev,&class_device_attr_pan_tilt);
if (rc) goto err_button;
}

return 0;

err_button:
video_device_remove_file(vdev, &class_device_attr_button);
err:
return rc;
}

static void pwc_remove_sysfs_files(struct video_device *vdev)
Expand Down Expand Up @@ -1408,7 +1421,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
struct usb_device *udev = interface_to_usbdev(intf);
struct pwc_device *pdev = NULL;
int vendor_id, product_id, type_id;
int i, hint;
int i, hint, rc;
int features = 0;
int video_nr = -1; /* default: use next available device */
char serial_number[30], *name;
Expand Down Expand Up @@ -1709,9 +1722,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
if (i < 0) {
PWC_ERROR("Failed to register as video device (%d).\n", i);
video_device_release(pdev->vdev); /* Drip... drip... drip... */
kfree(pdev); /* Oops, no memory leaks please */
return -EIO;
rc = i;
goto err;
}
else {
PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F);
Expand All @@ -1723,13 +1735,24 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id

PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
usb_set_intfdata (intf, pdev);
pwc_create_sysfs_files(pdev->vdev);
rc = pwc_create_sysfs_files(pdev->vdev);
if (rc)
goto err_unreg;

/* Set the leds off */
pwc_set_leds(pdev, 0, 0);
pwc_camera_power(pdev, 0);

return 0;

err_unreg:
if (hint < MAX_DEV_HINTS)
device_hint[hint].pdev = NULL;
video_unregister_device(pdev->vdev);
err:
video_device_release(pdev->vdev); /* Drip... drip... drip... */
kfree(pdev); /* Oops, no memory leaks please */
return rc;
}

/* The user janked out the cable... */
Expand Down
71 changes: 54 additions & 17 deletions trunk/drivers/media/video/sn9c102/sn9c102_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,23 +1240,53 @@ static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
sn9c102_show_frame_header, NULL);


static void sn9c102_create_sysfs(struct sn9c102_device* cam)
static int sn9c102_create_sysfs(struct sn9c102_device* cam)
{
struct video_device *v4ldev = cam->v4ldev;
int rc;

rc = video_device_create_file(v4ldev, &class_device_attr_reg);
if (rc) goto err;
rc = video_device_create_file(v4ldev, &class_device_attr_val);
if (rc) goto err_reg;
rc = video_device_create_file(v4ldev, &class_device_attr_frame_header);
if (rc) goto err_val;

video_device_create_file(v4ldev, &class_device_attr_reg);
video_device_create_file(v4ldev, &class_device_attr_val);
video_device_create_file(v4ldev, &class_device_attr_frame_header);
if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102)
video_device_create_file(v4ldev, &class_device_attr_green);
else if (cam->bridge == BRIDGE_SN9C103) {
video_device_create_file(v4ldev, &class_device_attr_blue);
video_device_create_file(v4ldev, &class_device_attr_red);
}
if (cam->sensor.sysfs_ops) {
video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
video_device_create_file(v4ldev, &class_device_attr_i2c_val);
rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
if (rc) goto err_frhead;
rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
if (rc) goto err_i2c_reg;
}

if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
rc = video_device_create_file(v4ldev, &class_device_attr_green);
if (rc) goto err_i2c_val;
} else if (cam->bridge == BRIDGE_SN9C103) {
rc = video_device_create_file(v4ldev, &class_device_attr_blue);
if (rc) goto err_i2c_val;
rc = video_device_create_file(v4ldev, &class_device_attr_red);
if (rc) goto err_blue;
}

return 0;

err_blue:
video_device_remove_file(v4ldev, &class_device_attr_blue);
err_i2c_val:
if (cam->sensor.sysfs_ops)
video_device_remove_file(v4ldev, &class_device_attr_i2c_val);
err_i2c_reg:
if (cam->sensor.sysfs_ops)
video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
err_frhead:
video_device_remove_file(v4ldev, &class_device_attr_frame_header);
err_val:
video_device_remove_file(v4ldev, &class_device_attr_val);
err_reg:
video_device_remove_file(v4ldev, &class_device_attr_reg);
err:
return rc;
}
#endif /* CONFIG_VIDEO_ADV_DEBUG */

Expand Down Expand Up @@ -2809,10 +2839,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
DBG(1, "V4L2 device registration failed");
if (err == -ENFILE && video_nr[dev_nr] == -1)
DBG(1, "Free /dev/videoX node not found");
video_nr[dev_nr] = -1;
dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
mutex_unlock(&cam->dev_mutex);
goto fail;
goto fail2;
}

DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor);
Expand All @@ -2823,7 +2850,9 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;

#ifdef CONFIG_VIDEO_ADV_DEBUG
sn9c102_create_sysfs(cam);
err = sn9c102_create_sysfs(cam);
if (err)
goto fail3;
DBG(2, "Optional device control through 'sysfs' interface ready");
#endif

Expand All @@ -2833,6 +2862,14 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)

return 0;

#ifdef CONFIG_VIDEO_ADV_DEBUG
fail3:
video_unregister_device(cam->v4ldev);
#endif
fail2:
video_nr[dev_nr] = -1;
dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
mutex_unlock(&cam->dev_mutex);
fail:
if (cam) {
kfree(cam->control_buffer);
Expand Down

0 comments on commit ad23a8c

Please sign in to comment.