From patchwork Thu Oct 5 00:53:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986211 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 3FDB4605A8 for ; Thu, 5 Oct 2017 00:57:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA0D28C43 for ; Thu, 5 Oct 2017 00:57:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2473128C45; Thu, 5 Oct 2017 00:57: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=-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 7FD7D28C43 for ; Thu, 5 Oct 2017 00:57:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753017AbdJEAxe (ORCPT ); Wed, 4 Oct 2017 20:53:34 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:54629 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753014AbdJEAxb (ORCPT ); Wed, 4 Oct 2017 20:53:31 -0400 Received: by mail-pf0-f170.google.com with SMTP id m28so2192552pfi.11 for ; Wed, 04 Oct 2017 17:53:31 -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 :content-transfer-encoding; bh=b69HPGLwQH5P9naK8xGtZT3+/VudwWyIc5iWDguffxo=; b=RJdofa5F4O7a51FlPCfYJ6+4d/pt7i2ye27Mz7oxWlkO3NBt7rNyWG4EGhtQ2FLjnF Qbo5CHzcls9eZnQoMQXatf9Oycwjb0iBe7gCPOuEQm0ighOCn+/mc8tQpXvXP6lRiyue A1O3ekDGejrFD1v2h7F2yLkSm9vhzuamflBkY= 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:content-transfer-encoding; bh=b69HPGLwQH5P9naK8xGtZT3+/VudwWyIc5iWDguffxo=; b=TPuxn2XWBq7lP8J+fu+vi6lkbgkiT+gbKQg1yagLHo1MmEvxg8hPphCaGf4UW6J1sE fVd1/8v4wSnmaevRnVRv8iQ0DmY7gSTQZKn2B9qjtQUTijdzVQDYzhoaSFZnmJB++I9B r8ZqcHb8a9LGMFh7KvUaCwzFWv7DikRVOoNIkEnOqC1dYAKcGO1J9ZCNTJgJwlAwCWWA ZYh9BIu5TUGvMchvWQ5DsdBmJcTmwrTuwgI2q8Ju+gVyzoA+i1F/Snhu4HcoAdILpRPy kVw0+e8+P200QolPbdJidP2tJ//EVBMh8oI6TNmW5X5w9s3kUd2BD/anf/6Q2kYbQe9H QrRA== X-Gm-Message-State: AMCzsaX4IARXw2tyS76GRVpwnHMfGORIFPAymwQFPt02Pp91H2xBvjql Iig3vdzD2yZaYtlv1n6oLJLnrA== X-Google-Smtp-Source: AOwi7QC7UwFT/+AW3cNME/l8ZnCV0QgbJ/XYMdmfEfXHDNCBT1Vjh8+1Y8PvGzFAlB1r+PCwUEwhSQ== X-Received: by 10.99.47.6 with SMTP id v6mr3284827pgv.452.1507164811430; Wed, 04 Oct 2017 17:53: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 r66sm27862660pfl.15.2017.10.04.17.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:53:30 -0700 (PDT) Date: Wed, 4 Oct 2017 17:53:29 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Dmitry Torokhov , Pali =?iso-8859-1?Q?Roh=E1r?= , Ben Gamari , Paul Donohue , Masaki Ota , linux-input@vger.kernel.org, Thomas Gleixner Subject: [PATCH] Input: Convert timers to use timer_setup() Message-ID: <20171005005329.GA23768@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. Adds a pointer back to input device in byd driver. Cc: Dmitry Torokhov Cc: "Pali Rohár" Cc: Ben Gamari Cc: Paul Donohue Cc: Masaki Ota Cc: linux-input@vger.kernel.org Cc: Thomas Gleixner Signed-off-by: Kees Cook Acked-by: Pali Rohár --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- drivers/input/ff-memless.c | 8 ++++---- drivers/input/mouse/alps.c | 8 ++++---- drivers/input/mouse/byd.c | 10 ++++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c index fcc6c3368182..2743ed4656e4 100644 --- a/drivers/input/ff-memless.c +++ b/drivers/input/ff-memless.c @@ -412,10 +412,10 @@ static void ml_play_effects(struct ml_device *ml) ml_schedule_timer(ml); } -static void ml_effect_timer(unsigned long timer_data) +static void ml_effect_timer(struct timer_list *t) { - struct input_dev *dev = (struct input_dev *)timer_data; - struct ml_device *ml = dev->ff->private; + struct ml_device *ml = from_timer(ml, t, timer); + struct input_dev *dev = ml->dev; unsigned long flags; pr_debug("timer: updating effects\n"); @@ -526,7 +526,7 @@ int input_ff_create_memless(struct input_dev *dev, void *data, ml->private = data; ml->play_effect = play_effect; ml->gain = 0xffff; - setup_timer(&ml->timer, ml_effect_timer, (unsigned long)dev); + timer_setup(&ml->timer, ml_effect_timer, 0); set_bit(FF_GAIN, dev->ffbit); diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 850b00e3ad8e..579b899add26 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1587,10 +1587,10 @@ static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse) return PSMOUSE_GOOD_DATA; } -static void alps_flush_packet(unsigned long data) +static void alps_flush_packet(struct timer_list *t) { - struct psmouse *psmouse = (struct psmouse *)data; - struct alps_data *priv = psmouse->private; + struct alps_data *priv = from_timer(priv, t, timer); + struct psmouse *psmouse = priv->psmouse; serio_pause_rx(psmouse->ps2dev.serio); @@ -2702,7 +2702,7 @@ static int alps_set_protocol(struct psmouse *psmouse, { psmouse->private = priv; - setup_timer(&priv->timer, alps_flush_packet, (unsigned long)psmouse); + timer_setup(&priv->timer, alps_flush_packet, 0); priv->proto_version = protocol->version; priv->byte0 = protocol->byte0; diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c index b64b81599f7e..f2aabf7f906f 100644 --- a/drivers/input/mouse/byd.c +++ b/drivers/input/mouse/byd.c @@ -227,6 +227,7 @@ struct byd_data { struct timer_list timer; + struct psmouse *psmouse; s32 abs_x; s32 abs_y; typeof(jiffies) last_touch_time; @@ -251,10 +252,10 @@ static void byd_report_input(struct psmouse *psmouse) input_sync(dev); } -static void byd_clear_touch(unsigned long data) +static void byd_clear_touch(struct timer_list *t) { - struct psmouse *psmouse = (struct psmouse *)data; - struct byd_data *priv = psmouse->private; + struct byd_data *priv = from_timer(priv, t, timer); + struct psmouse *psmouse = priv->psmouse; serio_pause_rx(psmouse->ps2dev.serio); priv->touch = false; @@ -478,7 +479,8 @@ int byd_init(struct psmouse *psmouse) if (!priv) return -ENOMEM; - setup_timer(&priv->timer, byd_clear_touch, (unsigned long) psmouse); + priv->psmouse = psmouse; + timer_setup(&priv->timer, byd_clear_touch, 0); psmouse->private = priv; psmouse->disconnect = byd_disconnect;