From patchwork Mon Oct 16 23:10:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010069 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 0EC6260230 for ; Mon, 16 Oct 2017 23:10:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00EF22857E for ; Mon, 16 Oct 2017 23:10:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FBA28689; Mon, 16 Oct 2017 23:10:30 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 ED2F62857E for ; Mon, 16 Oct 2017 23:10:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932308AbdJPXKQ (ORCPT ); Mon, 16 Oct 2017 19:10:16 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:50129 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752200AbdJPXKO (ORCPT ); Mon, 16 Oct 2017 19:10:14 -0400 Received: by mail-pg0-f54.google.com with SMTP id g6so6597143pgn.6 for ; Mon, 16 Oct 2017 16:10:14 -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=EziMTg0nkpWlt1IjIILlVf4zcqh8u3dHJt0KQzPPKHE=; b=Fbt8FYFfUqJM+6aq4zMwkK+PwbYI+rbBhMCd9n4dTmJoH54iG3P+IY72qNNFdZwC8G hSL1VNNf7y1bt47ev16ikg92Qb5Pkppg4rf4TgsuTBG7CdhBi21oPNmO0TKLSMoSNvU4 nRgynPAe5RyINxI9R1SEqy3FtZ2SNTZNpmIuI= 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=EziMTg0nkpWlt1IjIILlVf4zcqh8u3dHJt0KQzPPKHE=; b=EicavERGNSA/lBtrNhSq6qOceY4DNzcXkk6xVZ3+5lFCH3s2W/xgrHiAcioFpiqiMh 4JB0x9dYxna+2JuZPLRSJkic8wfbQ/z0aygIH1slUMlFIat93WYyfohRHuC29GgIPMuQ 9QgvKu3waVxS09Tn6RVIWvMMPUxL68+hBgg9dIIQh0DeCscEucooEm2hPSJRgw/moBZ2 yaA5JfPGLb02IwpuV8zoeSxlehU4lQ8GSl+1ufTuQkhU0wVC2ajM6gou0KIpjwndsxO2 SVOqNfZLBkod+ZQSwhRto09RqffI2yQ8GZmmhVkAeM5qSplq6hRH8h1w/SymJcyes0/6 ygMg== X-Gm-Message-State: AMCzsaUr0Qyq9bUzXyBs/I51sR4Cf8E4y4CQUBrf+ZLwGhjIOOCqCyhS gVLsj8FAJMb4N6M4LIfMW8ECfQ== X-Google-Smtp-Source: AOwi7QCCY0g1DqxUZoIa32YmiY66I17Tz1ksk6ojVJdx7UVe0nHiTu36D9nBRUKa2/B1HR1qbsbkBQ== X-Received: by 10.159.216.140 with SMTP id s12mr10479145plp.318.1508195414463; Mon, 16 Oct 2017 16:10:14 -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 k76sm17361162pfb.37.2017.10.16.16.10.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:10:13 -0700 (PDT) Date: Mon, 16 Oct 2017 16:10:12 -0700 From: Kees Cook To: Mauro Carvalho Chehab Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media/saa7146: Convert timers to use timer_setup() Message-ID: <20171016231012.GA99671@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 Signed-off-by: Kees Cook --- 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 69525ca4f52c..ae66c2325228 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 736f4f2d8290..926c5b145279 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;