Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbdHaXlK (ORCPT ); Thu, 31 Aug 2017 19:41:10 -0400 Received: from mail-pg0-f51.google.com ([74.125.83.51]:37594 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbdHaXjW (ORCPT ); Thu, 31 Aug 2017 19:39:22 -0400 X-Google-Smtp-Source: ADKCNb6Hdt1Yyr4BnG6qzz2RrRVpp76vRUbqvxo7iMkbPu7MqqrdfLrA+XDM/eLbTlrtd/oC6Vu51g== From: Kees Cook To: Thomas Gleixner Cc: Kees Cook , Felipe Balbi , Greg Kroah-Hartman , Raviteja Garimella , Michal Nazarewicz , "Gustavo A. R. Silva" , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 27/31] usb/gadget/snps_udc_core: Move timer initialization earlier Date: Thu, 31 Aug 2017 16:29:39 -0700 Message-Id: <1504222183-61202-28-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504222183-61202-1-git-send-email-keescook@chromium.org> References: <1504222183-61202-1-git-send-email-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2062 Lines: 62 With timer initialization made earlier at the start, there is no reason to make del_timer_sync() calls conditionally, there by removing the assignments and tests of the .data field. Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Raviteja Garimella Cc: Michal Nazarewicz Cc: "Gustavo A. R. Silva" Cc: linux-usb@vger.kernel.org Signed-off-by: Kees Cook --- drivers/usb/gadget/udc/snps_udc_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/snps_udc_core.c b/drivers/usb/gadget/udc/snps_udc_core.c index 5460e5ba1c3c..1607e901e16b 100644 --- a/drivers/usb/gadget/udc/snps_udc_core.c +++ b/drivers/usb/gadget/udc/snps_udc_core.c @@ -3067,14 +3067,12 @@ void udc_remove(struct udc *dev) stop_timer++; if (timer_pending(&udc_timer)) wait_for_completion(&on_exit); - if (udc_timer.data) - del_timer_sync(&udc_timer); + del_timer_sync(&udc_timer); /* remove pollstall timer */ stop_pollstall_timer++; if (timer_pending(&udc_pollstall_timer)) wait_for_completion(&on_pollstall_exit); - if (udc_pollstall_timer.data) - del_timer_sync(&udc_pollstall_timer); + del_timer_sync(&udc_pollstall_timer); udc = NULL; } EXPORT_SYMBOL_GPL(udc_remove); @@ -3164,9 +3162,9 @@ int udc_probe(struct udc *dev) u32 reg; int retval; - /* mark timer as not initialized */ - udc_timer.data = 0; - udc_pollstall_timer.data = 0; + /* timer init */ + setup_timer(&udc_timer, udc_timer_function, 0); + setup_timer(&udc_pollstall_timer, udc_pollstall_timer_function, 0); /* device struct setup */ dev->gadget.ops = &udc_ops; @@ -3206,10 +3204,6 @@ int udc_probe(struct udc *dev) if (retval) goto finished; - /* timer init */ - setup_timer(&udc_timer, udc_timer_function, 1); - setup_timer(&udc_pollstall_timer, udc_pollstall_timer_function, 1); - /* set SD */ reg = readl(&dev->regs->ctl); reg |= AMD_BIT(UDC_DEVCTL_SD); -- 2.7.4