greybus: camera: Use pointer for gb camera module ops
authorGjorgji Rosikopulos <grosikopulos@mm-sol.com>
Thu, 31 Mar 2016 11:12:45 +0000 (14:12 +0300)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 31 Mar 2016 17:07:59 +0000 (10:07 -0700)
No need to duplicate module ops on every registration.

NOTE: Change should be along merged with:
"msm: camera: Change gb_camera_module ops to pointer"

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/camera.c
drivers/staging/greybus/gb-camera.h

index a871b0f33733164351e9277a67dace2f4ea3384f..2de91d59a54e47df4e843f9021f03254db771579 100644 (file)
@@ -498,23 +498,30 @@ static int gb_camera_op_capture(void *priv, u32 request_id,
                unsigned int streams, unsigned int num_frames,
                size_t settings_size, const void *settings)
 {
-       return gb_camera_capture(priv, request_id, streams, num_frames,
+       struct gb_camera *gcam = priv;
+
+       return gb_camera_capture(gcam, request_id, streams, num_frames,
                                 settings_size, settings);
 }
 
 static int gb_camera_op_flush(void *priv, u32 *request_id)
 {
-       return gb_camera_flush(priv, request_id);
+       struct gb_camera *gcam = priv;
+
+       return gb_camera_flush(gcam, request_id);
 }
 
+static const struct gb_camera_ops gb_cam_ops = {
+       .capabilities = gb_camera_op_capabilities,
+       .configure_streams = gb_camera_op_configure_streams,
+       .capture = gb_camera_op_capture,
+       .flush = gb_camera_op_flush,
+};
+
 static int gb_camera_register_intf_ops(struct gb_camera *gcam)
 {
        gcam->module.priv = gcam;
-       gcam->module.ops.capabilities = gb_camera_op_capabilities;
-       gcam->module.ops.configure_streams = gb_camera_op_configure_streams;
-       gcam->module.ops.capture = gb_camera_op_capture;
-       gcam->module.ops.flush = gb_camera_op_flush;
-
+       gcam->module.ops = &gb_cam_ops;
        return gb_camera_register(&gcam->module);
 }
 
index 0a48a16b675ea6881a62d527482d86566354beb5..273b4fa6dd4f2bde188d86f18a19a19f19d1871f 100644 (file)
@@ -36,14 +36,14 @@ struct gb_camera_ops {
 
 struct gb_camera_module {
        void *priv;
-       struct gb_camera_ops ops;
+       const struct gb_camera_ops *ops;
 
        struct list_head list; /* Global list */
 };
 
 #define gb_camera_call(f, op, args...)      \
-       ((!(f) ? -ENODEV : ((f)->ops.op) ?  \
-       (f)->ops.op((f)->priv, ##args) : -ENOIOCTLCMD))
+       (!(f) ? -ENODEV : (((f)->ops->op) ?  \
+       (f)->ops->op((f)->priv, ##args) : -ENOIOCTLCMD))
 
 int gb_camera_register(struct gb_camera_module *module);
 int gb_camera_unregister(struct gb_camera_module *module);