From patchwork Tue Oct 24 14:18:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10024663 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 3165F6035E for ; Tue, 24 Oct 2017 14:18:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23E642851A for ; Tue, 24 Oct 2017 14:18:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18A8828533; Tue, 24 Oct 2017 14:18:53 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 6C7D8284D4 for ; Tue, 24 Oct 2017 14:18:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932111AbdJXOSn (ORCPT ); Tue, 24 Oct 2017 10:18:43 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:43532 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbdJXOSl (ORCPT ); Tue, 24 Oct 2017 10:18:41 -0400 Received: by mail-pf0-f195.google.com with SMTP id a8so19789982pfc.0 for ; Tue, 24 Oct 2017 07:18:41 -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=r6lUfG9ou1bs+9Syt0QfTIrxOQub2G46F7KeT6aMPoQ=; b=THc6sGawUDtD4NLt6QYYE8BOtIhFl4D84S/L0MZkoxD2KqP0et0kE2ro52kzI7dTv5 nKnh0Jz7kjjWWo1nF7F0bZYhexqRThG5T31byReJWwfuuS4eYY4wVi2qqYS0fLtMf3gS 0zevrHQUGuTFV39uSsfAuX1vxs7std5pc/QXA= 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=r6lUfG9ou1bs+9Syt0QfTIrxOQub2G46F7KeT6aMPoQ=; b=NmNGLwOyM0hckHw14hObVWYglJ0LT12oqkBoOY2SlMMmxyM/1fLwl/l5dY+hyXLUyV u6C2wQRP4+pn42qj2QUwT0ix9k5wJRSxdbj6n0IO0mejp6DiF1jq187oXWIYBtVptnSs gBiZDnv+tn2dSfsIgSrac+FV4TukDvE1zk+62XXSoJY4z++1lynODvqsg3+cN1YSBbLc O83YpgYgauB2LEvmzp0h8IBC4yYGx4II1HwRY1NcgMMW8U2ur8zGHeYjqOUR9D5Enc8j hiA4INwkL8XZe2cJUq8jo/02MdWupA2SugpASkoALOw8rtqlTt7oDm4eJdHn5OF3eIdH RINA== X-Gm-Message-State: AMCzsaXtyYt44/LbxX3vntuBkv//iLX10sXOkzseI/5QW919REECF9kx b2hKI0tKe051tRoWwO44u5ylSw== X-Google-Smtp-Source: ABhQp+RQScwueKbbgkyGeaOsTfEbgL7gYYGufaI/LElpZ7p8yv0o3fS7VVQsqOPjgJQQTNuKrUSj9w== X-Received: by 10.84.175.3 with SMTP id s3mr12799565plb.279.1508854720757; Tue, 24 Oct 2017 07:18:40 -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 g16sm781111pgn.43.2017.10.24.07.18.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 07:18:39 -0700 (PDT) Date: Tue, 24 Oct 2017 07:18:37 -0700 From: Kees Cook To: Dmitry Torokhov Cc: Rakesh Iyer , Laxman Dewangan , Thierry Reding , Jonathan Hunter , Guenter Roeck , Linus Walleij , Hans de Goede , Geliang Tang , linux-input@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: keyboard: Convert timers to use timer_setup() Message-ID: <20171024141837.GA78013@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@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: Dmitry Torokhov Cc: Rakesh Iyer Cc: Laxman Dewangan Cc: Thierry Reding Cc: Jonathan Hunter Cc: Guenter Roeck Cc: Linus Walleij Cc: Hans de Goede Cc: Geliang Tang Cc: linux-input@vger.kernel.org Cc: linux-tegra@vger.kernel.org Signed-off-by: Kees Cook --- drivers/input/keyboard/bf54x-keys.c | 7 +++---- drivers/input/keyboard/gpio_keys.c | 7 +++---- drivers/input/keyboard/imx_keypad.c | 8 ++++---- drivers/input/keyboard/locomokbd.c | 7 +++---- drivers/input/keyboard/omap-keypad.c | 6 +++--- drivers/input/keyboard/snvs_pwrkey.c | 7 +++---- drivers/input/keyboard/tegra-kbc.c | 6 +++--- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index 39bcbc38997f..8a07a426f88e 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c @@ -127,10 +127,9 @@ static inline void bfin_kpad_clear_irq(void) bfin_write_KPAD_ROWCOL(0xFFFF); } -static void bfin_kpad_timer(unsigned long data) +static void bfin_kpad_timer(struct timer_list *t) { - struct platform_device *pdev = (struct platform_device *) data; - struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); + struct bf54x_kpad *bf54x_kpad = from_timer(bf54x_kpad, t, timer); if (bfin_kpad_get_keypressed(bf54x_kpad)) { /* Try again later */ @@ -298,7 +297,7 @@ static int bfin_kpad_probe(struct platform_device *pdev) /* Init Keypad Key Up/Release test timer */ - setup_timer(&bf54x_kpad->timer, bfin_kpad_timer, (unsigned long) pdev); + timer_setup(&bf54x_kpad->timer, bfin_kpad_timer, 0); bfin_write_KPAD_PRESCALE(bfin_kpad_get_prescale(TIME_SCALE)); diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index e9f0ebf3267a..87e613dc33b8 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -419,9 +419,9 @@ static irqreturn_t gpio_keys_gpio_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static void gpio_keys_irq_timer(unsigned long _data) +static void gpio_keys_irq_timer(struct timer_list *t) { - struct gpio_button_data *bdata = (struct gpio_button_data *)_data; + struct gpio_button_data *bdata = from_timer(bdata, t, release_timer); struct input_dev *input = bdata->input; unsigned long flags; @@ -582,8 +582,7 @@ static int gpio_keys_setup_key(struct platform_device *pdev, } bdata->release_delay = button->debounce_interval; - setup_timer(&bdata->release_timer, - gpio_keys_irq_timer, (unsigned long)bdata); + timer_setup(&bdata->release_timer, gpio_keys_irq_timer, 0); isr = gpio_keys_irq_isr; irqflags = 0; diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c index 2165f3dd328b..d0220e82e018 100644 --- a/drivers/input/keyboard/imx_keypad.c +++ b/drivers/input/keyboard/imx_keypad.c @@ -184,9 +184,9 @@ static void imx_keypad_fire_events(struct imx_keypad *keypad, /* * imx_keypad_check_for_events is the timer handler. */ -static void imx_keypad_check_for_events(unsigned long data) +static void imx_keypad_check_for_events(struct timer_list *t) { - struct imx_keypad *keypad = (struct imx_keypad *) data; + struct imx_keypad *keypad = from_timer(keypad, t, check_matrix_timer); unsigned short matrix_volatile_state[MAX_MATRIX_KEY_COLS]; unsigned short reg_val; bool state_changed, is_zero_matrix; @@ -456,8 +456,8 @@ static int imx_keypad_probe(struct platform_device *pdev) keypad->irq = irq; keypad->stable_count = 0; - setup_timer(&keypad->check_matrix_timer, - imx_keypad_check_for_events, (unsigned long) keypad); + timer_setup(&keypad->check_matrix_timer, imx_keypad_check_for_events, + 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 0d74312d5b02..30d610758595 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -210,9 +210,9 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id) /* * LoCoMo timer checking for released keys */ -static void locomokbd_timer_callback(unsigned long data) +static void locomokbd_timer_callback(struct timer_list *t) { - struct locomokbd *locomokbd = (struct locomokbd *) data; + struct locomokbd *locomokbd = from_timer(locomokbd, t, timer); locomokbd_scankeyboard(locomokbd); } @@ -264,8 +264,7 @@ static int locomokbd_probe(struct locomo_dev *dev) spin_lock_init(&locomokbd->lock); - setup_timer(&locomokbd->timer, locomokbd_timer_callback, - (unsigned long)locomokbd); + timer_setup(&locomokbd->timer, locomokbd_timer_callback, 0); locomokbd->suspend_jiffies = jiffies; diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index 146b26f665f6..7bd107910a6e 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c @@ -41,7 +41,7 @@ #undef NEW_BOARD_LEARNING_MODE static void omap_kp_tasklet(unsigned long); -static void omap_kp_timer(unsigned long); +static void omap_kp_timer(struct timer_list *); static unsigned char keypad_state[8]; static DEFINE_MUTEX(kp_enable_mutex); @@ -74,7 +74,7 @@ static irqreturn_t omap_kp_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static void omap_kp_timer(unsigned long data) +static void omap_kp_timer(struct timer_list *unused) { tasklet_schedule(&kp_tasklet); } @@ -233,7 +233,7 @@ static int omap_kp_probe(struct platform_device *pdev) col_idx = 0; row_idx = 0; - setup_timer(&omap_kp->timer, omap_kp_timer, (unsigned long)omap_kp); + timer_setup(&omap_kp->timer, omap_kp_timer, 0); /* get the irq and init timer*/ kp_tasklet.data = (unsigned long) omap_kp; diff --git a/drivers/input/keyboard/snvs_pwrkey.c b/drivers/input/keyboard/snvs_pwrkey.c index 7544888c4749..53c768b95939 100644 --- a/drivers/input/keyboard/snvs_pwrkey.c +++ b/drivers/input/keyboard/snvs_pwrkey.c @@ -45,9 +45,9 @@ struct pwrkey_drv_data { struct input_dev *input; }; -static void imx_imx_snvs_check_for_events(unsigned long data) +static void imx_imx_snvs_check_for_events(struct timer_list *t) { - struct pwrkey_drv_data *pdata = (struct pwrkey_drv_data *) data; + struct pwrkey_drv_data *pdata = from_timer(pdata, t, check_timer); struct input_dev *input = pdata->input; u32 state; @@ -134,8 +134,7 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev) /* clear the unexpected interrupt before driver ready */ regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO); - setup_timer(&pdata->check_timer, - imx_imx_snvs_check_for_events, (unsigned long) pdata); + timer_setup(&pdata->check_timer, imx_imx_snvs_check_for_events, 0); input = devm_input_allocate_device(&pdev->dev); if (!input) { diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c index edc1385ca00b..875205f445b5 100644 --- a/drivers/input/keyboard/tegra-kbc.c +++ b/drivers/input/keyboard/tegra-kbc.c @@ -251,9 +251,9 @@ static void tegra_kbc_set_fifo_interrupt(struct tegra_kbc *kbc, bool enable) writel(val, kbc->mmio + KBC_CONTROL_0); } -static void tegra_kbc_keypress_timer(unsigned long data) +static void tegra_kbc_keypress_timer(struct timer_list *t) { - struct tegra_kbc *kbc = (struct tegra_kbc *)data; + struct tegra_kbc *kbc = from_timer(kbc, t, timer); unsigned long flags; u32 val; unsigned int i; @@ -655,7 +655,7 @@ static int tegra_kbc_probe(struct platform_device *pdev) return -ENOMEM; } - setup_timer(&kbc->timer, tegra_kbc_keypress_timer, (unsigned long)kbc); + timer_setup(&kbc->timer, tegra_kbc_keypress_timer, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); kbc->mmio = devm_ioremap_resource(&pdev->dev, res);