Skip to contentSkip to conversation

media: rockchip: rkisp1: Constify static structs

PATCH In review Rikard Falkeborn 2 participants 2 messages Nov 19, 2020 – Nov 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: rockchip: rkisp1: Constify static structs

These 'ops' structs are never modified, so make them const to allow the compiler to put them in read-only memory.

---
 drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c | 6 +++---
 drivers/media/platform/rockchip/rkisp1/rkisp1-common.h  | 2 +-
 drivers/media/platform/rockchip/rkisp1/rkisp1-params.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +3 -3
index b81235afd053..380582f68ace 100644
@@ -565,7 +565,7 @@ static void rkisp1_sp_set_data_path(struct rkisp1_capture *cap)
 	rkisp1_write(cap->rkisp1, dpcl, RKISP1_CIF_VI_DPCL);
 }
 
-static struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
+static const struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
 	.config = rkisp1_mp_config,
 	.enable = rkisp1_mp_enable,
 	.disable = rkisp1_mp_disable,
@@ -574,7 +574,7 @@ static struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
 	.is_stopped = rkisp1_mp_is_stopped,
 };
 
-static struct rkisp1_capture_ops rkisp1_capture_ops_sp = {
+static const struct rkisp1_capture_ops rkisp1_capture_ops_sp = {
 	.config = rkisp1_sp_config,
 	.enable = rkisp1_sp_enable,
 	.disable = rkisp1_sp_disable,
@@ -1038,7 +1038,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
 	return ret;
 }
 
-static struct vb2_ops rkisp1_vb2_ops = {
+static const struct vb2_ops rkisp1_vb2_ops = {
 	.queue_setup = rkisp1_vb2_queue_setup,
 	.buf_queue = rkisp1_vb2_buf_queue,
 	.buf_prepare = rkisp1_vb2_buf_prepare,
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -1
index 3a134e97161c..038c303a8aed 100644
@@ -214,7 +214,7 @@ struct rkisp1_capture {
 	struct rkisp1_vdev_node vnode;
 	struct rkisp1_device *rkisp1;
 	enum rkisp1_stream_id id;
-	struct rkisp1_capture_ops *ops;
+	const struct rkisp1_capture_ops *ops;
 	const struct rkisp1_capture_config *config;
 	bool is_streaming;
 	bool is_stopping;
drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +2 -2
index 03f9a81df440..6af4d551ffb5 100644
@@ -1469,7 +1469,7 @@ static void rkisp1_params_vb2_stop_streaming(struct vb2_queue *vq)
 		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
 }
 
-static struct vb2_ops rkisp1_params_vb2_ops = {
+static const struct vb2_ops rkisp1_params_vb2_ops = {
 	.queue_setup = rkisp1_params_vb2_queue_setup,
 	.wait_prepare = vb2_ops_wait_prepare,
 	.wait_finish = vb2_ops_wait_finish,
@@ -1479,7 +1479,7 @@ static struct vb2_ops rkisp1_params_vb2_ops = {
 
 };
 
-static struct v4l2_file_operations rkisp1_params_fops = {
+static const struct v4l2_file_operations rkisp1_params_fops = {
 	.mmap = vb2_fop_mmap,
 	.unlocked_ioctl = video_ioctl2,
 	.poll = vb2_fop_poll,
Signature · 7 lines
2.29.2


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Reviewed-by on v1 1/1
#1 lore raw

Am 19.11.20 um 23:18 schrieb Rikard Falkeborn:

Quoted 4 lines

These 'ops' structs are never modified, so make them const to allow the compiler to put them in read-only memory.

Thanks!

Quoted 73 lines
---
  drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c | 6 +++---
  drivers/media/platform/rockchip/rkisp1/rkisp1-common.h  | 2 +-
  drivers/media/platform/rockchip/rkisp1/rkisp1-params.c  | 4 ++--
  3 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +3 -3
index b81235afd053..380582f68ace 100644
@@ -565,7 +565,7 @@ static void rkisp1_sp_set_data_path(struct rkisp1_capture *cap)
  	rkisp1_write(cap->rkisp1, dpcl, RKISP1_CIF_VI_DPCL);
  }
 
-static struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
+static const struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
  	.config = rkisp1_mp_config,
  	.enable = rkisp1_mp_enable,
  	.disable = rkisp1_mp_disable,
@@ -574,7 +574,7 @@ static struct rkisp1_capture_ops rkisp1_capture_ops_mp = {
  	.is_stopped = rkisp1_mp_is_stopped,
  };
 
-static struct rkisp1_capture_ops rkisp1_capture_ops_sp = {
+static const struct rkisp1_capture_ops rkisp1_capture_ops_sp = {
  	.config = rkisp1_sp_config,
  	.enable = rkisp1_sp_enable,
  	.disable = rkisp1_sp_disable,
@@ -1038,7 +1038,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
  	return ret;
  }
 
-static struct vb2_ops rkisp1_vb2_ops = {
+static const struct vb2_ops rkisp1_vb2_ops = {
  	.queue_setup = rkisp1_vb2_queue_setup,
  	.buf_queue = rkisp1_vb2_buf_queue,
  	.buf_prepare = rkisp1_vb2_buf_prepare,
drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +1 -1
index 3a134e97161c..038c303a8aed 100644
@@ -214,7 +214,7 @@ struct rkisp1_capture {
  	struct rkisp1_vdev_node vnode;
  	struct rkisp1_device *rkisp1;
  	enum rkisp1_stream_id id;
-	struct rkisp1_capture_ops *ops;
+	const struct rkisp1_capture_ops *ops;
  	const struct rkisp1_capture_config *config;
  	bool is_streaming;
  	bool is_stopping;
drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +2 -2
index 03f9a81df440..6af4d551ffb5 100644
@@ -1469,7 +1469,7 @@ static void rkisp1_params_vb2_stop_streaming(struct vb2_queue *vq)
  		vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
  }
 
-static struct vb2_ops rkisp1_params_vb2_ops = {
+static const struct vb2_ops rkisp1_params_vb2_ops = {
  	.queue_setup = rkisp1_params_vb2_queue_setup,
  	.wait_prepare = vb2_ops_wait_prepare,
  	.wait_finish = vb2_ops_wait_finish,
@@ -1479,7 +1479,7 @@ static struct vb2_ops rkisp1_params_vb2_ops = {
 
  };
 
-static struct v4l2_file_operations rkisp1_params_fops = {
+static const struct v4l2_file_operations rkisp1_params_fops = {
  	.mmap = vb2_fop_mmap,
  	.unlocked_ioctl = video_ioctl2,
  	.poll = vb2_fop_poll,