From patchwork Thu Oct 5 00:53:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986205 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 2328F60291 for ; Thu, 5 Oct 2017 00:56:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 135F428C43 for ; Thu, 5 Oct 2017 00:56:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0872628C45; Thu, 5 Oct 2017 00:56:11 +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 2F32928C43 for ; Thu, 5 Oct 2017 00:56:10 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 55F87267456; Thu, 5 Oct 2017 02:54:28 +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 AD1D5267426; Thu, 5 Oct 2017 02:53:50 +0200 (CEST) Received: from mail-pg0-f53.google.com (mail-pg0-f53.google.com [74.125.83.53]) by alsa0.perex.cz (Postfix) with ESMTP id 5F26F267426 for ; Thu, 5 Oct 2017 02:53:40 +0200 (CEST) Received: by mail-pg0-f53.google.com with SMTP id b1so5916997pge.1 for ; Wed, 04 Oct 2017 17:53:40 -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=coTJofdNIOGJbyM2PHzlGsMXR6GiH/CbaDVc6Teo94A=; b=QT2sOVSWE4CjTw1itaTuSYpQ4pmK4Umj7JG23LD10ihv51up3nVDBagdoqbXLQDE74 NAcKJ5tdP2U7EIsjYv8K9iXwMQO2eUFNlkql6MjqDc5kMXiy7KsGtyGSgZzj/e1PgIZB 95Bw2Ejl6LtUH++PA6r9vETz64fdgwvumfNI0= 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=coTJofdNIOGJbyM2PHzlGsMXR6GiH/CbaDVc6Teo94A=; b=m9tdZXlAl8g3MP+zONjm4SvexAkEH6d/v8uc/DXvhSLvHpdfXuSnw28tnbbH+dfO0R xkukwUIF+mhkjtuxuas/tzTV2iEZaJLBdfIHjaocmI6ODP3R4/eBvHrk4/QWN4Rk3o/B ZUqqsbc8dtQ0DQe4ecxEVQL8ZtP7DDu/4qoHsuJOeiOYTNNMWIY2qG5PSwlK54+Y+oqe 52QcPnxmCG5C19QoSwjwcnxg5rQLgRNBWUgC1rFeUCQs69q4SFf3sNup+ghbGzRPk41z cX0PFUlTydH8mEnsrWi/BNNjmkV0WlZy8k1tSDPPLySm3BlEG/5wE2WVKyH2ooIpWXYk Wt0w== X-Gm-Message-State: AMCzsaXQRceLACWKPJngp1HpKGBna61K3dHqKF0enWMo/Xk/RywXAGXc ZYDwjkV7MNfcED58mflMCy7BLBUeypA= X-Google-Smtp-Source: AOwi7QC0lvQ9nLP2ep0CbBZWdaRXm9P3X/za8ycKHdvBxhMYW2ZDWy2liH4nQHd5349FdFTI7ZP0lg== X-Received: by 10.98.25.202 with SMTP id 193mr3529100pfz.204.1507164818872; Wed, 04 Oct 2017 17:53:38 -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 y16sm25487597pfl.99.2017.10.04.17.53.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:53:37 -0700 (PDT) Date: Wed, 4 Oct 2017 17:53:36 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Message-ID: <20171005005336.GA23796@beast> MIME-Version: 1.0 Content-Disposition: inline Cc: alsa-devel@alsa-project.org, Takashi Iwai , Mark Brown , Thomas Gleixner , Bhumika Goyal Subject: [alsa-devel] [PATCH] ALSA: sh: aica: 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. This requires adding a pointer to hold the timer's target substream, as there won't be a way to pass this in the future. Cc: Jaroslav Kysela Cc: Takashi Iwai Cc: Bhumika Goyal Cc: Mark Brown Cc: alsa-devel@alsa-project.org Cc: Thomas Gleixner Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- sound/sh/aica.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sound/sh/aica.c b/sound/sh/aica.c index fdc680ae8aa0..2b26311405a4 100644 --- a/sound/sh/aica.c +++ b/sound/sh/aica.c @@ -299,14 +299,14 @@ static void run_spu_dma(struct work_struct *work) } } -static void aica_period_elapsed(unsigned long timer_var) +static void aica_period_elapsed(struct timer_list *t) { + struct snd_card_aica *dreamcastcard = from_timer(dreamcastcard, + t, timer); + struct snd_pcm_substream *substream = dreamcastcard->timer_substream; /*timer function - so cannot sleep */ int play_period; struct snd_pcm_runtime *runtime; - struct snd_pcm_substream *substream; - struct snd_card_aica *dreamcastcard; - substream = (struct snd_pcm_substream *) timer_var; runtime = substream->runtime; dreamcastcard = substream->pcm->private_data; /* Have we played out an additional period? */ @@ -336,12 +336,12 @@ static void spu_begin_dma(struct snd_pcm_substream *substream) /*get the queue to do the work */ schedule_work(&(dreamcastcard->spu_dma_work)); /* Timer may already be running */ - if (unlikely(dreamcastcard->timer.data)) { + if (unlikely(dreamcastcard->timer_substream)) { mod_timer(&dreamcastcard->timer, jiffies + 4); return; } - setup_timer(&dreamcastcard->timer, aica_period_elapsed, - (unsigned long) substream); + timer_setup(&dreamcastcard->timer, aica_period_elapsed, 0); + dreamcastcard->timer_substream = substream; mod_timer(&dreamcastcard->timer, jiffies + 4); } @@ -379,7 +379,7 @@ static int snd_aicapcm_pcm_close(struct snd_pcm_substream { struct snd_card_aica *dreamcastcard = substream->pcm->private_data; flush_work(&(dreamcastcard->spu_dma_work)); - if (dreamcastcard->timer.data) + if (dreamcastcard->timer_substream) del_timer(&dreamcastcard->timer); kfree(dreamcastcard->channel); spu_disable(); @@ -600,7 +600,7 @@ static int snd_aica_probe(struct platform_device *devptr) { int err; struct snd_card_aica *dreamcastcard; - dreamcastcard = kmalloc(sizeof(struct snd_card_aica), GFP_KERNEL); + dreamcastcard = kzalloc(sizeof(struct snd_card_aica), GFP_KERNEL); if (unlikely(!dreamcastcard)) return -ENOMEM; err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER, @@ -619,8 +619,6 @@ static int snd_aica_probe(struct platform_device *devptr) err = snd_aicapcmchip(dreamcastcard, 0); if (unlikely(err < 0)) goto freedreamcast; - dreamcastcard->timer.data = 0; - dreamcastcard->channel = NULL; /* Add basic controls */ err = add_aicamixer_controls(dreamcastcard); if (unlikely(err < 0))