Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp609020pxj; Fri, 14 May 2021 11:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8Hi1otg4rYjslJS5cPFuRQ5FpZgY9tSAHXUAjW6kFlAYn0t0njWVuBe1yG9xK2RpXvcRt X-Received: by 2002:a5e:d711:: with SMTP id v17mr26482953iom.65.1621015308943; Fri, 14 May 2021 11:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621015308; cv=none; d=google.com; s=arc-20160816; b=UIlyCllvSPQENG4qGNErp93UQkQfMV29hc0oRncxRzGcXqtHqL2FyBs6uvKQ+5Pdxk hMtRSnfpZ67IPLmR/EBjj/O8zI1PGaEGAfpZDBiWWOZ3KyVqpe8fjkYoGIlplfzXtquU QiC7yvL79zM5VG9akNc2IChfFK1k67/CfAgyaCfOe/VXfUk3sDPakA0rV821nWFDWDb6 K/VgLjYFIbTtjTbpdZkOyDulD41V1OdevIYPciAIVHhkPmahNbv02cuWAnvtJcujWieu VGSGjCOBSei1kzdiHJszfkmZqm6ECamYfF33em0WedzVqrFYhBJ28QRwG42vTk5ynY2u uifA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=l0PbLxZ5At8sBUTje7hiMbKPlSw9YAwpROKrwgv9q+I=; b=dCDNIPBthiBYLIgKF/CECOQKMv6wOgL2FDzLmAsHpf9Qug8t7UOdI36OjB8OhJZsqj D8Jn++KAAv5vxmhnxgmOfAM6RKGw1RFQltqHEBLe5Nf9A9k9HM4DmyKd4Dn++fFUP9rv HC3Gxomi9JwGME8KHX4hrQlGvCra5AcOIX7pD0mpkTXSpWzPGftCOKyIHnXcu2nMtFhF 3Yco/MvRDJDC+YPTkHeZg8W497Yk/37evL+jZGeMn+BVcpykI9EplmL98CO2ofRYHi0J rh2Ec4MFmAODjYQjD2QtVZoNdz5tvGGBgNzA2N7UyWBZji0g406v4EGkUprTrrUf80yO WoKQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h10si8760085ili.90.2021.05.14.11.01.36; Fri, 14 May 2021 11:01:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232870AbhENMNO (ORCPT + 99 others); Fri, 14 May 2021 08:13:14 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:47652 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbhENMNN (ORCPT ); Fri, 14 May 2021 08:13:13 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 2.0.5) id 8f3f9d61dcd1e631; Fri, 14 May 2021 14:12:01 +0200 Received: from kreacher.localnet (89-64-80-69.dynamic.chello.pl [89.64.80.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 5D89466969E; Fri, 14 May 2021 14:12:00 +0200 (CEST) From: "Rafael J. Wysocki" To: Greg Kroah-Hartman Cc: LKML , "Rafael J. Wysocki" , Saravana Kannan , chenxiang Subject: [PATCH v1 2/2] drivers: base: Reduce device link removal code duplication Date: Fri, 14 May 2021 14:11:19 +0200 Message-ID: <4326215.LvFx2qVVIh@kreacher> In-Reply-To: <11761395.O9o76ZdvQC@kreacher> References: <11761395.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.80.69 X-CLIENT-HOSTNAME: 89-64-80-69.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrvdehiedgvdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdeigedrkedtrdeileenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekledrieegrdektddrieelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtohepghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrghrrghvrghnrghksehgohhoghhlvgdrtghomhdprhgtphhtthhopegthhgvnhigihgrnhhgieeisehhihhsihhlihgtohhnrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Reduce device link removal code duplication between the cases when SRCU is enabled and when it is disabled by moving the only differing piece of it (which is the removal of the link from the consumer and supplier lists) into a separate wrapper function (defined differently for each of the cases in question). No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/base/core.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) Index: linux-pm/drivers/base/core.c =================================================================== --- linux-pm.orig/drivers/base/core.c +++ linux-pm/drivers/base/core.c @@ -198,6 +198,12 @@ static void device_link_synchronize_remo { synchronize_srcu(&device_links_srcu); } + +static void device_link_remove_from_lists(struct device_link *link) +{ + list_del_rcu(&link->s_node); + list_del_rcu(&link->c_node); +} #else /* !CONFIG_SRCU */ static DECLARE_RWSEM(device_links_lock); @@ -232,6 +238,12 @@ int device_links_read_lock_held(void) static inline void device_link_synchronize_removal(void) { } + +static void device_link_remove_from_lists(struct device_link *link) +{ + list_del(&link->s_node); + list_del(&link->c_node); +} #endif /* !CONFIG_SRCU */ static bool device_is_ancestor(struct device *dev, struct device *target) @@ -854,7 +866,6 @@ out: } EXPORT_SYMBOL_GPL(device_link_add); -#ifdef CONFIG_SRCU static void __device_link_del(struct kref *kref) { struct device_link *link = container_of(kref, struct device_link, kref); @@ -864,25 +875,9 @@ static void __device_link_del(struct kre pm_runtime_drop_link(link); - list_del_rcu(&link->s_node); - list_del_rcu(&link->c_node); + device_link_remove_from_lists(link); device_unregister(&link->link_dev); } -#else /* !CONFIG_SRCU */ -static void __device_link_del(struct kref *kref) -{ - struct device_link *link = container_of(kref, struct device_link, kref); - - dev_info(link->consumer, "Dropping the link to %s\n", - dev_name(link->supplier)); - - pm_runtime_drop_link(link); - - list_del(&link->s_node); - list_del(&link->c_node); - device_unregister(&link->link_dev); -} -#endif /* !CONFIG_SRCU */ static void device_link_put_kref(struct device_link *link) {