diff mbox series

[11/13] ASoC: mediatek: mt6359-accdet: Handle mediatek,eint-use-ext-res as bool

Message ID 20250214-mt6359-accdet-dts-v1-11-677a151b9b4c@collabora.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series Get mt6359-accdet ready for usage in Devicetree | expand

Commit Message

NĂ­colas F. R. A. Prado Feb. 14, 2025, 5:18 p.m. UTC
The code currently allows for values between 0 and 4 for the
eint_use_ext_res property, but it should be handled as a boolean, either
configuring the internal resistor to be used or not. Update the code
accordingly.

Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>
---
 sound/soc/codecs/mt6359-accdet.c | 12 +++---------
 sound/soc/codecs/mt6359-accdet.h |  2 +-
 2 files changed, 4 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/mt6359-accdet.c b/sound/soc/codecs/mt6359-accdet.c
index c3d51c0753c815cd92935736300f57fd18e033f7..646cdd4e0b57f2a007fdcfcaecb7534e08ae61c4 100644
--- a/sound/soc/codecs/mt6359-accdet.c
+++ b/sound/soc/codecs/mt6359-accdet.c
@@ -82,8 +82,7 @@  static unsigned int adjust_eint_analog_setting(struct mt6359_accdet *priv)
 					   RG_EINT1CONFIGACCDET_MASK_SFT,
 					   BIT(RG_EINT1CONFIGACCDET_SFT));
 		}
-		if (priv->data->eint_use_ext_res == 0x3 ||
-		    priv->data->eint_use_ext_res == 0x4) {
+		if (!priv->data->eint_use_ext_res) {
 			/*select 500k, use internal resistor */
 			regmap_update_bits(priv->regmap,
 					   RG_EINT0HIRENB_ADDR,
@@ -547,12 +546,7 @@  static int mt6359_accdet_parse_dt(struct mt6359_accdet *priv)
 	else if (tmp == 2)
 		priv->caps |= ACCDET_PMIC_BI_EINT;
 
-	ret = of_property_read_u32(node, "mediatek,eint-use-ext-res",
-				   &priv->data->eint_use_ext_res);
-	if (ret) {
-		/* eint use internal resister */
-		priv->data->eint_use_ext_res = 0x0;
-	}
+	priv->data->eint_use_ext_res = of_property_read_bool(node, "mediatek,eint-use-ext-res");
 
 	ret = of_property_read_u32(node, "mediatek,eint-comp-vth",
 				   &priv->data->eint_comp_vth);
@@ -660,7 +654,7 @@  static void config_eint_init_by_mode(struct mt6359_accdet *priv)
 	if (priv->data->eint_detect_mode == 0x1 ||
 	    priv->data->eint_detect_mode == 0x2 ||
 	    priv->data->eint_detect_mode == 0x3) {
-		if (priv->data->eint_use_ext_res == 0x1) {
+		if (priv->data->eint_use_ext_res) {
 			if (priv->caps & ACCDET_PMIC_EINT0) {
 				regmap_update_bits(priv->regmap,
 						   RG_EINT0CONFIGACCDET_ADDR,
diff --git a/sound/soc/codecs/mt6359-accdet.h b/sound/soc/codecs/mt6359-accdet.h
index 148e181fc00048ea349c029b382507542a33202e..1a255a360b2319396e9b7a5a145a9317e575587f 100644
--- a/sound/soc/codecs/mt6359-accdet.h
+++ b/sound/soc/codecs/mt6359-accdet.h
@@ -76,7 +76,7 @@  struct dts_data {
 	struct pwm_deb_settings *pwm_deb;
 	unsigned int moisture_detect_enable;
 	unsigned int eint_detect_mode;
-	unsigned int eint_use_ext_res;
+	bool eint_use_ext_res;
 	unsigned int eint_comp_vth;
 	unsigned int moisture_detect_mode;
 	unsigned int moisture_comp_vth;