Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp781449pxb; Tue, 12 Apr 2022 13:17:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnI0PuQwebQNwEaMquMhhOT3TbfDOLQI2S/6pRwdX/h526pj9WRbqVbPSthETyWL6n7ICX X-Received: by 2002:a63:4b5b:0:b0:39d:3808:c226 with SMTP id k27-20020a634b5b000000b0039d3808c226mr12601997pgl.603.1649794669836; Tue, 12 Apr 2022 13:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649794669; cv=none; d=google.com; s=arc-20160816; b=OryLRJskQbHql6qr1LoxLBgMul2zpqSIsaeUZdf8CtsPcMzUfijBflJyl80NvMXrdP K0G0I711WVrjys6epPiZyUIBuJGON0KKqQZSEULpAPFKWp3pX0WIZVBrA1SR6KxcLXyq KxT/Cu/fWHX8j3Ua/IJwqGx1HftdfQJ1ByTt57wflRIvm1srLN1fL9LX6I7m3f3d/s9w cn9Zs4XQLD8NWSEOJcC9Cq4wCsCHEsh+H2tjsQNgXy0VMXqnZrKeN9UZlH55LyJhJBks gKHpzxW1yV6VtpmJuJ1sSmtekYw+t7IuRnZqQ7FGoKIGNqe0pLqBns7qFpbH0kaedu7G cCIQ== 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 :dkim-signature; bh=eXp82q1GVKGs5UDAmL5B3Qb2IO15a4RE0ejCjRJwazM=; b=wOSjko9w7Z0zWuKS1254nAFtIXnh1wGwWlWaoXm360aDTIukFzSwsKX+lrkMuZB5Ky sWoxSSQuGh3OwE6D5aS+e1f2f7yHEKc9I7gj1O5w/4mF7dNPg+fqVi1tvFXjHpTGQkdH zrTh42Lp6vYBLkHTy/GVWYLIclqaoGCR5JFS+757BqE6Z9kOD5rVwypqMBY7R/MH2gjT iYKncUdKKM8LwMPgGJ4P6t3oZkHB9ZvL0iC85LsTcDAgORCvZ2ZPdb54/onG1VwYeSaq VbqxplyRIMFVXlGDEfKT2cQHfe5vdg/r+2idDCurnJgvbd+u412NvQYzt+T6FWP3s8gm aeew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nx08HokV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t31-20020a63445f000000b00398580600aasi3608356pgk.433.2022.04.12.13.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:17:49 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=nx08HokV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FA848BF3D; Tue, 12 Apr 2022 13:01:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234789AbiDKXlY (ORCPT + 99 others); Mon, 11 Apr 2022 19:41:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbiDKXlR (ORCPT ); Mon, 11 Apr 2022 19:41:17 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27EACE96; Mon, 11 Apr 2022 16:39:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id ADD321F42D86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649720339; bh=kCYEDdovCVMqMqsKDmHApZZjAvEttkamvjOxDRb8Y/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nx08HokVCqLuQkUWX3rv2fv4uikfMucJnDiwNH7NGzpcW8362/JzsFA+T8pnB9rNP Nh2tUIEYoUm4h2VGRFzMQLXuy7mgTy+c0khut3jaDscDSqMMvUMEsukDJLG8tD4MDL vj4ggPnYxoa3v867GyElYDQzvBgZSBXa3mIdsCHhXm+tguMql+U+E5xj8wPXMcK7A6 0uh9uoi/rCbMu8A/I2IZxr0lSB4su90p49BTCC/554FnGngEacX7JTRv7MVDZF7lqU cVn2/2/romM/vCOmLU+jii/LndRccn1z1q7pRnyFpKcq7XTRFlJuAGp/K99F3f919c C0mZWcTbiCkjQ== From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Sebastian Reichel , Linus Walleij , Philipp Zabel , Greentime Hu , Vincent Chen , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Yoshinori Sato , Rich Felker , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , "Rafael J. Wysocki" , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Pavel Machek , Lee Jones , Andrew Morton , Guenter Roeck , Daniel Lezcano , Andy Shevchenko , Ulf Hansson , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Cc: linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v7 01/20] notifier: Add blocking_notifier_call_chain_is_empty() Date: Tue, 12 Apr 2022 02:38:13 +0300 Message-Id: <20220411233832.391817-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411233832.391817-1-dmitry.osipenko@collabora.com> References: <20220411233832.391817-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add blocking_notifier_call_chain_is_empty() that returns true if call chain is empty. Signed-off-by: Dmitry Osipenko --- include/linux/notifier.h | 2 ++ kernel/notifier.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 87069b8459af..d4717bc0ab85 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -173,6 +173,8 @@ extern int blocking_notifier_call_chain_robust(struct blocking_notifier_head *nh extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh, unsigned long val_up, unsigned long val_down, void *v); +extern bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh); + #define NOTIFY_DONE 0x0000 /* Don't care */ #define NOTIFY_OK 0x0001 /* Suits me */ #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ diff --git a/kernel/notifier.c b/kernel/notifier.c index ba005ebf4730..4ed6bda8f127 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -323,6 +323,19 @@ int blocking_notifier_call_chain(struct blocking_notifier_head *nh, } EXPORT_SYMBOL_GPL(blocking_notifier_call_chain); +/** + * blocking_notifier_call_chain_is_empty - Check whether notifier chain is empty + * @nh: Pointer to head of the blocking notifier chain + * + * Checks whether notifier chain is empty. + * + * Returns true is notifier chain is empty, false otherwise. + */ +bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh) +{ + return !rcu_access_pointer(nh->head); +} + /* * Raw notifier chain routines. There is no protection; * the caller must provide it. Use at your own risk! -- 2.35.1