ALSA: hda - Return error for invalid setup for VIA

Instead of ignoring the invalid pin configuration, return the error.
This will avoid unexpected crash, anyway.

Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/pci/hda/patch_via.c
+++ sound/pci/hda/patch_via.c
@@ -2341,7 +2341,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -2460,11 +2460,7 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
-	}
-
+	}

 	/* disable 32bit format on VT1708 */
 	if (codec->vendor_id == 0x11061708)
@@ -2541,7 +2537,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -2602,9 +2598,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration.  "
-		       "Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1709_10ch_volume_init_verbs;
@@ -2679,9 +2672,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration.  "
-		       "Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1709_6ch_volume_init_verbs;
@@ -2795,7 +2785,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -2940,9 +2930,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1708B_8ch_volume_init_verbs;
@@ -2976,9 +2963,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1708B_4ch_volume_init_verbs;
@@ -3087,7 +3071,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -3157,9 +3141,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1708S_volume_init_verbs;
@@ -3253,7 +3234,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -3344,9 +3325,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1702_volume_init_verbs;
@@ -3440,7 +3418,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -3569,9 +3547,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++] = vt1718S_volume_init_verbs;
@@ -3726,7 +3701,7 @@
 	if (err < 0)
 		return err;
 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -3879,9 +3854,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	spec->init_verbs[spec->num_iverbs++]  = vt1716S_volume_init_verbs;
@@ -4051,7 +4023,7 @@
 		return err;

 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_pins[0])
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -4218,9 +4190,6 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
 	}

 	if (spec->codec_type == VT1802)
@@ -4332,7 +4301,7 @@
 		return err;

 	if (!spec->autocfg.line_outs && !spec->autocfg.hp_outs)
-		return 0; /* can't find valid BIOS pin config */
+		return -EINVAL;

 	err = via_auto_create_multi_out_ctls(codec);
 	if (err < 0)
@@ -4480,11 +4449,7 @@
 	if (err < 0) {
 		via_free(codec);
 		return err;
-	} else if (!err) {
-		printk(KERN_INFO "hda_codec: Cannot set up configuration "
-		       "from BIOS.  Using genenic mode...\n");
-	}
-
+	}

 	spec->init_verbs[spec->num_iverbs++]  = vt1812_volume_init_verbs;
 	spec->init_verbs[spec->num_iverbs++] = vt1812_uniwill_init_verbs;


ASoC: AD1836: Use snd_soc_update_bits for read-modify-write

Use snd_soc_update_bits for read-modify-write register access instead of
open-coding it using snd_soc_read and snd_soc_write.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Acked-by: Liam Girdwood <a57ef363056e61beffa2efa59c68550d40db03b0@ti.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/codecs/ad1836.c
+++ sound/soc/codecs/ad1836.c
@@ -174,19 +174,15 @@
 		pm_message_t state)
 {
 	/* reset clock control mode */
-	u16 adc_ctrl2 = snd_soc_read(codec, AD1836_ADC_CTRL2);
-	adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK;
-
-	return snd_soc_write(codec, AD1836_ADC_CTRL2, adc_ctrl2);
+	return snd_soc_update_bits(codec, AD1836_ADC_CTRL2,
+		AD1836_ADC_SERFMT_MASK, 0);
 }

 static int ad1836_soc_resume(struct snd_soc_codec *codec)
 {
 	/* restore clock control mode */
-	u16 adc_ctrl2 = snd_soc_read(codec, AD1836_ADC_CTRL2);
-	adc_ctrl2 |= AD1836_ADC_AUX;
-
-	return snd_soc_write(codec, AD1836_ADC_CTRL2, adc_ctrl2);
+	return snd_soc_update_bits(codec, AD1836_ADC_CTRL2,
+		AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX);
 }
 #else
 #define ad1836_soc_suspend NULL
@@ -266,10 +262,8 @@
 static int ad1836_remove(struct snd_soc_codec *codec)
 {
 	/* reset clock control mode */
-	u16 adc_ctrl2 = snd_soc_read(codec, AD1836_ADC_CTRL2);
-	adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK;
-
-	return snd_soc_write(codec, AD1836_ADC_CTRL2, adc_ctrl2);
+	return snd_soc_update_bits(codec, AD1836_ADC_CTRL2,
+		AD1836_ADC_SERFMT_MASK, 0);
 }

 static struct snd_soc_codec_driver soc_codec_dev_ad1836 = {


ASoC: rt5631: Convert to direct regmap API usage

We're trying to remove all usage of the ASoc level cache and I/O code and
for a device like this with a pretty sparse register map the rbtree cache
is a better idea anyway.

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/codecs/rt5631.c
+++ sound/soc/codecs/rt5631.c
@@ -18,7 +18,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
-#include <linux/spi/spi.h>
+#include <linux/regmap.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -30,6 +30,7 @@
 #include "rt5631.h"

 struct rt5631_priv {
+	struct regmap *regmap;
 	int codec_version;
 	int master;
 	int sysclk;
@@ -38,33 +39,33 @@
 	int dmic_used_flag;
 };

-static const u16 rt5631_reg[RT5631_VENDOR_ID2 + 1] = {
-	[RT5631_SPK_OUT_VOL] = 0x8888,
-	[RT5631_HP_OUT_VOL] = 0x8080,
-	[RT5631_MONO_AXO_1_2_VOL] = 0xa080,
-	[RT5631_AUX_IN_VOL] = 0x0808,
-	[RT5631_ADC_REC_MIXER] = 0xf0f0,
-	[RT5631_VDAC_DIG_VOL] = 0x0010,
-	[RT5631_OUTMIXER_L_CTRL] = 0xffc0,
-	[RT5631_OUTMIXER_R_CTRL] = 0xffc0,
-	[RT5631_AXO1MIXER_CTRL] = 0x88c0,
-	[RT5631_AXO2MIXER_CTRL] = 0x88c0,
-	[RT5631_DIG_MIC_CTRL] = 0x3000,
-	[RT5631_MONO_INPUT_VOL] = 0x8808,
-	[RT5631_SPK_MIXER_CTRL] = 0xf8f8,
-	[RT5631_SPK_MONO_OUT_CTRL] = 0xfc00,
-	[RT5631_SPK_MONO_HP_OUT_CTRL] = 0x4440,
-	[RT5631_SDP_CTRL] = 0x8000,
-	[RT5631_MONO_SDP_CTRL] = 0x8000,
-	[RT5631_STEREO_AD_DA_CLK_CTRL] = 0x2010,
-	[RT5631_GEN_PUR_CTRL_REG] = 0x0e00,
-	[RT5631_INT_ST_IRQ_CTRL_2] = 0x071a,
-	[RT5631_MISC_CTRL] = 0x2040,
-	[RT5631_DEPOP_FUN_CTRL_2] = 0x8000,
-	[RT5631_SOFT_VOL_CTRL] = 0x07e0,
-	[RT5631_ALC_CTRL_1] = 0x0206,
-	[RT5631_ALC_CTRL_3] = 0x2000,
-	[RT5631_PSEUDO_SPATL_CTRL] = 0x0553,
+static const struct reg_default rt5631_reg[] = {
+	{ RT5631_SPK_OUT_VOL, 0x8888 },
+	{ RT5631_HP_OUT_VOL, 0x8080 },
+	{ RT5631_MONO_AXO_1_2_VOL, 0xa080 },
+	{ RT5631_AUX_IN_VOL, 0x0808 },
+	{ RT5631_ADC_REC_MIXER, 0xf0f0 },
+	{ RT5631_VDAC_DIG_VOL, 0x0010 },
+	{ RT5631_OUTMIXER_L_CTRL, 0xffc0 },
+	{ RT5631_OUTMIXER_R_CTRL, 0xffc0 },
+	{ RT5631_AXO1MIXER_CTRL, 0x88c0 },
+	{ RT5631_AXO2MIXER_CTRL, 0x88c0 },
+	{ RT5631_DIG_MIC_CTRL, 0x3000 },
+	{ RT5631_MONO_INPUT_VOL, 0x8808 },
+	{ RT5631_SPK_MIXER_CTRL, 0xf8f8 },
+	{ RT5631_SPK_MONO_OUT_CTRL, 0xfc00 },
+	{ RT5631_SPK_MONO_HP_OUT_CTRL, 0x4440 },
+	{ RT5631_SDP_CTRL, 0x8000 },
+	{ RT5631_MONO_SDP_CTRL, 0x8000 },
+	{ RT5631_STEREO_AD_DA_CLK_CTRL, 0x2010 },
+	{ RT5631_GEN_PUR_CTRL_REG, 0x0e00 },
+	{ RT5631_INT_ST_IRQ_CTRL_2, 0x071a },
+	{ RT5631_MISC_CTRL, 0x2040 },
+	{ RT5631_DEPOP_FUN_CTRL_2, 0x8000 },
+	{ RT5631_SOFT_VOL_CTRL, 0x07e0 },
+	{ RT5631_ALC_CTRL_1, 0x0206 },
+	{ RT5631_ALC_CTRL_3, 0x2000 },
+	{ RT5631_PSEUDO_SPATL_CTRL, 0x0553 },
 };

 /**
@@ -96,8 +97,7 @@
 	return snd_soc_write(codec, RT5631_RESET, 0);
 }

-static int rt5631_volatile_register(struct snd_soc_codec *codec,
-				    unsigned int reg)
+static bool rt5631_volatile_register(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
 	case RT5631_RESET:
@@ -111,8 +111,7 @@
 	}
 }

-static int rt5631_readable_register(struct snd_soc_codec *codec,
-				    unsigned int reg)
+static bool rt5631_readable_register(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
 	case RT5631_RESET:
@@ -1543,6 +1542,8 @@
 static int rt5631_set_bias_level(struct snd_soc_codec *codec,
 			enum snd_soc_bias_level level)
 {
+	struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec);
+
 	switch (level) {
 	case SND_SOC_BIAS_ON:
 	case SND_SOC_BIAS_PREPARE:
@@ -1560,8 +1561,8 @@
 			snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3,
 				RT5631_PWR_FAST_VREF_CTRL,
 				RT5631_PWR_FAST_VREF_CTRL);
-			codec->cache_only = false;
-			snd_soc_cache_sync(codec);
+			regcache_cache_only(rt5631->regmap, false);
+			regcache_sync(rt5631->regmap);
 		}
 		break;

@@ -1586,7 +1587,9 @@
 	unsigned int val;
 	int ret;

-	ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C);
+	codec->control_data = rt5631->regmap;
+
+	ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP);
 	if (ret != 0) {
 		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
 		return ret;
@@ -1697,12 +1700,6 @@
 	.suspend = rt5631_suspend,
 	.resume = rt5631_resume,
 	.set_bias_level = rt5631_set_bias_level,
-	.reg_cache_size = RT5631_VENDOR_ID2 + 1,
-	.reg_word_size = sizeof(u16),
-	.reg_cache_default = rt5631_reg,
-	.volatile_register = rt5631_volatile_register,
-	.readable_register = rt5631_readable_register,
-	.reg_cache_step = 1,
 	.controls = rt5631_snd_controls,
 	.num_controls = ARRAY_SIZE(rt5631_snd_controls),
 	.dapm_widgets = rt5631_dapm_widgets,
@@ -1717,6 +1714,18 @@
 };
 MODULE_DEVICE_TABLE(i2c, rt5631_i2c_id);

+static const struct regmap_config rt5631_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 16,
+
+	.readable_reg = rt5631_readable_register,
+	.volatile_reg = rt5631_volatile_register,
+	.max_register = RT5631_VENDOR_ID2,
+	.reg_defaults = rt5631_reg,
+	.num_reg_defaults = ARRAY_SIZE(rt5631_reg),
+	.cache_type = REGCACHE_RBTREE,
+};
+
 static int rt5631_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
@@ -1729,6 +1738,10 @@
 		return -ENOMEM;

 	i2c_set_clientdata(i2c, rt5631);
+
+	rt5631->regmap = devm_regmap_init_i2c(i2c, &rt5631_regmap_config);
+	if (IS_ERR(rt5631->regmap))
+		return PTR_ERR(rt5631->regmap);

 	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631,
 			rt5631_dai, ARRAY_SIZE(rt5631_dai));


ASoC: rt5631: constify of_device_id array

of_device_id is always used as const.
(See driver.of_match_table and open firmware functions)

Signed-off-by: Fabian Frederick <3efd2a027b14fd890cd23a9ef6d1134b4e5ad850@skynet.be>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>

--- sound/soc/codecs/rt5631.c
+++ sound/soc/codecs/rt5631.c
@@ -1675,7 +1675,7 @@
 MODULE_DEVICE_TABLE(i2c, rt5631_i2c_id);

 #ifdef CONFIG_OF
-static struct of_device_id rt5631_i2c_dt_ids[] = {
+static const struct of_device_id rt5631_i2c_dt_ids[] = {
 	{ .compatible = "realtek,rt5631"},
 	{ .compatible = "realtek,alc5631"},
 	{ }


ASoC: Allow WM8903 mic detect disable and don't force bias on

Don't force enable the microphone bias on WM8903 when doing jack
detection, and don't force enable microphone bias. This allows
platforms to only enable microphone detection when a jack has been
inserted.

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <a57ef363056e61beffa2efa59c68550d40db03b0@slimlogic.co.uk>

--- sound/soc/codecs/wm8903.c
+++ sound/soc/codecs/wm8903.c
@@ -1465,7 +1465,7 @@
 		      int det, int shrt)
 {
 	struct wm8903_priv *wm8903 = codec->private_data;
-	int irq_mask = 0;
+	int irq_mask = WM8903_MICDET_EINT | WM8903_MICSHRT_EINT;

 	dev_dbg(codec->dev, "Enabling microphone detection: %x %x\n",
 		det, shrt);
@@ -1485,16 +1485,17 @@
 			    WM8903_MICDET_EINT | WM8903_MICSHRT_EINT,
 			    irq_mask);

-	/* Enable mic detection, this may not have been set through
-	 * platform data (eg, if the defaults are OK). */
-	snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0,
-			    WM8903_WSEQ_ENA, WM8903_WSEQ_ENA);
-	snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0,
-			    WM8903_MICDET_ENA, WM8903_MICDET_ENA);
-
-	/* Force the microphone bias on; this will trigger an initial
-	 * detection. */
-	snd_soc_dapm_force_enable_pin(codec, "Mic Bias");
+	if (det && shrt) {
+		/* Enable mic detection, this may not have been set through
+		 * platform data (eg, if the defaults are OK). */
+		snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0,
+				    WM8903_WSEQ_ENA, WM8903_WSEQ_ENA);
+		snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0,
+				    WM8903_MICDET_ENA, WM8903_MICDET_ENA);
+	} else {
+		snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0,
+				    WM8903_MICDET_ENA, 0);
+	}

 	return 0;
 }


ASoC: Use shared controls for input signal path in WM8915

Gives finer grained power management.

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <a57ef363056e61beffa2efa59c68550d40db03b0@ti.com>

--- sound/soc/codecs/wm8915.c
+++ sound/soc/codecs/wm8915.c
@@ -991,10 +991,10 @@
 SND_SOC_DAPM_PGA("IN1L PGA", WM8915_POWER_MANAGEMENT_2, 5, 0, NULL, 0),
 SND_SOC_DAPM_PGA("IN1R PGA", WM8915_POWER_MANAGEMENT_2, 4, 0, NULL, 0),

-SND_SOC_DAPM_PGA("ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
-
-SND_SOC_DAPM_MUX("IN1 Mux", SND_SOC_NOPM, 0, 0, &in1_mux),
-SND_SOC_DAPM_MUX("IN2 Mux", SND_SOC_NOPM, 0, 0, &in2_mux),
+SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &in1_mux),
+SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &in1_mux),
+SND_SOC_DAPM_MUX("IN2L Mux", SND_SOC_NOPM, 0, 0, &in2_mux),
+SND_SOC_DAPM_MUX("IN2R Mux", SND_SOC_NOPM, 0, 0, &in2_mux),

 SND_SOC_DAPM_PGA("IN1L", WM8915_POWER_MANAGEMENT_7, 2, 0, NULL, 0),
 SND_SOC_DAPM_PGA("IN1R", WM8915_POWER_MANAGEMENT_7, 3, 0, NULL, 0),
@@ -1172,28 +1172,33 @@
 	{ "DMIC1L", NULL, "DMIC1" },
 	{ "DMIC1R", NULL, "DMIC1" },

-	{ "ADC", NULL, "ADCL" },
-	{ "ADC", NULL, "ADCR" },
-
-	{ "IN1 Mux", "ADC", "ADC" },
-	{ "IN1 Mux", "DMIC1", "DMIC1" },
-	{ "IN1 Mux", "DMIC2", "DMIC2" },
-
-	{ "IN2 Mux", "ADC", "ADC" },
-	{ "IN2 Mux", "DMIC1", "DMIC1" },
-	{ "IN2 Mux", "DMIC2", "DMIC2" },
-
-	{ "Left Sidetone", "IN1", "IN1 Mux" },
-	{ "Left Sidetone", "IN2", "IN2 Mux" },
-
-	{ "Right Sidetone", "IN1", "IN1 Mux" },
-	{ "Right Sidetone", "IN2", "IN2 Mux" },
-
-	{ "DSP1TXL", "IN1 Switch", "IN1 Mux" },
-	{ "DSP1TXR", "IN1 Switch", "IN1 Mux" },
-
-	{ "DSP2TXL", "IN1 Switch", "IN2 Mux" },
-	{ "DSP2TXR", "IN1 Switch", "IN2 Mux" },
+	{ "IN1L Mux", "ADC", "ADCL" },
+	{ "IN1L Mux", "DMIC1", "DMIC1L" },
+	{ "IN1L Mux", "DMIC2", "DMIC2L" },
+
+	{ "IN1R Mux", "ADC", "ADCR" },
+	{ "IN1R Mux", "DMIC1", "DMIC1R" },
+	{ "IN1R Mux", "DMIC2", "DMIC2R" },
+
+	{ "IN2L Mux", "ADC", "ADCL" },
+	{ "IN2L Mux", "DMIC1", "DMIC1L" },
+	{ "IN2L Mux", "DMIC2", "DMIC2L" },
+
+	{ "IN2R Mux", "ADC", "ADCR" },
+	{ "IN2R Mux", "DMIC1", "DMIC1R" },
+	{ "IN2R Mux", "DMIC2", "DMIC2R" },
+
+	{ "Left Sidetone", "IN1", "IN1L Mux" },
+	{ "Left Sidetone", "IN2", "IN2L Mux" },
+
+	{ "Right Sidetone", "IN1", "IN1R Mux" },
+	{ "Right Sidetone", "IN2", "IN2R Mux" },
+
+	{ "DSP1TXL", "IN1 Switch", "IN1L Mux" },
+	{ "DSP1TXR", "IN1 Switch", "IN1R Mux" },
+
+	{ "DSP2TXL", "IN1 Switch", "IN2L Mux" },
+	{ "DSP2TXR", "IN1 Switch", "IN2R Mux" },

 	{ "AIF1TX0", NULL, "DSP1TXL" },
 	{ "AIF1TX1", NULL, "DSP1TXR" },


lib-http server: Removed extra "return;" that was never called.

--- src/lib-http/http-server-connection.c
+++ src/lib-http/http-server-connection.c
@@ -510,7 +510,6 @@
 				conn->input_broken = TRUE;
 				http_server_request_fail_close(req, 413, "Payload Too Large");
 				break;
-			return;
 			default:
 				i_unreached();
 			}


ASoC: Staticise TLV values in WM8940

ASoC: Staticise TLV values in WM8940

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/codecs/wm8940.c
+++ sound/soc/codecs/wm8940.c
@@ -168,16 +168,16 @@
 static const struct soc_enum wm8940_filter_mode_enum
 = SOC_ENUM_SINGLE(WM8940_ADC, 7, 2, wm8940_filter_mode_text);

-DECLARE_TLV_DB_SCALE(wm8940_spk_vol_tlv, -5700, 100, 1);
-DECLARE_TLV_DB_SCALE(wm8940_att_tlv, -1000, 1000, 0);
-DECLARE_TLV_DB_SCALE(wm8940_pga_vol_tlv, -1200, 75, 0);
-DECLARE_TLV_DB_SCALE(wm8940_alc_min_tlv, -1200, 600, 0);
-DECLARE_TLV_DB_SCALE(wm8940_alc_max_tlv, 675, 600, 0);
-DECLARE_TLV_DB_SCALE(wm8940_alc_tar_tlv, -2250, 50, 0);
-DECLARE_TLV_DB_SCALE(wm8940_lim_boost_tlv, 0, 100, 0);
-DECLARE_TLV_DB_SCALE(wm8940_lim_thresh_tlv, -600, 100, 0);
-DECLARE_TLV_DB_SCALE(wm8940_adc_tlv, -12750, 50, 1);
-DECLARE_TLV_DB_SCALE(wm8940_capture_boost_vol_tlv, 0, 2000, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_spk_vol_tlv, -5700, 100, 1);
+static DECLARE_TLV_DB_SCALE(wm8940_att_tlv, -1000, 1000, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_pga_vol_tlv, -1200, 75, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_alc_min_tlv, -1200, 600, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_alc_max_tlv, 675, 600, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_alc_tar_tlv, -2250, 50, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_lim_boost_tlv, 0, 100, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_lim_thresh_tlv, -600, 100, 0);
+static DECLARE_TLV_DB_SCALE(wm8940_adc_tlv, -12750, 50, 1);
+static DECLARE_TLV_DB_SCALE(wm8940_capture_boost_vol_tlv, 0, 2000, 0);

 static const struct snd_kcontrol_new wm8940_snd_controls[] = {
 	SOC_SINGLE("Digital Loopback Switch", WM8940_COMPANDINGCTL,
@@ -253,7 +253,7 @@
 	SOC_DAPM_SINGLE("PCM Playback Switch", WM8940_MONOMIX, 0, 1, 0),
 };

-DECLARE_TLV_DB_SCALE(wm8940_boost_vol_tlv, -1500, 300, 1);
+static DECLARE_TLV_DB_SCALE(wm8940_boost_vol_tlv, -1500, 300, 1);
 static const struct snd_kcontrol_new wm8940_input_boost_controls[] = {
 	SOC_DAPM_SINGLE("Mic PGA Switch", WM8940_PGAGAIN, 6, 1, 1),
 	SOC_DAPM_SINGLE_TLV("Aux Volume", WM8940_ADCBOOST,


ASoC: Fix comments for disabling amplifier and PGA

Signed-off-by: Axel Lin <b6ffd6973e972cb999e8e535ab74da7fee0c035f@gmail.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- sound/soc/codecs/wm8961.c
+++ sound/soc/codecs/wm8961.c
@@ -422,11 +422,11 @@
 	}

 	if (event & SND_SOC_DAPM_PRE_PMD) {
-		/* Enable the amplifier */
+		/* Disable the amplifier */
 		spk_reg &= ~(WM8961_SPKL_ENA | WM8961_SPKR_ENA);
 		snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg);

-		/* Enable the PGA */
+		/* Disable the PGA */
 		pwr_reg &= ~(WM8961_SPKL_PGA | WM8961_SPKR_PGA);
 		snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg);
 	}


Bail early on error.

Bail early on error.

git-svn-id: 70cf712206e5b8426a8d7451e052914a94f8fa22@26041 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/ecore_desktop/ecore_desktop.c
+++ src/lib/ecore_desktop/ecore_desktop.c
@@ -791,130 +791,125 @@

    if (fill && (desktop->exec_params))
      {
+	Ecore_DList        *command;
+	char               *p, *t, buf[PATH_MAX + 10];
+	int                 len = 0;
+
 	params = strdup(desktop->exec_params);
-	if (params)
-	  {
-	     Ecore_DList        *command;
-
-	     command = ecore_dlist_new();
-	     if (command)
-	       {
-		  char               *p, *t, buf[PATH_MAX + 10];
-		  int                 len = 0;
-
-		  ecore_dlist_set_free_cb(command, free);
-		  t = params;
-		  for (p = params; *p; p++)
+	if (!params) goto error;
+	command = ecore_dlist_new();
+	if (!command) goto error;
+
+	ecore_dlist_set_free_cb(command, free);
+	t = params;
+	for (p = params; *p; p++)
+	  {
+	     if (*p == '%')
+	       {
+		  *p = '\0';
+		  ecore_dlist_append(command, strdup(t));
+		  *p = '%';
+		  t = p;
+	       }
+	  }
+	if (t < p)
+	  {
+	     ecore_dlist_append(command, strdup(t));
+	  }
+	if (!ecore_dlist_is_empty(command))
+	  {
+	     ecore_dlist_goto_first(command);
+	     while ((p = ecore_dlist_next(command)) != NULL)
+	       {
+		  t = NULL;
+		  /* FIXME: implement the rest of these when EFM can pass us files. */
+		  if (p[0] == '%')
+		    switch (p[1])
+		      {
+		       case 'f':	/* Single file name, multiple invokations if multiple files.  If the file is on the net, download first and point to temp file. */
+			  break;
+
+		       case 'u':	/* Single URL, multiple invokations if multiple URLs. */
+			  break;
+
+		       case 'c':	/* Translated Name field frem .desktop file. */
+			  t = desktop->name;
+			  break;
+
+		       case 'k':	/* Location of the .desktop file, may be a URL, or empty. */
+			  t = desktop->original_path;
+			  break;
+
+		       case 'F':	/* Multiple file names.  If the files are on the net, download first and point to temp files. */
+			  break;
+
+		       case 'U':	/* Multiple URLs. */
+			  break;
+
+		       case 'd':	/* Directory of the file in %f. */
+			  break;
+
+		       case 'D':	/* Directories of the files in %F. */
+			  break;
+
+		       case 'n':	/* Single filename without path. */
+			  break;
+
+		       case 'N':	/* Multiple filenames without paths. */
+			  break;
+
+		       case 'i':	/* "--icon Icon" field from .desktop file, or empty. */
+			  if (desktop->icon)
+			    {
+			       snprintf(buf, sizeof(buf), "--icon %s", desktop->icon);
+			       t = buf;
+			    }
+			  break;
+
+		       case 'v':	/* Device field from .desktop file. */
+			  break;
+
+		       case '%':	/* A '%' character. */
+			  t = "%";
+			  break;
+
+		       default:
+			  break;
+		      }
+		  if (t)
 		    {
-		       if (*p == '%')
-			 {
-			    *p = '\0';
-			    ecore_dlist_append(command, strdup(t));
-			    *p = '%';
-			    t = p;
-			 }
+		       len += strlen(t);
+		       ecore_dlist_previous(command);
+		       ecore_dlist_insert(command, strdup(t));
+		       ecore_dlist_next(command);
+		       ecore_dlist_next(command);
 		    }
-		  if (t < p)
+		  len += strlen(p);
+	       }
+	     free(params);
+	     params = malloc(len + 1);
+	     if (params)
+	       {
+		  params[0] = '\0';
+		  ecore_dlist_goto_first(command);
+		  while ((p = ecore_dlist_next(command)) != NULL)
 		    {
-		       ecore_dlist_append(command, strdup(t));
+		       if (p[0] == '%')
+			 strcat(params, &p[2]);
+		       else
+			 strcat(params, p);
 		    }
-		  if (!ecore_dlist_is_empty(command))
-		    {
-		       ecore_dlist_goto_first(command);
-		       while ((p = ecore_dlist_next(command)) != NULL)
-			 {
-			    t = NULL;
-			    /* FIXME: implement the rest of these when EFM can pass us files. */
-			    if (p[0] == '%')
-			       switch (p[1])
-				 {
-				 case 'f':	/* Single file name, multiple invokations if multiple files.  If the file is on the net, download first and point to temp file. */
-				    break;
-
-				 case 'u':	/* Single URL, multiple invokations if multiple URLs. */
-				    break;
-
-				 case 'c':	/* Translated Name field frem .desktop file. */
-				    t = desktop->name;
-				    break;
-
-				 case 'k':	/* Location of the .desktop file, may be a URL, or empty. */
-				    t = desktop->original_path;
-				    break;
-
-				 case 'F':	/* Multiple file names.  If the files are on the net, download first and point to temp files. */
-				    break;
-
-				 case 'U':	/* Multiple URLs. */
-				    break;
-
-				 case 'd':	/* Directory of the file in %f. */
-				    break;
-
-				 case 'D':	/* Directories of the files in %F. */
-				    break;
-
-				 case 'n':	/* Single filename without path. */
-				    break;
-
-				 case 'N':	/* Multiple filenames without paths. */
-				    break;
-
-				 case 'i':	/* "--icon Icon" field from .desktop file, or empty. */
-				    if (desktop->icon)
-				      {
-					 snprintf(buf, sizeof(buf), "--icon %s",
-						  desktop->icon);
-					 t = buf;
-				      }
-				    break;
-
-				 case 'v':	/* Device field from .desktop file. */
-				    break;
-
-				 case '%':	/* A '%' character. */
-				    t = "%";
-				    break;
-
-				 default:
-				    break;
-				 }
-			    if (t)
-			      {
-				 len += strlen(t);
-				 ecore_dlist_previous(command);
-				 ecore_dlist_insert(command, strdup(t));
-				 ecore_dlist_next(command);
-				 ecore_dlist_next(command);
-			      }
-			    len += strlen(p);
-			 }
-		       free(params);
-		       params = malloc(len + 1);
-		       if (params)
-			 {
-			    params[0] = '\0';
-			    ecore_dlist_goto_first(command);
-			    while ((p = ecore_dlist_next(command)) != NULL)
-			      {
-				 if (p[0] == '%')
-				    strcat(params, &p[2]);
-				 else
-				    strcat(params, p);
-			      }
-			 }
-		    }
-		  ecore_list_destroy(command);
-	       }
-	  }
+	       }
+	  }
+	ecore_list_destroy(command);
      }
    else if (desktop->exec_params)
       params = strdup(desktop->exec_params);

    result = ecore_desktop_merge_command(desktop->exec, params);

-   if (params)
-      free(params);
+error:
+   if (params) free(params);
    return result;
 }


ASoC: wm8962: Do not call configure_bclk() inside wm8962_set_dai_sysclk()

Currently after playing any audio file, we get the following error message:

$ aplay clarinet.wav
Playing WAVE 'clarinet.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
$ wm8962 0-001a: Unsupported sysclk ratio 544

This error message appears about 5 seconds after the audio playback has
finished.

Quoting Mark Brown [1]:

"The issue here is triggered by the machine
switching from the FLL to direct MCLK usage where the MCLK isn't
generating a useful ratio.

I suspect we should just kill the configure_bclk() in set_sysclk(), that
one isn't safe as we can't reconfigure a live SYSCLK and it's probably
the one that generates your warnings."

Confirmed that the "Unsupported sysclk ratio" error message comes from
wm8962_set_dai_sysclk(), so get rid of wm8962_configure_bclk() inside this
function.

[1] http://mailman.alsa-project.org/pipermail/alsa-devel/2013-July/064241.html

Signed-off-by: Fabio Estevam <679188261afeb60eb822cd934fd7b46a48ddd743@freescale.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@linaro.org>

--- sound/soc/codecs/wm8962.c
+++ sound/soc/codecs/wm8962.c
@@ -2621,8 +2621,6 @@

 	wm8962->sysclk_rate = freq;

-	wm8962_configure_bclk(codec);
-
 	return 0;
 }


set the window to fullscreen if requested when creating the ecore_evas (win ce)

SVN revision: 38653

--- src/lib/ecore_evas/ecore_evas_wince.c
+++ src/lib/ecore_evas/ecore_evas_wince.c
@@ -990,6 +990,8 @@
         return NULL;
      }

+   ecore_wince_window_fullscreen_set(ee->engine.wince.window, fullscreen);
+
    /* init evas here */
    ee->evas = evas_new();
    evas_data_attach_set(ee->evas, ee);


fixed some targeting

fixed some targeting

--- tibbeCrobot.c
+++ tibbeCrobot.c
@@ -48,20 +48,12 @@
 int
 tnkDir, 	/* the direction of the tank in 0-360 degrees */
 cOpAng, 	/* Current Angle of opponent */
-scnDist, /* Scan distance returned from scan 0 if not found max 700 for cannon reach */
+scnDist, 	/* Scan distance returned from scan 0 if not found max 700 for cannon reach */
 tnkWall, 	/* avoid wall */
 tnkTurn,	/* Is tank Turning */
-
 pOpAng,		/* Prevoius angle of opponent */
-fOpAng, 	/* Future Angle of opponent */
-tnkDmg,		/* keep track of Tank Damage */
-
-pOpXPos,	/* Previous opponent X position */
-pOpYPos,	/* Previous opponent Y position */
-cOpXPos,	/* Previous opponent X position */
-cOpYPos,	/* Previous opponent Y position */
-
-fireSol;	/* if we have a fireing solution */
+pScnDist; 	/* prevoius Scan distance returned from scan 0 if not found max 700 for cannon reach */
+

 /*int tnkFlag;	 what does the tank think about in a binary 8 bit,
 	0 0 0 0 0 0 0 value
@@ -103,10 +95,8 @@
 	else drive((tnkDir = rand(80) + 5 + (loc_x()/11) + (loc_y()/11)),100);
 	cOpAng = tnkDir; /* set current opponent angle first time */
 	DoScnLo(1); /* do a low scan to find him again with first scan enable */
-	if (DoScnMd(1)) { /* do a medium scan with first scan enable */
-		cOpXPos = loc_x() + (scnDist * cos(cOpAng))/100000; /* figure out the enemy x position using the cosine rule */
-		cOpYPos = loc_y() + (scnDist * sin(cOpAng))/100000; /* figure out the enemy y position using the sine rule */
-	}
+	DoScnMd(1); /* do a medium scan with first scan enable */
+	pOpAng = cOpAng; pScnDist = scnDist; /* uppdatera föregående värden */

 	/* End of one time program and start of loop */
 	/*--------------------------------------------------------------------------------------------*/
@@ -120,286 +110,272 @@
 				else (tnkDir = rand(80) + 5 + (loc_x()/11) + (loc_y()/11)); /* calc a new turn based on the x & y position of the tank. flip if y<x., 11 is to get about 90 degree from position */
 				tnkTurn = 0; /* stop turning */
 			}
-			if (speed() < 50) drive(tnkDir,100); /* if the speed is below 50, full speed ahead in new direction*/
-			if (loc_x() < 900 && loc_x() > 100 && loc_y() < 900 && loc_y() > 100){ /* are we outside the wall zone? */
-				if (speed() == 100) tnkWall = 0; /* if we have full speed stop the wall scenario */
-			}
+			if (speed() < 50) {
+				drive(tnkDir,100); /* if the speed is below 50, full speed ahead in new direction*/
+				tnkWall = 0;
+			}
 		}
 		else { /* if we are not in the wall zone */
 			/* ----------------------- MAIN Logic for Fireing -------------------------- */
-			if (loc_x() > 900 || loc_x() < 100 || loc_y() > 900 || loc_y() < 100) { /* check if we get into the wall zone again */
-				tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
-				drive(tnkDir,0);  /* stop the engine */
-			}
 			if (DoScnHi()) { /* do a high scan to get a fire solution */
-				if (scnDist < 710) { /* Next values seems to be good 5000000-6000000 angle and dist */
-					if (fireSol < 50) {
-						cannon(cOpAng-((sin(fOpAng+180-cOpAng)*scnDist)/6000000) ,scnDist-((cos(fOpAng+180-cOpAng)*scnDist)/700000)); /* if we are closer than 700 meters fire */
-					}
-					else {
-						cannon(cOpAng,scnDist);
-					}
+				if (scnDist < 710) {
+					cannon(cOpAng-((pOpAng-cOpAng) % 360),scnDist-(pScnDist-scnDist));
 				}
-				pOpXPos = cOpXPos; /* set the prevoius position */
-				pOpYPos = cOpYPos;/* set the prevoius position */
-				cOpXPos = loc_x() + (scnDist * cos(cOpAng))/100000; /* figure out the enemy x position using the cosine rule */
-				cOpYPos = loc_y() + (scnDist * sin(cOpAng))/100000; /* figure out the enemy y position using the sine rule */
-				pOpAng = fOpAng;
-				fOpAng = PltOpCr(); /* plot opponent course to find heading */
-				if (fOpAng >= pOpAng)
-				fireSol = fOpAng - pOpAng;
-				else
-				fireSol = pOpAng - fOpAng;
+				if (loc_x() > 850 || loc_x() < 150 || loc_y() > 850 || loc_y() < 150) { /* check if we get into the wall zone again */
+					tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
+					drive(tnkDir,0);  /* stop the engine */
+				}
 			} /* ----------------------- MAIN Logic for finding opponent again -------------------------- */
-			else {
-				if (DoScnMd(0)) { /* do a medium scan with first scan disable */
+			else if (DoScnMd(0)) { /* do a medium scan with first scan disable */
+			}
+			else if (DoScnLo(0) && !tnkWall) { /* do a low scan to find him again with first scan disable  */
+				if (DoScnMd(1) && !tnkWall) { /* do a medium scan with first scan enable */
 				}
-				else {
-					if (DoScnLo(0) && !tnkWall) { /* do a low scan to find him again with first scan disable  */
-						if (DoScnMd(1) && !tnkWall) { /* do a medium scan with first scan enable */
-						}
-					}
-					else {
-						if (DoScnLo(1) && !tnkWall) { /* do a low scan to find him again with first scan enable */
-							if (DoScnMd(1) && !tnkWall) { /* do a medium scan with first scan enable */
-							}
-						}
-					}
-				} /* End of Med scan failure */
-			} /* End of high scan failure */
+			}
+			else if (DoScnLo(1) && !tnkWall) { /* do a low scan to find him again with first scan enable */
+				if (DoScnMd(1) && !tnkWall) { /* do a medium scan with first scan enable */
+				}
+			}
 		} /* End of Normal (Not Wall) scenario */
-		} /* End of while() */
-	} /* End of main() */
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* End of program and start of functions */
-
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* DoScnLo around with max 20 degree jumps starting from startDir up to 170 degree, 10 degree resolution */
-	DoScnLo(frstScn) {
-
-		if (frstScn) {
-			if (( scnDist = scan(cOpAng, 10))) { /* 10 degree resolution scan 10 + | + 10 */
-				return 1;
-			}
-			if (( scnDist = scan(cOpAng + 10, 10))) {
-				cOpAng += 10;
-				return 1;
-			}
-			if (( scnDist = scan(cOpAng - 10, 10))) {
-				cOpAng -= 10;
-				return 1;
-			}
-		}
-		if (( scnDist = scan(cOpAng + 30, 10))) {
-			cOpAng += 30;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 30, 10))) {
-			cOpAng -= 30;
+		pOpAng = cOpAng; pScnDist = scnDist; /* uppdatera föregående värden */
+	} /* End of while() */
+} /* End of main() */
+
+/*--------------------------------------------------------------------------------------------*/
+/* End of program and start of functions */
+
+
+/*--------------------------------------------------------------------------------------------*/
+/* DoScnLo around with max 20 degree jumps starting from startDir up to 170 degree, 10 degree resolution */
+DoScnLo(frstScn) {
+
+	if (frstScn) {
+		if (( scnDist = scan(cOpAng, 10))) { /* 10 degree resolution scan 10 + | + 10 */
+			return 1;
+		}
+		if (( scnDist = scan(cOpAng + 10, 10))) {
+			cOpAng += 10;
+			return 1;
+		}
+		if (( scnDist = scan(cOpAng - 10, 10))) {
+			cOpAng -= 10;
 			return 1;
 		}
-		if (( scnDist = scan(cOpAng + 50, 10))) {
-			cOpAng += 50;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 50, 10))) {
-			cOpAng -= 50;
+	}
+	if (( scnDist = scan(cOpAng + 30, 10))) {
+		cOpAng += 30;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 30, 10))) {
+		cOpAng -= 30;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 50, 10))) {
+		cOpAng += 50;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 50, 10))) {
+		cOpAng -= 50;
+		return 1;
+	}
+	if (loc_x() > 850 || loc_x() < 150 || loc_y() > 850 || loc_y() < 150) { /* check if we get into the wall zone again */
+		tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
+		drive(tnkDir,0); /* stop the engine */
+		return 0;
+	}
+	if (( scnDist = scan(cOpAng + 70, 10))) {
+		cOpAng += 70;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 70, 10))) {
+		cOpAng -= 70;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 90, 10))) {
+		cOpAng += 90;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 90, 10))) {
+		cOpAng -= 90;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 110, 10))) {
+		cOpAng += 110;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 110, 10))) {
+		cOpAng -= 110;
+		return 1;
+	}
+	if (loc_x() > 850 || loc_x() < 150 || loc_y() > 850 || loc_y() < 150) { /* check if we get into the wall zone again */
+		tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
+		drive(tnkDir,0); /* stop the engine */
+		return 0;
+	}
+	if (( scnDist = scan(cOpAng + 130, 10))) {
+		cOpAng += 130;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 130, 10))) {
+		cOpAng -= 130;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 150, 10))) {
+		cOpAng += 150;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 150, 10))) {
+		cOpAng -= 150;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 170, 10))) {
+		cOpAng += 170;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 170, 10))) {
+		cOpAng -= 170;
+		return 1;
+	}
+	return 0;
+}
+
+/*--------------------------------------------------------------------------------------------*/
+/* DoScnMe around with max 8 degree jumps starting from startDir up to 32 degree, 4 degree resolution */
+DoScnMd(frstScn) {
+	if (frstScn) {
+		if (( scnDist = scan(cOpAng, 4))) { /* 4 degree resolution scan 4 + | + 4 */
+			return 1;
+		}
+		if (( scnDist = scan(cOpAng + 8, 4))) {
+			cOpAng += 8;
+			return 1;
+		}
+		if (( scnDist = scan(cOpAng - 8, 4))) {
+			cOpAng -= 8;
 			return 1;
 		}
-		if (loc_x() > 900 || loc_x() < 100 || loc_y() > 900 || loc_y() < 100) { /* check if we get into the wall zone again */
-			tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
-			drive(tnkDir,0); /* stop the engine */
-			return 0;
-		}
-		if (( scnDist = scan(cOpAng + 70, 10))) {
-			cOpAng += 70;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 70, 10))) {
-			cOpAng -= 70;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 90, 10))) {
-			cOpAng += 90;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 90, 10))) {
-			cOpAng -= 90;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 110, 10))) {
-			cOpAng += 110;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 110, 10))) {
-			cOpAng -= 110;
-			return 1;
-		}
-		if (loc_x() > 900 || loc_x() < 100 || loc_y() > 900 || loc_y() < 100) { /* check if we get into the wall zone again */
-			tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
-			drive(tnkDir,0); /* stop the engine */
-			return 0;
-		}
-		if (( scnDist = scan(cOpAng + 130, 10))) {
-			cOpAng += 130;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 130, 10))) {
-			cOpAng -= 130;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 150, 10))) {
-			cOpAng += 150;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 150, 10))) {
-			cOpAng -= 150;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 170, 10))) {
-			cOpAng += 170;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 170, 10))) {
-			cOpAng -= 170;
-			return 1;
-		}
+	}
+	if (( scnDist = scan(cOpAng + 16, 4))) {
+		cOpAng += 16;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 16, 4))) {
+		cOpAng -= 16;
+		return 1;
+	}
+	if (loc_x() > 850 || loc_x() < 150 || loc_y() > 850 || loc_y() < 150) { /* check if we get into the wall zone again */
+		tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
+		drive(tnkDir,0); /* stop the engine */
 		return 0;
 	}
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* DoScnMe around with max 8 degree jumps starting from startDir up to 32 degree, 4 degree resolution */
-	DoScnMd(frstScn) {
-
-		if (frstScn) {
-			if (( scnDist = scan(cOpAng, 4))) { /* 4 degree resolution scan 4 + | + 4 */
-				return 1;
-			}
-			if (( scnDist = scan(cOpAng + 8, 4))) {
-				cOpAng += 8;
-				return 1;
-			}
-			if (( scnDist = scan(cOpAng - 8, 4))) {
-				cOpAng -= 8;
-				return 1;
-			}
-		}
-		if (( scnDist = scan(cOpAng + 16, 4))) {
-			cOpAng += 16;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 16, 4))) {
-			cOpAng -= 16;
-			return 1;
-		}
-		if (loc_x() > 900 || loc_x() < 100 || loc_y() > 900 || loc_y() < 100) { /* check if we get into the wall zone again */
-			tnkWall = 1; tnkTurn = 1; /* start the wall scenario and turn */
-			drive(tnkDir,0); /* stop the engine */
-			return 0;
-		}
-		if (( scnDist = scan(cOpAng + 24, 4))) {
-			cOpAng += 24;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 24, 4))) {
-			cOpAng -= 24;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 32, 4))) {
-			cOpAng += 32;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 32, 4))) {
-			cOpAng -= 32;
-			return 1;
-		}
-
-		return 0;
-	}
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* DoScnHi around with min 4 degree jumps starting from startDir up to 12 degree, 2 degree resolution */
-	DoScnHi() {
-
-		if (( scnDist = scan(cOpAng, 2))) { /* 2 degree resolution scan 2 + | + 2 */
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 4, 2))) {
-			cOpAng += 4;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 4, 2))) {
-			cOpAng -= 4;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 8, 2))) {
-			cOpAng += 8;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 8, 2))) {
-			cOpAng -= 8;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng + 12, 2))) {
-			cOpAng += 12;
-			return 1;
-		}
-		if (( scnDist = scan(cOpAng - 12, 2))) {
-			cOpAng -= 12;
-			return 1;
-		}
-		return 0;
-	}
-
-
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* Calc distance with sqrt */
-	ClcDist(xx, yy) {
-		return sqrt(((loc_x() - xx) * (loc_x() - xx)) + ((loc_y() - yy) * (loc_y() - yy)));
-	}
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* plot course returns degree 0-359 */
-	PlotCrs(xx,yy) {
-		/* atan only returns -90 to +90 */
-
-		if (loc_x() != xx) {
-			if (yy > loc_y()) { /* if north */
-				if (xx > loc_x()) return atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 	/* norr-höger, quadrant 1 */
-				else return 180 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 		/* norrvänster, quadrant 2 */
-			}
-			else { /* if south */
-				if (xx > loc_x()) return 359 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 	/* syd-höger, quadrant 4 */
-				else return 180 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 				/* syd-vänster, quadrant 3 */
-			}
-		}
-		else {
-			if (yy > loc_y()) return 90;		/* north */
-			else return 270;       			/* south */
-		}
-	}
-
-
-	/*--------------------------------------------------------------------------------------------*/
-	/* plot Opponent course returns degree 0-359 */
-	PltOpCr() {
-		/* atan only returns -90 to +90 */
-
-		if (pOpXPos != cOpXPos) {
-			if (cOpYPos > pOpYPos) { /* if north */
-				if (cOpXPos > pOpXPos) return atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 	/* norr-höger, quadrant 1 */
-				else return 180 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 		/* norrvänster, quadrant 2 */
-			}
-			else { /* if south */
-				if (cOpXPos > pOpXPos) return 359 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 	/* syd-höger, quadrant 4 */
-				else return 180 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 				/* syd-vänster, quadrant 3 */
-			}
-		}
-		else {
-			if (cOpYPos > pOpYPos) return 90;		/* north */
-			else return 270;       			/* south */
-		}
-	}
+	if (( scnDist = scan(cOpAng + 24, 4))) {
+		cOpAng += 24;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 24, 4))) {
+		cOpAng -= 24;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 32, 4))) {
+		cOpAng += 32;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 32, 4))) {
+		cOpAng -= 32;
+		return 1;
+	}
+
+	return 0;
+}
+
+/*--------------------------------------------------------------------------------------------*/
+/* DoScnHi around with min 4 degree jumps starting from startDir up to 12 degree, 2 degree resolution */
+DoScnHi() {
+	if (( scnDist = scan(cOpAng, 2))) { /* 2 degree resolution scan 2 + | + 2 */
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 4, 2))) {
+		cOpAng += 4;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 4, 2))) {
+		cOpAng -= 4;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 8, 2))) {
+		cOpAng += 8;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 8, 2))) {
+		cOpAng -= 8;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 12, 2))) {
+		cOpAng += 12;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 12, 2))) {
+		cOpAng -= 12;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng + 16, 2))) {
+		cOpAng += 16;
+		return 1;
+	}
+	if (( scnDist = scan(cOpAng - 16, 2))) {
+		cOpAng -= 16;
+		return 1;
+	}
+	return 0;
+}
+
+
+
+/*--------------------------------------------------------------------------------------------*/
+/* Calc distance with sqrt */
+ClcDist(xx, yy) {
+	return sqrt(((loc_x() - xx) * (loc_x() - xx)) + ((loc_y() - yy) * (loc_y() - yy)));
+}
+
+/*--------------------------------------------------------------------------------------------*/
+/* plot course returns degree 0-359 */
+PlotCrs(xx,yy) {
+	/* atan only returns -90 to +90 */
+
+	if (loc_x() != xx) {
+		if (yy > loc_y()) { /* if north */
+			if (xx > loc_x()) return atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 	/* norr-höger, quadrant 1 */
+			else return 180 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 		/* norrvänster, quadrant 2 */
+		}
+		else { /* if south */
+			if (xx > loc_x()) return 359 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 	/* syd-höger, quadrant 4 */
+			else return 180 + atan((100000 * (loc_y() - yy)) / (loc_x() - xx)); 				/* syd-vänster, quadrant 3 */
+		}
+	}
+	else {
+		if (yy > loc_y()) return 90;		/* north */
+		else return 270;       			/* south */
+	}
+}
+
+
+/*--------------------------------------------------------------------------------------------*/
+/* plot Opponent course returns degree 0-359 */
+PltOpCr() {
+	/* atan only returns -90 to +90 */
+
+	if (pOpXPos != cOpXPos) {
+		if (cOpYPos > pOpYPos) { /* if north */
+			if (cOpXPos > pOpXPos) return atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 	/* norr-höger, quadrant 1 */
+			else return 180 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 		/* norrvänster, quadrant 2 */
+		}
+		else { /* if south */
+			if (cOpXPos > pOpXPos) return 359 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 	/* syd-höger, quadrant 4 */
+			else return 180 + atan((100000 * (pOpYPos - cOpYPos)) / (pOpXPos - cOpXPos)); 				/* syd-vänster, quadrant 3 */
+		}
+	}
+	else {
+		if (cOpYPos > pOpYPos) return 90;		/* north */
+		else return 270;       			/* south */
+	}
+}


ASoC: codecs: wm8962: Fix register cache incoherency

The multi-component patch(commit f0fba2ad1) moved the allocation of the
register cache from the driver to the ASoC core. Most drivers where adjusted to
this, but the wm8962 driver still uses its own register cache for its
private functions, while functions from the ASoC core use the generic cache.
Thus we end up with two from each other incoherent caches, which can lead to
undefined behaviour.
This patch fixes the issue by changing the wm8962 driver to use the
generic register cache in its private functions.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@kernel.org (for 2.6.37 only)

--- sound/soc/codecs/wm8962.c
+++ sound/soc/codecs/wm8962.c
@@ -51,8 +51,6 @@
 /* codec private data */
 struct wm8962_priv {
 	struct snd_soc_codec *codec;
-
-	u16 reg_cache[WM8962_MAX_REGISTER + 1];

 	int sysclk;
 	int sysclk_rate;
@@ -1991,8 +1989,7 @@
 			    struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
-	u16 *reg_cache = wm8962->reg_cache;
+	u16 *reg_cache = codec->reg_cache;
 	int ret;

 	/* Apply the update (if any) */
@@ -2020,8 +2017,7 @@
 			    struct snd_ctl_elem_value *ucontrol)
 {
 	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
-	struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
-	u16 *reg_cache = wm8962->reg_cache;
+	u16 *reg_cache = codec->reg_cache;
 	int ret;

 	/* Apply the update (if any) */
@@ -2329,8 +2325,7 @@
 			 struct snd_kcontrol *kcontrol, int event)
 {
 	struct snd_soc_codec *codec = w->codec;
-	struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
-	u16 *reg_cache = wm8962->reg_cache;
+	u16 *reg_cache = codec->reg_cache;
 	int reg;

 	switch (w->shift) {
@@ -2719,7 +2714,7 @@

 static void wm8962_sync_cache(struct snd_soc_codec *codec)
 {
-	struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
+	u16 *reg_cache = codec->reg_cache;
 	int i;

 	if (!codec->cache_sync)
@@ -2732,13 +2727,13 @@
 	/* Sync back cached values if they're different from the
 	 * hardware default.
 	 */
-	for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) {
+	for (i = 1; i < codec->driver->reg_cache_size; i++) {
 		if (i == WM8962_SOFTWARE_RESET)
 			continue;
-		if (wm8962->reg_cache[i] == wm8962_reg[i])
+		if (reg_cache[i] == wm8962_reg[i])
 			continue;

-		snd_soc_write(codec, i, wm8962->reg_cache[i]);
+		snd_soc_write(codec, i, reg_cache[i]);
 	}

 	codec->cache_sync = 0;
@@ -3406,12 +3401,11 @@
 #ifdef CONFIG_PM
 static int wm8962_resume(struct snd_soc_codec *codec)
 {
-	struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec);
 	u16 *reg_cache = codec->reg_cache;
 	int i;

 	/* Restore the registers */
-	for (i = 1; i < ARRAY_SIZE(wm8962->reg_cache); i++) {
+	for (i = 1; i < codec->driver->reg_cache_size; i++) {
 		switch (i) {
 		case WM8962_SOFTWARE_RESET:
 			continue;
@@ -3705,6 +3699,7 @@
 	struct wm8962_pdata *pdata = dev_get_platdata(codec->dev);
 	struct i2c_client *i2c = container_of(codec->dev, struct i2c_client,
 					      dev);
+	u16 *reg_cache = codec->reg_cache;
 	int i, trigger, irq_pol;

 	wm8962->codec = codec;
@@ -3804,7 +3799,7 @@

 		/* Put the speakers into mono mode? */
 		if (pdata->spk_mono)
-			wm8962->reg_cache[WM8962_CLASS_D_CONTROL_2]
+			reg_cache[WM8962_CLASS_D_CONTROL_2]
 				|= WM8962_SPK_MONO;

 		/* Micbias setup, detection enable and detection
@@ -3819,16 +3814,16 @@
 	}

 	/* Latch volume update bits */
-	wm8962->reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
-	wm8962->reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
-	wm8962->reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
-	wm8962->reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
-	wm8962->reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
-	wm8962->reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
-	wm8962->reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
-	wm8962->reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
-	wm8962->reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
-	wm8962->reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;
+	reg_cache[WM8962_LEFT_INPUT_VOLUME] |= WM8962_IN_VU;
+	reg_cache[WM8962_RIGHT_INPUT_VOLUME] |= WM8962_IN_VU;
+	reg_cache[WM8962_LEFT_ADC_VOLUME] |= WM8962_ADC_VU;
+	reg_cache[WM8962_RIGHT_ADC_VOLUME] |= WM8962_ADC_VU;
+	reg_cache[WM8962_LEFT_DAC_VOLUME] |= WM8962_DAC_VU;
+	reg_cache[WM8962_RIGHT_DAC_VOLUME] |= WM8962_DAC_VU;
+	reg_cache[WM8962_SPKOUTL_VOLUME] |= WM8962_SPKOUT_VU;
+	reg_cache[WM8962_SPKOUTR_VOLUME] |= WM8962_SPKOUT_VU;
+	reg_cache[WM8962_HPOUTL_VOLUME] |= WM8962_HPOUT_VU;
+	reg_cache[WM8962_HPOUTR_VOLUME] |= WM8962_HPOUT_VU;

 	wm8962_add_widgets(codec);


Remove extra parentheses on calls to _ecore_mouse_button.

SVN revision: 45266

--- src/lib/ecore_x/xlib/ecore_x_events.c
+++ src/lib/ecore_x/xlib/ecore_x_events.c
@@ -482,7 +482,7 @@
                case XI_ButtonPress:
                   _ecore_mouse_button
                     (ECORE_EVENT_MOUSE_BUTTON_DOWN,
-                    (evd->time,
+                     evd->time,
                      0, // state
                      0, // button
                      evd->event_x, evd->event_y,
@@ -503,7 +503,7 @@
                case XI_ButtonRelease:
                   _ecore_mouse_button
                     (ECORE_EVENT_MOUSE_BUTTON_UP,
-                    (evd->time,
+                     evd->time,
                      0, // state
                      0, // button
                      evd->event_x, evd->event_y,


table printer: Be more careful with shrink

Ensure that 0 <= shrink[i] <= widths[i],
to avoid bad situations.

Closes: #2496
Approved by: matthiasclasen

--- app/flatpak-table-printer.c
+++ app/flatpak-table-printer.c
@@ -464,11 +464,10 @@
               if (!ellipsize)
                 continue;

-              shrinkable += widths[i];
               if (col && col->title)
-                shrinkable -= strlen (col->title);
+                shrinkable += MAX (0, widths[i] - strlen (col->title));
               else
-                shrinkable -= 5;
+                shrinkable += MAX (0, widths[i] - 5);
             }

           for (i = 0; i < printer->columns->len && i < printer->n_columns; i++)
@@ -478,15 +477,16 @@

               if (ellipsize)
                 {
-                  int sh = widths[i];
+                  int sh;
                   if (col && col->title)
-                    sh = MAX (0, sh - strlen (col->title));
+                    sh = MAX (0, widths[i] - strlen (col->title));
                   else
-                    sh = MAX (0, sh - 5);
-                  shrinks[i] = shortfall * (sh / (double)shrinkable);
+                    sh = MAX (0, widths[i] - 5);
+                  shrinks[i] = MIN (shortfall * (sh / (double)shrinkable), widths[i]);
                   leftover -= shrinks[i];
                 }
             }
+
           last = leftover + 1;
           while (leftover > 0 && leftover < last)
             {


ASoC: wm8991: Replace w->codec snd_soc_dapm_to_codec(w->dapm)

The codec field of the snd_soc_widget struct is eventually going to be
removed, use snd_soc_dapm_to_codec(w->dapm) instead.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Acked-by: Charles Keepax <8e4aa0015eb43ed5ca66aaca3fb498609e1e427c@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@kernel.org>

--- sound/soc/codecs/wm8991.c
+++ sound/soc/codecs/wm8991.c
@@ -382,13 +382,14 @@
 static int outmixer_event(struct snd_soc_dapm_widget *w,
 			  struct snd_kcontrol *kcontrol, int event)
 {
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
 	u32 reg_shift = kcontrol->private_value & 0xfff;
 	int ret = 0;
 	u16 reg;

 	switch (reg_shift) {
 	case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8):
-		reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER1);
+		reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1);
 		if (reg & WM8991_LDLO) {
 			printk(KERN_WARNING
 			       "Cannot set as Output Mixer 1 LDLO Set\n");
@@ -397,7 +398,7 @@
 		break;

 	case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8):
-		reg = snd_soc_read(w->codec, WM8991_OUTPUT_MIXER2);
+		reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2);
 		if (reg & WM8991_RDRO) {
 			printk(KERN_WARNING
 			       "Cannot set as Output Mixer 2 RDRO Set\n");
@@ -406,7 +407,7 @@
 		break;

 	case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8):
-		reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER);
+		reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER);
 		if (reg & WM8991_LDSPK) {
 			printk(KERN_WARNING
 			       "Cannot set as Speaker Mixer LDSPK Set\n");
@@ -415,7 +416,7 @@
 		break;

 	case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8):
-		reg = snd_soc_read(w->codec, WM8991_SPEAKER_MIXER);
+		reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER);
 		if (reg & WM8991_RDSPK) {
 			printk(KERN_WARNING
 			       "Cannot set as Speaker Mixer RDSPK Set\n");


Do not dereference before checking for null

--- src/lib/image/enesim_image_provider.c
+++ src/lib/image/enesim_image_provider.c
@@ -41,9 +41,10 @@
 	Enesim_Buffer_Format pfmt;

 	/* sanitize the values */
-	*w = 0;
-	*h = 0;
-	*sfmt = ENESIM_BUFFER_FORMATS;
+	if (w) *w = 0;
+	if (h) *h = 0;
+	if (sfmt) *sfmt = ENESIM_BUFFER_FORMATS;
+
 	/* get the info from the image */
 	if (!p->d->info_get) return ret;


Improve the intern table hashing algorithm

--- src/intern.c
+++ src/intern.c
@@ -9,6 +9,7 @@
 #define TABLE_SIZE_BITS 10
 #define TABLE_SIZE (1 << TABLE_SIZE_BITS)
 #define DEFAULT_BUCKET_CAP 16
+#define HASH_SEED 5381

 // A bucket is a dynamic array of strings. It begins with a default capacity,
 // and it doubles its capacity every time the length would exceed it.
@@ -32,9 +33,9 @@

 InternId intern_string_n(const char *str, size_t n) {
 	// Calculate the hash value of the string.
-	InternId h = 5381;
+	InternId h = HASH_SEED;
 	for (size_t i = 0; i < n; i++) {
-		h = ((h << 5) + h) + (InternId)str[i];
+		h ^= (h << 5) + (h >> 2) + (InternId)str[i];
 	}
 	h %= TABLE_SIZE;


ASoC: Intel: Check ops before we derefference pointers.

Check ops pointer members before we can derefference them.

Signed-off-by: Liam Girdwood <1c687ae09fa7f11acd34075a0ae6b39df2be9341@linux.intel.com>
Signed-off-by: Jie Yang <ad2ec63dbc95ba363c35dd8116ca556a9d24614a@intel.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@linaro.org>

--- sound/soc/intel/sst-dsp.c
+++ sound/soc/intel/sst-dsp.c
@@ -224,19 +224,23 @@

 void sst_dsp_dump(struct sst_dsp *sst)
 {
-	sst->ops->dump(sst);
+	if (sst->ops->dump)
+		sst->ops->dump(sst);
 }
 EXPORT_SYMBOL_GPL(sst_dsp_dump);

 void sst_dsp_reset(struct sst_dsp *sst)
 {
-	sst->ops->reset(sst);
+	if (sst->ops->reset)
+		sst->ops->reset(sst);
 }
 EXPORT_SYMBOL_GPL(sst_dsp_reset);

 int sst_dsp_boot(struct sst_dsp *sst)
 {
-	sst->ops->boot(sst);
+	if (sst->ops->boot)
+		sst->ops->boot(sst);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sst_dsp_boot);


On second read through, it doesn't appear that the old IO system had a write buffer on stdout. Take that away in the new system to try and fix some rakudo issues reported by pmichaud++

--- src/io/api.c
+++ src/io/api.c
@@ -76,8 +76,8 @@

         os_handle = Parrot_io_internal_std_os_handle(interp, PIO_STDOUT_FILENO);
         handle    = Parrot_io_fdopen_flags(interp, PMCNULL, os_handle, PIO_F_WRITE);
-        Parrot_io_buffer_add_to_handle(interp, handle, IO_PTR_IDX_WRITE_BUFFER, BUFFER_SIZE_ANY,
-                                       PIO_BF_LINEBUF);
+        /* Parrot_io_buffer_add_to_handle(interp, handle, IO_PTR_IDX_WRITE_BUFFER, BUFFER_SIZE_ANY,
+                                       PIO_BF_LINEBUF); */
         _PIO_STDOUT(interp) = handle;

         os_handle           = Parrot_io_internal_std_os_handle(interp, PIO_STDERR_FILENO);


Add line numbers to epd parsing errors

Add line numbers to epd parsing errors

--- src/io/epd.c
+++ src/io/epd.c
@@ -37,6 +37,7 @@
 	int brank = 0, bfile = 0;
 	int operandLength = 0, descriptionLength = 0;
 	int done = 0;
+	int lineNo = 1;

 	file = fopen(filename, "r");

@@ -80,6 +81,7 @@
 				else if (*string == '\n')
 				{
 					++string;
+					++lineNo;
 				}
 				else if (*string == 0)
 				{
@@ -110,6 +112,7 @@
 			case EPD_COMMENT:
 				if (*string == '\n')
 				{
+					++lineNo;
 					state = EPD_START;
 				}
 				++string;
@@ -220,7 +223,8 @@
 						break;
 					default:
 						fprintf(stderr,
-						        "Unable to parse piece placement, unrecognised character: %c\n",
+						        "(%i) Unable to parse piece placement, unrecognised character: %c\n",
+						        lineNo,
 								*string);
 						goto error;
 				}
@@ -241,7 +245,8 @@
 				else
 				{
 					fprintf(stderr,
-					        "Unable to parse side to move, unrecognised character: %c\n",
+					        "(%i) Unable to parse side to move, unrecognised character: %c\n",
+					        lineNo,
 					        *string);
 					goto error;
 				}
@@ -280,7 +285,8 @@
 						break;
 					default:
 						fprintf(stderr,
-						        "Unable to parse castling, unrecognised character: %c\n",
+						        "(%i) Unable to parse castling, unrecognised character: %c\n",
+						        lineNo,
 						        *string);
 						goto error;
 				}
@@ -312,9 +318,10 @@
 					}
 					else
 					{
-					fprintf(stderr,
-					        "Unable to parse en passant, unrecognised rank character: %c\n",
-					        *string);
+						fprintf(stderr,
+						        "(%i) Unable to parse en passant, unrecognised rank character: %c\n",
+						        lineNo,
+						        *string);
 						goto error;
 					}
 					epd->description[descriptionLength++] = *string;
@@ -329,7 +336,8 @@
 					else
 					{
 						fprintf(stderr,
-						        "Unable to parse en passant, unrecognised file character: %c\n",
+						        "(%i) Unable to parse en passant, unrecognised file character: %c\n",
+						        lineNo,
 						        *string);
 						goto error;
 					}
@@ -379,14 +387,17 @@
 					    !('a' <= *string && *string <= 'z') &&
 					    !('A' <= *string && *string <= 'Z'))
 					{
-						fprintf(stderr, "Expected letter as first character of opcode\n");
+						fprintf(stderr,
+						        "(%i) Expected letter as first character of opcode\n",
+						        lineNo);
 						goto error;
 					}
 					strncat(operation->opcode, string, 1);
 					if(strlen(operation->opcode) > 14)
 					{
 						fprintf(stderr,
-						        "Opcode was longer than 14 characters, %s\n",
+						        "(%i) Opcode was longer than 14 characters, %s\n",
+						        lineNo,
 						        operation->opcode);
 						goto error;
 					}


Added some explicit includes.

Added some explicit includes.

git-svn-id: 65dd0ccd495961f396d5302e5521154b071f0302@1877 5b2332b8-efa3-11de-8684-7d64432d61a3

--- RexLogicModule/RexNetworkUtils.h
+++ RexLogicModule/RexNetworkUtils.h
@@ -3,6 +3,8 @@
 #ifndef incl_RexNetworkUtils_h
 #define incl_RexNetworkUtils_h

+#include "ModuleInterface.h"
+#include "ComponentInterface.h"
 #include "RexTypes.h"
 #include "RexUUID.h"


Update clunet_bootloader.c

Update clunet_bootloader.c

--- demo_project/clunet_bootloader/clunet_bootloader.c
+++ demo_project/clunet_bootloader/clunet_bootloader.c
@@ -49,11 +49,11 @@
 #define BOOTLOADER_TIMEOUT_OVERFLOWS ((uint16_t)(((float)BOOTLOADER_TIMEOUT / 1000.0f) * ((float)F_CPU / (float)CLUNET_TIMER_PRESCALER / 256.0f)))

-static char buffer[MY_SPM_PAGESIZE + 11];
+static uint8_t buffer[MY_SPM_PAGESIZE + 11];

 static void (*jump_to_app)(void) = 0x0000;

-static char
+static uint8_t
 control_command[5] =		{
 					CLUNET_DEVICE_ID,
 					CLUNET_BROADCAST_ADDRESS,
@@ -62,7 +62,7 @@
 					0				// субкоманда
 				};

-static char
+static uint8_t
 update_init_response[6] =	{
 					CLUNET_DEVICE_ID,
 					CLUNET_BROADCAST_ADDRESS,
@@ -80,7 +80,7 @@
 	Блокирует управление до обнаружения интервала или начала передачи от другого устройства в пределах допустимой рассинхронизации.
 */
 static void
-wait_interframe()
+wait_interframe(void)
 {
 	uint8_t delta;
 _clear:
@@ -103,7 +103,7 @@
 	Возвращает: 0 при успехе, 1 при прошедшем таймауте ожидания (так никто и не начал передачу)
 */
 static uint8_t
-wait_for_start()
+wait_for_start(void)
 {
 	CLUNET_TIMER_REG = 0;
 	uint16_t overflows = BOOTLOADER_TIMEOUT_OVERFLOWS;
@@ -146,20 +146,21 @@
 }

 /* Функция нахождения контрольной суммы Maxim iButton 8-bit */
-static char
-check_crc(const char* data, const uint8_t size)
-{
-      char crc = 0;
+static uint8_t
+check_crc(const uint8_t* data, const uint8_t size)
+{
+      uint8_t crc = 0;
       uint8_t a = 0;
       do
       {
             uint8_t b = 8;
-            char inbyte = data[a];
+            uint8_t inbyte = data[a];
             do
             {
                   uint8_t mix = (crc ^ inbyte) & 1;
                   crc >>= 1;
-                  if (mix) crc ^= 0x8C;
+                  if (mix)
+                  	crc ^= 0x8C;
                   inbyte >>= 1;
             }
             while (--b);
@@ -174,7 +175,7 @@

 	uint8_t numBits, bitIndex, byteIndex;

-	char crc = check_crc(data, size);
+	uint8_t crc = check_crc(data, size);

 _repeat:

@@ -183,8 +184,8 @@
 	CLUNET_SEND_1;
 	numBits = 4; // Начинаем с посылки 4 бит (стартовый и 3 бита приоритета)
 	byteIndex = bitIndex = 0;
-	char sendingByte = data[0];
-	char xBitMask = 0; // Битовая маска для целей подсчета бит и получения текущего состояния линии
+	uint8_t sendingByte = data[0];
+	uint8_t xBitMask = 0; // Битовая маска для целей подсчета бит и получения текущего состояния линии
 	do
 	{
 		while (((sendingByte << bitIndex) & 0x80) ^ xBitMask)
@@ -251,7 +252,7 @@
 */

 static uint8_t
-read()
+read(void)
 {
 	// Ждем освобождения линии и межкадровое пространство в блокирующем режиме (в конце концов замкнутая накоротко линия это ненормально)
 	wait_interframe();
@@ -365,18 +366,17 @@

 int main (void)
 {
-
 	cli();
  	CLUNET_TIMER_INIT;
 	CLUNET_PIN_INIT;

-	// Посылаем широковещательный пакет, что мы в загрузчике
-	send_firmware_command(COMMAND_FIRMWARE_UPDATE_START);
-
 	// Делаем 5 попыток получить в ответ служебный пакет, при успехе переходим в режим прошивки, иначе загружаем основную программу
 	uint8_t packets = 5;
 	do
 	{
+		// Посылаем широковещательный пакет, что мы в загрузчике
+		send_firmware_command(COMMAND_FIRMWARE_UPDATE_START);
+
 		if (read() && (RECEIVED_SUB_COMMAND == COMMAND_FIRMWARE_UPDATE_INIT))
 		{

@@ -391,7 +391,6 @@

 			while(1)
 			{
-
 				// Если системный пакет получен и он от нужного устройства, то обработаем его
 				if (read() && FLASHER_ADDRESS == flasher_address)
 				{


Update clunet_bootloader.c

Update clunet_bootloader.c

--- demo_project/clunet_bootloader/clunet_bootloader.c
+++ demo_project/clunet_bootloader/clunet_bootloader.c
@@ -113,25 +113,28 @@
 	uint8_t time = 0;

 	CLUNET_TIMER_REG = 0;
+	CLUNET_TIMER_OVERFLOW_CLEAR;

 	while(CLUNET_READING != CLUNET_READING)
-		if (CLUNET_TIMER_REG == 255)
-		{
-			CLUNET_TIMER_REG = 0;
+		if (CLUNET_TIMER_OVERFLOW)
+		{
+			// После 256 полных циклов таймера выйдем по таймауту
 			if (!++time)
 				return 0;
+			CLUNET_TIMER_OVERFLOW_CLEAR;
 		}

-	register uint8_t ticks = CLUNET_TIMER_REG;
+	uint8_t ticks = CLUNET_TIMER_REG;

 	time = 0;

 	while(CLUNET_READING != CLUNET_READING)
-		if (CLUNET_TIMER_REG == 255)
-		{
-			CLUNET_TIMER_REG = 0;
-			if (!++time)
+		if (CLUNET_TIMER_OVERFLOW)
+		{
+			// Ошибка: слишком большой период
+			if (++time > 1)
 				return 0;
+			CLUNET_TIMER_OVERFLOW_CLEAR;
 		}

 	ticks = CLUNET_TIMER_REG - ticks;


Fixing crash associated with failure to report

--- LCM/dsc/engine/ca/CAInfrastructure/WebPullClient.c
+++ LCM/dsc/engine/ca/CAInfrastructure/WebPullClient.c
@@ -2571,7 +2571,7 @@
                         MI_Char* x_ms_header,
                         MI_Char* auth_header,
                         MI_Char* requestBody,
-			_Outptr_result_maybenull_ MI_Instance **extendedError)
+                        _Outptr_result_maybenull_ MI_Instance **extendedError)
 {
     MI_Result r = MI_RESULT_OK;
     const char *emptyString = "";
@@ -2636,26 +2636,26 @@
     res = curl_easy_setopt(curl, CURLOPT_SSLCERTTYPE, "PEM");
     if (res != CURLE_OK)
       {
-	curl_slist_free_all(list);
-	curl_easy_cleanup(curl);
-	curl_global_cleanup();
-	return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
+        curl_slist_free_all(list);
+        curl_easy_cleanup(curl);
+        curl_global_cleanup();
+        return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
       }
     res = curl_easy_setopt(curl, CURLOPT_SSLCERT, CONFIG_CERTSDIR "/oaas.crt");
     if (res != CURLE_OK)
       {
-	curl_slist_free_all(list);
-	curl_easy_cleanup(curl);
-	curl_global_cleanup();
-	return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
+        curl_slist_free_all(list);
+        curl_easy_cleanup(curl);
+        curl_global_cleanup();
+        return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
       };
     res = curl_easy_setopt(curl, CURLOPT_SSLKEY, CONFIG_CERTSDIR "/oaas.key");
     if (res != CURLE_OK)
       {
-	curl_slist_free_all(list);
-	curl_easy_cleanup(curl);
-	curl_global_cleanup();
-	return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
+        curl_slist_free_all(list);
+        curl_easy_cleanup(curl);
+        curl_global_cleanup();
+        return GetCimMIError(MI_RESULT_FAILED, extendedError, ID_PULL_CERTOPTS_NOT_SUPPORTED);
       }

@@ -2680,15 +2680,17 @@

     if (responseCode != 200 && responseCode != 201 && responseCode != 204)
     {
-      // Error on register
-
-      curl_slist_free_all(list);
-      curl_easy_cleanup(curl);
-      curl_global_cleanup();
-
-      free(headerChunk.data);
-      free(dataChunk.data);
-      return GetCimMIError2Params(MI_RESULT_FAILED, extendedError, ID_PULL_SERVERHTTPERRORCODEREGISTER, actionUrl, responseCode);
+        MI_Char statusCodeValue[MAX_STATUSCODE_SIZE] = {0};
+        // Error on register
+
+        curl_slist_free_all(list);
+        curl_easy_cleanup(curl);
+        curl_global_cleanup();
+
+        free(headerChunk.data);
+        free(dataChunk.data);
+        Stprintf(statusCodeValue, MAX_STATUSCODE_SIZE, MI_T("%d"), responseCode);
+        return GetCimMIError2Params(MI_RESULT_FAILED, extendedError, ID_PULL_SERVERHTTPERRORCODEREGISTER, actionUrl, statusCodeValue);
     }

     curl_slist_free_all(list);
@@ -2843,7 +2845,8 @@
     }
     else
     {
-      snprintf(dataBuffer, "%d", responseCode);
+      MI_Char statusCodeValue[MAX_STATUSCODE_SIZE] = {0};
+      Stprintf(statusCodeValue, MAX_STATUSCODE_SIZE, MI_T("%d"), responseCode);
       return GetCimMIError1Param(MI_RESULT_FAILED, extendedError, ID_PULL_REPORTINGFAILED, dataBuffer);
     }


missing include

missing include

git-svn-id: afcf11d89342f630bd950d18a70234a9e277d909@84095 523d945c-050c-4681-91ec-863ad3bb968a

--- LGPL/CommonSoftware/acsnc/ws/include/acsncHelper.h
+++ LGPL/CommonSoftware/acsnc/ws/include/acsncHelper.h
@@ -21,7 +21,7 @@
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
-* "@(#) $Id: acsncHelper.h,v 1.66 2008/02/06 15:26:39 msekoran Exp $"
+* "@(#) $Id: acsncHelper.h,v 1.67 2008/02/07 10:18:17 msekoran Exp $"
 *
 * who       when      what
 * --------  --------  ----------------------------------------------
@@ -46,6 +46,7 @@
 #include "acsncS.h"
 #include "acsncC.h"
 #include "acsncORBHelper.h"
+#include "acsncCDBProperties.h"

 #include <ACSErrTypeCommon.h>


MFV r273060:

MFV r273060:

Use write_psize instead of write_asize when doing vdev_space_update.
Without this change the accounting of L2ARC usage would be wrong and
give 16EB free space because the number became negative and overflows.

Obtained from:  FreeNAS (issue #6239)

--- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -5228,7 +5228,7 @@
 	ARCSTAT_INCR(arcstat_l2_write_bytes, write_asize);
 	ARCSTAT_INCR(arcstat_l2_size, write_sz);
 	ARCSTAT_INCR(arcstat_l2_asize, write_asize);
-	vdev_space_update(dev->l2ad_vdev, write_asize, 0, 0);
+	vdev_space_update(dev->l2ad_vdev, write_psize, 0, 0);

 	/*
 	 * Bump device hand to the device start if it is approaching the end.


[percolation] Remove old commented out debugging code

--- percolation/clusters.c
+++ percolation/clusters.c
@@ -97,12 +97,6 @@
         }
     }

-    /* for debugging purposes */
-    /*
-    print_lattice(lattice, rows, columns, 1);
-    print_lattice(labels, 2, lattice_size/4, 1);
-    */
-
     /* resolve temporary labels */
     for (i = 0; i < lattice_size; i++) {
         current_label = lattice[i];


tweaked a comment.

tweaked a comment.

--- src/appleseed/renderer/modeling/project/project.h
+++ src/appleseed/renderer/modeling/project/project.h
@@ -54,7 +54,7 @@
     // Delete this instance.
     virtual void release();

-    // Set or get the project path.
+    // Set/get the project path.
     bool has_path() const;
     void set_path(const char* path);
     const char* get_path() const;


null value handling, $KEY macro handling

--- source/functions/sqlite.c
+++ source/functions/sqlite.c
@@ -24,6 +24,7 @@
 #define KEYVALUE_SQL "select key, value from clusters where cluster=?"
 #define HAS_SQL "select cluster from clusters where key=? and value=?"
 #define ALLCLUSTER_SQL "select distinct cluster from clusters"
+#define EMPTY_STRING ""

 sqlite3* _open_db(range_request* rr)
@@ -35,7 +36,6 @@

     /* open the db */
     if (!(db = libcrange_get_cache(lr, "sqlite:nodes"))) {
-        //global for now
         sqlite_db_path = libcrange_getcfg(lr, "sqlitedb");
         if (!sqlite_db_path) sqlite_db_path = DEFAULT_SQLITE_DB;

@@ -50,6 +50,44 @@
     return db;
 }

+static char* _substitute_dollars(apr_pool_t* pool,
+                                 const char* cluster, const char* line)
+{
+    static char buf[262144];
+    char* dst = buf;
+    int len = strlen(cluster);
+    int in_regex = 0;
+    char c;
+    assert(line);
+    assert(cluster);
+
+    while ((c = *line) != '\0') {
+        if (!in_regex && c == '$') {
+            strcpy(dst, "cluster(");
+            dst += sizeof("cluster(") - 1;
+            strcpy(dst, cluster);
+            dst += len;
+            *dst++ = ':';
+            c = *++line;
+            while (isalnum(c) || c == '_') {
+                *dst++ = c;
+                c = *++line;
+            }
+            *dst++ = ')';
+        }
+        else if (c == '/') {
+            in_regex = !in_regex;
+            *dst++ = *line++;
+        }
+        else {
+            *dst++ = *line++;
+        }
+    }
+    *dst = '\0';
+    return buf;
+}
+
+

 static set* _cluster_keys(range_request* rr, apr_pool_t* pool,
                           const char* cluster)
@@ -79,7 +117,10 @@
         /* add it to the return */
         const char* key = (const char*)sqlite3_column_text(stmt, 0);
         const char* value = (const char*)sqlite3_column_text(stmt, 1);
-        set_add(sections, key, apr_psprintf(pool, "%s", value));
+        if (NULL == value) {
+            value = EMPTY_STRING;
+        }
+        set_add(sections, key, apr_psprintf(pool, "%s",  _substitute_dollars(pool, cluster, value) ));
     }
     sqlite3_finalize(stmt);


Fix up a mistype yesterday afternoon.

Fix up a mistype yesterday afternoon.

git-svn-id: 4705079bc6b8aadf675e3696f5c015a6aa4916e3@4480 3c1deb5b-d424-0410-962d-aba41a686d42


fixed non ai spawning

fixed non ai spawning

--- src/ludumdare31/ld31/game/ld31_game.c
+++ src/ludumdare31/ld31/game/ld31_game.c
@@ -939,6 +939,9 @@
 					if (amount > max) {
 						amount = max;
 					}
+					if (amount == 0) {
+						amount++;
+					}
 					while (amount >= 0) {
 						int x = (rand() % 24 + 1) * tile_size;
 						int y = (rand() % 24 + 1) * tile_size;


Qdoffs now exports the GWorldObj_{New,Convert} functions.

--- Mac/Include/pymactoolbox.h
+++ Mac/Include/pymactoolbox.h
@@ -56,6 +56,10 @@
 extern PyObject *QdRGB_New(RGBColor *);
 extern int QdRGB_Convert(PyObject *, RGBColor *);

+/* Qdoffs exports */
+extern PyObject *GWorldObj_New(GWorldPtr);
+extern int GWorldObj_Convert(PyObject *, GWorldPtr *);
+
 /* Qt exports */
 extern PyObject *TrackObj_New(Track);
 extern int TrackObj_Convert(PyObject *, Track *);


avr-asm-ops/sqrt_25_large.h: optimization We don't need to shift everything right at the beginning, since there's no possibility of 'x' overflowing, like it was when we were still doing 32bit square root.


tests: souphttpsrc: use SoupKnownStatusCode if needed

From libsoup docs:

Prior to 2.44 SoupStatus was called SoupKnownStatusCode,
but the individual values have always had the names they
have now.

Fixes:
  https://bugzilla.gnome.org/show_bug.cgi?id=727329

--- tests/check/elements/souphttpsrc.c
+++ tests/check/elements/souphttpsrc.c
@@ -34,7 +34,12 @@
 #include <libsoup/soup-auth-domain.h>
 #include <libsoup/soup-auth-domain-basic.h>
 #include <libsoup/soup-auth-domain-digest.h>
+#include <libsoup/soup-version.h>
 #include <gst/check/gstcheck.h>
+
+#if !(SOUP_CHECK_VERSION(2, 44, 0))
+#define SoupStatus SoupKnownStatusCode
+#endif

 static guint http_port = 0, https_port = 0;


mutool extract: Remove spurious 'break' statement and fix double free.

--- source/tools/pdfextract.c
+++ source/tools/pdfextract.c
@@ -119,7 +119,6 @@
 			unsigned char *data;
 			size_t len = fz_buffer_storage(ctx, cbuf->buffer, &data);
 			writejpeg(ctx, data, len, buf);
-			break;
 		}
 		else
 		{
@@ -131,7 +130,6 @@
 	{
 		fz_drop_image(ctx, image);
 		fz_drop_pixmap(ctx, pix);
-		pdf_drop_obj(ctx, ref);
 	}
 	fz_catch(ctx)
 		fz_rethrow(ctx);


typo in unit test runner

typo in unit test runner

--- backend.native/tests/main.c
+++ backend.native/tests/main.c
@@ -24,7 +24,7 @@
   main((void *)0);
   return 0;
 #else
-  return exit(run_test());
+  exit(run_test());
 #endif
 }


- missing STATUS

- missing STATUS

--- php_http_request_api.h
+++ php_http_request_api.h
@@ -77,7 +77,7 @@
 PHP_HTTP_API const char *_http_request_method_string(http_request_method m);

 #define http_request_body_fill(b, fields, files) _http_request_body_fill((b), (fields), (files) TSRMLS_CC)
-PHP_HTTP_API _http_request_body_fill(http_request_body *body, HashTable *fields, HashTable *files TSRMLS_DC);
+PHP_HTTP_API STATUS _http_request_body_fill(http_request_body *body, HashTable *fields, HashTable *files TSRMLS_DC);

 #define http_request_body_dtor(b) _http_request_body_dtor((b) TSRMLS_CC)
 PHP_HTTP_API void _http_request_body_dtor(http_request_body *body TSRMLS_DC);


i40e: use correct vf_id offset for virtchnl message

The vf_id needs to be offset by the vf_base_id from hw function capabilities
for the case of multiple PFs.

Change-ID: I20ca8621f98e9cdf98649380b8eeaa35db52677c
Signed-off-by: Ashish Shah <77be4739a86e3dd7e128684005f83c3898fe2fc6@intel.com>
Tested-by: Sibai Li <7b32709b4fa5663a47e0d1f9518bcee0920157c8@intel.com>
Signed-off-by: Aaron Brown <4723df1d9a4136f7b76e1bf6434e33afc91d2139@intel.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


brcmfmac: Increase max buffer size for receiving control message from dongle

The max buffer size for receiving control message from dongle needs to be
increased considering possible block padding. Otherwise some big control
message can't be received due to buffer overrun check.

Reviewed-by: Pieter-Paul Giesberts <d101f7ec36e185d305862a92a05a9a0c1b62aa38@broadcom.com>
Signed-off-by: Daniel Kim <996ffb484be4810f081e1899e9b77a0b6fd6a184@broadcom.com>
Signed-off-by: Arend van Spriel <06447fbe43693466d3293d0b5eaeeb2efd3d7d3a@broadcom.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>


staging: media: Remove memset.

staging: media: Remove memset.

The memory area set by the call to memset is immediately
overwritten by the subsequent call to memcpy. Hence, remove that
redundant memset.

Signed-off-by: Navya Sri Nizamkari <2220f5fded1749fc9f263cc20f55877611b12255@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -907,7 +907,6 @@
 			.out_chr_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE,
 		},
 	};
-	memset(&resizer->config, 0, sizeof(struct resizer_params));
 	memcpy(&resizer->config, &rsz_default_config,
 	       sizeof(struct resizer_params));
 }


staging: usbip: userspace: Check return value for mkdir()

mkdir() could fail, so we should check its return value.

Signed-off-by: Tobias Klauser <9249c549618448e4c699e8032ba6c7f0d7fd4b7f@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>


Fix typo reported in bug #1585

Fix typo reported in bug #1585

--- bacula/src/dird/pythondir.c
+++ bacula/src/dird/pythondir.c
@@ -202,7 +202,7 @@
       buf[1] = 0;
       buf[0] = jcr->FDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);
-   case 29:                           /* SDJobStatus */
+   case 20:                           /* SDJobStatus */
       buf[1] = 0;
       buf[0] = jcr->SDJobStatus;
       return Py_BuildValue((char *)getvars[i].fmt, buf);


idiag: fix memory leak in idiagnl_msg_set_cong()

Acked-by: Thomas Graf <17c2d8920621522552b392f72d8fdb4d1e866b44@suug.ch>
Signed-off-by: Thomas Haller <16e26612e4159990a6b3691e92592e691ff74132@redhat.com>

--- lib/idiag/idiag_msg_obj.c
+++ lib/idiag/idiag_msg_obj.c
@@ -324,6 +324,7 @@

 void idiagnl_msg_set_cong(struct idiagnl_msg *msg, char *cong)
 {
+	free (msg->idiag_cong);
 	msg->idiag_cong = strdup(cong);
 }


spelling

spelling

--- lib/isc/include/isc/mem.h
+++ lib/isc/include/isc/mem.h
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */

-/* $Id: mem.h,v 1.89 2010/08/11 22:54:58 jinmei Exp $ */
+/* $Id: mem.h,v 1.90 2011/08/09 10:29:23 fdupont Exp $ */

 #ifndef ISC_MEM_H
 #define ISC_MEM_H 1
@@ -334,7 +334,7 @@
  * ISC_MEMFLAG_INTERNAL is not set, 'target_size' is ignored.
  *
  * 'max_size' is also used to size the statistics arrays and the array
- * used to record active memory when ISC_MEM_DEBUGRECORD is set.  Settin
+ * used to record active memory when ISC_MEM_DEBUGRECORD is set.  Setting
  * 'max_size' too low can have detrimental effects on performance.
  *
  * A memory context created using isc_mem_createx() will obtain


Removes <Eigen/StdVector> from eigen_types.h

--- drake/common/eigen_types.h
+++ drake/common/eigen_types.h
@@ -6,7 +6,6 @@

 #include <Eigen/Dense>
 #include <unsupported/Eigen/AutoDiff>
-#include <Eigen/StdVector>

 namespace drake {


Fixed slipage in editor.

Fixed slipage in editor.

--- lib/libc/gen/getpeereid.c
+++ lib/libc/gen/getpeereid.c
@@ -24,6 +24,7 @@
  * SUCH DAMAGE.
  */

+#include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

 #include <sys/param.h>


vhost: fix passing destroyed device to destroy callback

Application should be able to obtain information like 'ifname' from
the 'vid' passed to 'destroy_connection' callback. Currently, all the
API calls with passed 'vid' fails with 'device not found'.

Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close")
Cc: stable@dpdk.org

Signed-off-by: Ilya Maximets <e6f59449982e74b9a8013e88011af79c397f66d7@samsung.com>
Reviewed-by: Tiwei Bie <f338cf29d7d69ff1bc99f755ebfb0eb0accd409e@intel.com>

--- lib/librte_vhost/socket.c
+++ lib/librte_vhost/socket.c
@@ -297,12 +297,18 @@

 	ret = vhost_user_msg_handler(conn->vid, connfd);
 	if (ret < 0) {
+		struct virtio_net *dev = get_device(conn->vid);
+
 		close(connfd);
 		*remove = 1;
-		vhost_destroy_device(conn->vid);
+
+		if (dev)
+			vhost_destroy_device_notify(dev);

 		if (vsocket->notify_ops->destroy_connection)
 			vsocket->notify_ops->destroy_connection(conn->vid);
+
+		vhost_destroy_device(conn->vid);

 		pthread_mutex_lock(&vsocket->conn_mutex);
 		TAILQ_REMOVE(&vsocket->conn_list, conn, next);


aoe: remove vestigial request queue allocation

Before the aoe driver was an I/O request handler, it was a
make_request-style block driver.  Even so, there was a problem where
sysfs expected a request queue to exist, so one was provided in commit
7135a71b19be ("aoe: allocate unused request_queue for sysfs").

During the transition to the request-handler style, a patch was merged
that was based on a driver without the noop queue, and the noop queue
remained in place after the patch was merged, even though a new
functional queue was introduced by the patch, allocated through
blk_init_queue.

The user impact is a memory leak proportional to the number of AoE
targets discovered.  This patch removes the memory leak and cleans up
vestiges of the old do-nothing queue from the aoeblk_gdalloc function.

Signed-off-by: Ed Cashin <a5847c07920d7541d8e1bc46cb039fb7ad61c4b4@coraid.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/block/aoe/aoeblk.c
+++ drivers/block/aoe/aoeblk.c
@@ -278,18 +278,12 @@
 	if (q == NULL) {
 		pr_err("aoe: cannot allocate block queue for %ld.%d\n",
 			d->aoemajor, d->aoeminor);
-		mempool_destroy(mp);
-		goto err_disk;
-	}
-
-	d->blkq = blk_alloc_queue(GFP_KERNEL);
-	if (!d->blkq)
 		goto err_mempool;
-	d->blkq->backing_dev_info.name = "aoe";
-	if (bdi_init(&d->blkq->backing_dev_info))
-		goto err_blkq;
+	}
+
 	spin_lock_irqsave(&d->lock, flags);
-	blk_queue_max_hw_sectors(d->blkq, BLK_DEF_MAX_SECTORS);
+	blk_queue_max_hw_sectors(q, BLK_DEF_MAX_SECTORS);
+	q->backing_dev_info.name = "aoe";
 	q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE;
 	d->bufpool = mp;
 	d->blkq = gd->queue = q;
@@ -314,11 +308,8 @@
 	aoedisk_add_sysfs(d);
 	return;

-err_blkq:
-	blk_cleanup_queue(d->blkq);
-	d->blkq = NULL;
 err_mempool:
-	mempool_destroy(d->bufpool);
+	mempool_destroy(mp);
 err_disk:
 	put_disk(gd);
 err:


[PATCH] tpm: fix bug for TPM on ThinkPad T60 and Z60

The TPM chip on the ThinkPad T60 and Z60 machines is returning 0xFFFF for
the vendor ID which is a check the driver made to double check it was
actually talking to the memory mapped space of a TPM.  This patch removes
the check since it isn't absolutely necessary and was causing device
discovery to fail on these machines.

Signed-off-by: Kylene Hall <dd5f49a515c64a570ff7a179ea0a0c51657c5a32@us.ibm.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- drivers/char/tpm/tpm_tis.c
+++ drivers/char/tpm/tpm_tis.c
@@ -457,10 +457,6 @@
 	}

 	vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
-	if ((vendor & 0xFFFF) == 0xFFFF) {
-		rc = -ENODEV;
-		goto out_err;
-	}

 	/* Default timeouts */
 	chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);


clk: qcom: Do some error handling in configure_bank()

Currently configure_bank() returns void. Add some error
checking on the regmap calls and propagate if there is
any error.

Signed-off-by: Georgi Djakov <f81855f978b85fa6db70ddca8c1c5be629bdb342@linaro.org>
Signed-off-by: Stephen Boyd <010521127f513270fe503d86ab8316ac5147f4b7@codeaurora.org>


crypto: omap-sham - hmac calculation bug fix for sha1 base hash

This patch fixes 2 hmac inter-dependent bugs.

1. "omap-sham: hash-in-progress is stored in hw format" commit introduced
optimization where temporary hash had been stored in OMAP specific format
(big endian).
For SHA1 it is different to real hash format, which is little endian.
Final HMAC value was calculated using incorrect hash.
Because CONFIG_CRYPTO_MANAGER_TESTS was disabled this error remained
unnoticed. After enabling this option, bug has been found.

2. HMAC was calculated using temporrary hash value.
For a single-request updates, temporary hash was the final one and
HMAC result was correct. But in fact only the final hash had to be used.
All crypto tests for HMAC produces only single request and
could not catch the problem. This problem is fixed here.

Signed-off-by: Dmitry Kasatkin <8adb5f95ce8fa26dbddb33bd46c9f98f39d4d75f@nokia.com>
Signed-off-by: Herbert Xu <ef65de1c7be0aa837fe7b25ba9a7739905af6a55@gondor.apana.org.au>

--- drivers/crypto/omap-sham.c
+++ drivers/crypto/omap-sham.c
@@ -78,7 +78,6 @@
 #define FLAGS_SHA1		0x0010
 #define FLAGS_DMA_ACTIVE	0x0020
 #define FLAGS_OUTPUT_READY	0x0040
-#define FLAGS_CLEAN		0x0080
 #define FLAGS_INIT		0x0100
 #define FLAGS_CPU		0x0200
 #define FLAGS_HMAC		0x0400
@@ -511,26 +510,6 @@
 	return 0;
 }

-static void omap_sham_cleanup(struct ahash_request *req)
-{
-	struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
-	struct omap_sham_dev *dd = ctx->dd;
-	unsigned long flags;
-
-	spin_lock_irqsave(&dd->lock, flags);
-	if (ctx->flags & FLAGS_CLEAN) {
-		spin_unlock_irqrestore(&dd->lock, flags);
-		return;
-	}
-	ctx->flags |= FLAGS_CLEAN;
-	spin_unlock_irqrestore(&dd->lock, flags);
-
-	if (ctx->digcnt)
-		omap_sham_copy_ready_hash(req);
-
-	dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt);
-}
-
 static int omap_sham_init(struct ahash_request *req)
 {
 	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
@@ -618,9 +597,8 @@
 	return err;
 }

-static int omap_sham_finish_req_hmac(struct ahash_request *req)
-{
-	struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
+static int omap_sham_finish_hmac(struct ahash_request *req)
+{
 	struct omap_sham_ctx *tctx = crypto_tfm_ctx(req->base.tfm);
 	struct omap_sham_hmac_ctx *bctx = tctx->base;
 	int bs = crypto_shash_blocksize(bctx->shash);
@@ -635,24 +613,38 @@

 	return crypto_shash_init(&desc.shash) ?:
 	       crypto_shash_update(&desc.shash, bctx->opad, bs) ?:
-	       crypto_shash_finup(&desc.shash, ctx->digest, ds, ctx->digest);
-}
-
-static void omap_sham_finish_req(struct ahash_request *req, int err)
+	       crypto_shash_finup(&desc.shash, req->result, ds, req->result);
+}
+
+static int omap_sham_finish(struct ahash_request *req)
 {
 	struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
 	struct omap_sham_dev *dd = ctx->dd;
+	int err = 0;
+
+	if (ctx->digcnt) {
+		omap_sham_copy_ready_hash(req);
+		if (ctx->flags & FLAGS_HMAC)
+			err = omap_sham_finish_hmac(req);
+	}
+
+	dev_dbg(dd->dev, "digcnt: %d, bufcnt: %d\n", ctx->digcnt, ctx->bufcnt);
+
+	return err;
+}
+
+static void omap_sham_finish_req(struct ahash_request *req, int err)
+{
+	struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
+	struct omap_sham_dev *dd = ctx->dd;

 	if (!err) {
 		omap_sham_copy_hash(ctx->dd->req, 1);
-		if (ctx->flags & FLAGS_HMAC)
-			err = omap_sham_finish_req_hmac(req);
+		if (ctx->flags & FLAGS_FINAL)
+			err = omap_sham_finish(req);
 	} else {
 		ctx->flags |= FLAGS_ERROR;
 	}
-
-	if ((ctx->flags & FLAGS_FINAL) || err)
-		omap_sham_cleanup(req);

 	clk_disable(dd->iclk);
 	dd->flags &= ~FLAGS_BUSY;
@@ -809,22 +801,21 @@
 static int omap_sham_final(struct ahash_request *req)
 {
 	struct omap_sham_reqctx *ctx = ahash_request_ctx(req);
-	int err = 0;

 	ctx->flags |= FLAGS_FINUP;

-	if (!(ctx->flags & FLAGS_ERROR)) {
-		/* OMAP HW accel works only with buffers >= 9 */
-		/* HMAC is always >= 9 because of ipad */
-		if ((ctx->digcnt + ctx->bufcnt) < 9)
-			err = omap_sham_final_shash(req);
-		else if (ctx->bufcnt)
-			return omap_sham_enqueue(req, OP_FINAL);
-	}
-
-	omap_sham_cleanup(req);
-
-	return err;
+	if (ctx->flags & FLAGS_ERROR)
+		return 0; /* uncompleted hash is not needed */
+
+	/* OMAP HW accel works only with buffers >= 9 */
+	/* HMAC is always >= 9 because ipad == block size */
+	if ((ctx->digcnt + ctx->bufcnt) < 9)
+		return omap_sham_final_shash(req);
+	else if (ctx->bufcnt)
+		return omap_sham_enqueue(req, OP_FINAL);
+
+	/* copy ready hash (+ finalize hmac) */
+	return omap_sham_finish(req);
 }

 static int omap_sham_finup(struct ahash_request *req)


dw_dmac: fill optional encoded parameters in register structure

There is a block of the registers that are optional. However, if enabled they
contain useful information about the controller hardware configuration. We will
use this piece of data to autoconfigure the driver.

Signed-off-by: Andy Shevchenko <74f0c009df510614346aa771cd21959b78cdb413@linux.intel.com>
Acked-by: Viresh Kumar <5ff32272b3d9f86512eddc8e0af523fc6f7924e5@linaro.org>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@linux.intel.com>

--- drivers/dma/dw_dmac_regs.h
+++ drivers/dma/dw_dmac_regs.h
@@ -82,8 +82,38 @@
 	DW_REG(ID);
 	DW_REG(TEST);

+	/* reserved */
+	DW_REG(__reserved0);
+	DW_REG(__reserved1);
+
 	/* optional encoded params, 0x3c8..0x3f7 */
-};
+	u32	__reserved;
+
+	/* per-channel configuration registers */
+	u32	DWC_PARAMS[DW_DMA_MAX_NR_CHANNELS];
+	u32	MULTI_BLK_TYPE;
+	u32	MAX_BLK_SIZE;
+
+	/* top-level parameters */
+	u32	DW_PARAMS;
+};
+
+/* To access the registers in early stage of probe */
+#define dma_read_byaddr(addr, name) \
+	readl((addr) + offsetof(struct dw_dma_regs, name))
+
+/* Bitfields in DW_PARAMS */
+#define DW_PARAMS_NR_CHAN	8		/* number of channels */
+#define DW_PARAMS_NR_MASTER	11		/* number of AHB masters */
+#define DW_PARAMS_DATA_WIDTH(n)	(15 + 2 * (n))
+#define DW_PARAMS_DATA_WIDTH1	15		/* master 1 data width */
+#define DW_PARAMS_DATA_WIDTH2	17		/* master 2 data width */
+#define DW_PARAMS_DATA_WIDTH3	19		/* master 3 data width */
+#define DW_PARAMS_DATA_WIDTH4	21		/* master 4 data width */
+#define DW_PARAMS_EN		28		/* encoded parameters */
+
+/* Bitfields in DWC_PARAMS */
+#define DWC_PARAMS_MBLK_EN	11		/* multi block transfer */

 /* Bitfields in CTL_LO */
 #define DWC_CTLL_INT_EN		(1 << 0)	/* irqs enabled? */


gpio: gpio-74x164: Remove redundant spi_set_drvdata

Driver core sets driver data to NULL upon failure or remove.

Signed-off-by: Sachin Kamat <1c3b1584a6008857f36c03c58f657c0fc16fc09e@linaro.org>
Cc: Gabor Juhos <0b85b0feb94c9a44e8676965f48a70291ba74edb@openwrt.org>
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>


gpio: f7188x: set can_sleep attribute

gpio: f7188x: set can_sleep attribute

Since request_muxed_region() is used to synchronize access on the
Super-I/O controller, then the can_sleep attribute must be set for
the f7188x GPIO chips.

Signed-off-by: Simon Guinot <3ab4e30ada880520f74922b979fc5ca34d9375bb@sequanux.org>
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>


drm/edid: Add both 60Hz and 59.94Hz CEA modes to connector's mode list

Having both modes can be beneficial for video playback cases. If you can
match the video framerate exactly, and the audio and video clocks come
from the same source, you should be able to avoid dropped/repeated
frames without expensive operations such as resampling the audio to
match video output rate.

Rather than add both variants based on the CEA extension short video
descriptors in do_cea_modes(), add only one variant there. Once all
the EDID has been fully probed, do a loop over the entire probed mode
list, during which we add the other variants for all modes that match
CEA modes. This allows us to match modes that didn't come via the CEA
short video descriptors. For example one Samsung TV here doesn't have
the 640x480-60 mode as a SVD, but instead it's specified via a detailed
timing descriptor.

Signed-off-by: Ville Syrjälä <cd6e8d405ca90be3a03d5427c5b24fbd2d68dcc4@linux.intel.com>
Reviewed-by: Daniel Vetter <c1b6782c4af8f0673da8923a0702a1832e5940f4@ffwll.ch>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/drm_edid.c
+++ drivers/gpu/drm/drm_edid.c
@@ -2321,6 +2321,31 @@
 }
 EXPORT_SYMBOL(drm_find_cea_extension);

+/*
+ * Calculate the alternate clock for the CEA mode
+ * (60Hz vs. 59.94Hz etc.)
+ */
+static unsigned int
+cea_mode_alternate_clock(const struct drm_display_mode *cea_mode)
+{
+	unsigned int clock = cea_mode->clock;
+
+	if (cea_mode->vrefresh % 6 != 0)
+		return clock;
+
+	/*
+	 * edid_cea_modes contains the 59.94Hz
+	 * variant for 240 and 480 line modes,
+	 * and the 60Hz variant otherwise.
+	 */
+	if (cea_mode->vdisplay == 240 || cea_mode->vdisplay == 480)
+		clock = clock * 1001 / 1000;
+	else
+		clock = DIV_ROUND_UP(clock * 1000, 1001);
+
+	return clock;
+}
+
 /**
  * drm_match_cea_mode - look for a CEA mode matching given mode
  * @to_match: display mode
@@ -2339,21 +2364,9 @@
 		const struct drm_display_mode *cea_mode = &edid_cea_modes[mode];
 		unsigned int clock1, clock2;

-		clock1 = clock2 = cea_mode->clock;
-
 		/* Check both 60Hz and 59.94Hz */
-		if (cea_mode->vrefresh % 6 == 0) {
-			/*
-			 * edid_cea_modes contains the 59.94Hz
-			 * variant for 240 and 480 line modes,
-			 * and the 60Hz variant otherwise.
-			 */
-			if (cea_mode->vdisplay == 240 ||
-			    cea_mode->vdisplay == 480)
-				clock1 = clock1 * 1001 / 1000;
-			else
-				clock2 = DIV_ROUND_UP(clock2 * 1000, 1001);
-		}
+		clock1 = cea_mode->clock;
+		clock2 = cea_mode_alternate_clock(cea_mode);

 		if ((KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock1) ||
 		     KHZ2PICOS(to_match->clock) == KHZ2PICOS(clock2)) &&
@@ -2364,6 +2377,66 @@
 }
 EXPORT_SYMBOL(drm_match_cea_mode);

+static int
+add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_display_mode *mode, *tmp;
+	LIST_HEAD(list);
+	int modes = 0;
+
+	/* Don't add CEA modes if the CEA extension block is missing */
+	if (!drm_find_cea_extension(edid))
+		return 0;
+
+	/*
+	 * Go through all probed modes and create a new mode
+	 * with the alternate clock for certain CEA modes.
+	 */
+	list_for_each_entry(mode, &connector->probed_modes, head) {
+		const struct drm_display_mode *cea_mode;
+		struct drm_display_mode *newmode;
+		u8 cea_mode_idx = drm_match_cea_mode(mode) - 1;
+		unsigned int clock1, clock2;
+
+		if (cea_mode_idx >= ARRAY_SIZE(edid_cea_modes))
+			continue;
+
+		cea_mode = &edid_cea_modes[cea_mode_idx];
+
+		clock1 = cea_mode->clock;
+		clock2 = cea_mode_alternate_clock(cea_mode);
+
+		if (clock1 == clock2)
+			continue;
+
+		if (mode->clock != clock1 && mode->clock != clock2)
+			continue;
+
+		newmode = drm_mode_duplicate(dev, cea_mode);
+		if (!newmode)
+			continue;
+
+		/*
+		 * The current mode could be either variant. Make
+		 * sure to pick the "other" clock for the new mode.
+		 */
+		if (mode->clock != clock1)
+			newmode->clock = clock1;
+		else
+			newmode->clock = clock2;
+
+		list_add_tail(&newmode->head, &list);
+	}
+
+	list_for_each_entry_safe(mode, tmp, &list, head) {
+		list_del(&mode->head);
+		drm_mode_probed_add(connector, mode);
+		modes++;
+	}
+
+	return modes;
+}

 static int
 do_cea_modes (struct drm_connector *connector, u8 *db, u8 len)
@@ -2946,6 +3019,7 @@
 	if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)
 		num_modes += add_inferred_modes(connector, edid);
 	num_modes += add_cea_modes(connector, edid);
+	num_modes += add_alternate_cea_modes(connector, edid);

 	if (quirks & (EDID_QUIRK_PREFER_LARGE_60 | EDID_QUIRK_PREFER_LARGE_75))
 		edid_fixup_preferred(connector, quirks);