Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5520577iob; Mon, 9 May 2022 19:20:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFK7jjFa1r5lz5C8UIC3Dz+74PwXZjXw3U5xMDGQfKSGNNyAaXvWy+bTwZDUwb9eNLUcvt X-Received: by 2002:a63:6507:0:b0:3c6:d417:914b with SMTP id z7-20020a636507000000b003c6d417914bmr4347514pgb.475.1652149242140; Mon, 09 May 2022 19:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652149242; cv=none; d=google.com; s=arc-20160816; b=krFKiasmbUYy1iiVsKZvjruQZ7wU0UdZ3aDf1AgJfDZG6WO9RGJViiBHugZOVwiuGR 9bVL/R9Qdtsw4TqA1joc5OgB/K0v0iZTb7Y5kn8SLpqVF557S4JE4XRzNab/M7BbSgb+ VambX6Br12C5Wut7QfG3/Fy89M1FlL1WtzAkzFGu+Pp6VDE/BlQSmYHXKn3CVeRAJKDU gO87CKCesWBBxgvC6BVbsCDe/aDdyl5QvXaQX4tnRP4WW6d00c8H8pdrBOehJuY8gAej plvgbt1L42b6RPot4dilnf/Rh2rSPJT8DJ3lwN2Bssgqt4H9y03ZJRKlTcGJNgkrS1hf NU3g== 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=sMryYZ/WZpclXZloqP/yj4EyjeyCBxkMqHg5WOtOZ9E=; b=AsxMO8PyeJGyDcVUde1+rM7xuemeRqCUXb7AC4Q6Ps91s6bEtxSH8b1GfBuIAotBnR ilmVbQ0X/AI3FPrYL4xS366rpSNX8Q6SiuP4svzG24NMjt/bw+8nnQYRJxjMIwx3ycox EzOlAcKJdGX/virVkWW0HNZvvdK3CW66tarWF5z3Ews9j/hatrLMs/yWWi90A5nnd5/v g06k8CR+mBKMewcD8Lhw/iWBH6lLUGV0cK3YIeg+aFQibLHy0nCJn1EEGq2Pkvv/Ok/C GG8i7bHNgnlU6FZHUircNqj+SKfQ3FMZLLOyix8WjtlmEyZN8iseO36B240W5y247lBl 0clg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YhxhnTI9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j37-20020a634a65000000b003c64100b08dsi16241918pgl.507.2022.05.09.19.20.24; Mon, 09 May 2022 19:20:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YhxhnTI9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232587AbiEIXhS (ORCPT + 99 others); Mon, 9 May 2022 19:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232535AbiEIXhG (ORCPT ); Mon, 9 May 2022 19:37:06 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC1721B169; Mon, 9 May 2022 16:33:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 5E2CD1F4195B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652139187; bh=fLk9P/8GBXV/gow9gw4QGytkxQFyLU71HSagZYJ8o5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YhxhnTI9NvbLfj67ZcRhPX86XV8hnVmvB2+NtO95NIqYARKmayRkU9nopvPEQT8Me W2nnVXm0D2hSk50qdVKpG+UHHCKbjvMu3DEa3LaZ5ZzUrWUuvj9BT9vVQEbRgMTGth m/otgMrFJikr7jdN+Q40cxAuxrylVYKjYtjLq4WIIwC/OBLKnmv6GgSMh0Y+uGoD/L 1hhg9iEoCH1Pdja7DSW7Pk4PTjR/qfW5ULonIQQvmnkEROj2Q2BUmPpY9d1Q7Ecq17 xmwMvW1NNWwMi/Qww4oq/Msiaz19CBS0NzvNZDBPy+6YaGpixClw4HeYhLf1899Vzj FC16JVNO96lKg== 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 v8 01/27] notifier: Add atomic_notifier_call_chain_is_empty() Date: Tue, 10 May 2022 02:32:09 +0300 Message-Id: <20220509233235.995021-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220509233235.995021-1-dmitry.osipenko@collabora.com> References: <20220509233235.995021-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=unavailable 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 atomic_notifier_call_chain_is_empty() that returns true if given atomic call chain is empty. Reviewed-by: Michał Mirosław 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..95e2440037de 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 atomic_notifier_call_chain_is_empty(struct atomic_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..aaf5b56452a6 100644 --- a/kernel/notifier.c +++ b/kernel/notifier.c @@ -204,6 +204,19 @@ int atomic_notifier_call_chain(struct atomic_notifier_head *nh, EXPORT_SYMBOL_GPL(atomic_notifier_call_chain); NOKPROBE_SYMBOL(atomic_notifier_call_chain); +/** + * atomicnotifier_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 atomic_notifier_call_chain_is_empty(struct atomic_notifier_head *nh) +{ + return !rcu_access_pointer(nh->head); +} + /* * Blocking notifier chain routines. All access to the chain is * synchronized by an rwsem. -- 2.35.1