Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp259893pxb; Wed, 8 Sep 2021 23:45:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3RHo2AxKs3PE5D/rxcVkvvA8KG04mW8oiVrBFTXCPLO7lf/VUzZ9c0NYgiaMpa+gDmnnL X-Received: by 2002:a02:c055:: with SMTP id u21mr1498365jam.113.1631169904589; Wed, 08 Sep 2021 23:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631169904; cv=none; d=google.com; s=arc-20160816; b=GaOhEgiIYwgsj2O/DEotpWEREeD8BRIUDma9mQRapbaNI5IwouxCDyIOEwYb+Pxnfn ZKdAe1zDKQ2AxjdZ8/b6xt5ekkbvGInxezKNTkf8THuPFzslNoDeH/j/hrbhVK+BnNtF rpH2Tbfqq3QrlcuSwTI8xDcayKtE+q94fhBGaZvEuVIzSNuWf5RpD6j/LoIIQ78jI/PM HLdG29FB1YTttNOBrNUfyYZGMCUR41wxkLm92Y7bYHpNmjkwbs5FjVfxn5a+sHT9xKHP 5MvPiIWxkrJhJg4P1oWk2i6lrq/pAf2eoAsYKmaiLDI9wkye+Dogs/wAlvXkSqXXkju6 wDBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wLtrwmO0KBTWvlGY6UVPf2jvdy+hEiVk6Rtto3aVzfU=; b=KMSE1WIjlkRZdJpffNOAwfzg6IVEACZjSdykgxrQYjpTAJTbZasfvzXYML28neg0Yn bnaXuOJtgciYbyeCx65dmHc24m6SF70/RiqxY7rXxvLvxVpFGQX5zDKzfqmEEfGW/h8b jt/OB5l3aYpJtdUiOhhIRJzQdIHB+l2IaxVd8Bsr+LdPHWkIF0zwf1kVz6kKktSMySYi raEpueR9Le1u85hBi67ZID5d3tRi/PM4+BuVFK3mpkviXxl18lNrltoxQIaQnrO84arB rMOa52CorxmNcwywizKNDcZL3bLzaGYr6JZH6IxYb14rkbbWOlYko0sUWd8+8SCPu0lT EMOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DWrGqNCi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m62si740227ioa.15.2021.09.08.23.44.52; Wed, 08 Sep 2021 23:45:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=DWrGqNCi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350712AbhIIGnd (ORCPT + 99 others); Thu, 9 Sep 2021 02:43:33 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:37366 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350854AbhIIGn2 (ORCPT ); Thu, 9 Sep 2021 02:43:28 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1896gFWC057035; Thu, 9 Sep 2021 01:42:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1631169735; bh=wLtrwmO0KBTWvlGY6UVPf2jvdy+hEiVk6Rtto3aVzfU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DWrGqNCi+X/qlxOjfC+pw16TZ4HdikDxqjN1y82Mmcq5cRfrhWnFVZzVBn/s1nvV/ qDnDynupjjKGXo6r6JZTaUBiN+mtV24Q2NFxTH9CHsZZeZA96ikqsU3m7VavDFYKWB s8Rb5069VtVBS5ZssiP16Em9lBFuzc/lWmHYMD+w= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1896gFgr029618 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Sep 2021 01:42:15 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 9 Sep 2021 01:42:14 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 9 Sep 2021 01:42:15 -0500 Received: from a0393678-lt.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1896g04S062945; Thu, 9 Sep 2021 01:42:12 -0500 From: Kishon Vijay Abraham I To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern CC: , , , Kishon Vijay Abraham I , Subject: [PATCH v4 3/3] usb: core: hcd: Modularize HCD stop configuration in usb_stop_hcd() Date: Thu, 9 Sep 2021 12:12:00 +0530 Message-ID: <20210909064200.16216-4-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210909064200.16216-1-kishon@ti.com> References: <20210909064200.16216-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change. Since configuration to stop HCD is invoked from multiple places, group all of them in usb_stop_hcd(). Signed-off-by: Kishon Vijay Abraham I Acked-by: Alan Stern Tested-by: Chris Chiu --- drivers/usb/core/hcd.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 99ff2d23be05..7ee6e4cc0d89 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2760,6 +2760,26 @@ static void usb_put_invalidate_rhdev(struct usb_hcd *hcd) usb_put_dev(rhdev); } +/** + * usb_stop_hcd - Halt the HCD + * @hcd: the usb_hcd that has to be halted + * + * Stop the root-hub polling timer and invoke the HCD's ->stop callback. + */ +static void usb_stop_hcd(struct usb_hcd *hcd) +{ + hcd->rh_pollable = 0; + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); + del_timer_sync(&hcd->rh_timer); + + hcd->driver->stop(hcd); + hcd->state = HC_STATE_HALT; + + /* In case the HCD restarted the timer, stop it again. */ + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); + del_timer_sync(&hcd->rh_timer); +} + /** * usb_add_hcd - finish generic HCD structure initialization and register * @hcd: the usb_hcd structure to initialize @@ -2960,13 +2980,7 @@ int usb_add_hcd(struct usb_hcd *hcd, return retval; err_register_root_hub: - hcd->rh_pollable = 0; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); - hcd->driver->stop(hcd); - hcd->state = HC_STATE_HALT; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); + usb_stop_hcd(hcd); err_hcd_driver_start: if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) free_irq(irqnum, hcd); @@ -3039,16 +3053,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) * interrupt occurs), but usb_hcd_poll_rh_status() won't invoke * the hub_status_data() callback. */ - hcd->rh_pollable = 0; - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); - - hcd->driver->stop(hcd); - hcd->state = HC_STATE_HALT; - - /* In case the HCD restarted the timer, stop it again. */ - clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); - del_timer_sync(&hcd->rh_timer); + usb_stop_hcd(hcd); if (usb_hcd_is_primary_hcd(hcd)) { if (hcd->irq > 0) -- 2.17.1