diff mbox series

[2/2] ASoC: codecs: lpass-macro: Use enum for handling codec version

Message ID 20240625165736.722106-2-krzysztof.kozlowski@linaro.org (mailing list archive)
State Accepted
Commit 06462d6f3fb3c445b5abac7b134d9fe9e361113f
Headers show
Series [1/2] ASoC: codecs: lpass-macro: Gracefully handle unknown version | expand

Commit Message

Krzysztof Kozlowski June 25, 2024, 4:57 p.m. UTC
Replace 'int' with proper 'enum lpass_codec_version' in every place
which handles the parsed codec version (not raw register values!) to be
explicit about contents of the variable.  This makes code easier to read
and compilers could check missing switch cases.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 sound/soc/codecs/lpass-macro-common.c | 8 ++++----
 sound/soc/codecs/lpass-macro-common.h | 4 ++--
 sound/soc/codecs/lpass-rx-macro.c     | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

Dmitry Baryshkov June 26, 2024, 4:52 a.m. UTC | #1
On Tue, Jun 25, 2024 at 06:57:36PM GMT, Krzysztof Kozlowski wrote:
> Replace 'int' with proper 'enum lpass_codec_version' in every place
> which handles the parsed codec version (not raw register values!) to be
> explicit about contents of the variable.  This makes code easier to read
> and compilers could check missing switch cases.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  sound/soc/codecs/lpass-macro-common.c | 8 ++++----
>  sound/soc/codecs/lpass-macro-common.h | 4 ++--
>  sound/soc/codecs/lpass-rx-macro.c     | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
diff mbox series

Patch

diff --git a/sound/soc/codecs/lpass-macro-common.c b/sound/soc/codecs/lpass-macro-common.c
index 8b038a99a8f9..6e3b8d0897dd 100644
--- a/sound/soc/codecs/lpass-macro-common.c
+++ b/sound/soc/codecs/lpass-macro-common.c
@@ -12,7 +12,7 @@ 
 #include "lpass-macro-common.h"
 
 static DEFINE_MUTEX(lpass_codec_mutex);
-static int lpass_codec_version;
+static enum lpass_codec_version lpass_codec_version;
 
 struct lpass_macro *lpass_macro_pds_init(struct device *dev)
 {
@@ -69,7 +69,7 @@  void lpass_macro_pds_exit(struct lpass_macro *pds)
 }
 EXPORT_SYMBOL_GPL(lpass_macro_pds_exit);
 
-void lpass_macro_set_codec_version(int version)
+void lpass_macro_set_codec_version(enum lpass_codec_version version)
 {
 	mutex_lock(&lpass_codec_mutex);
 	lpass_codec_version = version;
@@ -77,9 +77,9 @@  void lpass_macro_set_codec_version(int version)
 }
 EXPORT_SYMBOL_GPL(lpass_macro_set_codec_version);
 
-int lpass_macro_get_codec_version(void)
+enum lpass_codec_version lpass_macro_get_codec_version(void)
 {
-	int ver;
+	enum lpass_codec_version ver;
 
 	mutex_lock(&lpass_codec_mutex);
 	ver = lpass_codec_version;
diff --git a/sound/soc/codecs/lpass-macro-common.h b/sound/soc/codecs/lpass-macro-common.h
index 94697d0ba8c9..3aa9737f2737 100644
--- a/sound/soc/codecs/lpass-macro-common.h
+++ b/sound/soc/codecs/lpass-macro-common.h
@@ -38,8 +38,8 @@  struct lpass_macro {
 
 struct lpass_macro *lpass_macro_pds_init(struct device *dev);
 void lpass_macro_pds_exit(struct lpass_macro *pds);
-void lpass_macro_set_codec_version(int version);
-int lpass_macro_get_codec_version(void);
+void lpass_macro_set_codec_version(enum lpass_codec_version version);
+enum lpass_codec_version lpass_macro_get_codec_version(void);
 
 static inline const char *lpass_macro_get_codec_version_string(int version)
 {
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 1c3429f004ed..320e3261c151 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -642,7 +642,7 @@  struct rx_macro {
 	int rx_mclk_users;
 	int clsh_users;
 	int rx_mclk_cnt;
-	int codec_version;
+	enum lpass_codec_version codec_version;
 	int rxn_reg_stride;
 	bool is_ear_mode_on;
 	bool hph_pwr_mode;