瀏覽代碼

extcon: arizona: Deobfuscate arizona_extcon_do_magic

arizona_extcon_do_magic does not lend a lot of clarity to the purpose
of the function, and as all the registers used are described in the
datasheet there is no need to obfuscate the code. This patch renames the
function to arizona_extcon_hp_clamp, as it controls clamping on the
headphone output.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Charles Keepax 10 年之前
父節點
當前提交
112bdfaa52
共有 3 個文件被更改,包括 23 次插入19 次删除
  1. 20 16
      drivers/extcon/extcon-arizona.c
  2. 1 1
      include/linux/mfd/arizona/core.h
  3. 2 2
      sound/soc/codecs/arizona.c

+ 20 - 16
drivers/extcon/extcon-arizona.c

@@ -136,18 +136,22 @@ static const char *arizona_cable[] = {
 
 
 static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
 static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info);
 
 
-static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
-				    unsigned int magic)
+static void arizona_extcon_hp_clamp(struct arizona_extcon_info *info,
+				    bool clamp)
 {
 {
 	struct arizona *arizona = info->arizona;
 	struct arizona *arizona = info->arizona;
+	unsigned int val = 0;
 	int ret;
 	int ret;
 
 
+	if (clamp)
+		val = ARIZONA_RMV_SHRT_HP1L;
+
 	mutex_lock(&arizona->dapm->card->dapm_mutex);
 	mutex_lock(&arizona->dapm->card->dapm_mutex);
 
 
-	arizona->hpdet_magic = magic;
+	arizona->hpdet_clamp = clamp;
 
 
-	/* Keep the HP output stages disabled while doing the magic */
-	if (magic) {
+	/* Keep the HP output stages disabled while doing the clamp */
+	if (clamp) {
 		ret = regmap_update_bits(arizona->regmap,
 		ret = regmap_update_bits(arizona->regmap,
 					 ARIZONA_OUTPUT_ENABLES_1,
 					 ARIZONA_OUTPUT_ENABLES_1,
 					 ARIZONA_OUT1L_ENA |
 					 ARIZONA_OUT1L_ENA |
@@ -158,20 +162,20 @@ static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
 				 ret);
 				 ret);
 	}
 	}
 
 
-	ret = regmap_update_bits(arizona->regmap, 0x225, 0x4000,
-				 magic);
+	ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1L,
+				 ARIZONA_RMV_SHRT_HP1L, val);
 	if (ret != 0)
 	if (ret != 0)
-		dev_warn(arizona->dev, "Failed to do magic: %d\n",
+		dev_warn(arizona->dev, "Failed to do clamp: %d\n",
 				 ret);
 				 ret);
 
 
-	ret = regmap_update_bits(arizona->regmap, 0x226, 0x4000,
-				 magic);
+	ret = regmap_update_bits(arizona->regmap, ARIZONA_HP_CTRL_1R,
+				 ARIZONA_RMV_SHRT_HP1R, val);
 	if (ret != 0)
 	if (ret != 0)
-		dev_warn(arizona->dev, "Failed to do magic: %d\n",
+		dev_warn(arizona->dev, "Failed to do clamp: %d\n",
 			 ret);
 			 ret);
 
 
-	/* Restore the desired state while not doing the magic */
-	if (!magic) {
+	/* Restore the desired state while not doing the clamp */
+	if (!clamp) {
 		ret = regmap_update_bits(arizona->regmap,
 		ret = regmap_update_bits(arizona->regmap,
 					 ARIZONA_OUTPUT_ENABLES_1,
 					 ARIZONA_OUTPUT_ENABLES_1,
 					 ARIZONA_OUT1L_ENA |
 					 ARIZONA_OUT1L_ENA |
@@ -603,7 +607,7 @@ done:
 			   ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
 			   ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
 			   0);
 			   0);
 
 
-	arizona_extcon_do_magic(info, 0);
+	arizona_extcon_hp_clamp(info, false);
 
 
 	if (id_gpio)
 	if (id_gpio)
 		gpio_set_value_cansleep(id_gpio, 0);
 		gpio_set_value_cansleep(id_gpio, 0);
@@ -648,7 +652,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
 	if (info->mic)
 	if (info->mic)
 		arizona_stop_mic(info);
 		arizona_stop_mic(info);
 
 
-	arizona_extcon_do_magic(info, 0x4000);
+	arizona_extcon_hp_clamp(info, true);
 
 
 	ret = regmap_update_bits(arizona->regmap,
 	ret = regmap_update_bits(arizona->regmap,
 				 ARIZONA_ACCESSORY_DETECT_MODE_1,
 				 ARIZONA_ACCESSORY_DETECT_MODE_1,
@@ -699,7 +703,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)
 
 
 	info->hpdet_active = true;
 	info->hpdet_active = true;
 
 
-	arizona_extcon_do_magic(info, 0x4000);
+	arizona_extcon_hp_clamp(info, true);
 
 
 	ret = regmap_update_bits(arizona->regmap,
 	ret = regmap_update_bits(arizona->regmap,
 				 ARIZONA_ACCESSORY_DETECT_MODE_1,
 				 ARIZONA_ACCESSORY_DETECT_MODE_1,

+ 1 - 1
include/linux/mfd/arizona/core.h

@@ -126,7 +126,7 @@ struct arizona {
 	struct regmap_irq_chip_data *aod_irq_chip;
 	struct regmap_irq_chip_data *aod_irq_chip;
 	struct regmap_irq_chip_data *irq_chip;
 	struct regmap_irq_chip_data *irq_chip;
 
 
-	bool hpdet_magic;
+	bool hpdet_clamp;
 	unsigned int hp_ena;
 	unsigned int hp_ena;
 
 
 	struct mutex clk_lock;
 	struct mutex clk_lock;

+ 2 - 2
sound/soc/codecs/arizona.c

@@ -840,8 +840,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w,
 	priv->arizona->hp_ena &= ~mask;
 	priv->arizona->hp_ena &= ~mask;
 	priv->arizona->hp_ena |= val;
 	priv->arizona->hp_ena |= val;
 
 
-	/* Force off if HPDET magic is active */
-	if (priv->arizona->hpdet_magic)
+	/* Force off if HPDET clamp is active */
+	if (priv->arizona->hpdet_clamp)
 		val = 0;
 		val = 0;
 
 
 	regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1,
 	regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1,