From patchwork Thu Oct 5 00:53:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986225 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 BE0E4605A8 for ; Thu, 5 Oct 2017 00:58:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF97E28C43 for ; Thu, 5 Oct 2017 00:58:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A371E28C45; Thu, 5 Oct 2017 00:58:27 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F100828C43 for ; Thu, 5 Oct 2017 00:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751433AbdJEA6Z (ORCPT ); Wed, 4 Oct 2017 20:58:25 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:45539 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbdJEAxF (ORCPT ); Wed, 4 Oct 2017 20:53:05 -0400 Received: by mail-pg0-f45.google.com with SMTP id b192so4336486pga.2 for ; Wed, 04 Oct 2017 17:53:04 -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=4XRBx789MD+70NUpkVTp8SX+8q/pEliseX7ZbBZKRDI=; b=ld5RenrFnz83m0zp3NEHnNwofUNtWz0Fq5xuvHJz+5LTfuMRpEaSz7l+8ygDtnNaax bKe2rz8yjs2H6+ofaAxbebXerGdEjmxwhJgJtpTASVZp6EZxta7KWVXnWA4yTuc0VaUx /rW1J7ssfNKe4aT0kCRU/CbGmILdo44OA3hkE= 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=4XRBx789MD+70NUpkVTp8SX+8q/pEliseX7ZbBZKRDI=; b=hiSvAxHJp3SCfb7olddxq1qrZLroo/XqnYb4fr2LD6+n6C1lDX9lF6nBgolKtLIhYa ZNVHubzGA34tc7IYbK9vDJeBgv7M3thLB6qsgQCRqw2bOVXTpFjmgyYf/QOA1E+TNMlC EFlydvAEO0M8usy/mkgwADWAPTyCDlMm2nPu8NSNxIzAgm3oFQLoLWE/9AOyMpfNuYRn D0r/k2F7iatMbFpHVsVuRbC0N6apGotetK+zd/ZNH24ksbzddyy+PBetwWxebO+yTZTL J2iVyTXdh/79X/vbXi02tbjp/fPgzgQyiMWhzjVxMu7QcRCrZoO6wx85ocOgF1tgqjjt 8y6A== X-Gm-Message-State: AHPjjUhQQrHCoYG1eBTAV4UmbIqMUqYtX8GX+bRPFlya4yq9HNZt5SJs AP0ujCkUbRYHk67jD06LMnpJqQ== X-Google-Smtp-Source: AOwi7QDutMD6LWK6CIz7XcYL729zdIRLen6d/XBrxG4mCzXN56EhXGfJv0pz74rUt2qFP3AdQch7yw== X-Received: by 10.99.121.77 with SMTP id u74mr19918738pgc.81.1507164784643; Wed, 04 Oct 2017 17:53:04 -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 m69sm5592345pfk.54.2017.10.04.17.53.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:53:03 -0700 (PDT) Date: Wed, 4 Oct 2017 17:53:02 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Mauro Carvalho Chehab , Sakari Ailus , Sean Young , Geliang Tang , Hans Verkuil , linux-media@vger.kernel.org, Thomas Gleixner Subject: [PATCH] media: saa7134: Convert timers to use timer_setup() Message-ID: <20171005005302.GA23696@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.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: Mauro Carvalho Chehab Cc: Sakari Ailus Cc: Sean Young Cc: Geliang Tang Cc: Hans Verkuil Cc: linux-media@vger.kernel.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. --- drivers/media/pci/saa7134/saa7134-core.c | 6 +++--- drivers/media/pci/saa7134/saa7134-input.c | 9 ++++----- drivers/media/pci/saa7134/saa7134-ts.c | 3 +-- drivers/media/pci/saa7134/saa7134-vbi.c | 3 +-- drivers/media/pci/saa7134/saa7134-video.c | 3 +-- drivers/media/pci/saa7134/saa7134.h | 2 +- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index 7976c5a12ca8..9e76de2411ae 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -338,9 +338,9 @@ void saa7134_buffer_next(struct saa7134_dev *dev, } } -void saa7134_buffer_timeout(unsigned long data) +void saa7134_buffer_timeout(struct timer_list *t) { - struct saa7134_dmaqueue *q = (struct saa7134_dmaqueue *)data; + struct saa7134_dmaqueue *q = from_timer(q, t, timeout); struct saa7134_dev *dev = q->dev; unsigned long flags; @@ -378,7 +378,7 @@ void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q) } } spin_unlock_irqrestore(&dev->slock, flags); - saa7134_buffer_timeout((unsigned long)q); /* also calls del_timer(&q->timeout) */ + saa7134_buffer_timeout(&q->timeout); /* also calls del_timer(&q->timeout) */ } EXPORT_SYMBOL_GPL(saa7134_stop_streaming); diff --git a/drivers/media/pci/saa7134/saa7134-input.c b/drivers/media/pci/saa7134/saa7134-input.c index 9337e4615519..2d5abeddc079 100644 --- a/drivers/media/pci/saa7134/saa7134-input.c +++ b/drivers/media/pci/saa7134/saa7134-input.c @@ -447,10 +447,10 @@ void saa7134_input_irq(struct saa7134_dev *dev) } } -static void saa7134_input_timer(unsigned long data) +static void saa7134_input_timer(struct timer_list *t) { - struct saa7134_dev *dev = (struct saa7134_dev *)data; - struct saa7134_card_ir *ir = dev->remote; + struct saa7134_card_ir *ir = from_timer(ir, t, timer); + struct saa7134_dev *dev = ir->dev->priv; build_key(dev); mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); @@ -507,8 +507,7 @@ static int __saa7134_ir_start(void *priv) ir->running = true; if (ir->polling) { - setup_timer(&ir->timer, saa7134_input_timer, - (unsigned long)dev); + timer_setup(&ir->timer, saa7134_input_timer, 0); ir->timer.expires = jiffies + HZ; add_timer(&ir->timer); } diff --git a/drivers/media/pci/saa7134/saa7134-ts.c b/drivers/media/pci/saa7134/saa7134-ts.c index 7414878af9e0..2be703617e29 100644 --- a/drivers/media/pci/saa7134/saa7134-ts.c +++ b/drivers/media/pci/saa7134/saa7134-ts.c @@ -223,8 +223,7 @@ int saa7134_ts_init1(struct saa7134_dev *dev) dev->ts.nr_packets = ts_nr_packets; INIT_LIST_HEAD(&dev->ts_q.queue); - setup_timer(&dev->ts_q.timeout, saa7134_buffer_timeout, - (unsigned long)(&dev->ts_q)); + timer_setup(&dev->ts_q.timeout, saa7134_buffer_timeout, 0); dev->ts_q.dev = dev; dev->ts_q.need_two = 1; dev->ts_started = 0; diff --git a/drivers/media/pci/saa7134/saa7134-vbi.c b/drivers/media/pci/saa7134/saa7134-vbi.c index bcad9b2d9bb3..af494c6147f1 100644 --- a/drivers/media/pci/saa7134/saa7134-vbi.c +++ b/drivers/media/pci/saa7134/saa7134-vbi.c @@ -181,8 +181,7 @@ struct vb2_ops saa7134_vbi_qops = { int saa7134_vbi_init1(struct saa7134_dev *dev) { INIT_LIST_HEAD(&dev->vbi_q.queue); - setup_timer(&dev->vbi_q.timeout, saa7134_buffer_timeout, - (unsigned long)(&dev->vbi_q)); + timer_setup(&dev->vbi_q.timeout, saa7134_buffer_timeout, 0); dev->vbi_q.dev = dev; if (vbibufs < 2) diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index 51d42bbf969e..82d2a24644e4 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2145,8 +2145,7 @@ int saa7134_video_init1(struct saa7134_dev *dev) dev->automute = 0; INIT_LIST_HEAD(&dev->video_q.queue); - setup_timer(&dev->video_q.timeout, saa7134_buffer_timeout, - (unsigned long)(&dev->video_q)); + timer_setup(&dev->video_q.timeout, saa7134_buffer_timeout, 0); dev->video_q.dev = dev; dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); dev->width = 720; diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 816b5282d671..70131b93da3d 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -773,7 +773,7 @@ int saa7134_buffer_queue(struct saa7134_dev *dev, struct saa7134_dmaqueue *q, void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q, unsigned int state); void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q); -void saa7134_buffer_timeout(unsigned long data); +void saa7134_buffer_timeout(struct timer_list *t); void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q); int saa7134_set_dmabits(struct saa7134_dev *dev);