Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1145997imm; Tue, 5 Jun 2018 09:45:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKwbvKKCXhUT+RPoH9MRLdQTxSzDsNlRnpAYIG4hjNzzxnkFYFRv3QuyeKqu7MMXu/KtHbL X-Received: by 2002:a63:bc0a:: with SMTP id q10-v6mr21554124pge.70.1528217123336; Tue, 05 Jun 2018 09:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528217123; cv=none; d=google.com; s=arc-20160816; b=JOWf84t7U2GHk4IjBCPTjhBV5b6N3f5rAWAWaKzlnUPRaQ3MX73nRiMxKsD7Ejmitr 3gxFEqfbtnA+01tW4LWkfIamwjBkdUOIJjJrnUXAyvunAKRfpG31uXCA3F1cb+Dqjwl8 H3Dr6Hrgd5/U8p6z9odrNpTmOVcoF49VVcNWfE9yuEev0eoIEO07VYUS+FKlP3XFhbXR NDR/Wu4SIFtk/l8fpvUjThPYuyfBi7HKJdCXffnPEsaD07yLw+Z2yn1IBdC1cB3v2djB /h65EDr555nFhDfI93qEAk8UUdOoEgeUECFQAXZtmq+6Mx+QsvqUPxL2kVl2cuUAouFF /0Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=n+kEP/XoID0h5YoDmpNMg5DqljXhhCbV+DEYJvN4OTs=; b=JK9JDIsaPUhYoQNgwr/TD9JbWwgelMuziIoANtZviT3PZtIu0cfiYIo1+TtsWAxes2 TCTuc65ZSNqwjGAwlrCXUOtexUL+DK8feJf+mr8itdsIKPT3kgekmO7BgyuuknB8mgk/ rSt2tF5GKd6heG6BFlRdj8oZBXGY175zRiIHjfNlBZs/3wpGVz4c92WoqI34N12eF/CZ 4paB8Q9Ng0oehBtOvAY8Tc///6RMUqy6lYvRDn2dUl+AV8wso/dhYDuvPCdtj6Ivblms rQTKwEKVezP+l4EE5cmLxKeaYzRZ79WQQO9dkFgP4RZKJs9Uipr9GNunc/wUpH9RmAJI ReFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D5vqc/20; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s1-v6si4231203pgb.486.2018.06.05.09.45.08; Tue, 05 Jun 2018 09:45:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D5vqc/20; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209AbeFEQoV (ORCPT + 99 others); Tue, 5 Jun 2018 12:44:21 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46767 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbeFEQoT (ORCPT ); Tue, 5 Jun 2018 12:44:19 -0400 Received: by mail-qt0-f196.google.com with SMTP id h5-v6so3093899qtm.13; Tue, 05 Jun 2018 09:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=n+kEP/XoID0h5YoDmpNMg5DqljXhhCbV+DEYJvN4OTs=; b=D5vqc/20pPtFwWd2ZNw6YORzCKomGVuYLRgHfPWNiSFYmgxEFW36xpT/vnFz+o3oHZ 85retkaNk48eEJ+LW/U+9R54MGbXJoTS+mGIsIgVhqJyV+CtpNQGOjJIz/VjeFxL3uqN TxXezR7atm895biyoKRQF0zVHI6gl53SUGKFgLImcZfi5yB9N2sceF/KueDP6hp/TMIy cjyZUrqVju9KKsEO2wX2G5cMo9jesFRhRJS2TLOF7vhh23v6AJb4cX/TBfQho9l+rNZu bvKsRr6TVymDj8kidDenzMX3hQELtX6Grpmz00vmDtM+V2+haa8xBXwhL7XVStViIXKq nKsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=n+kEP/XoID0h5YoDmpNMg5DqljXhhCbV+DEYJvN4OTs=; b=kIN4r0vRzaHzm2fxsPLo1C1/h7f4Ba35QPGhPLbHVvTGYrXcNyh8a9AKB2UPQ8szsc hSuD01TcNlpaMEtEhK+r8TM7Bet2Fun6H3WZhY0oFkjHDIBYfDzUQyzp6jl+0qsbqCvA 89QCfeKzPSQMonTgpIYm/2NklebHfe62bKVxDnWSyuChLyDsbEV9oC+3vicJnajXnQxl Ij+i0dwh2ghdiBGYGpAnlWCoLHtAzQW6YQzfqnWC04OmydHYlDKgV4VkGC4qPvm3ajxX ifF2ybbVKnDHEQAAP7BtxY6ZTOJuYSTpTU0pn+uCkKvx4X1WsffgefmkIRkcd4yXSw+m ZPrQ== X-Gm-Message-State: APt69E3l52E8WZsBX37x48Ie4TDp7A4Yy16mfQf98b+FI8ckOnwYSnTM t1VrI7JjQ95ila8SnggzQeLPfP2YztSQ1O/1e+c= X-Received: by 2002:a0c:b2ca:: with SMTP id d10-v6mr19591364qvf.16.1528217058650; Tue, 05 Jun 2018 09:44:18 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 09:44:18 -0700 (PDT) In-Reply-To: <20180516024004.28977-2-pasha.tatashin@oracle.com> References: <20180516024004.28977-1-pasha.tatashin@oracle.com> <20180516024004.28977-2-pasha.tatashin@oracle.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 19:44:18 +0300 Message-ID: Subject: Re: [PATCH v5 1/3] drivers core: refactor device_shutdown To: Pavel Tatashin Cc: Steven Sistare , Daniel Jordan , Linux Kernel Mailing List , "Kirsher, Jeffrey T" , intel-wired-lan@lists.osuosl.org, netdev , Greg Kroah-Hartman , Alexander Duyck , tobin@apporbit.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 16, 2018 at 5:40 AM, Pavel Tatashin wrote: > device_shutdown() traverses through the list of devices, and calls > dev->{bug/driver}->shutdown() for each entry in the list. > > Refactor the function by keeping device_shutdown() to do the logic of > traversing the list of devices, and device_shutdown_one() to perform the > actual shutdown operation on one device. > FWIW, Reviewed-by: Andy Shevchenko > Signed-off-by: Pavel Tatashin > --- > drivers/base/core.c | 50 +++++++++++++++++++++++++++------------------ > 1 file changed, 30 insertions(+), 20 deletions(-) > > diff --git a/drivers/base/core.c b/drivers/base/core.c > index b610816eb887..ed189f6d1a2f 100644 > --- a/drivers/base/core.c > +++ b/drivers/base/core.c > @@ -2765,6 +2765,35 @@ int device_move(struct device *dev, struct device *new_parent, > } > EXPORT_SYMBOL_GPL(device_move); > > +/* > + * device_shutdown_one - call ->shutdown() for the device passed as > + * argument. > + */ > +static void device_shutdown_one(struct device *dev) > +{ > + /* Don't allow any more runtime suspends */ > + pm_runtime_get_noresume(dev); > + pm_runtime_barrier(dev); > + > + if (dev->class && dev->class->shutdown_pre) { > + if (initcall_debug) > + dev_info(dev, "shutdown_pre\n"); > + dev->class->shutdown_pre(dev); > + } > + if (dev->bus && dev->bus->shutdown) { > + if (initcall_debug) > + dev_info(dev, "shutdown\n"); > + dev->bus->shutdown(dev); > + } else if (dev->driver && dev->driver->shutdown) { > + if (initcall_debug) > + dev_info(dev, "shutdown\n"); > + dev->driver->shutdown(dev); > + } > + > + /* decrement the reference counter */ > + put_device(dev); > +} > + > /** > * device_shutdown - call ->shutdown() on each device to shutdown. > */ > @@ -2801,30 +2830,11 @@ void device_shutdown(void) > device_lock(parent); > device_lock(dev); > > - /* Don't allow any more runtime suspends */ > - pm_runtime_get_noresume(dev); > - pm_runtime_barrier(dev); > - > - if (dev->class && dev->class->shutdown_pre) { > - if (initcall_debug) > - dev_info(dev, "shutdown_pre\n"); > - dev->class->shutdown_pre(dev); > - } > - if (dev->bus && dev->bus->shutdown) { > - if (initcall_debug) > - dev_info(dev, "shutdown\n"); > - dev->bus->shutdown(dev); > - } else if (dev->driver && dev->driver->shutdown) { > - if (initcall_debug) > - dev_info(dev, "shutdown\n"); > - dev->driver->shutdown(dev); > - } > - > + device_shutdown_one(dev); > device_unlock(dev); > if (parent) > device_unlock(parent); > > - put_device(dev); > put_device(parent); > > spin_lock(&devices_kset->list_lock); > -- > 2.17.0 > -- With Best Regards, Andy Shevchenko