From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbdJXKIM (ORCPT ); Tue, 24 Oct 2017 06:08:12 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:56419 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932397AbdJXKIF (ORCPT ); Tue, 24 Oct 2017 06:08:05 -0400 X-Google-Smtp-Source: ABhQp+QvGlbGVorVDOJKk8N+diZFORRkHucl0sAyYmL+J+iNim/w19L3Yy8lQWPtDNKqbjpAR6Dn/Q== Date: Tue, 24 Oct 2017 03:08:03 -0700 From: Kees Cook To: Greg Kroah-Hartman Cc: Felipe Balbi , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: zero: Convert timers to use timer_setup() Message-ID: <20171024100803.GA69062@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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. Adds a static tracking variable to match the timer global. Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Kees Cook --- drivers/usb/gadget/legacy/zero.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c index d02e2ce73ea5..3acc589dae98 100644 --- a/drivers/usb/gadget/legacy/zero.c +++ b/drivers/usb/gadget/legacy/zero.c @@ -154,10 +154,11 @@ static struct usb_gadget_strings *dev_strings[] = { /*-------------------------------------------------------------------------*/ static struct timer_list autoresume_timer; +static struct usb_composite_dev *autoresume_cdev; -static void zero_autoresume(unsigned long _c) +static void zero_autoresume(struct timer_list *unused) { - struct usb_composite_dev *cdev = (void *)_c; + struct usb_composite_dev *cdev = autoresume_cdev; struct usb_gadget *g = cdev->gadget; /* unconfigured devices can't issue wakeups */ @@ -282,7 +283,8 @@ static int zero_bind(struct usb_composite_dev *cdev) device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id; - setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev); + autoresume_cdev = cdev; + timer_setup(&autoresume_timer, zero_autoresume, 0); func_inst_ss = usb_get_function_instance("SourceSink"); if (IS_ERR(func_inst_ss)) -- 2.7.4 -- Kees Cook Pixel Security