media: v4l2-flash: Flash ops aren't mandatory
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 8 Jun 2017 11:19:49 +0000 (07:19 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 26 Jul 2017 12:41:07 +0000 (08:41 -0400)
None of the flash operations are mandatory and therefore there should be
no need for the flash ops structure either. Accept NULL.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/v4l2-core/v4l2-flash-led-class.c

index 6d69119ff09793b7d92d158b77b436ea11f6cd34..aabc85dbb8b596c026e2e981a86eea4a91d44eb8 100644 (file)
@@ -18,7 +18,7 @@
 #include <media/v4l2-flash-led-class.h>
 
 #define has_flash_op(v4l2_flash, op)                           \
-       (v4l2_flash && v4l2_flash->ops->op)
+       (v4l2_flash && v4l2_flash->ops && v4l2_flash->ops->op)
 
 #define call_flash_op(v4l2_flash, op, arg)                     \
                (has_flash_op(v4l2_flash, op) ?                 \
@@ -299,7 +299,6 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
                          struct v4l2_flash_ctrl_data *ctrl_init_data)
 {
        struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
-       const struct led_flash_ops *fled_cdev_ops = fled_cdev->ops;
        struct led_classdev *led_cdev = &fled_cdev->led_cdev;
        struct v4l2_ctrl_config *ctrl_cfg;
        u32 mask;
@@ -376,7 +375,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
        }
 
        /* Init STROBE_STATUS ctrl data */
-       if (fled_cdev_ops->strobe_get) {
+       if (has_flash_op(fled_cdev, strobe_get)) {
                ctrl_init_data[STROBE_STATUS].cid =
                                        V4L2_CID_FLASH_STROBE_STATUS;
                ctrl_cfg = &ctrl_init_data[STROBE_STATUS].config;
@@ -386,7 +385,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
        }
 
        /* Init FLASH_TIMEOUT ctrl data */
-       if (fled_cdev_ops->timeout_set) {
+       if (has_flash_op(fled_cdev, timeout_set)) {
                ctrl_init_data[FLASH_TIMEOUT].cid = V4L2_CID_FLASH_TIMEOUT;
                ctrl_cfg = &ctrl_init_data[FLASH_TIMEOUT].config;
                __lfs_to_v4l2_ctrl_config(&fled_cdev->timeout, ctrl_cfg);
@@ -394,7 +393,7 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash,
        }
 
        /* Init FLASH_INTENSITY ctrl data */
-       if (fled_cdev_ops->flash_brightness_set) {
+       if (has_flash_op(fled_cdev, flash_brightness_set)) {
                ctrl_init_data[FLASH_INTENSITY].cid = V4L2_CID_FLASH_INTENSITY;
                ctrl_cfg = &ctrl_init_data[FLASH_INTENSITY].config;
                __lfs_to_v4l2_ctrl_config(&fled_cdev->brightness, ctrl_cfg);
@@ -618,7 +617,7 @@ struct v4l2_flash *v4l2_flash_init(
        struct v4l2_subdev *sd;
        int ret;
 
-       if (!fled_cdev || !ops || !config)
+       if (!fled_cdev || !config)
                return ERR_PTR(-EINVAL);
 
        led_cdev = &fled_cdev->led_cdev;