From patchwork Wed Oct 25 15:09:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10026835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BAC9601E8 for ; Wed, 25 Oct 2017 15:09:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DAD427F8C for ; Wed, 25 Oct 2017 15:09:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 211462841C; Wed, 25 Oct 2017 15:09:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FB1327F8C for ; Wed, 25 Oct 2017 15:09:41 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 26E68267094; Wed, 25 Oct 2017 17:09:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 18E09267096; Wed, 25 Oct 2017 17:09:38 +0200 (CEST) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by alsa0.perex.cz (Postfix) with ESMTP id 71F3A266A51 for ; Wed, 25 Oct 2017 17:09:33 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id b79so192762pfk.5 for ; Wed, 25 Oct 2017 08:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=SUuruXfmQLsaGbzte+MOEBAStYYENjbPKUlRWSMhXTs=; b=L6kVVJGy6NDSyDoQkT1zNkBr+/TwxI8YanEOkGFzYtKDmNrBfcAa0QY4+Ves5+uTMg prMflGxF+UkWfbfOppxA9J5G6Zeu38NP1AKg1sjB94B+t4f+5sR3QAr0mMZApeniRROj 3rxFUaHr1sP/sT4yIK+mBKWsxkgDZzmxAhlcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=SUuruXfmQLsaGbzte+MOEBAStYYENjbPKUlRWSMhXTs=; b=GTIFoihZ9BS2HpmQVxIf6h3eLg4YZxuZd4zbsuA1wTQMm4tar3Qe7K2ke48YjYlTf2 7rvUpbUkiWR2AO2IB3gng8JixK28YU8KF/dZlOWwUZKmAREVe0tk70o+tW2DEHh+pz/U 8kXmZnNZvvy6krlArg5mBwdyXaF2bJleokvDtydd/tLqJ9xnrLGYKJXJW+mJTJuGRoQR rrTj7NQChbvaHoEjnUxkj8WkJUkBWLsSIg7DhEllWV7m6iYkUwj1EmTAVHR2e7gnQoPz Ahm+JgGzZZuvbnyG+vU8kUQXUxkxmuKKiSWGcFqQDRNPxEof7lKZ0DP0iXb8jgOxIRwL CRlw== X-Gm-Message-State: AMCzsaXmUFWbAF5VmqLd3fFYxV7uBsL6ShVor3axO8qozsUPp9ib+uO4 +UsWMYH3guPKn2qMhvKK0tyJOYY0+40= X-Google-Smtp-Source: ABhQp+TSCRqDzdoogGT05pWk71xt1jt2o4dVFz8K7N1ZUYzTJQl7mmRdAzwmE7mAt0yBaFGliOTBsA== X-Received: by 10.99.170.1 with SMTP id e1mr2338666pgf.12.1508944169878; Wed, 25 Oct 2017 08:09:29 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id 76sm6004445pfq.4.2017.10.25.08.09.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 08:09:28 -0700 (PDT) Date: Wed, 25 Oct 2017 08:09:27 -0700 From: Kees Cook To: Takashi Iwai Message-ID: <20171025150927.GA12207@beast> MIME-Version: 1.0 Content-Disposition: inline Cc: Oder Chiou , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Liam Girdwood , Peter Ujfalusi , Mark Brown , Bard Liao , Takashi Sakamoto , Jarkko Nikula Subject: [alsa-devel] [PATCH] sound: Convert timers to use timer_setup() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Bard Liao Cc: Oder Chiou Cc: Liam Girdwood Cc: Mark Brown Cc: Peter Ujfalusi Cc: Jarkko Nikula Cc: Takashi Sakamoto Cc: alsa-devel@alsa-project.org Signed-off-by: Kees Cook Acked-by: Mark Brown --- 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(-) 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);