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: 826547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JH6RGQ8L"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGDxy5kbWz9sRn for ; Tue, 17 Oct 2017 10:27:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753084AbdJPX1d (ORCPT ); Mon, 16 Oct 2017 19:27:33 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:56423 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752471AbdJPX1c (ORCPT ); Mon, 16 Oct 2017 19:27:32 -0400 Received: by mail-pg0-f43.google.com with SMTP id m18so8043600pgd.13 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=Rufkl6cnJ7rIdE4NABpO4OIx8n8+ceFC6/8XrSN+mmSoCwiwEDIUWwFz54G9kf44a+ +HxzPLgQ20nDNxbfUoEKaR5fnoNQBcaxyArJPVEsJT/BhVMgM1tjC/ksd89dMGVhJ/bN a0eA+laGE13sMM0W5/TNA5K77rOiZckZb58VecvN4do05XakRuO7uiujcC2RHQKea1gG ZZ0ezkD1JiGoWVevr33oJgC6aOFZ4dTExHdk2OqISIYv6nzi+pHSRsbddqzR0z1u2uxL 7Y6BhvoD0HWz27MPT5hFKK7ug5NqUNDXl7eIM1cRnGNV0jPdmyQ/eQatspw5wQoTucdC qe5g== X-Gm-Message-State: AMCzsaWcMX2zOFm5HplCtoAjKgcZCOJSgYhY4WXjeMPePmMHRd2H2FnK Al7+HZTguqpOQqPqd5Dt/miZ8Q== 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 Cc: Vladimir Zapolskiy , Sylvain Lemieux , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c/busses: Convert timers to use timer_setup() Message-ID: <20171016232729.GA101069@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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);