From patchwork Mon Oct 16 23:27:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010155 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 4597360235 for ; Mon, 16 Oct 2017 23:28:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 361D0286C5 for ; Mon, 16 Oct 2017 23:28:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AD7D286EF; Mon, 16 Oct 2017 23:28:02 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C55EB286C5 for ; Mon, 16 Oct 2017 23:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=l1AMMCyYTB9yO38zdLqEr3va8tPuRQl8/btUmjbx4ps=; b=I+EUhzVWDg7p5l zDVp6LjsDQOr8Hce48h4fgA8CXyWnCHwsEHka+Cv/rGiJ/5+Tl2qtoVBD4W3cyC9YEnRZ1ySj9py5 6IQm04cAOJLU6gaBCoj0+a6oENS62ZYKaLDYOUXVme5nY6hbc0AXLYTRMB4m0GXGw6Kw0o9o4Z30n DOwInLuNsn2zsVW7ySV7M4QPRPfidZEi+AdID2cmHbfgi6zWfsU5AnXlh1J2RUF+k1Bo6QWdJ4Bjv zalUMwqeNxQmfp5GVj+rjdC0+nGe6J+EJOUyJvjAmvZz4bYtlNCHBRter0jh66AperDUNZr/lNpP6 cY3MNXnqBpO38E7MB3XA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Enc-00073O-VB; Mon, 16 Oct 2017 23:27:56 +0000 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4EnZ-00071q-4P for linux-arm-kernel@lists.infradead.org; Mon, 16 Oct 2017 23:27:54 +0000 Received: by mail-pg0-x234.google.com with SMTP id j3so8049713pga.1 for ; Mon, 16 Oct 2017 16:27:32 -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=o3PtLqLydSJe65VoQEw/JaZBb7PTqXsw9zJ+cxewbds=; b=JH6RGQ8Lo8dOcbieCOT26nyRlUlBh6Rt+COHuRgLJKfb4y4bs3YECm6dePBbPcZUCh rxVceOkQFTdeR7mU+Fz087Bjlz62LMWYuCGIKsHzEPOKmxp8DM3wRhAhe+nqOJ9LfLwW pJI9Vrmehmp27V6uZr70IInUgUZCzMypJQKqU= 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=o3PtLqLydSJe65VoQEw/JaZBb7PTqXsw9zJ+cxewbds=; b=flptAvqFTFyBfpDAgZtuaOqPTgAXySaFVuQyCV51Cy7KDD6nEgzyEYPicRUF5T3bvD agScueCwhfugt7d6+U5HiAfdgTmY6zRMwwet48hqXhzB3wQMY4mVNvrpo/PevNstvjpy rWYQlBC0RZmlVHGLxH6Xq6YZ1lxGjxkJGLIAVDIW8syyt2UGYHdsJH0hGKs5ZEPH9Iai xme/6UX4tUeZSar1nxx8Syl2aOxNWDAvMq7XV1ETmMn/KwcvYVJzio2zu3MoVF24m4cx cIXxIpAgJRmGYbbW1QH5PkbYK65g7PXwkSdbANe8zPf1fsjqUj9uGmOCj13jtMOkVmRa On+Q== X-Gm-Message-State: AMCzsaVIaBm8sPN5G5m8oJLl5dnadVfWyvIIFHet6YqjbW6w7P5Rm7/a vKU+2J3M0ZYadFR2+14GbD5tPA== X-Google-Smtp-Source: AOwi7QDmT0y9wCWlC0J7q/lho6UfhjxNTlEW5pCT67PbptozhzVQaASr+44v6JVAMz74Ci5RLEsDTQ== X-Received: by 10.159.252.194 with SMTP id o2mr9151848pls.8.1508196451855; Mon, 16 Oct 2017 16:27:31 -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 x4sm14424567pge.23.2017.10.16.16.27.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:27:30 -0700 (PDT) Date: Mon, 16 Oct 2017 16:27:29 -0700 From: Kees Cook To: Wolfram Sang Subject: [PATCH] i2c/busses: Convert timers to use timer_setup() Message-ID: <20171016232729.GA101069@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171016_162753_205841_F27710EA X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Sylvain Lemieux , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vladimir Zapolskiy Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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: Wolfram Sang Cc: Vladimir Zapolskiy Cc: Sylvain Lemieux Cc: linux-i2c@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook --- drivers/i2c/busses/i2c-img-scb.c | 7 +++---- drivers/i2c/busses/i2c-pnx.c | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c index eb1d91b986fd..823b0b33b2cb 100644 --- a/drivers/i2c/busses/i2c-img-scb.c +++ b/drivers/i2c/busses/i2c-img-scb.c @@ -826,9 +826,9 @@ static unsigned int img_i2c_atomic(struct img_i2c *i2c, * Timer function to check if something has gone wrong in automatic mode (so we * don't have to handle so many interrupts just to catch an exception). */ -static void img_i2c_check_timer(unsigned long arg) +static void img_i2c_check_timer(struct timer_list *t) { - struct img_i2c *i2c = (struct img_i2c *)arg; + struct img_i2c *i2c = from_timer(i2c, t, check_timer); unsigned long flags; unsigned int line_status; @@ -1362,8 +1362,7 @@ static int img_i2c_probe(struct platform_device *pdev) } /* Set up the exception check timer */ - setup_timer(&i2c->check_timer, img_i2c_check_timer, - (unsigned long)i2c); + timer_setup(&i2c->check_timer, img_i2c_check_timer, 0); i2c->bitrate = timings[0].max_bitrate; if (!of_property_read_u32(node, "clock-frequency", &val)) diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 42d6b3a226f8..a542041df0cd 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c @@ -112,7 +112,6 @@ static inline void i2c_pnx_arm_timer(struct i2c_pnx_algo_data *alg_data) jiffies, expires); timer->expires = jiffies + expires; - timer->data = (unsigned long)alg_data; add_timer(timer); } @@ -435,9 +434,9 @@ static irqreturn_t i2c_pnx_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void i2c_pnx_timeout(unsigned long data) +static void i2c_pnx_timeout(struct timer_list *t) { - struct i2c_pnx_algo_data *alg_data = (struct i2c_pnx_algo_data *)data; + struct i2c_pnx_algo_data *alg_data = from_timer(alg_data, t, mif.timer); u32 ctl; dev_err(&alg_data->adapter.dev, @@ -659,8 +658,7 @@ static int i2c_pnx_probe(struct platform_device *pdev) if (IS_ERR(alg_data->clk)) return PTR_ERR(alg_data->clk); - setup_timer(&alg_data->mif.timer, i2c_pnx_timeout, - (unsigned long)alg_data); + timer_setup(&alg_data->mif.timer, i2c_pnx_timeout, 0); snprintf(alg_data->adapter.name, sizeof(alg_data->adapter.name), "%s", pdev->name);