All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: tas5086: move two variables into private struct
@ 2013-10-01 12:48 Daniel Mack
  2013-10-01 12:48 ` [PATCH 2/3] ASoC: tas5086: move initialization code to own functions Daniel Mack
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Mack @ 2013-10-01 12:48 UTC (permalink / raw)
  To: alsa-devel; +Cc: broonie, s.neumann, Daniel Mack

We need to access the charge_period and start_mid_z values from other
places later, so move them to the private struct.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
 sound/soc/codecs/tas5086.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c
index 6d31d88..31b5868 100644
--- a/sound/soc/codecs/tas5086.c
+++ b/sound/soc/codecs/tas5086.c
@@ -244,6 +244,8 @@ struct tas5086_private {
 	unsigned int	mclk, sclk;
 	unsigned int	format;
 	bool		deemph;
+	unsigned int	charge_period;
+	unsigned int	pwm_start_mid_z;
 	/* Current sample rate for de-emphasis control */
 	int		rate;
 	/* GPIO driving Reset pin, if any */
@@ -720,13 +722,15 @@ static const int tas5086_charge_period[] = {
 static int tas5086_probe(struct snd_soc_codec *codec)
 {
 	struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec);
-	int charge_period = 1300000; /* hardware default is 1300 ms */
-	u8 pwm_start_mid_z = 0;
 	int i, ret;
 
+	priv->pwm_start_mid_z = 0;
+	priv->charge_period = 1300000; /* hardware default is 1300 ms */
+
 	if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) {
 		struct device_node *of_node = codec->dev->of_node;
-		of_property_read_u32(of_node, "ti,charge-period", &charge_period);
+		of_property_read_u32(of_node, "ti,charge-period",
+				     &priv->charge_period);
 
 		for (i = 0; i < 6; i++) {
 			char name[25];
@@ -735,7 +739,7 @@ static int tas5086_probe(struct snd_soc_codec *codec)
 				 "ti,mid-z-channel-%d", i + 1);
 
 			if (of_get_property(of_node, name, NULL) != NULL)
-				pwm_start_mid_z |= 1 << i;
+				priv->pwm_start_mid_z |= 1 << i;
 		}
 	}
 
@@ -744,25 +748,25 @@ static int tas5086_probe(struct snd_soc_codec *codec)
 	 * configure 'part 1' of the PWM starts to use Mid-Z, and tell
 	 * all configured mid-z channels to start start under 'part 1'.
 	 */
-	if (pwm_start_mid_z)
+	if (priv->pwm_start_mid_z)
 		regmap_write(priv->regmap, TAS5086_PWM_START,
 			     TAS5086_PWM_START_MIDZ_FOR_START_1 |
-				pwm_start_mid_z);
+				priv->pwm_start_mid_z);
 
 	/* lookup and set split-capacitor charge period */
-	if (charge_period == 0) {
+	if (priv->charge_period == 0) {
 		regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0);
 	} else {
 		i = index_in_array(tas5086_charge_period,
 				   ARRAY_SIZE(tas5086_charge_period),
-				   charge_period);
+				   priv->charge_period);
 		if (i >= 0)
 			regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE,
 				     i + 0x08);
 		else
 			dev_warn(codec->dev,
 				 "Invalid split-cap charge period of %d ns.\n",
-				 charge_period);
+				 priv->charge_period);
 	}
 
 	/* enable factory trim */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-03 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-01 12:48 [PATCH 1/3] ASoC: tas5086: move two variables into private struct Daniel Mack
2013-10-01 12:48 ` [PATCH 2/3] ASoC: tas5086: move initialization code to own functions Daniel Mack
2013-10-01 12:48 ` [PATCH 3/3] ASoC: tas5086: add suspend callback Daniel Mack
2013-10-03 13:14 ` [PATCH 1/3] ASoC: tas5086: move two variables into private struct Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.