From 6aa7de059173a986114ac43b8f50b297a86f09a8 Mon Sep 17 00:00:00 2001 From: Mark Rutland Date: Mon, 23 Oct 2017 14:07:29 -0700 Subject: locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() Please do not apply this to mainline directly, instead please re-run the coccinelle script shown below and apply its output. For several reasons, it is desirable to use {READ,WRITE}_ONCE() in preference to ACCESS_ONCE(), and new code is expected to use one of the former. So far, there's been no reason to change most existing uses of ACCESS_ONCE(), as these aren't harmful, and changing them results in churn. However, for some features, the read/write distinction is critical to correct operation. To distinguish these cases, separate read/write accessors must be used. This patch migrates (most) remaining ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following coccinelle script: ---- // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and // WRITE_ONCE() // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch virtual patch @ depends on patch @ expression E1, E2; @@ - ACCESS_ONCE(E1) = E2 + WRITE_ONCE(E1, E2) @ depends on patch @ expression E; @@ - ACCESS_ONCE(E) + READ_ONCE(E) ---- Signed-off-by: Mark Rutland Signed-off-by: Paul E. McKenney Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: davem@davemloft.net Cc: linux-arch@vger.kernel.org Cc: mpe@ellerman.id.au Cc: shuah@kernel.org Cc: snitzer@redhat.com Cc: thor.thayer@linux.intel.com Cc: tj@kernel.org Cc: viro@zeniv.linux.org.uk Cc: will.deacon@arm.com Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com Signed-off-by: Ingo Molnar --- sound/soc/xtensa/xtfpga-i2s.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index 8382ffa3bcaf..2472144b329e 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -165,7 +165,7 @@ static bool xtfpga_pcm_push_tx(struct xtfpga_i2s *i2s) tx_substream = rcu_dereference(i2s->tx_substream); tx_active = tx_substream && snd_pcm_running(tx_substream); if (tx_active) { - unsigned tx_ptr = ACCESS_ONCE(i2s->tx_ptr); + unsigned tx_ptr = READ_ONCE(i2s->tx_ptr); unsigned new_tx_ptr = i2s->tx_fn(i2s, tx_substream->runtime, tx_ptr); @@ -437,7 +437,7 @@ static int xtfpga_pcm_trigger(struct snd_pcm_substream *substream, int cmd) case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - ACCESS_ONCE(i2s->tx_ptr) = 0; + WRITE_ONCE(i2s->tx_ptr, 0); rcu_assign_pointer(i2s->tx_substream, substream); xtfpga_pcm_refill_fifo(i2s); break; @@ -459,7 +459,7 @@ static snd_pcm_uframes_t xtfpga_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct xtfpga_i2s *i2s = runtime->private_data; - snd_pcm_uframes_t pos = ACCESS_ONCE(i2s->tx_ptr); + snd_pcm_uframes_t pos = READ_ONCE(i2s->tx_ptr); return pos < runtime->buffer_size ? pos : 0; } -- cgit v1.2.3-58-ga151 From 7211ec6392c8650ebc804023178c245464417ed2 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 25 Oct 2017 08:09:27 -0700 Subject: ALSA: Convert timers to use timer_setup() In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. These are all the "mechanical" changes remaining in the sound subsystem. Signed-off-by: Kees Cook Acked-by: Mark Brown Signed-off-by: Takashi Iwai --- sound/i2c/other/ak4117.c | 8 ++++---- sound/pci/ctxfi/cttimer.c | 7 +++---- sound/pci/echoaudio/midi.c | 10 +++++----- sound/pci/korg1212/korg1212.c | 7 +++---- sound/pci/rme9652/hdsp.c | 8 ++++---- sound/pci/rme9652/hdspm.c | 8 ++++---- sound/soc/codecs/rt5645.c | 7 +++---- sound/soc/omap/ams-delta.c | 4 ++-- 8 files changed, 28 insertions(+), 31 deletions(-) (limited to 'sound/soc') diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 3ab099fb8c15..b923342cadf4 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -35,7 +35,7 @@ MODULE_LICENSE("GPL"); #define AK4117_ADDR 0x00 /* fixed address */ -static void snd_ak4117_timer(unsigned long data); +static void snd_ak4117_timer(struct timer_list *t); static void reg_write(struct ak4117 *ak4117, unsigned char reg, unsigned char val) { @@ -91,7 +91,7 @@ int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t chip->read = read; chip->write = write; chip->private_data = private_data; - setup_timer(&chip->timer, snd_ak4117_timer, (unsigned long)chip); + timer_setup(&chip->timer, snd_ak4117_timer, 0); for (reg = 0; reg < 5; reg++) chip->regmap[reg] = pgm[reg]; @@ -529,9 +529,9 @@ int snd_ak4117_check_rate_and_errors(struct ak4117 *ak4117, unsigned int flags) return res; } -static void snd_ak4117_timer(unsigned long data) +static void snd_ak4117_timer(struct timer_list *t) { - struct ak4117 *chip = (struct ak4117 *)data; + struct ak4117 *chip = from_timer(chip, t, timer); if (chip->init) return; diff --git a/sound/pci/ctxfi/cttimer.c b/sound/pci/ctxfi/cttimer.c index 8f945341720b..08e874e9a7f6 100644 --- a/sound/pci/ctxfi/cttimer.c +++ b/sound/pci/ctxfi/cttimer.c @@ -63,9 +63,9 @@ struct ct_timer { * system-timer-based updates */ -static void ct_systimer_callback(unsigned long data) +static void ct_systimer_callback(struct timer_list *t) { - struct ct_timer_instance *ti = (struct ct_timer_instance *)data; + struct ct_timer_instance *ti = from_timer(ti, t, timer); struct snd_pcm_substream *substream = ti->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct ct_atc_pcm *apcm = ti->apcm; @@ -93,8 +93,7 @@ static void ct_systimer_callback(unsigned long data) static void ct_systimer_init(struct ct_timer_instance *ti) { - setup_timer(&ti->timer, ct_systimer_callback, - (unsigned long)ti); + timer_setup(&ti->timer, ct_systimer_callback, 0); } static void ct_systimer_start(struct ct_timer_instance *ti) diff --git a/sound/pci/echoaudio/midi.c b/sound/pci/echoaudio/midi.c index 8c685ddb1a41..6045a115cffe 100644 --- a/sound/pci/echoaudio/midi.c +++ b/sound/pci/echoaudio/midi.c @@ -199,9 +199,9 @@ static int snd_echo_midi_output_open(struct snd_rawmidi_substream *substream) -static void snd_echo_midi_output_write(unsigned long data) +static void snd_echo_midi_output_write(struct timer_list *t) { - struct echoaudio *chip = (struct echoaudio *)data; + struct echoaudio *chip = from_timer(chip, t, timer); unsigned long flags; int bytes, sent, time; unsigned char buf[MIDI_OUT_BUFFER_SIZE - 1]; @@ -257,8 +257,8 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream spin_lock_irq(&chip->lock); if (up) { if (!chip->tinuse) { - setup_timer(&chip->timer, snd_echo_midi_output_write, - (unsigned long)chip); + timer_setup(&chip->timer, snd_echo_midi_output_write, + 0); chip->tinuse = 1; } } else { @@ -273,7 +273,7 @@ static void snd_echo_midi_output_trigger(struct snd_rawmidi_substream *substream spin_unlock_irq(&chip->lock); if (up && !chip->midi_full) - snd_echo_midi_output_write((unsigned long)chip); + snd_echo_midi_output_write(&chip->timer); } diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index 04cd71c74e5c..c7b007164c99 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -599,9 +599,9 @@ static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212) } /* timer callback for checking the ack of stop request */ -static void snd_korg1212_timer_func(unsigned long data) +static void snd_korg1212_timer_func(struct timer_list *t) { - struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data; + struct snd_korg1212 *korg1212 = from_timer(korg1212, t, timer); unsigned long flags; spin_lock_irqsave(&korg1212->lock, flags); @@ -2189,8 +2189,7 @@ static int snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, init_waitqueue_head(&korg1212->wait); spin_lock_init(&korg1212->lock); mutex_init(&korg1212->open_mutex); - setup_timer(&korg1212->timer, snd_korg1212_timer_func, - (unsigned long)korg1212); + timer_setup(&korg1212->timer, snd_korg1212_timer_func, 0); korg1212->irq = -1; korg1212->clkSource = K1212_CLKIDX_Local; diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 9f0f73875f01..1bff4b1b39cd 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -1410,9 +1410,9 @@ static void snd_hdsp_midi_input_trigger(struct snd_rawmidi_substream *substream, spin_unlock_irqrestore (&hdsp->lock, flags); } -static void snd_hdsp_midi_output_timer(unsigned long data) +static void snd_hdsp_midi_output_timer(struct timer_list *t) { - struct hdsp_midi *hmidi = (struct hdsp_midi *) data; + struct hdsp_midi *hmidi = from_timer(hmidi, t, timer); unsigned long flags; snd_hdsp_midi_output_write(hmidi); @@ -1439,8 +1439,8 @@ static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { - setup_timer(&hmidi->timer, snd_hdsp_midi_output_timer, - (unsigned long) hmidi); + timer_setup(&hmidi->timer, snd_hdsp_midi_output_timer, + 0); mod_timer(&hmidi->timer, 1 + jiffies); hmidi->istimer++; } diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index f20d42714e4d..4c59983158e0 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -1946,9 +1946,9 @@ snd_hdspm_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) spin_unlock_irqrestore (&hdspm->lock, flags); } -static void snd_hdspm_midi_output_timer(unsigned long data) +static void snd_hdspm_midi_output_timer(struct timer_list *t) { - struct hdspm_midi *hmidi = (struct hdspm_midi *) data; + struct hdspm_midi *hmidi = from_timer(hmidi, t, timer); unsigned long flags; snd_hdspm_midi_output_write(hmidi); @@ -1976,8 +1976,8 @@ snd_hdspm_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { - setup_timer(&hmidi->timer, snd_hdspm_midi_output_timer, - (unsigned long) hmidi); + timer_setup(&hmidi->timer, + snd_hdspm_midi_output_timer, 0); mod_timer(&hmidi->timer, 1 + jiffies); hmidi->istimer++; } diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index a98647ac497c..735f2d0033dd 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3340,9 +3340,9 @@ static irqreturn_t rt5645_irq(int irq, void *data) return IRQ_HANDLED; } -static void rt5645_btn_check_callback(unsigned long data) +static void rt5645_btn_check_callback(struct timer_list *t) { - struct rt5645_priv *rt5645 = (struct rt5645_priv *)data; + struct rt5645_priv *rt5645 = from_timer(rt5645, t, btn_check_timer); queue_delayed_work(system_power_efficient_wq, &rt5645->jack_detect_work, msecs_to_jiffies(5)); @@ -3934,8 +3934,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5645->regmap, RT5645_IRQ_CTRL2, RT5645_JD_1_1_MASK, RT5645_JD_1_1_INV); } - setup_timer(&rt5645->btn_check_timer, - rt5645_btn_check_callback, (unsigned long)rt5645); + timer_setup(&rt5645->btn_check_timer, rt5645_btn_check_callback, 0); INIT_DELAYED_WORK(&rt5645->jack_detect_work, rt5645_jack_detect_work); INIT_DELAYED_WORK(&rt5645->rcclock_work, rt5645_rcclock_work); diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 6c49f3d6fd96..d40219678700 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -260,7 +260,7 @@ static bool cx81801_cmd_pending; static bool ams_delta_muted; static DEFINE_SPINLOCK(ams_delta_lock); -static void cx81801_timeout(unsigned long data) +static void cx81801_timeout(struct timer_list *unused) { int muted; @@ -349,7 +349,7 @@ static void cx81801_receive(struct tty_struct *tty, /* First modem response, complete setup procedure */ /* Initialize timer used for config pulse generation */ - setup_timer(&cx81801_timer, cx81801_timeout, 0); + timer_setup(&cx81801_timer, cx81801_timeout, 0); v253_ops.receive_buf(tty, cp, fp, count); -- cgit v1.2.3-58-ga151 From 20a52c059be2eb470db75076d55e1d932173fcc3 Mon Sep 17 00:00:00 2001 From: Vinod Koul Date: Wed, 15 Nov 2017 10:11:02 +0530 Subject: ASoC: Intel: Add help text for SND_SOC_INTEL_SST_TOPLEVEL Symbol SND_SOC_INTEL_SST_TOPLEVEL is user selectable so add the help text for this symbol. Signed-off-by: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/Kconfig | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index bb8be10b8437..7b49d04e3c60 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig @@ -34,6 +34,11 @@ config SND_SOC_INTEL_SST_TOPLEVEL depends on X86 || COMPILE_TEST select SND_SOC_INTEL_MACH select SND_SOC_INTEL_COMMON + help + Intel ASoC Audio Drivers. If you have a Intel machine that + has audio controller with a DSP and I2S or DMIC port, then + enable this option by saying Y or M + If unsure select "N". config SND_SOC_INTEL_HASWELL tristate "Intel ASoC SST driver for Haswell/Broadwell" -- cgit v1.2.3-58-ga151 From 3bd333677d6091d989068b0f7ff7aba975e62dc5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 9 Nov 2017 01:04:37 +0000 Subject: ASoC: don't use codec hw_write on twl6040 twl6040 driver is using codec hw_write/control_data, but it is redundant code. This patch cleanup these Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 1773ff84ee3b..a8e6941a1868 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -106,10 +106,12 @@ static const struct snd_pcm_hw_constraint_list sysclk_constraints[] = { { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, }, }; +#define to_twl6040(codec) dev_get_drvdata((codec)->dev->parent) + static unsigned int twl6040_read(struct snd_soc_codec *codec, unsigned int reg) { struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); u8 value; if (reg >= TWL6040_CACHEREGNUM) @@ -171,7 +173,7 @@ static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec, static int twl6040_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) { - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); if (reg >= TWL6040_CACHEREGNUM) return -EIO; @@ -572,7 +574,7 @@ EXPORT_SYMBOL_GPL(twl6040_get_trim_value); int twl6040_get_hs_step_size(struct snd_soc_codec *codec) { - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); if (twl6040_get_revid(twl6040) < TWL6040_REV_ES1_3) /* For ES under ES_1.3 HS step is 2 mV */ @@ -830,7 +832,7 @@ static const struct snd_soc_dapm_route intercon[] = { static int twl6040_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); int ret = 0; @@ -922,7 +924,7 @@ static int twl6040_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_codec *codec = dai->codec; - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); int ret; @@ -964,7 +966,7 @@ static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai, static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id id, int mute) { - struct twl6040 *twl6040 = codec->control_data; + struct twl6040 *twl6040 = to_twl6040(codec); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); int hslctl, hsrctl, earctl; int hflctl, hfrctl; @@ -1108,7 +1110,6 @@ static struct snd_soc_dai_driver twl6040_dai[] = { static int twl6040_probe(struct snd_soc_codec *codec) { struct twl6040_data *priv; - struct twl6040 *twl6040 = dev_get_drvdata(codec->dev->parent); struct platform_device *pdev = to_platform_device(codec->dev); int ret = 0; @@ -1119,7 +1120,6 @@ static int twl6040_probe(struct snd_soc_codec *codec) snd_soc_codec_set_drvdata(codec, priv); priv->codec = codec; - codec->control_data = twl6040; priv->plug_irq = platform_get_irq(pdev, 0); if (priv->plug_irq < 0) { -- cgit v1.2.3-58-ga151 From 93a00c467fe998bf5716cbc9cabc127046054782 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 14 Nov 2017 01:04:58 +0000 Subject: ASoC: don't use snd_soc_write/read on twl6040 twl6040 doesn't use regmap nor reg_cache. Its write/read are done through twl6040_reg_write/read. This driver directly calling these functions, but sometimes using snd_soc_write/read. As part of cleanup, snd_soc_codec_driver::write, read will be removed soon. Then, write/read access through snd_soc_write/read will doesn't work on this driver, since it doesn't use regmap nor reg_cache. This patch replace snd_soc_write/read to twl6040_write/read. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index a8e6941a1868..3b895b4b451c 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -543,7 +543,7 @@ int twl6040_get_dl1_gain(struct snd_soc_codec *codec) if (snd_soc_dapm_get_pin_status(dapm, "HSOR") || snd_soc_dapm_get_pin_status(dapm, "HSOL")) { - u8 val = snd_soc_read(codec, TWL6040_REG_HSLCTL); + u8 val = twl6040_read(codec, TWL6040_REG_HSLCTL); if (val & TWL6040_HSDACMODE) /* HSDACL in LP mode */ return -8; /* -8dB */ @@ -1158,8 +1158,6 @@ static int twl6040_remove(struct snd_soc_codec *codec) static const struct snd_soc_codec_driver soc_codec_dev_twl6040 = { .probe = twl6040_probe, .remove = twl6040_remove, - .read = twl6040_read, - .write = twl6040_write, .set_bias_level = twl6040_set_bias_level, .suspend_bias_off = true, .ignore_pmdown_time = true, -- cgit v1.2.3-58-ga151