From patchwork Tue Oct 24 15:34:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10025011 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 D42E060245 for ; Tue, 24 Oct 2017 15:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D8028520 for ; Tue, 24 Oct 2017 15:35:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9D0428A19; Tue, 24 Oct 2017 15:35:20 +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 1D8C828520 for ; Tue, 24 Oct 2017 15:35:20 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B7A4326738E; Tue, 24 Oct 2017 17:35:11 +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 902B626738E; Tue, 24 Oct 2017 17:35:10 +0200 (CEST) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by alsa0.perex.cz (Postfix) with ESMTP id 91BAF267374 for ; Tue, 24 Oct 2017 17:35:01 +0200 (CEST) Received: by mail-pf0-f195.google.com with SMTP id b6so19944506pfh.7 for ; Tue, 24 Oct 2017 08:35:01 -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=LCbW3BMZY1WgPzLMm1dlIGXMLfJht5SAsayAKkdyQvE=; b=hKm2PeB69vEU29tGXO9zJ6+CrG6zQyt8CLYXS2ZTwnPUbbalLjNZ34StllzmIF5qHQ T1eph2oIh0n76d9O5x0RLhxbgJgx9LYtNfBNWLlBPI8x0o5SGwzSDMKOAGjTlXs8XVGq 19cdGHsNXHPa8YLgEKo8IwotmgR3HElmmA47I= 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=LCbW3BMZY1WgPzLMm1dlIGXMLfJht5SAsayAKkdyQvE=; b=VuS3LA6BZoCO2D+CWylyizH907sE4jbvILkvJhd7v4bHM+zKJXhePEKQ5AwaN8GK3T zzCC+50LK2nMIbYxox4WKtrt6/OVn6wr/+uUkVaIzOPscAGTwXOKA80N8f74Sta08erb NXgM2MWP0q/tI+ZVgQ1/fASzcXYDNExWHHYVq++2Ov7/M+1/GFOi5FI2MgPDyldC/yR2 5q5Lq12sYcjsjOMSThgrn+DIJC6wzWKVzGgaSFizxbBvMHDE5/jXOi6w+xoUcmwIM9tl tal++O8YKH1/k8jK3lSXBOn9w0Ipbee8KKDj0bd7Av2cjojVptB9Qis9vyh4nPa9TLB3 dJ1w== X-Gm-Message-State: AMCzsaUsW02nBbfUJU9Z0nPAol/2U8UnqugzANPCcIig9X90w6l0EOZs P8fMWyzGX9oHsdl9RtHJykuAcFZ4S+E= X-Google-Smtp-Source: ABhQp+QEI1Ul/N/g6sJw8nTEiD2TGUZWGKNMUZw/C/ML24LkwkYRpKAcNZjcz55jbqQqIJORivleyA== X-Received: by 10.99.102.69 with SMTP id a66mr15130511pgc.346.1508859300140; Tue, 24 Oct 2017 08:35:00 -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 s4sm964190pgr.32.2017.10.24.08.34.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 08:34:58 -0700 (PDT) Date: Tue, 24 Oct 2017 08:34:58 -0700 From: Kees Cook To: Takashi Iwai Message-ID: <20171024153458.GA112893@beast> MIME-Version: 1.0 Content-Disposition: inline Cc: alsa-devel@alsa-project.org, Takashi Sakamoto , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ALSA: sb: 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. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Takashi Sakamoto Cc: alsa-devel@alsa-project.org Signed-off-by: Kees Cook --- include/sound/sb.h | 1 + sound/isa/sb/emu8000_pcm.c | 6 +++--- sound/isa/sb/sb8_midi.c | 12 ++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/sound/sb.h b/include/sound/sb.h index bacefaee411a..4aef395189ec 100644 --- a/include/sound/sb.h +++ b/include/sound/sb.h @@ -83,6 +83,7 @@ struct snd_sb { unsigned int playback_format; unsigned int capture_format; struct timer_list midi_timer; + struct snd_rawmidi_substream *timer_substream; unsigned int p_dma_size; unsigned int p_period_size; unsigned int c_dma_size; diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index 8f34551abd8d..bc5af71d3bdb 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -193,9 +193,9 @@ static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch) * timer interrupt handler * check the current position and update the period if necessary. */ -static void emu8k_pcm_timer_func(unsigned long data) +static void emu8k_pcm_timer_func(struct timer_list *t) { - struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data; + struct snd_emu8k_pcm *rec = from_timer(rec, t, timer); int ptr, delta; spin_lock(&rec->timer_lock); @@ -241,7 +241,7 @@ static int emu8k_pcm_open(struct snd_pcm_substream *subs) runtime->private_data = rec; spin_lock_init(&rec->timer_lock); - setup_timer(&rec->timer, emu8k_pcm_timer_func, (unsigned long)rec); + timer_setup(&rec->timer, emu8k_pcm_timer_func, 0); runtime->hw = emu8k_pcm_hw; runtime->hw.buffer_bytes_max = emu->mem_size - LOOP_BLANK_SIZE * 3; diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index bd672abb4854..cf23dc5d0507 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -209,10 +209,10 @@ static void snd_sb8dsp_midi_output_write(struct snd_rawmidi_substream *substream } } -static void snd_sb8dsp_midi_output_timer(unsigned long data) +static void snd_sb8dsp_midi_output_timer(struct timer_list *t) { - struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data; - struct snd_sb * chip = substream->rmidi->private_data; + struct snd_sb *chip = from_timer(chip, t, midi_timer); + struct snd_rawmidi_substream *substream = chip->timer_substream; unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); @@ -230,9 +230,9 @@ static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substre spin_lock_irqsave(&chip->open_lock, flags); if (up) { if (!(chip->open & SB_OPEN_MIDI_OUTPUT_TRIGGER)) { - setup_timer(&chip->midi_timer, - snd_sb8dsp_midi_output_timer, - (unsigned long) substream); + chip->timer_substream = substream; + timer_setup(&chip->midi_timer, + snd_sb8dsp_midi_output_timer, 0); mod_timer(&chip->midi_timer, 1 + jiffies); chip->open |= SB_OPEN_MIDI_OUTPUT_TRIGGER; }