From patchwork Thu Oct 5 00:52: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: 9986227 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 F269A605A8 for ; Thu, 5 Oct 2017 00:58:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E48E428C43 for ; Thu, 5 Oct 2017 00:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D95BA28C45; Thu, 5 Oct 2017 00:58:35 +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 7235428C43 for ; Thu, 5 Oct 2017 00:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925AbdJEAxC (ORCPT ); Wed, 4 Oct 2017 20:53:02 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:53157 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752912AbdJEAxB (ORCPT ); Wed, 4 Oct 2017 20:53:01 -0400 Received: by mail-pg0-f51.google.com with SMTP id i195so7410421pgd.9 for ; Wed, 04 Oct 2017 17:53:00 -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=n02l+DhD5fx/vd32rPE8ltDBeS5DASysXyO/OCX8L3E=; b=HlNwSoS0ba13eArnOH25Xt71TKUaok0dhsoXTu0ThuUu1qqQ1YMSOapvC8Zgd79jBz eF3tFr9jxnHEWE+zdigTKJ5H/iJ2x0c89djJYMWLPpfgYPR+zNd5ajXh/4MAUmIs0ktH VvjNIy5doWgGSXZqIiK7tBEH3zTaj6f8kffpY= 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=n02l+DhD5fx/vd32rPE8ltDBeS5DASysXyO/OCX8L3E=; b=Au7izWwC4hfohBW6t26qle8wKbolMLP/x92o4QKQhDC5zkYGgQyx+SVw71QhrxEN/q ++zYprIlPgRqOtPXnrarZ+yvZusMZftxVX4xxNZJU1M9O6Lj11rha1fsGMEW7QN2SxVD Zbrz6QjPas4he0XhjUXSi+Rov8gkrMrimAljdvYFJq7PENofpKh8IcSC6K9SxBTefmDq vmhL7t1m3XYPpbV5px8rzl8n6qDU7Aih6ZtmZx7NAlrTuPuHakx9MfHlSmoqrKkpS4NB SMGJCHhD4WYb5gWMtrYkYG/2cUIR/D8Lwt0rCCA6ULVwDRB5Ke4o3RR8P+O2iKs2opu/ yXHg== X-Gm-Message-State: AMCzsaX8wCZ7v4iIrQLrI1owZA6qlj4b6vvtU0e71rQbSjNpDbc360il 9F94z70P8szvIvFiCM85GWuK2g== X-Google-Smtp-Source: AOwi7QDrcH/YqWycUeRSrJMbn2+kNwMc+kdZ0Bqmo9btfWMb6WgDJW4yqP4623T5ejEsfkMxiUGrsw== X-Received: by 10.99.114.29 with SMTP id n29mr10541963pgc.237.1507164780651; Wed, 04 Oct 2017 17:53: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 k7sm1082326pgp.52.2017.10.04.17.52.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:52:59 -0700 (PDT) Date: Wed, 4 Oct 2017 17:52:58 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org, Thomas Gleixner Subject: [PATCH] media/saa7146: Convert timers to use timer_setup() Message-ID: <20171005005258.GA23682@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. This requires adding a pointer to hold the timer's target file, as there won't be a way to pass this in the future. Cc: Hans Verkuil Cc: Mauro Carvalho Chehab 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/common/saa7146/saa7146_fops.c | 2 +- drivers/media/common/saa7146/saa7146_vbi.c | 9 +++++---- include/media/drv-intf/saa7146_vv.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/common/saa7146/saa7146_fops.c b/drivers/media/common/saa7146/saa7146_fops.c index 930d2c94d5d3..c4664f0da874 100644 --- a/drivers/media/common/saa7146/saa7146_fops.c +++ b/drivers/media/common/saa7146/saa7146_fops.c @@ -559,7 +559,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) vbi->start[1] = 312; vbi->count[1] = 16; - init_timer(&vv->vbi_read_timeout); + timer_setup(&vv->vbi_read_timeout, NULL, 0); vv->ov_fb.capability = V4L2_FBUF_CAP_LIST_CLIPPING; vv->ov_fb.flags = V4L2_FBUF_FLAG_PRIMARY; diff --git a/drivers/media/common/saa7146/saa7146_vbi.c b/drivers/media/common/saa7146/saa7146_vbi.c index d79e4d7ecd9f..f65c0b934c22 100644 --- a/drivers/media/common/saa7146/saa7146_vbi.c +++ b/drivers/media/common/saa7146/saa7146_vbi.c @@ -348,9 +348,10 @@ static void vbi_stop(struct saa7146_fh *fh, struct file *file) spin_unlock_irqrestore(&dev->slock, flags); } -static void vbi_read_timeout(unsigned long data) +static void vbi_read_timeout(struct timer_list *t) { - struct file *file = (struct file*)data; + struct saa7146_vv *vv = from_timer(vv, t, vbi_read_timeout); + struct file *file = vv->vbi_read_timeout_file; struct saa7146_fh *fh = file->private_data; struct saa7146_dev *dev = fh->dev; @@ -401,8 +402,8 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) sizeof(struct saa7146_buf), file, &dev->v4l2_lock); - vv->vbi_read_timeout.function = vbi_read_timeout; - vv->vbi_read_timeout.data = (unsigned long)file; + vv->vbi_read_timeout.function = (TIMER_FUNC_TYPE)vbi_read_timeout; + vv->vbi_read_timeout_file = file; /* initialize the brs */ if ( 0 != (SAA7146_USE_PORT_B_FOR_VBI & dev->ext_vv_data->flags)) { diff --git a/include/media/drv-intf/saa7146_vv.h b/include/media/drv-intf/saa7146_vv.h index 0da6ccc0615b..fbe36d05fb79 100644 --- a/include/media/drv-intf/saa7146_vv.h +++ b/include/media/drv-intf/saa7146_vv.h @@ -107,6 +107,7 @@ struct saa7146_vv struct saa7146_dmaqueue vbi_dmaq; struct v4l2_vbi_format vbi_fmt; struct timer_list vbi_read_timeout; + struct file *vbi_read_timeout_file; /* vbi workaround interrupt queue */ wait_queue_head_t vbi_wq; int vbi_fieldcount;