From patchwork Mon Oct 16 23:15:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010103 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 A844260235 for ; Mon, 16 Oct 2017 23:15:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9720A286E7 for ; Mon, 16 Oct 2017 23:15:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8927B286F2; Mon, 16 Oct 2017 23:15:51 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 173B2286E7 for ; Mon, 16 Oct 2017 23:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757147AbdJPXPh (ORCPT ); Mon, 16 Oct 2017 19:15:37 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:51959 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757120AbdJPXPg (ORCPT ); Mon, 16 Oct 2017 19:15:36 -0400 Received: by mail-pg0-f54.google.com with SMTP id p9so3429523pgc.8 for ; Mon, 16 Oct 2017 16:15:36 -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=8QUvIfxb5l33sMxI9wnl1UqFvS1jUgRxnC9ixwlvIjY=; b=nNB2a6OyX+57mfB1mqzQ/G/r0Qh25QPQMCWizdO8gb+N/WN1VnjISftjrMETdt7QGF dXF5JBYnxF76xdDRKa2aFXzn8+XeD0IpH8bATAUuGDQWPtDITwzEE1k8PE1ZLBot2VEl 5HxSF82V2yg/356VJumV9iUviKXxU1u3a+WNQ= 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=8QUvIfxb5l33sMxI9wnl1UqFvS1jUgRxnC9ixwlvIjY=; b=HIW31ZjdpVcSLbuTCS69tGD1mLO7x7hJyYxTrgEH2uBUsBQNndurgLvS2Wm+bJjbVh 3sM5vFi1wmv25RHjhp1EQ+AyMBohWblYyhGZJkypif2rg0f5G7dMnJxeQiwDud6AhEoY 4sph3Qh1ZlSypBjpV/ZccO/9mlVi6Y2r52nPsp9YN5WbiLRAoiQXfQac6A91+j5lgrs9 AEsCY+UecxWHkTZhYic+co7rxXz+AtdNadg9E/wiO4N+81nLdrhKBKMzUkPNNArhJiMb 4PCoKATDAmXvmEkbwEmkV3dycd8RO3+WY8xFSYip5lpRdkJGLvs14qnqpFNYiBBq9DRB lYVg== X-Gm-Message-State: AMCzsaXSA/+nifhtm5iJLoEGOSWTKgj3E0n6YO7VS9EsvzUZaqOHtZrs 6rBEM+L6KlDTsHSxJECm9juCag== X-Google-Smtp-Source: AOwi7QAZPWqhzvixzAIDkjTP1x+wmuesEpq4qqE0PBII2CLoNLZ1IO7xX491+yOIJK3v5uxx09OBhQ== X-Received: by 10.98.247.26 with SMTP id h26mr10031126pfi.233.1508195736302; Mon, 16 Oct 2017 16:15:36 -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 q7sm14351601pgn.56.2017.10.16.16.15.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 16:15:35 -0700 (PDT) Date: Mon, 16 Oct 2017 16:15:34 -0700 From: Kees Cook To: Dmitry Torokhov Cc: Pali =?iso-8859-1?Q?Roh=E1r?= , Ben Gamari , Paul Donohue , Masaki Ota , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Input: Convert timers to use timer_setup() Message-ID: <20171016231534.GA100079@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 Signed-off-by: Kees Cook --- 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;