From: Lee Jones <lee.jones@linaro.org>
To: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Cc: cw00.choi@samsung.com, myungjoo.ham@samsung.com,
sameo@linux.intel.com, lgirdwood@gmail.com, broonie@kernel.org,
patches@opensource.wolfsonmicro.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] extcon: arizona: Deobfuscate arizona_extcon_do_magic
Date: Mon, 16 Feb 2015 16:50:03 +0000 [thread overview]
Message-ID: <20150216165003.GS14545@x1> (raw)
In-Reply-To: <1424101263-27593-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>
On Mon, 16 Feb 2015, Charles Keepax wrote:
> 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>
> ---
> drivers/extcon/extcon-arizona.c | 36 ++++++++++++++++++++----------------
> include/linux/mfd/arizona/core.h | 2 +-
Acked-by: Lee Jones <lee.jones@linaro.org>
> sound/soc/codecs/arizona.c | 4 ++--
> 3 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 63f01c4..95cf7f8 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/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_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;
> + unsigned int val = 0;
> int ret;
>
> + if (clamp)
> + val = ARIZONA_RMV_SHRT_HP1L;
> +
> 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,
> ARIZONA_OUTPUT_ENABLES_1,
> ARIZONA_OUT1L_ENA |
> @@ -158,20 +162,20 @@ static void arizona_extcon_do_magic(struct arizona_extcon_info *info,
> 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)
> - dev_warn(arizona->dev, "Failed to do magic: %d\n",
> + dev_warn(arizona->dev, "Failed to do clamp: %d\n",
> 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)
> - dev_warn(arizona->dev, "Failed to do magic: %d\n",
> + dev_warn(arizona->dev, "Failed to do clamp: %d\n",
> 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,
> ARIZONA_OUTPUT_ENABLES_1,
> ARIZONA_OUT1L_ENA |
> @@ -603,7 +607,7 @@ done:
> ARIZONA_HP_IMPEDANCE_RANGE_MASK | ARIZONA_HP_POLL,
> 0);
>
> - arizona_extcon_do_magic(info, 0);
> + arizona_extcon_hp_clamp(info, false);
>
> if (id_gpio)
> gpio_set_value_cansleep(id_gpio, 0);
> @@ -648,7 +652,7 @@ static void arizona_identify_headphone(struct arizona_extcon_info *info)
> if (info->mic)
> arizona_stop_mic(info);
>
> - arizona_extcon_do_magic(info, 0x4000);
> + arizona_extcon_hp_clamp(info, true);
>
> ret = regmap_update_bits(arizona->regmap,
> 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;
>
> - arizona_extcon_do_magic(info, 0x4000);
> + arizona_extcon_hp_clamp(info, true);
>
> ret = regmap_update_bits(arizona->regmap,
> ARIZONA_ACCESSORY_DETECT_MODE_1,
> diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
> index 910e3aa..4863548 100644
> --- a/include/linux/mfd/arizona/core.h
> +++ b/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 *irq_chip;
>
> - bool hpdet_magic;
> + bool hpdet_clamp;
> unsigned int hp_ena;
>
> struct mutex clk_lock;
> diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
> index 9550d74..a6e5c70 100644
> --- a/sound/soc/codecs/arizona.c
> +++ b/sound/soc/codecs/arizona.c
> @@ -780,8 +780,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w,
> priv->arizona->hp_ena &= ~mask;
> 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;
>
> regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1,
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
next prev parent reply other threads:[~2015-02-16 16:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-16 15:41 [PATCH 1/2] extcon: arizona: Deobfuscate arizona_extcon_do_magic Charles Keepax
2015-02-16 15:41 ` [PATCH 2/2] extcon: arizona: Fix headphone clamping on wm5110 Charles Keepax
2015-02-16 16:49 ` Chanwoo Choi
2015-02-16 16:48 ` [PATCH 1/2] extcon: arizona: Deobfuscate arizona_extcon_do_magic Chanwoo Choi
2015-02-16 23:58 ` Chanwoo Choi
2015-02-16 16:50 ` Lee Jones [this message]
2015-02-17 1:56 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150216165003.GS14545@x1 \
--to=lee.jones@linaro.org \
--cc=broonie@kernel.org \
--cc=ckeepax@opensource.wolfsonmicro.com \
--cc=cw00.choi@samsung.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=patches@opensource.wolfsonmicro.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox