v4l2_flash->iled_cdev = iled_cdev;
v4l2_flash->ops = ops;
sd->dev = dev;
- sd->of_node = of_node;
+ sd->of_node = of_node ? of_node : led_cdev->dev->of_node;
v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
sd->internal_ops = &v4l2_flash_subdev_internal_ops;
sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
if (ret < 0)
goto err_init_controls;
- if (sd->of_node)
- of_node_get(sd->of_node);
- else
- of_node_get(led_cdev->dev->of_node);
+ of_node_get(sd->of_node);
ret = v4l2_async_register_subdev(sd);
if (ret < 0)
return v4l2_flash;
err_async_register_sd:
- of_node_put(led_cdev->dev->of_node);
+ of_node_put(sd->of_node);
v4l2_ctrl_handler_free(sd->ctrl_handler);
err_init_controls:
media_entity_cleanup(&sd->entity);
v4l2_async_unregister_subdev(sd);
- if (sd->of_node)
- of_node_put(sd->of_node);
- else
- of_node_put(led_cdev->dev->of_node);
+ of_node_put(sd->of_node);
v4l2_ctrl_handler_free(sd->ctrl_handler);
media_entity_cleanup(&sd->entity);