Hi,
Few simple cleanups for Samsung Exynos SoC S5P MFC drivers.
Best regards,
Krzysztof
---
Krzysztof Kozlowski (15):
media: s5p-mfc: drop unused static s5p_mfc_cmds
media: s5p-mfc: drop unused static s5p_mfc_ops
media: s5p-mfc: drop unused get_*_def_fmt declarations
media: s5p-mfc: constify fw_name strings
media: s5p-mfc: constify s5p_mfc_buf_size structures
media: s5p-mfc: constify s5p_mfc_variant structures
media: s5p-mfc: constify s5p_mfc_hw_cmds structures
media: s5p-mfc: constify s5p_mfc_hw_ops structures
media: s5p-mfc: constify s5p_mfc_fmt structures
media: s5p-mfc: constify struct structures
media: s5p-mfc: constify pointers to s5p_mfc_cmd_args
media: s5p-mfc: constify local pointers to s5p_mfc_enc_params
media: s5p-mfc: drop useless clock refcnt debugging
media: s5p-mfc: drop useless static s5p_mfc_dev in s5p_mfc_pm.c
media: s5p-mfc: drop static device variable in s5p_mfc_pm.c
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 76 +++++++++++-----------
.../media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c | 8 +--
.../media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h | 2 +-
.../platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c | 6 +-
.../platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h | 2 +-
.../platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 8 +--
.../platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h | 2 +-
.../platform/samsung/s5p-mfc/s5p_mfc_common.h | 14 ++--
.../media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c | 26 ++++----
.../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 20 +++---
.../media/platform/samsung/s5p-mfc/s5p_mfc_dec.h | 3 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 12 ++--
.../media/platform/samsung/s5p-mfc/s5p_mfc_enc.h | 3 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_opr.c | 7 +-
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 28 ++++----
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h | 2 +-
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 36 +++++-----
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h | 2 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_pm.c | 51 ++++++---------
.../media/platform/samsung/s5p-mfc/s5p_mfc_pm.h | 8 +--
20 files changed, 147 insertions(+), 169 deletions(-)
---
base-commit: ceb2fe0d438644e1de06b9a6468a1fb8e2199c70
change-id: 20231224-n-s5p-mfc-const-def6093c0104
Best regards,
--
Krzysztof Kozlowski <[email protected]>
File-scope static variable "s5p_mfc_cmds" is not read after assignment,
thus it can be dropped entirely.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
index 774c573dc075..196d8c99647b 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
@@ -12,14 +12,10 @@
#include "s5p_mfc_cmd_v5.h"
#include "s5p_mfc_cmd_v6.h"
-static struct s5p_mfc_hw_cmds *s5p_mfc_cmds;
-
void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev))
- s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v6();
+ dev->mfc_cmds = s5p_mfc_init_hw_cmds_v6();
else
- s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v5();
-
- dev->mfc_cmds = s5p_mfc_cmds;
+ dev->mfc_cmds = s5p_mfc_init_hw_cmds_v5();
}
--
2.34.1
File-scope static variable "s5p_mfc_ops" is not read after assignment,
thus it can be dropped entirely.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
index 673962301173..5ba791fa3676 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
@@ -14,18 +14,15 @@
#include "s5p_mfc_opr_v5.h"
#include "s5p_mfc_opr_v6.h"
-static struct s5p_mfc_hw_ops *s5p_mfc_ops;
-
void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev)
{
if (IS_MFCV6_PLUS(dev)) {
- s5p_mfc_ops = s5p_mfc_init_hw_ops_v6();
+ dev->mfc_ops = s5p_mfc_init_hw_ops_v6();
dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6;
} else {
- s5p_mfc_ops = s5p_mfc_init_hw_ops_v5();
+ dev->mfc_ops = s5p_mfc_init_hw_ops_v5();
dev->warn_start = S5P_FIMV_ERR_WARNINGS_START;
}
- dev->mfc_ops = s5p_mfc_ops;
}
void s5p_mfc_init_regs(struct s5p_mfc_dev *dev)
--
2.34.1
get_dec_def_fmt() and get_enc_def_fmt() do not have definitions, so
their declarations are pointless.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h | 1 -
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h | 1 -
2 files changed, 2 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
index 0c52ab46cff7..d4310966a0c2 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
@@ -12,7 +12,6 @@
const struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
struct vb2_ops *get_dec_queue_ops(void);
const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void);
-struct s5p_mfc_fmt *get_dec_def_fmt(bool src);
int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_dec_ctrls_delete(struct s5p_mfc_ctx *ctx);
void s5p_mfc_dec_init(struct s5p_mfc_ctx *ctx);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
index 3f1b1a037a4f..0cf08b8d40ff 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
@@ -12,7 +12,6 @@
const struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
struct vb2_ops *get_enc_queue_ops(void);
const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void);
-struct s5p_mfc_fmt *get_enc_def_fmt(bool src);
int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_enc_ctrls_delete(struct s5p_mfc_ctx *ctx);
void s5p_mfc_enc_init(struct s5p_mfc_ctx *ctx);
--
2.34.1
Constify stored pointers to firmware names for code safety. These are
not modified by the driver.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 5304f42c8c72..f33a755327ef 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -227,7 +227,7 @@ struct s5p_mfc_variant {
unsigned int port_num;
u32 version_bit;
struct s5p_mfc_buf_size *buf_size;
- char *fw_name[MFC_FW_MAX_VERSIONS];
+ const char *fw_name[MFC_FW_MAX_VERSIONS];
const char *clk_names[MFC_MAX_CLOCKS];
int num_clocks;
bool use_clock_gating;
--
2.34.1
Static "s5p_mfc_variant" structures are not modified by the driver, so
they can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index 6af7b812c5df..5d10c1cb8b92 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -1529,7 +1529,7 @@ static const struct s5p_mfc_buf_size buf_size_v5 = {
.priv = &mfc_buf_size_v5,
};
-static struct s5p_mfc_variant mfc_drvdata_v5 = {
+static const struct s5p_mfc_variant mfc_drvdata_v5 = {
.version = MFC_VERSION,
.version_bit = MFC_V5_BIT,
.port_num = MFC_NUM_PORTS,
@@ -1554,7 +1554,7 @@ static const struct s5p_mfc_buf_size buf_size_v6 = {
.priv = &mfc_buf_size_v6,
};
-static struct s5p_mfc_variant mfc_drvdata_v6 = {
+static const struct s5p_mfc_variant mfc_drvdata_v6 = {
.version = MFC_VERSION_V6,
.version_bit = MFC_V6_BIT,
.port_num = MFC_NUM_PORTS_V6,
@@ -1583,7 +1583,7 @@ static const struct s5p_mfc_buf_size buf_size_v7 = {
.priv = &mfc_buf_size_v7,
};
-static struct s5p_mfc_variant mfc_drvdata_v7 = {
+static const struct s5p_mfc_variant mfc_drvdata_v7 = {
.version = MFC_VERSION_V7,
.version_bit = MFC_V7_BIT,
.port_num = MFC_NUM_PORTS_V7,
@@ -1593,7 +1593,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
.num_clocks = 1,
};
-static struct s5p_mfc_variant mfc_drvdata_v7_3250 = {
+static const struct s5p_mfc_variant mfc_drvdata_v7_3250 = {
.version = MFC_VERSION_V7,
.version_bit = MFC_V7_BIT,
.port_num = MFC_NUM_PORTS_V7,
@@ -1617,7 +1617,7 @@ static const struct s5p_mfc_buf_size buf_size_v8 = {
.priv = &mfc_buf_size_v8,
};
-static struct s5p_mfc_variant mfc_drvdata_v8 = {
+static const struct s5p_mfc_variant mfc_drvdata_v8 = {
.version = MFC_VERSION_V8,
.version_bit = MFC_V8_BIT,
.port_num = MFC_NUM_PORTS_V8,
@@ -1627,7 +1627,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
.num_clocks = 1,
};
-static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
+static const struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
.version = MFC_VERSION_V8,
.version_bit = MFC_V8_BIT,
.port_num = MFC_NUM_PORTS_V8,
@@ -1652,7 +1652,7 @@ static const struct s5p_mfc_buf_size buf_size_v10 = {
.priv = &mfc_buf_size_v10,
};
-static struct s5p_mfc_variant mfc_drvdata_v10 = {
+static const struct s5p_mfc_variant mfc_drvdata_v10 = {
.version = MFC_VERSION_V10,
.version_bit = MFC_V10_BIT,
.port_num = MFC_NUM_PORTS_V10,
--
2.34.1
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 <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 20 ++++++++++----------
.../media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 2 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 2 +-
.../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 6 +++---
.../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 6 +++---
6 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index e30e54935d79..6af7b812c5df 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -1516,14 +1516,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,
@@ -1540,7 +1540,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,
@@ -1548,7 +1548,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,
@@ -1569,7 +1569,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,
@@ -1577,7 +1577,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,
@@ -1603,7 +1603,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,
@@ -1611,7 +1611,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,
@@ -1637,7 +1637,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,
@@ -1646,7 +1646,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,
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
index f8588e52dfc8..25c4719a5dd0 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -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);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index f33a755327ef..6a47f3434c60 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -219,14 +219,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;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index 268ffe4da53c..4dbe8792ac3d 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -426,7 +426,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);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
index 28a06dc343fd..13a3ff55e547 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
@@ -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);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index c0df5ac9fcff..70a62400908e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -333,7 +333,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();
@@ -393,7 +393,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();
@@ -493,7 +493,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"
--
2.34.1
Static "s5p_mfc_hw_cmds" structures are not modified by the driver, so
they can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
index 327e54e70611..1fbf7ed5d4cc 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
@@ -148,7 +148,7 @@ static int s5p_mfc_close_inst_cmd_v5(struct s5p_mfc_ctx *ctx)
}
/* Initialize cmd function pointers for MFC v5 */
-static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
+static const struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
.cmd_host2risc = s5p_mfc_cmd_host2risc_v5,
.sys_init_cmd = s5p_mfc_sys_init_cmd_v5,
.sleep_cmd = s5p_mfc_sleep_cmd_v5,
@@ -157,7 +157,7 @@ static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
.close_inst_cmd = s5p_mfc_close_inst_cmd_v5,
};
-struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void)
+const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void)
{
return &s5p_mfc_cmds_v5;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
index 6eafa514aebc..c626376053c4 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
@@ -11,6 +11,6 @@
#include "s5p_mfc_common.h"
-struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void);
+const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void);
#endif /* S5P_MFC_CMD_H_ */
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
index 25c4719a5dd0..740aa4dfae57 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -154,7 +154,7 @@ static int s5p_mfc_close_inst_cmd_v6(struct s5p_mfc_ctx *ctx)
}
/* Initialize cmd function pointers for MFC v6 */
-static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
+static const struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
.cmd_host2risc = s5p_mfc_cmd_host2risc_v6,
.sys_init_cmd = s5p_mfc_sys_init_cmd_v6,
.sleep_cmd = s5p_mfc_sleep_cmd_v6,
@@ -163,7 +163,7 @@ static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
.close_inst_cmd = s5p_mfc_close_inst_cmd_v6,
};
-struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
+const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
{
return &s5p_mfc_cmds_v6;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
index 9dc44460cc38..29083436f517 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
@@ -11,6 +11,6 @@
#include "s5p_mfc_common.h"
-struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void);
+const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void);
#endif /* S5P_MFC_CMD_H_ */
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 6a47f3434c60..9278ed537e9c 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -339,7 +339,7 @@ struct s5p_mfc_dev {
struct s5p_mfc_priv_buf ctx_buf;
int warn_start;
struct s5p_mfc_hw_ops *mfc_ops;
- struct s5p_mfc_hw_cmds *mfc_cmds;
+ const struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
enum s5p_mfc_fw_ver fw_ver;
bool fw_get_done;
--
2.34.1
Static "s5p_mfc_hw_ops" structures are not modified by the driver, so
they can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index 9278ed537e9c..fa556f27fa06 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -338,7 +338,7 @@ struct s5p_mfc_dev {
struct s5p_mfc_priv_buf ctx_buf;
int warn_start;
- struct s5p_mfc_hw_ops *mfc_ops;
+ const struct s5p_mfc_hw_ops *mfc_ops;
const struct s5p_mfc_hw_cmds *mfc_cmds;
const struct s5p_mfc_regs *mfc_regs;
enum s5p_mfc_fw_ver fw_ver;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
index 13a3ff55e547..2a0fb78e8e82 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1591,7 +1591,7 @@ static unsigned int s5p_mfc_get_crop_info_v_v5(struct s5p_mfc_ctx *ctx)
}
/* Initialize opr function pointers for MFC v5 */
-static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
+static const struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
.alloc_dec_temp_buffers = s5p_mfc_alloc_dec_temp_buffers_v5,
.release_dec_desc_buffer = s5p_mfc_release_dec_desc_buffer_v5,
.alloc_codec_buffers = s5p_mfc_alloc_codec_buffers_v5,
@@ -1631,7 +1631,7 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v5 = {
.get_crop_info_v = s5p_mfc_get_crop_info_v_v5,
};
-struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void)
+const struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void)
{
return &s5p_mfc_ops_v5;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h
index b53d376ead60..0b98c619676e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.h
@@ -78,5 +78,5 @@ enum MFC_SHM_OFS {
FRAME_PACK_SEI_INFO = 0x17c, /* E */
};
-struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void);
+const struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v5(void);
#endif /* S5P_MFC_OPR_H_ */
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 70a62400908e..6157c5f97707 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -2484,7 +2484,7 @@ const struct s5p_mfc_regs *s5p_mfc_init_regs_v6_plus(struct s5p_mfc_dev *dev)
}
/* Initialize opr function pointers for MFC v6 */
-static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
+static const struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
.alloc_dec_temp_buffers = s5p_mfc_alloc_dec_temp_buffers_v6,
.release_dec_desc_buffer = s5p_mfc_release_dec_desc_buffer_v6,
.alloc_codec_buffers = s5p_mfc_alloc_codec_buffers_v6,
@@ -2528,7 +2528,7 @@ static struct s5p_mfc_hw_ops s5p_mfc_ops_v6 = {
.get_e_min_scratch_buf_size = s5p_mfc_get_e_min_scratch_buf_size,
};
-struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void)
+const struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void)
{
return &s5p_mfc_ops_v6;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
index e4dd03c5454c..e4b651a8d590 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.h
@@ -52,6 +52,6 @@
#define FRAME_DELTA_DEFAULT 1
-struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void);
+const struct s5p_mfc_hw_ops *s5p_mfc_init_hw_ops_v6(void);
const struct s5p_mfc_regs *s5p_mfc_init_regs_v6_plus(struct s5p_mfc_dev *dev);
#endif /* S5P_MFC_OPR_V6_H_ */
--
2.34.1
Static "s5p_mfc_fmt" structures are not modified by the driver, so
they can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 6 +++---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 8 ++++----
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
index fa556f27fa06..e9283020070e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
@@ -633,8 +633,8 @@ struct s5p_mfc_ctx {
unsigned int int_err;
wait_queue_head_t queue;
- struct s5p_mfc_fmt *src_fmt;
- struct s5p_mfc_fmt *dst_fmt;
+ const struct s5p_mfc_fmt *src_fmt;
+ const struct s5p_mfc_fmt *dst_fmt;
struct vb2_queue vq_src;
struct vb2_queue vq_dst;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index 4dbe8792ac3d..2f664c7e9e4c 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -27,7 +27,7 @@
#include "s5p_mfc_opr.h"
#include "s5p_mfc_pm.h"
-static struct s5p_mfc_fmt formats[] = {
+static const struct s5p_mfc_fmt formats[] = {
{
.fourcc = V4L2_PIX_FMT_NV12MT_16X16,
.codec_mode = S5P_MFC_CODEC_NONE,
@@ -163,7 +163,7 @@ static struct s5p_mfc_fmt formats[] = {
#define NUM_FORMATS ARRAY_SIZE(formats)
/* Find selected format description */
-static struct s5p_mfc_fmt *find_format(struct v4l2_format *f, unsigned int t)
+static const struct s5p_mfc_fmt *find_format(struct v4l2_format *f, unsigned int t)
{
unsigned int i;
@@ -387,7 +387,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_fmt *fmt;
+ const struct s5p_mfc_fmt *fmt;
mfc_debug(2, "Type is %d\n", f->type);
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index 4b4c129c09e7..d6a4b9c701eb 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -30,7 +30,7 @@
#define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12M
#define DEF_DST_FMT_ENC V4L2_PIX_FMT_H264
-static struct s5p_mfc_fmt formats[] = {
+static const struct s5p_mfc_fmt formats[] = {
{
.fourcc = V4L2_PIX_FMT_NV12MT_16X16,
.codec_mode = S5P_MFC_CODEC_NONE,
@@ -97,7 +97,7 @@ static struct s5p_mfc_fmt formats[] = {
};
#define NUM_FORMATS ARRAY_SIZE(formats)
-static struct s5p_mfc_fmt *find_format(struct v4l2_format *f, unsigned int t)
+static const struct s5p_mfc_fmt *find_format(struct v4l2_format *f, unsigned int t)
{
unsigned int i;
@@ -1394,7 +1394,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
{
struct s5p_mfc_dev *dev = video_drvdata(file);
- struct s5p_mfc_fmt *fmt;
+ const struct s5p_mfc_fmt *fmt;
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
@@ -2355,7 +2355,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops = {
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
};
-static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
+static int check_vb_with_fmt(const struct s5p_mfc_fmt *fmt, struct vb2_buffer *vb)
{
int i;
--
2.34.1
Static "struct" structures are not modified by the driver, so
they can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 4 ++--
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index 2f664c7e9e4c..eef26d4e02cf 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -1117,7 +1117,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
}
-static struct vb2_ops s5p_mfc_dec_qops = {
+static const struct vb2_ops s5p_mfc_dec_qops = {
.queue_setup = s5p_mfc_queue_setup,
.wait_prepare = vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
@@ -1132,7 +1132,7 @@ const struct s5p_mfc_codec_ops *get_dec_codec_ops(void)
return &decoder_codec_ops;
}
-struct vb2_ops *get_dec_queue_ops(void)
+const struct vb2_ops *get_dec_queue_ops(void)
{
return &s5p_mfc_dec_qops;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
index d4310966a0c2..47a6eb9a8fc0 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
@@ -10,7 +10,7 @@
#define S5P_MFC_DEC_H_
const struct s5p_mfc_codec_ops *get_dec_codec_ops(void);
-struct vb2_ops *get_dec_queue_ops(void);
+const struct vb2_ops *get_dec_queue_ops(void);
const struct v4l2_ioctl_ops *get_dec_v4l2_ioctl_ops(void);
int s5p_mfc_dec_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_dec_ctrls_delete(struct s5p_mfc_ctx *ctx);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
index d6a4b9c701eb..537c6e603cd5 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
@@ -2594,7 +2594,7 @@ static void s5p_mfc_buf_queue(struct vb2_buffer *vb)
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
}
-static struct vb2_ops s5p_mfc_enc_qops = {
+static const struct vb2_ops s5p_mfc_enc_qops = {
.queue_setup = s5p_mfc_queue_setup,
.wait_prepare = vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
@@ -2610,7 +2610,7 @@ const struct s5p_mfc_codec_ops *get_enc_codec_ops(void)
return &encoder_codec_ops;
}
-struct vb2_ops *get_enc_queue_ops(void)
+const struct vb2_ops *get_enc_queue_ops(void)
{
return &s5p_mfc_enc_qops;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
index 0cf08b8d40ff..62d6db67fd91 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
@@ -10,7 +10,7 @@
#define S5P_MFC_ENC_H_
const struct s5p_mfc_codec_ops *get_enc_codec_ops(void);
-struct vb2_ops *get_enc_queue_ops(void);
+const struct vb2_ops *get_enc_queue_ops(void);
const struct v4l2_ioctl_ops *get_enc_v4l2_ioctl_ops(void);
int s5p_mfc_enc_ctrls_setup(struct s5p_mfc_ctx *ctx);
void s5p_mfc_enc_ctrls_delete(struct s5p_mfc_ctx *ctx);
--
2.34.1
In few places functions do not modify pointed "struct
s5p_mfc_cmd_args", thus the pointer can point to const data for
additional safety and self-documenting intention of the function.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c | 2 +-
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h
index 945d12fdceb7..172c5a63b58e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.h
@@ -19,7 +19,7 @@ struct s5p_mfc_cmd_args {
struct s5p_mfc_hw_cmds {
int (*cmd_host2risc)(struct s5p_mfc_dev *dev, int cmd,
- struct s5p_mfc_cmd_args *args);
+ const struct s5p_mfc_cmd_args *args);
int (*sys_init_cmd)(struct s5p_mfc_dev *dev);
int (*sleep_cmd)(struct s5p_mfc_dev *dev);
int (*wakeup_cmd)(struct s5p_mfc_dev *dev);
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
index 1fbf7ed5d4cc..82ee6d300c73 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
@@ -14,7 +14,7 @@
/* This function is used to send a command to the MFC */
static int s5p_mfc_cmd_host2risc_v5(struct s5p_mfc_dev *dev, int cmd,
- struct s5p_mfc_cmd_args *args)
+ const struct s5p_mfc_cmd_args *args)
{
int cur_cmd;
unsigned long timeout;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
index 740aa4dfae57..47bc3014b5d8 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
@@ -15,7 +15,7 @@
#include "s5p_mfc_cmd_v6.h"
static int s5p_mfc_cmd_host2risc_v6(struct s5p_mfc_dev *dev, int cmd,
- struct s5p_mfc_cmd_args *args)
+ const struct s5p_mfc_cmd_args *args)
{
mfc_debug(2, "Issue the command: %d\n", cmd);
--
2.34.1
Constify the local variables pointing to "struct s5p_mfc_enc_params" and
other encoding params to annotate the function is not modifying pointed
data.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
.../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 14 +++++++-------
.../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 18 +++++++++---------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
index 2a0fb78e8e82..ba22c6a3219a 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
@@ -674,7 +674,7 @@ static int s5p_mfc_set_enc_ref_buffer_v5(struct s5p_mfc_ctx *ctx)
static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
- struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
unsigned int reg;
unsigned int shm;
@@ -757,8 +757,8 @@ static int s5p_mfc_set_enc_params(struct s5p_mfc_ctx *ctx)
static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
- struct s5p_mfc_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_h264_enc_params *p_264 = &p->codec.h264;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_h264_enc_params *p_264 = &p->codec.h264;
unsigned int reg;
unsigned int shm;
@@ -914,8 +914,8 @@ static int s5p_mfc_set_enc_params_h264(struct s5p_mfc_ctx *ctx)
static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
- struct s5p_mfc_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
unsigned int reg;
unsigned int shm;
unsigned int framerate;
@@ -993,8 +993,8 @@ static int s5p_mfc_set_enc_params_mpeg4(struct s5p_mfc_ctx *ctx)
static int s5p_mfc_set_enc_params_h263(struct s5p_mfc_ctx *ctx)
{
struct s5p_mfc_dev *dev = ctx->dev;
- struct s5p_mfc_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
unsigned int reg;
unsigned int shm;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 6157c5f97707..08545213caa9 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -750,7 +750,7 @@ static int s5p_mfc_set_enc_params(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_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
unsigned int reg = 0;
mfc_debug_enter();
@@ -1196,8 +1196,8 @@ static int s5p_mfc_set_enc_params_mpeg4(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_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_mpeg4_enc_params *p_mpeg4 = &p->codec.mpeg4;
unsigned int reg = 0;
mfc_debug_enter();
@@ -1278,8 +1278,8 @@ static int s5p_mfc_set_enc_params_h263(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_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_mpeg4_enc_params *p_h263 = &p->codec.mpeg4;
unsigned int reg = 0;
mfc_debug_enter();
@@ -1348,8 +1348,8 @@ static int s5p_mfc_set_enc_params_vp8(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_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_vp8_enc_params *p_vp8 = &p->codec.vp8;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_vp8_enc_params *p_vp8 = &p->codec.vp8;
unsigned int reg = 0;
unsigned int val = 0;
@@ -1737,8 +1737,8 @@ static int s5p_mfc_h264_set_aso_slice_order_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_enc_params *p = &ctx->enc_params;
- struct s5p_mfc_h264_enc_params *p_h264 = &p->codec.h264;
+ const struct s5p_mfc_enc_params *p = &ctx->enc_params;
+ const struct s5p_mfc_h264_enc_params *p_h264 = &p->codec.h264;
int i;
if (p_h264->aso) {
--
2.34.1
Drop useless debugging of clock enabl/disable counts, because core
handles this much better.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
index 187849841a28..29b141d4a7a7 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
@@ -16,7 +16,6 @@
static struct s5p_mfc_pm *pm;
static struct s5p_mfc_dev *p_dev;
-static atomic_t clk_ref;
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
@@ -49,7 +48,6 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
pm->clock_gate = pm->clocks[0];
pm_runtime_enable(pm->device);
- atomic_set(&clk_ref, 0);
return 0;
}
@@ -60,17 +58,11 @@ void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
int s5p_mfc_clock_on(void)
{
- atomic_inc(&clk_ref);
- mfc_debug(3, "+ %d\n", atomic_read(&clk_ref));
-
return clk_enable(pm->clock_gate);
}
void s5p_mfc_clock_off(void)
{
- atomic_dec(&clk_ref);
- mfc_debug(3, "- %d\n", atomic_read(&clk_ref));
-
clk_disable(pm->clock_gate);
}
--
2.34.1
Pointer "struct s5p_mfc_dev" is stored in s5p_mfc_pm.c once and never
used again.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
index 29b141d4a7a7..ecb3065c33c9 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
@@ -15,15 +15,12 @@
#include "s5p_mfc_pm.h"
static struct s5p_mfc_pm *pm;
-static struct s5p_mfc_dev *p_dev;
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
int i;
pm = &dev->pm;
- p_dev = dev;
-
pm->num_clocks = dev->variant->num_clocks;
pm->clk_names = dev->variant->clk_names;
pm->device = &dev->plat_dev->dev;
--
2.34.1
Change the interface of power management functions in s5p_mfc_pm.c to
accept the pointer to S5P MFC device structure. instead of relying on
file-scope static variable. This makes code easier to read and modify
in case more devices are added.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 42 +++++++++++-----------
.../media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c | 26 +++++++-------
.../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 8 ++---
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 4 +--
.../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 8 ++---
.../media/platform/samsung/s5p-mfc/s5p_mfc_pm.c | 40 ++++++++++-----------
.../media/platform/samsung/s5p-mfc/s5p_mfc_pm.h | 8 ++---
7 files changed, 67 insertions(+), 69 deletions(-)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
index 5d10c1cb8b92..f0bda2f7f1c2 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
@@ -183,7 +183,7 @@ static void s5p_mfc_watchdog_worker(struct work_struct *work)
mfc_err("Error: some instance may be closing/opening\n");
spin_lock_irqsave(&dev->irqlock, flags);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
for (i = 0; i < MFC_NUM_CONTEXTS; i++) {
ctx = dev->ctx[i];
@@ -211,9 +211,9 @@ static void s5p_mfc_watchdog_worker(struct work_struct *work)
mfc_err("Failed to reload FW\n");
goto unlock;
}
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
ret = s5p_mfc_init_hw(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
if (ret)
mfc_err("Failed to reinit FW\n");
}
@@ -393,7 +393,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
wake_up_ctx(ctx, reason, err);
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
return;
}
@@ -465,7 +465,7 @@ static void s5p_mfc_handle_frame(struct s5p_mfc_ctx *ctx,
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
wake_up_ctx(ctx, reason, err);
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
/* if suspending, wake up device and do not try_run again*/
if (test_bit(0, &dev->enter_suspend))
wake_up_dev(dev, reason, err);
@@ -509,7 +509,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
}
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
wake_up_dev(dev, reason, err);
}
@@ -565,7 +565,7 @@ static void s5p_mfc_handle_seq_done(struct s5p_mfc_ctx *ctx,
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
clear_work_bit(ctx);
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
wake_up_ctx(ctx, reason, err);
}
@@ -601,14 +601,14 @@ static void s5p_mfc_handle_init_buffers(struct s5p_mfc_ctx *ctx,
}
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
wake_up(&ctx->queue);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
wake_up(&ctx->queue);
}
@@ -636,7 +636,7 @@ static void s5p_mfc_handle_stream_complete(struct s5p_mfc_ctx *ctx)
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
wake_up(&ctx->queue);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
}
@@ -688,7 +688,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
}
s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
wake_up_ctx(ctx, reason, err);
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
} else {
@@ -752,7 +752,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
if (test_and_clear_bit(0, &dev->hw_lock) == 0)
mfc_err("Failed to unlock hw\n");
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
clear_work_bit(ctx);
wake_up(&ctx->queue);
@@ -837,20 +837,20 @@ static int s5p_mfc_open(struct file *file)
dev->watchdog_timer.expires = jiffies +
msecs_to_jiffies(MFC_WATCHDOG_INTERVAL);
add_timer(&dev->watchdog_timer);
- ret = s5p_mfc_power_on();
+ ret = s5p_mfc_power_on(dev);
if (ret < 0) {
mfc_err("power on failed\n");
goto err_pwr_enable;
}
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
ret = s5p_mfc_load_firmware(dev);
if (ret) {
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
goto err_load_fw;
}
/* Init the FW */
ret = s5p_mfc_init_hw(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
if (ret)
goto err_init_hw;
}
@@ -927,7 +927,7 @@ static int s5p_mfc_open(struct file *file)
err_load_fw:
err_pwr_enable:
if (dev->num_inst == 1) {
- if (s5p_mfc_power_off() < 0)
+ if (s5p_mfc_power_off(dev) < 0)
mfc_err("power off failed\n");
del_timer_sync(&dev->watchdog_timer);
}
@@ -959,7 +959,7 @@ static int s5p_mfc_release(struct file *file)
vb2_queue_release(&ctx->vq_src);
vb2_queue_release(&ctx->vq_dst);
if (dev) {
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
/* Mark context as idle */
clear_work_bit_irqsave(ctx);
@@ -979,12 +979,12 @@ static int s5p_mfc_release(struct file *file)
mfc_debug(2, "Last instance\n");
s5p_mfc_deinit_hw(dev);
del_timer_sync(&dev->watchdog_timer);
- s5p_mfc_clock_off();
- if (s5p_mfc_power_off() < 0)
+ s5p_mfc_clock_off(dev);
+ if (s5p_mfc_power_off(dev) < 0)
mfc_err("Power off failed\n");
} else {
mfc_debug(2, "Shutting down clock\n");
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
}
}
if (dev)
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
index 6d3c92045c05..8eedf6524c39 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
@@ -215,7 +215,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
dev->risc_on = 0;
ret = s5p_mfc_reset(dev);
if (ret) {
@@ -243,7 +243,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
mfc_err("Failed to load firmware\n");
s5p_mfc_reset(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
return -EIO;
}
s5p_mfc_clean_dev_int_flags(dev);
@@ -252,14 +252,14 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
if (ret) {
mfc_err("Failed to send command to MFC - timeout\n");
s5p_mfc_reset(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
return ret;
}
mfc_debug(2, "Ok, now will wait for completion of hardware init\n");
if (s5p_mfc_wait_for_done_dev(dev, S5P_MFC_R2H_CMD_SYS_INIT_RET)) {
mfc_err("Failed to init hardware\n");
s5p_mfc_reset(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
return -EIO;
}
dev->int_cond = 0;
@@ -269,7 +269,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
mfc_err("Failed to init firmware - error: %d int: %d\n",
dev->int_err, dev->int_type);
s5p_mfc_reset(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
return -EIO;
}
if (IS_MFCV6_PLUS(dev))
@@ -279,7 +279,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
(ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
mfc_debug_leave();
return 0;
}
@@ -288,12 +288,12 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
/* Deinitialize hardware */
void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev)
{
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
s5p_mfc_reset(dev);
s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer, dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
}
int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
@@ -301,7 +301,7 @@ int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
int ret;
mfc_debug_enter();
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
s5p_mfc_clean_dev_int_flags(dev);
ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev);
if (ret) {
@@ -312,7 +312,7 @@ int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
mfc_err("Failed to sleep\n");
return -EIO;
}
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
dev->int_cond = 0;
if (dev->int_err != 0 || dev->int_type !=
S5P_MFC_R2H_CMD_SLEEP_RET) {
@@ -384,12 +384,12 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
mfc_debug_enter();
/* 0. MFC reset */
mfc_debug(2, "MFC reset..\n");
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
dev->risc_on = 0;
ret = s5p_mfc_reset(dev);
if (ret) {
mfc_err("Failed to reset MFC - timeout\n");
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
return ret;
}
mfc_debug(2, "Done MFC reset..\n");
@@ -404,7 +404,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
else
ret = s5p_mfc_wait_wakeup(dev);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
if (ret)
return ret;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
index eef26d4e02cf..b620db8896e1 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
@@ -477,7 +477,7 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
{
int ret = 0;
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
if (reqbufs->count == 0) {
mfc_debug(2, "Freeing buffers\n");
@@ -514,7 +514,7 @@ static int reqbufs_output(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
ret = -EINVAL;
}
out:
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
if (ret)
mfc_err("Failed allocating buffers for OUTPUT queue\n");
return ret;
@@ -525,7 +525,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
{
int ret = 0;
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
if (reqbufs->count == 0) {
mfc_debug(2, "Freeing buffers\n");
@@ -568,7 +568,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev, struct s5p_mfc_ctx *ctx,
ret = -EINVAL;
}
out:
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
if (ret)
mfc_err("Failed allocating buffers for CAPTURE queue\n");
return ret;
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
index ba22c6a3219a..87492db83536 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
@@ -1346,7 +1346,7 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev)
* Last frame has already been sent to MFC.
* Now obtaining frames from MFC buffer
*/
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
s5p_mfc_clean_ctx_int_flags(ctx);
if (ctx->type == MFCINST_DECODER) {
@@ -1422,7 +1422,7 @@ static void s5p_mfc_try_run_v5(struct s5p_mfc_dev *dev)
* scheduled, reduce the clock count as no one will
* ever do this, because no interrupt related to this try_run
* will ever come from hardware. */
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
}
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
index 08545213caa9..8908c159a91e 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1992,7 +1992,7 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
/* Last frame has already been sent to MFC
* Now obtaining frames from MFC buffer */
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(dev);
s5p_mfc_clean_ctx_int_flags(ctx);
if (ctx->type == MFCINST_DECODER) {
@@ -2072,7 +2072,7 @@ static void s5p_mfc_try_run_v6(struct s5p_mfc_dev *dev)
* scheduled, reduce the clock count as no one will
* ever do this, because no interrupt related to this try_run
* will ever come from hardware. */
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(dev);
}
}
@@ -2088,9 +2088,9 @@ s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned long ofs)
{
int ret;
- s5p_mfc_clock_on();
+ s5p_mfc_clock_on(ctx->dev);
ret = readl((void __iomem *)ofs);
- s5p_mfc_clock_off();
+ s5p_mfc_clock_off(ctx->dev);
return ret;
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
index ecb3065c33c9..ae4241408383 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
@@ -14,13 +14,11 @@
#include "s5p_mfc_debug.h"
#include "s5p_mfc_pm.h"
-static struct s5p_mfc_pm *pm;
-
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
{
+ struct s5p_mfc_pm *pm = &dev->pm;
int i;
- pm = &dev->pm;
pm->num_clocks = dev->variant->num_clocks;
pm->clk_names = dev->variant->clk_names;
pm->device = &dev->plat_dev->dev;
@@ -50,58 +48,58 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
void s5p_mfc_final_pm(struct s5p_mfc_dev *dev)
{
- pm_runtime_disable(pm->device);
+ pm_runtime_disable(dev->pm.device);
}
-int s5p_mfc_clock_on(void)
+int s5p_mfc_clock_on(struct s5p_mfc_dev *dev)
{
- return clk_enable(pm->clock_gate);
+ return clk_enable(dev->pm.clock_gate);
}
-void s5p_mfc_clock_off(void)
+void s5p_mfc_clock_off(struct s5p_mfc_dev *dev)
{
- clk_disable(pm->clock_gate);
+ clk_disable(dev->pm.clock_gate);
}
-int s5p_mfc_power_on(void)
+int s5p_mfc_power_on(struct s5p_mfc_dev *dev)
{
int i, ret = 0;
- ret = pm_runtime_resume_and_get(pm->device);
+ ret = pm_runtime_resume_and_get(dev->pm.device);
if (ret < 0)
return ret;
/* clock control */
- for (i = 0; i < pm->num_clocks; i++) {
- ret = clk_prepare_enable(pm->clocks[i]);
+ for (i = 0; i < dev->pm.num_clocks; i++) {
+ ret = clk_prepare_enable(dev->pm.clocks[i]);
if (ret < 0) {
mfc_err("clock prepare failed for clock: %s\n",
- pm->clk_names[i]);
+ dev->pm.clk_names[i]);
goto err;
}
}
/* prepare for software clock gating */
- clk_disable(pm->clock_gate);
+ clk_disable(dev->pm.clock_gate);
return 0;
err:
while (--i >= 0)
- clk_disable_unprepare(pm->clocks[i]);
- pm_runtime_put(pm->device);
+ clk_disable_unprepare(dev->pm.clocks[i]);
+ pm_runtime_put(dev->pm.device);
return ret;
}
-int s5p_mfc_power_off(void)
+int s5p_mfc_power_off(struct s5p_mfc_dev *dev)
{
int i;
/* finish software clock gating */
- clk_enable(pm->clock_gate);
+ clk_enable(dev->pm.clock_gate);
- for (i = 0; i < pm->num_clocks; i++)
- clk_disable_unprepare(pm->clocks[i]);
+ for (i = 0; i < dev->pm.num_clocks; i++)
+ clk_disable_unprepare(dev->pm.clocks[i]);
- return pm_runtime_put_sync(pm->device);
+ return pm_runtime_put_sync(dev->pm.device);
}
diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
index 4159d2364e87..9c71036f0385 100644
--- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
+++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
@@ -12,9 +12,9 @@
int s5p_mfc_init_pm(struct s5p_mfc_dev *dev);
void s5p_mfc_final_pm(struct s5p_mfc_dev *dev);
-int s5p_mfc_clock_on(void);
-void s5p_mfc_clock_off(void);
-int s5p_mfc_power_on(void);
-int s5p_mfc_power_off(void);
+int s5p_mfc_clock_on(struct s5p_mfc_dev *dev);
+void s5p_mfc_clock_off(struct s5p_mfc_dev *dev);
+int s5p_mfc_power_on(struct s5p_mfc_dev *dev);
+int s5p_mfc_power_off(struct s5p_mfc_dev *dev);
#endif /* S5P_MFC_PM_H_ */
--
2.34.1
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 01/15] media: s5p-mfc: drop unused static s5p_mfc_cmds
>
> File-scope static variable "s5p_mfc_cmds" is not read after assignment, thus
> it can be dropped entirely.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
> index 774c573dc075..196d8c99647b 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd.c
> @@ -12,14 +12,10 @@
> #include "s5p_mfc_cmd_v5.h"
> #include "s5p_mfc_cmd_v6.h"
>
> -static struct s5p_mfc_hw_cmds *s5p_mfc_cmds;
> -
> void s5p_mfc_init_hw_cmds(struct s5p_mfc_dev *dev) {
> if (IS_MFCV6_PLUS(dev))
> - s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v6();
> + dev->mfc_cmds = s5p_mfc_init_hw_cmds_v6();
> else
> - s5p_mfc_cmds = s5p_mfc_init_hw_cmds_v5();
> -
> - dev->mfc_cmds = s5p_mfc_cmds;
> + dev->mfc_cmds = s5p_mfc_init_hw_cmds_v5();
> }
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 02/15] media: s5p-mfc: drop unused static s5p_mfc_ops
>
> File-scope static variable "s5p_mfc_ops" is not read after assignment, thus it
> can be dropped entirely.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
> index 673962301173..5ba791fa3676 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr.c
> @@ -14,18 +14,15 @@
> #include "s5p_mfc_opr_v5.h"
> #include "s5p_mfc_opr_v6.h"
>
> -static struct s5p_mfc_hw_ops *s5p_mfc_ops;
> -
> void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev) {
> if (IS_MFCV6_PLUS(dev)) {
> - s5p_mfc_ops = s5p_mfc_init_hw_ops_v6();
> + dev->mfc_ops = s5p_mfc_init_hw_ops_v6();
> dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6;
> } else {
> - s5p_mfc_ops = s5p_mfc_init_hw_ops_v5();
> + dev->mfc_ops = s5p_mfc_init_hw_ops_v5();
> dev->warn_start = S5P_FIMV_ERR_WARNINGS_START;
> }
> - dev->mfc_ops = s5p_mfc_ops;
> }
>
> void s5p_mfc_init_regs(struct s5p_mfc_dev *dev)
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 03/15] media: s5p-mfc: drop unused get_*_def_fmt
> declarations
>
> get_dec_def_fmt() and get_enc_def_fmt() do not have definitions, so their
> declarations are pointless.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h | 1 -
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h | 1 -
> 2 files changed, 2 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
> index 0c52ab46cff7..d4310966a0c2 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.h
> @@ -12,7 +12,6 @@
> const struct s5p_mfc_codec_ops *get_dec_codec_ops(void); struct
> vb2_ops *get_dec_queue_ops(void); const struct v4l2_ioctl_ops
> *get_dec_v4l2_ioctl_ops(void); -struct s5p_mfc_fmt
> *get_dec_def_fmt(bool src); int s5p_mfc_dec_ctrls_setup(struct
> s5p_mfc_ctx *ctx); void s5p_mfc_dec_ctrls_delete(struct s5p_mfc_ctx
> *ctx); void s5p_mfc_dec_init(struct s5p_mfc_ctx *ctx); diff --git
> a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
> index 3f1b1a037a4f..0cf08b8d40ff 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.h
> @@ -12,7 +12,6 @@
> const struct s5p_mfc_codec_ops *get_enc_codec_ops(void); struct
> vb2_ops *get_enc_queue_ops(void); const struct v4l2_ioctl_ops
> *get_enc_v4l2_ioctl_ops(void); -struct s5p_mfc_fmt
> *get_enc_def_fmt(bool src); int s5p_mfc_enc_ctrls_setup(struct
> s5p_mfc_ctx *ctx); void s5p_mfc_enc_ctrls_delete(struct s5p_mfc_ctx
> *ctx); void s5p_mfc_enc_init(struct s5p_mfc_ctx *ctx);
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 06/15] media: s5p-mfc: constify s5p_mfc_variant structures
>
> Static "s5p_mfc_variant" structures are not modified by the driver, so they
> can be made const for code safety.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> index 6af7b812c5df..5d10c1cb8b92 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> @@ -1529,7 +1529,7 @@ static const struct s5p_mfc_buf_size buf_size_v5 =
> {
> .priv = &mfc_buf_size_v5,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v5 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v5 = {
> .version = MFC_VERSION,
> .version_bit = MFC_V5_BIT,
> .port_num = MFC_NUM_PORTS,
> @@ -1554,7 +1554,7 @@ static const struct s5p_mfc_buf_size buf_size_v6 =
> {
> .priv = &mfc_buf_size_v6,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v6 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v6 = {
> .version = MFC_VERSION_V6,
> .version_bit = MFC_V6_BIT,
> .port_num = MFC_NUM_PORTS_V6,
> @@ -1583,7 +1583,7 @@ static const struct s5p_mfc_buf_size buf_size_v7 =
> {
> .priv = &mfc_buf_size_v7,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v7 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v7 = {
> .version = MFC_VERSION_V7,
> .version_bit = MFC_V7_BIT,
> .port_num = MFC_NUM_PORTS_V7,
> @@ -1593,7 +1593,7 @@ static struct s5p_mfc_variant mfc_drvdata_v7 = {
> .num_clocks = 1,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v7_3250 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v7_3250 = {
> .version = MFC_VERSION_V7,
> .version_bit = MFC_V7_BIT,
> .port_num = MFC_NUM_PORTS_V7,
> @@ -1617,7 +1617,7 @@ static const struct s5p_mfc_buf_size buf_size_v8 =
> {
> .priv = &mfc_buf_size_v8,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v8 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v8 = {
> .version = MFC_VERSION_V8,
> .version_bit = MFC_V8_BIT,
> .port_num = MFC_NUM_PORTS_V8,
> @@ -1627,7 +1627,7 @@ static struct s5p_mfc_variant mfc_drvdata_v8 = {
> .num_clocks = 1,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v8_5433 = {
> .version = MFC_VERSION_V8,
> .version_bit = MFC_V8_BIT,
> .port_num = MFC_NUM_PORTS_V8,
> @@ -1652,7 +1652,7 @@ static const struct s5p_mfc_buf_size buf_size_v10
> = {
> .priv = &mfc_buf_size_v10,
> };
>
> -static struct s5p_mfc_variant mfc_drvdata_v10 = {
> +static const struct s5p_mfc_variant mfc_drvdata_v10 = {
> .version = MFC_VERSION_V10,
> .version_bit = MFC_V10_BIT,
> .port_num = MFC_NUM_PORTS_V10,
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 05/15] media: s5p-mfc: constify s5p_mfc_buf_size
> structures
>
> 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 <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 20 ++++++++++---
> -------
> .../media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 2 +-
> .../media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 4 ++--
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 2 +-
> .../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 6 +++---
> .../media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 6 +++---
> 6 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> index e30e54935d79..6af7b812c5df 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> @@ -1516,14 +1516,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,
> @@ -1540,7 +1540,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,
> @@ -1548,7 +1548,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,
> @@ -1569,7 +1569,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,
> @@ -1577,7 +1577,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,
> @@ -1603,7 +1603,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,
> @@ -1611,7 +1611,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,
> @@ -1637,7 +1637,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, @@ -
> 1646,7 +1646,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,
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> index f8588e52dfc8..25c4719a5dd0 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> @@ -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); diff --git a/drivers/media/platform/samsung/s5p-
> mfc/s5p_mfc_common.h b/drivers/media/platform/samsung/s5p-
> mfc/s5p_mfc_common.h
> index f33a755327ef..6a47f3434c60 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> @@ -219,14 +219,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;
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> index 268ffe4da53c..4dbe8792ac3d 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> @@ -426,7 +426,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);
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> index 28a06dc343fd..13a3ff55e547 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> @@ -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); diff --
> git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> index c0df5ac9fcff..70a62400908e 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> @@ -333,7 +333,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();
> @@ -393,7 +393,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();
> @@ -493,7 +493,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"
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 15/15] media: s5p-mfc: drop static device variable in
> s5p_mfc_pm.c
>
> Change the interface of power management functions in s5p_mfc_pm.c to
> accept the pointer to S5P MFC device structure. instead of relying on file-
> scope static variable. This makes code easier to read and modify in case
> more devices are added.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c | 42 +++++++++++---
> --------
> .../media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c | 26 +++++++-------
> .../media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 8 ++---
> .../platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c | 4 +--
> .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 8 ++---
> .../media/platform/samsung/s5p-mfc/s5p_mfc_pm.c | 40 ++++++++++----
> -------
> .../media/platform/samsung/s5p-mfc/s5p_mfc_pm.h | 8 ++---
> 7 files changed, 67 insertions(+), 69 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> index 5d10c1cb8b92..f0bda2f7f1c2 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc.c
> @@ -183,7 +183,7 @@ static void s5p_mfc_watchdog_worker(struct
> work_struct *work)
> mfc_err("Error: some instance may be closing/opening\n");
> spin_lock_irqsave(&dev->irqlock, flags);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
>
> for (i = 0; i < MFC_NUM_CONTEXTS; i++) {
> ctx = dev->ctx[i];
> @@ -211,9 +211,9 @@ static void s5p_mfc_watchdog_worker(struct
> work_struct *work)
> mfc_err("Failed to reload FW\n");
> goto unlock;
> }
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> ret = s5p_mfc_init_hw(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> if (ret)
> mfc_err("Failed to reinit FW\n");
> }
> @@ -393,7 +393,7 @@ static void s5p_mfc_handle_frame(struct
> s5p_mfc_ctx *ctx,
> s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
> wake_up_ctx(ctx, reason, err);
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
> return;
> }
> @@ -465,7 +465,7 @@ static void s5p_mfc_handle_frame(struct
> s5p_mfc_ctx *ctx,
> s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
> wake_up_ctx(ctx, reason, err);
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> /* if suspending, wake up device and do not try_run again*/
> if (test_bit(0, &dev->enter_suspend))
> wake_up_dev(dev, reason, err);
> @@ -509,7 +509,7 @@ static void s5p_mfc_handle_error(struct
> s5p_mfc_dev *dev,
> }
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
> s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> wake_up_dev(dev, reason, err);
> }
>
> @@ -565,7 +565,7 @@ static void s5p_mfc_handle_seq_done(struct
> s5p_mfc_ctx *ctx,
> s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags, dev);
> clear_work_bit(ctx);
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
> wake_up_ctx(ctx, reason, err);
> }
> @@ -601,14 +601,14 @@ static void s5p_mfc_handle_init_buffers(struct
> s5p_mfc_ctx *ctx,
> }
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
>
> wake_up(&ctx->queue);
> s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
> } else {
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
>
> wake_up(&ctx->queue);
> }
> @@ -636,7 +636,7 @@ static void s5p_mfc_handle_stream_complete(struct
> s5p_mfc_ctx *ctx)
>
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock) == 0);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> wake_up(&ctx->queue);
> s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); } @@ -688,7 +688,7
> @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
> }
> s5p_mfc_hw_call(dev->mfc_ops, clear_int_flags,
> dev);
> WARN_ON(test_and_clear_bit(0, &dev->hw_lock)
> == 0);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> wake_up_ctx(ctx, reason, err);
> s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
> } else {
> @@ -752,7 +752,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
> if (test_and_clear_bit(0, &dev->hw_lock) == 0)
> mfc_err("Failed to unlock hw\n");
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> clear_work_bit(ctx);
> wake_up(&ctx->queue);
>
> @@ -837,20 +837,20 @@ static int s5p_mfc_open(struct file *file)
> dev->watchdog_timer.expires = jiffies +
>
> msecs_to_jiffies(MFC_WATCHDOG_INTERVAL);
> add_timer(&dev->watchdog_timer);
> - ret = s5p_mfc_power_on();
> + ret = s5p_mfc_power_on(dev);
> if (ret < 0) {
> mfc_err("power on failed\n");
> goto err_pwr_enable;
> }
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> ret = s5p_mfc_load_firmware(dev);
> if (ret) {
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> goto err_load_fw;
> }
> /* Init the FW */
> ret = s5p_mfc_init_hw(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> if (ret)
> goto err_init_hw;
> }
> @@ -927,7 +927,7 @@ static int s5p_mfc_open(struct file *file)
> err_load_fw:
> err_pwr_enable:
> if (dev->num_inst == 1) {
> - if (s5p_mfc_power_off() < 0)
> + if (s5p_mfc_power_off(dev) < 0)
> mfc_err("power off failed\n");
> del_timer_sync(&dev->watchdog_timer);
> }
> @@ -959,7 +959,7 @@ static int s5p_mfc_release(struct file *file)
> vb2_queue_release(&ctx->vq_src);
> vb2_queue_release(&ctx->vq_dst);
> if (dev) {
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
>
> /* Mark context as idle */
> clear_work_bit_irqsave(ctx);
> @@ -979,12 +979,12 @@ static int s5p_mfc_release(struct file *file)
> mfc_debug(2, "Last instance\n");
> s5p_mfc_deinit_hw(dev);
> del_timer_sync(&dev->watchdog_timer);
> - s5p_mfc_clock_off();
> - if (s5p_mfc_power_off() < 0)
> + s5p_mfc_clock_off(dev);
> + if (s5p_mfc_power_off(dev) < 0)
> mfc_err("Power off failed\n");
> } else {
> mfc_debug(2, "Shutting down clock\n");
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> }
> }
> if (dev)
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
> index 6d3c92045c05..8eedf6524c39 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_ctrl.c
> @@ -215,7 +215,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
>
> /* 0. MFC reset */
> mfc_debug(2, "MFC reset..\n");
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> dev->risc_on = 0;
> ret = s5p_mfc_reset(dev);
> if (ret) {
> @@ -243,7 +243,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
> if (s5p_mfc_wait_for_done_dev(dev,
> S5P_MFC_R2H_CMD_FW_STATUS_RET)) {
> mfc_err("Failed to load firmware\n");
> s5p_mfc_reset(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> return -EIO;
> }
> s5p_mfc_clean_dev_int_flags(dev);
> @@ -252,14 +252,14 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
> if (ret) {
> mfc_err("Failed to send command to MFC - timeout\n");
> s5p_mfc_reset(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> return ret;
> }
> mfc_debug(2, "Ok, now will wait for completion of hardware init\n");
> if (s5p_mfc_wait_for_done_dev(dev,
> S5P_MFC_R2H_CMD_SYS_INIT_RET)) {
> mfc_err("Failed to init hardware\n");
> s5p_mfc_reset(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> return -EIO;
> }
> dev->int_cond = 0;
> @@ -269,7 +269,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
> mfc_err("Failed to init firmware - error: %d int: %d\n",
> dev->int_err, dev->int_type);
> s5p_mfc_reset(dev);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> return -EIO;
> }
> if (IS_MFCV6_PLUS(dev))
> @@ -279,7 +279,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
>
> mfc_debug(2, "MFC F/W version : %02xyy, %02xmm, %02xdd\n",
> (ver >> 16) & 0xFF, (ver >> 8) & 0xFF, ver & 0xFF);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> mfc_debug_leave();
> return 0;
> }
> @@ -288,12 +288,12 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev)
> /* Deinitialize hardware */
> void s5p_mfc_deinit_hw(struct s5p_mfc_dev *dev) {
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
>
> s5p_mfc_reset(dev);
> s5p_mfc_hw_call(dev->mfc_ops, release_dev_context_buffer,
> dev);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> }
>
> int s5p_mfc_sleep(struct s5p_mfc_dev *dev) @@ -301,7 +301,7 @@ int
> s5p_mfc_sleep(struct s5p_mfc_dev *dev)
> int ret;
>
> mfc_debug_enter();
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> s5p_mfc_clean_dev_int_flags(dev);
> ret = s5p_mfc_hw_call(dev->mfc_cmds, sleep_cmd, dev);
> if (ret) {
> @@ -312,7 +312,7 @@ int s5p_mfc_sleep(struct s5p_mfc_dev *dev)
> mfc_err("Failed to sleep\n");
> return -EIO;
> }
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> dev->int_cond = 0;
> if (dev->int_err != 0 || dev->int_type !=
>
> S5P_MFC_R2H_CMD_SLEEP_RET) {
> @@ -384,12 +384,12 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
> mfc_debug_enter();
> /* 0. MFC reset */
> mfc_debug(2, "MFC reset..\n");
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> dev->risc_on = 0;
> ret = s5p_mfc_reset(dev);
> if (ret) {
> mfc_err("Failed to reset MFC - timeout\n");
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> return ret;
> }
> mfc_debug(2, "Done MFC reset..\n");
> @@ -404,7 +404,7 @@ int s5p_mfc_wakeup(struct s5p_mfc_dev *dev)
> else
> ret = s5p_mfc_wait_wakeup(dev);
>
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> if (ret)
> return ret;
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> index eef26d4e02cf..b620db8896e1 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> @@ -477,7 +477,7 @@ static int reqbufs_output(struct s5p_mfc_dev *dev,
> struct s5p_mfc_ctx *ctx, {
> int ret = 0;
>
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
>
> if (reqbufs->count == 0) {
> mfc_debug(2, "Freeing buffers\n");
> @@ -514,7 +514,7 @@ static int reqbufs_output(struct s5p_mfc_dev *dev,
> struct s5p_mfc_ctx *ctx,
> ret = -EINVAL;
> }
> out:
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> if (ret)
> mfc_err("Failed allocating buffers for OUTPUT queue\n");
> return ret;
> @@ -525,7 +525,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev,
> struct s5p_mfc_ctx *ctx, {
> int ret = 0;
>
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
>
> if (reqbufs->count == 0) {
> mfc_debug(2, "Freeing buffers\n");
> @@ -568,7 +568,7 @@ static int reqbufs_capture(struct s5p_mfc_dev *dev,
> struct s5p_mfc_ctx *ctx,
> ret = -EINVAL;
> }
> out:
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> if (ret)
> mfc_err("Failed allocating buffers for CAPTURE queue\n");
> return ret;
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> index ba22c6a3219a..87492db83536 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v5.c
> @@ -1346,7 +1346,7 @@ static void s5p_mfc_try_run_v5(struct
> s5p_mfc_dev *dev)
> * Last frame has already been sent to MFC.
> * Now obtaining frames from MFC buffer
> */
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> s5p_mfc_clean_ctx_int_flags(ctx);
>
> if (ctx->type == MFCINST_DECODER) {
> @@ -1422,7 +1422,7 @@ static void s5p_mfc_try_run_v5(struct
> s5p_mfc_dev *dev)
> * scheduled, reduce the clock count as no one will
> * ever do this, because no interrupt related to this try_run
> * will ever come from hardware. */
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> }
> }
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> index 08545213caa9..8908c159a91e 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c
> @@ -1992,7 +1992,7 @@ static void s5p_mfc_try_run_v6(struct
> s5p_mfc_dev *dev)
> /* Last frame has already been sent to MFC
> * Now obtaining frames from MFC buffer */
>
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(dev);
> s5p_mfc_clean_ctx_int_flags(ctx);
>
> if (ctx->type == MFCINST_DECODER) {
> @@ -2072,7 +2072,7 @@ static void s5p_mfc_try_run_v6(struct
> s5p_mfc_dev *dev)
> * scheduled, reduce the clock count as no one will
> * ever do this, because no interrupt related to this try_run
> * will ever come from hardware. */
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(dev);
> }
> }
>
> @@ -2088,9 +2088,9 @@ s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx,
> unsigned long ofs) {
> int ret;
>
> - s5p_mfc_clock_on();
> + s5p_mfc_clock_on(ctx->dev);
> ret = readl((void __iomem *)ofs);
> - s5p_mfc_clock_off();
> + s5p_mfc_clock_off(ctx->dev);
>
> return ret;
> }
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
> index ecb3065c33c9..ae4241408383 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.c
> @@ -14,13 +14,11 @@
> #include "s5p_mfc_debug.h"
> #include "s5p_mfc_pm.h"
>
> -static struct s5p_mfc_pm *pm;
> -
> int s5p_mfc_init_pm(struct s5p_mfc_dev *dev) {
> + struct s5p_mfc_pm *pm = &dev->pm;
> int i;
>
> - pm = &dev->pm;
> pm->num_clocks = dev->variant->num_clocks;
> pm->clk_names = dev->variant->clk_names;
> pm->device = &dev->plat_dev->dev;
> @@ -50,58 +48,58 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
>
> void s5p_mfc_final_pm(struct s5p_mfc_dev *dev) {
> - pm_runtime_disable(pm->device);
> + pm_runtime_disable(dev->pm.device);
> }
>
> -int s5p_mfc_clock_on(void)
> +int s5p_mfc_clock_on(struct s5p_mfc_dev *dev)
> {
> - return clk_enable(pm->clock_gate);
> + return clk_enable(dev->pm.clock_gate);
> }
>
> -void s5p_mfc_clock_off(void)
> +void s5p_mfc_clock_off(struct s5p_mfc_dev *dev)
> {
> - clk_disable(pm->clock_gate);
> + clk_disable(dev->pm.clock_gate);
> }
>
> -int s5p_mfc_power_on(void)
> +int s5p_mfc_power_on(struct s5p_mfc_dev *dev)
> {
> int i, ret = 0;
>
> - ret = pm_runtime_resume_and_get(pm->device);
> + ret = pm_runtime_resume_and_get(dev->pm.device);
> if (ret < 0)
> return ret;
>
> /* clock control */
> - for (i = 0; i < pm->num_clocks; i++) {
> - ret = clk_prepare_enable(pm->clocks[i]);
> + for (i = 0; i < dev->pm.num_clocks; i++) {
> + ret = clk_prepare_enable(dev->pm.clocks[i]);
> if (ret < 0) {
> mfc_err("clock prepare failed for clock: %s\n",
> - pm->clk_names[i]);
> + dev->pm.clk_names[i]);
> goto err;
> }
> }
>
> /* prepare for software clock gating */
> - clk_disable(pm->clock_gate);
> + clk_disable(dev->pm.clock_gate);
>
> return 0;
> err:
> while (--i >= 0)
> - clk_disable_unprepare(pm->clocks[i]);
> - pm_runtime_put(pm->device);
> + clk_disable_unprepare(dev->pm.clocks[i]);
> + pm_runtime_put(dev->pm.device);
> return ret;
> }
>
> -int s5p_mfc_power_off(void)
> +int s5p_mfc_power_off(struct s5p_mfc_dev *dev)
> {
> int i;
>
> /* finish software clock gating */
> - clk_enable(pm->clock_gate);
> + clk_enable(dev->pm.clock_gate);
>
> - for (i = 0; i < pm->num_clocks; i++)
> - clk_disable_unprepare(pm->clocks[i]);
> + for (i = 0; i < dev->pm.num_clocks; i++)
> + clk_disable_unprepare(dev->pm.clocks[i]);
>
> - return pm_runtime_put_sync(pm->device);
> + return pm_runtime_put_sync(dev->pm.device);
> }
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
> index 4159d2364e87..9c71036f0385 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_pm.h
> @@ -12,9 +12,9 @@
> int s5p_mfc_init_pm(struct s5p_mfc_dev *dev); void
> s5p_mfc_final_pm(struct s5p_mfc_dev *dev);
>
> -int s5p_mfc_clock_on(void);
> -void s5p_mfc_clock_off(void);
> -int s5p_mfc_power_on(void);
> -int s5p_mfc_power_off(void);
> +int s5p_mfc_clock_on(struct s5p_mfc_dev *dev); void
> +s5p_mfc_clock_off(struct s5p_mfc_dev *dev); int
> s5p_mfc_power_on(struct
> +s5p_mfc_dev *dev); int s5p_mfc_power_off(struct s5p_mfc_dev *dev);
>
> #endif /* S5P_MFC_PM_H_ */
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 09/15] media: s5p-mfc: constify s5p_mfc_fmt structures
>
> Static "s5p_mfc_fmt" structures are not modified by the driver, so they can
> be made const for code safety.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 4 ++--
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c | 6 +++---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 8 ++++----
> 3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> index fa556f27fa06..e9283020070e 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> @@ -633,8 +633,8 @@ struct s5p_mfc_ctx {
> unsigned int int_err;
> wait_queue_head_t queue;
>
> - struct s5p_mfc_fmt *src_fmt;
> - struct s5p_mfc_fmt *dst_fmt;
> + const struct s5p_mfc_fmt *src_fmt;
> + const struct s5p_mfc_fmt *dst_fmt;
>
> struct vb2_queue vq_src;
> struct vb2_queue vq_dst;
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> index 4dbe8792ac3d..2f664c7e9e4c 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_dec.c
> @@ -27,7 +27,7 @@
> #include "s5p_mfc_opr.h"
> #include "s5p_mfc_pm.h"
>
> -static struct s5p_mfc_fmt formats[] = {
> +static const struct s5p_mfc_fmt formats[] = {
> {
> .fourcc = V4L2_PIX_FMT_NV12MT_16X16,
> .codec_mode = S5P_MFC_CODEC_NONE,
> @@ -163,7 +163,7 @@ static struct s5p_mfc_fmt formats[] = { #define
> NUM_FORMATS ARRAY_SIZE(formats)
>
> /* Find selected format description */
> -static struct s5p_mfc_fmt *find_format(struct v4l2_format *f, unsigned int
> t)
> +static const struct s5p_mfc_fmt *find_format(struct v4l2_format *f,
> +unsigned int t)
> {
> unsigned int i;
>
> @@ -387,7 +387,7 @@ static int vidioc_g_fmt(struct file *file, void *priv,
> struct v4l2_format *f) static int vidioc_try_fmt(struct file *file, void *priv,
> struct v4l2_format *f) {
> struct s5p_mfc_dev *dev = video_drvdata(file);
> - struct s5p_mfc_fmt *fmt;
> + const struct s5p_mfc_fmt *fmt;
>
> mfc_debug(2, "Type is %d\n", f->type);
> if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { diff --git
> a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> index 4b4c129c09e7..d6a4b9c701eb 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c
> @@ -30,7 +30,7 @@
> #define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12M
> #define DEF_DST_FMT_ENC V4L2_PIX_FMT_H264
>
> -static struct s5p_mfc_fmt formats[] = {
> +static const struct s5p_mfc_fmt formats[] = {
> {
> .fourcc = V4L2_PIX_FMT_NV12MT_16X16,
> .codec_mode = S5P_MFC_CODEC_NONE,
> @@ -97,7 +97,7 @@ static struct s5p_mfc_fmt formats[] = { };
>
> #define NUM_FORMATS ARRAY_SIZE(formats) -static struct s5p_mfc_fmt
> *find_format(struct v4l2_format *f, unsigned int t)
> +static const struct s5p_mfc_fmt *find_format(struct v4l2_format *f,
> +unsigned int t)
> {
> unsigned int i;
>
> @@ -1394,7 +1394,7 @@ static int vidioc_g_fmt(struct file *file, void *priv,
> struct v4l2_format *f) static int vidioc_try_fmt(struct file *file, void *priv,
> struct v4l2_format *f) {
> struct s5p_mfc_dev *dev = video_drvdata(file);
> - struct s5p_mfc_fmt *fmt;
> + const struct s5p_mfc_fmt *fmt;
> struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
>
> if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { @@ -
> 2355,7 +2355,7 @@ static const struct v4l2_ioctl_ops s5p_mfc_enc_ioctl_ops
> = {
> .vidioc_unsubscribe_event = v4l2_event_unsubscribe, };
>
> -static int check_vb_with_fmt(struct s5p_mfc_fmt *fmt, struct vb2_buffer
> *vb)
> +static int check_vb_with_fmt(const struct s5p_mfc_fmt *fmt, struct
> +vb2_buffer *vb)
> {
> int i;
>
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 04/15] media: s5p-mfc: constify fw_name strings
>
> Constify stored pointers to firmware names for code safety. These are not
> modified by the driver.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> index 5304f42c8c72..f33a755327ef 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> @@ -227,7 +227,7 @@ struct s5p_mfc_variant {
> unsigned int port_num;
> u32 version_bit;
> struct s5p_mfc_buf_size *buf_size;
> - char *fw_name[MFC_FW_MAX_VERSIONS];
> + const char *fw_name[MFC_FW_MAX_VERSIONS];
> const char *clk_names[MFC_MAX_CLOCKS];
> int num_clocks;
> bool use_clock_gating;
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
> -----Original Message-----
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 24 December 2023 21:14
> To: Marek Szyprowski <[email protected]>; Andrzej Hajda
> <[email protected]>; Mauro Carvalho Chehab
> <[email protected]>
> Cc: Aakarsh Jain <[email protected]>; [email protected]; linux-
> [email protected]; Smitha T Murthy
> <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; Krzysztof Kozlowski
> <[email protected]>
> Subject: [PATCH 07/15] media: s5p-mfc: constify s5p_mfc_hw_cmds
> structures
>
> Static "s5p_mfc_hw_cmds" structures are not modified by the driver, so they
> can be made const for code safety.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c | 4 ++--
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h | 2 +-
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c | 4 ++--
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h | 2 +-
> drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h | 2 +-
> 5 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
> index 327e54e70611..1fbf7ed5d4cc 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.c
> @@ -148,7 +148,7 @@ static int s5p_mfc_close_inst_cmd_v5(struct
> s5p_mfc_ctx *ctx) }
>
> /* Initialize cmd function pointers for MFC v5 */ -static struct
> s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
> +static const struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
> .cmd_host2risc = s5p_mfc_cmd_host2risc_v5,
> .sys_init_cmd = s5p_mfc_sys_init_cmd_v5,
> .sleep_cmd = s5p_mfc_sleep_cmd_v5,
> @@ -157,7 +157,7 @@ static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v5 = {
> .close_inst_cmd = s5p_mfc_close_inst_cmd_v5, };
>
> -struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void)
> +const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void)
> {
> return &s5p_mfc_cmds_v5;
> }
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
> index 6eafa514aebc..c626376053c4 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v5.h
> @@ -11,6 +11,6 @@
>
> #include "s5p_mfc_common.h"
>
> -struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void);
> +const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v5(void);
>
> #endif /* S5P_MFC_CMD_H_ */
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> index 25c4719a5dd0..740aa4dfae57 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.c
> @@ -154,7 +154,7 @@ static int s5p_mfc_close_inst_cmd_v6(struct
> s5p_mfc_ctx *ctx) }
>
> /* Initialize cmd function pointers for MFC v6 */ -static struct
> s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
> +static const struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
> .cmd_host2risc = s5p_mfc_cmd_host2risc_v6,
> .sys_init_cmd = s5p_mfc_sys_init_cmd_v6,
> .sleep_cmd = s5p_mfc_sleep_cmd_v6,
> @@ -163,7 +163,7 @@ static struct s5p_mfc_hw_cmds s5p_mfc_cmds_v6 = {
> .close_inst_cmd = s5p_mfc_close_inst_cmd_v6, };
>
> -struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
> +const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void)
> {
> return &s5p_mfc_cmds_v6;
> }
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
> index 9dc44460cc38..29083436f517 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_cmd_v6.h
> @@ -11,6 +11,6 @@
>
> #include "s5p_mfc_common.h"
>
> -struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void);
> +const struct s5p_mfc_hw_cmds *s5p_mfc_init_hw_cmds_v6(void);
>
> #endif /* S5P_MFC_CMD_H_ */
> diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> index 6a47f3434c60..9278ed537e9c 100644
> --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h
> @@ -339,7 +339,7 @@ struct s5p_mfc_dev {
> struct s5p_mfc_priv_buf ctx_buf;
> int warn_start;
> struct s5p_mfc_hw_ops *mfc_ops;
> - struct s5p_mfc_hw_cmds *mfc_cmds;
> + const struct s5p_mfc_hw_cmds *mfc_cmds;
> const struct s5p_mfc_regs *mfc_regs;
> enum s5p_mfc_fw_ver fw_ver;
> bool fw_get_done;
>
> --
> 2.34.1
Reviewed-by: Aakarsh Jain <[email protected]>
Thanks!
On 26/12/2023 07:21, Aakarsh Jain wrote:
>> -int s5p_mfc_clock_on(void);
>> -void s5p_mfc_clock_off(void);
>> -int s5p_mfc_power_on(void);
>> -int s5p_mfc_power_off(void);
>> +int s5p_mfc_clock_on(struct s5p_mfc_dev *dev); void
>> +s5p_mfc_clock_off(struct s5p_mfc_dev *dev); int
>> s5p_mfc_power_on(struct
>> +s5p_mfc_dev *dev); int s5p_mfc_power_off(struct s5p_mfc_dev *dev);
>>
>> #endif /* S5P_MFC_PM_H_ */
>>
>> --
>> 2.34.1
>
> Reviewed-by: Aakarsh Jain <[email protected]>
Pleasy kindly trim the replies from unnecessary context. It makes it
much easier to find new content.
Best regards,
Krzysztof