media: s5p-mfc: constify s5p_mfc_buf_size structures
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Sun, 24 Dec 2023 15:44:04 +0000 (16:44 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 22 Jan 2024 11:16:43 +0000 (12:16 +0100)
Static "s5p_mfc_buf_size*" structures are not modified by the driver, so
they can be made const for code safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Aakarsh Jain <aakarsh.jain@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c

index fbb047eadf5afffe4c8db70660a6fc630dc56d57..2af166b84f7d9985e05d7ec3f9d4c8d5feff72aa 100644 (file)
@@ -1520,14 +1520,14 @@ static const struct dev_pm_ops s5p_mfc_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(s5p_mfc_suspend, s5p_mfc_resume)
 };
 
-static struct s5p_mfc_buf_size_v5 mfc_buf_size_v5 = {
+static const struct s5p_mfc_buf_size_v5 mfc_buf_size_v5 = {
        .h264_ctx       = MFC_H264_CTX_BUF_SIZE,
        .non_h264_ctx   = MFC_CTX_BUF_SIZE,
        .dsc            = DESC_BUF_SIZE,
        .shm            = SHARED_BUF_SIZE,
 };
 
-static struct s5p_mfc_buf_size buf_size_v5 = {
+static const struct s5p_mfc_buf_size buf_size_v5 = {
        .fw     = MAX_FW_SIZE,
        .cpb    = MAX_CPB_SIZE,
        .priv   = &mfc_buf_size_v5,
@@ -1544,7 +1544,7 @@ static struct s5p_mfc_variant mfc_drvdata_v5 = {
        .use_clock_gating = true,
 };
 
-static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
+static const struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
        .dev_ctx        = MFC_CTX_BUF_SIZE_V6,
        .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V6,
        .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V6,
@@ -1552,7 +1552,7 @@ static struct s5p_mfc_buf_size_v6 mfc_buf_size_v6 = {
        .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V6,
 };
 
-static struct s5p_mfc_buf_size buf_size_v6 = {
+static const struct s5p_mfc_buf_size buf_size_v6 = {
        .fw     = MAX_FW_SIZE_V6,
        .cpb    = MAX_CPB_SIZE_V6,
        .priv   = &mfc_buf_size_v6,
@@ -1573,7 +1573,7 @@ static struct s5p_mfc_variant mfc_drvdata_v6 = {
        .num_clocks     = 1,
 };
 
-static struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
+static const struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
        .dev_ctx        = MFC_CTX_BUF_SIZE_V7,
        .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V7,
        .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V7,
@@ -1581,7 +1581,7 @@ static struct s5p_mfc_buf_size_v6 mfc_buf_size_v7 = {
        .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V7,
 };
 
-static struct s5p_mfc_buf_size buf_size_v7 = {
+static const struct s5p_mfc_buf_size buf_size_v7 = {
        .fw     = MAX_FW_SIZE_V7,
        .cpb    = MAX_CPB_SIZE_V7,
        .priv   = &mfc_buf_size_v7,
@@ -1607,7 +1607,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7_3250 = {
        .num_clocks     = 2,
 };
 
-static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
+static const struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
        .dev_ctx        = MFC_CTX_BUF_SIZE_V8,
        .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V8,
        .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V8,
@@ -1615,7 +1615,7 @@ static struct s5p_mfc_buf_size_v6 mfc_buf_size_v8 = {
        .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V8,
 };
 
-static struct s5p_mfc_buf_size buf_size_v8 = {
+static const struct s5p_mfc_buf_size buf_size_v8 = {
        .fw     = MAX_FW_SIZE_V8,
        .cpb    = MAX_CPB_SIZE_V8,
        .priv   = &mfc_buf_size_v8,
@@ -1641,7 +1641,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
        .num_clocks     = 3,
 };
 
-static struct s5p_mfc_buf_size_v6 mfc_buf_size_v10 = {
+static const struct s5p_mfc_buf_size_v6 mfc_buf_size_v10 = {
        .dev_ctx        = MFC_CTX_BUF_SIZE_V10,
        .h264_dec_ctx   = MFC_H264_DEC_CTX_BUF_SIZE_V10,
        .other_dec_ctx  = MFC_OTHER_DEC_CTX_BUF_SIZE_V10,
@@ -1650,7 +1650,7 @@ static struct s5p_mfc_buf_size_v6 mfc_buf_size_v10 = {
        .other_enc_ctx  = MFC_OTHER_ENC_CTX_BUF_SIZE_V10,
 };
 
-static struct s5p_mfc_buf_size buf_size_v10 = {
+static const struct s5p_mfc_buf_size buf_size_v10 = {
        .fw     = MAX_FW_SIZE_V10,
        .cpb    = MAX_CPB_SIZE_V10,
        .priv   = &mfc_buf_size_v10,
index f8588e52dfc823a52fbfc3a50b8ec97053d0ea19..25c4719a5dd058791c537c6ac03f8b263cb52e85 100644 (file)
@@ -32,7 +32,7 @@ static int s5p_mfc_cmd_host2risc_v6(struct s5p_mfc_dev *dev, int cmd,
 static int s5p_mfc_sys_init_cmd_v6(struct s5p_mfc_dev *dev)
 {
        struct s5p_mfc_cmd_args h2r_args;
-       struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
        int ret;
 
        ret = s5p_mfc_hw_call(dev->mfc_ops, alloc_dev_context_buffer, dev);
index cd4361ac6d5df6e4a68dfabb3595b653b1ebf5af..77ebceeb65e8691f375de89a872730f375e4adfd 100644 (file)
@@ -221,14 +221,14 @@ struct s5p_mfc_buf_size_v6 {
 struct s5p_mfc_buf_size {
        unsigned int fw;
        unsigned int cpb;
-       void *priv;
+       const void *priv;
 };
 
 struct s5p_mfc_variant {
        unsigned int version;
        unsigned int port_num;
        u32 version_bit;
-       struct s5p_mfc_buf_size *buf_size;
+       const struct s5p_mfc_buf_size *buf_size;
        const char      *fw_name[MFC_FW_MAX_VERSIONS];
        const char      *clk_names[MFC_MAX_CLOCKS];
        int             num_clocks;
index 3957f28d4547c097c8a78aee35d7bf6a4ec4db93..ad7a868af6c3fce4550c0bf151968c784153d0f6 100644 (file)
@@ -445,7 +445,7 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
        struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
        int ret = 0;
        struct v4l2_pix_format_mplane *pix_mp;
-       struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
+       const struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
 
        mfc_debug_enter();
        ret = vidioc_try_fmt(file, priv, f);
index fcfaf125a5a1df814263c26a7cce65775932380f..37293e833b625546a865032dfd445ae0a46d5b12 100644 (file)
@@ -34,7 +34,7 @@
 static int s5p_mfc_alloc_dec_temp_buffers_v5(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
        int ret;
 
        ctx->dsc.size = buf_size->dsc;
@@ -200,7 +200,7 @@ static void s5p_mfc_release_codec_buffers_v5(struct s5p_mfc_ctx *ctx)
 static int s5p_mfc_alloc_instance_buffer_v5(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
        int ret;
 
        if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
@@ -345,7 +345,7 @@ static void s5p_mfc_enc_calc_src_size_v5(struct s5p_mfc_ctx *ctx)
 static void s5p_mfc_set_dec_desc_buffer(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v5 *buf_size = dev->variant->buf_size->priv;
 
        mfc_write(dev, OFFSETA(ctx->dsc.dma), S5P_FIMV_SI_CH0_DESC_ADR);
        mfc_write(dev, buf_size->dsc, S5P_FIMV_SI_CH0_DESC_SIZE);
index fd945211d28e7793176a06a6c400e476aad2b30f..2573f101838c31d8f3c1078f0f54eaad64c4e279 100644 (file)
@@ -383,7 +383,7 @@ static void s5p_mfc_release_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
 static int s5p_mfc_alloc_instance_buffer_v6(struct s5p_mfc_ctx *ctx)
 {
        struct s5p_mfc_dev *dev = ctx->dev;
-       struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
        int ret;
 
        mfc_debug_enter();
@@ -443,7 +443,7 @@ static void s5p_mfc_release_instance_buffer_v6(struct s5p_mfc_ctx *ctx)
 /* Allocate context buffers for SYS_INIT */
 static int s5p_mfc_alloc_dev_context_buffer_v6(struct s5p_mfc_dev *dev)
 {
-       struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
+       const struct s5p_mfc_buf_size_v6 *buf_size = dev->variant->buf_size->priv;
        int ret;
 
        mfc_debug_enter();
@@ -587,7 +587,7 @@ static int s5p_mfc_set_dec_stream_buffer_v6(struct s5p_mfc_ctx *ctx,
 {
        struct s5p_mfc_dev *dev = ctx->dev;
        const struct s5p_mfc_regs *mfc_regs = dev->mfc_regs;
-       struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
+       const struct s5p_mfc_buf_size *buf_size = dev->variant->buf_size;
 
        mfc_debug_enter();
        mfc_debug(2, "inst_no: %d, buf_addr: 0x%08x,\n"