diff mbox series

[RESEND,4/4] ASoC: mediatek: mt8183-da7219: apply some refactors

Message ID 20200213112003.4.Ia542007f51d3de753a9e0a83135ee074581dbf71@changeid (mailing list archive)
State New, archived
Headers show
Series ASoC: mediatek: mt8183-da7219: pick fixes from mt8183-mt6358 | expand

Commit Message

Tzung-Bi Shih Feb. 13, 2020, 3:27 a.m. UTC
1. Moves headset jack to card-specific storage.
2. Removes trailing blank line.
3. Moves card registration to the end of probe.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mediatek/mt8183/mt8183-da7219-max98357.c  | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

Comments

Mark Brown Feb. 13, 2020, 12:27 p.m. UTC | #1
On Thu, Feb 13, 2020 at 11:27:28AM +0800, Tzung-Bi Shih wrote:
> 1. Moves headset jack to card-specific storage.
> 2. Removes trailing blank line.
> 3. Moves card registration to the end of probe.

I'll apply this but it feels like it should be at least two patches - if
you're writing a changelog with numbered changes like this it's a big
warning sign.
Tzung-Bi Shih Feb. 13, 2020, 1:42 p.m. UTC | #2
On Thu, Feb 13, 2020 at 8:27 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Thu, Feb 13, 2020 at 11:27:28AM +0800, Tzung-Bi Shih wrote:
> > 1. Moves headset jack to card-specific storage.
> > 2. Removes trailing blank line.
> > 3. Moves card registration to the end of probe.
>
> I'll apply this but it feels like it should be at least two patches - if
> you're writing a changelog with numbered changes like this it's a big
> warning sign.

I see.  Will pay more attention and won't squash small changes next time.
diff mbox series

Patch

diff --git a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
index c7f766f24e44..c0c85972cfb7 100644
--- a/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
+++ b/sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
@@ -16,8 +16,6 @@ 
 #include "../../codecs/da7219-aad.h"
 #include "../../codecs/da7219.h"
 
-static struct snd_soc_jack headset_jack;
-
 enum PINCTRL_PIN_STATE {
 	PIN_STATE_DEFAULT = 0,
 	PIN_TDM_OUT_ON,
@@ -32,6 +30,7 @@  static const char * const mt8183_pin_str[PIN_STATE_MAX] = {
 struct mt8183_da7219_max98357_priv {
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pin_states[PIN_STATE_MAX];
+	struct snd_soc_jack headset_jack;
 };
 
 static int mt8183_mt6358_i2s_hw_params(struct snd_pcm_substream *substream,
@@ -510,6 +509,8 @@  static int
 mt8183_da7219_max98357_headset_init(struct snd_soc_component *component)
 {
 	int ret;
+	struct mt8183_da7219_max98357_priv *priv =
+			snd_soc_card_get_drvdata(component->card);
 
 	/* Enable Headset and 4 Buttons Jack detection */
 	ret = snd_soc_card_jack_new(&mt8183_da7219_max98357_card,
@@ -517,12 +518,12 @@  mt8183_da7219_max98357_headset_init(struct snd_soc_component *component)
 				    SND_JACK_HEADSET |
 				    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 				    SND_JACK_BTN_2 | SND_JACK_BTN_3,
-				    &headset_jack,
+				    &priv->headset_jack,
 				    NULL, 0);
 	if (ret)
 		return ret;
 
-	da7219_aad_jack_det(component, &headset_jack);
+	da7219_aad_jack_det(component, &priv->headset_jack);
 
 	return ret;
 }
@@ -559,13 +560,6 @@  static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ret = devm_snd_soc_register_card(&pdev->dev, card);
-	if (ret) {
-		dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
-			__func__, ret);
-		return ret;
-	}
-
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
@@ -607,7 +601,7 @@  static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)
 				 __func__, ret);
 	}
 
-	return ret;
+	return devm_snd_soc_register_card(&pdev->dev, card);
 }
 
 #ifdef CONFIG_OF
@@ -634,4 +628,3 @@  MODULE_DESCRIPTION("MT8183-DA7219-MAX98357 ALSA SoC machine driver");
 MODULE_AUTHOR("Shunli Wang <shunli.wang@mediatek.com>");
 MODULE_LICENSE("GPL v2");
 MODULE_ALIAS("mt8183_da7219_max98357 soc card");
-