Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp623555pxb; Tue, 1 Feb 2022 07:11:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNz0kVnyEZwYxXCyRdTaBeIas3RKzWLh9fMpyngdk0Jwt+CdGhlUvPsFO3s2vyt0A8CHOv X-Received: by 2002:a17:907:6d8c:: with SMTP id sb12mr21858509ejc.23.1643728311935; Tue, 01 Feb 2022 07:11:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643728311; cv=none; d=google.com; s=arc-20160816; b=VUuEFP8aw8psN7LDnNzx+SiGmj4B2pbjbGENpuNLFcljfBx746EbybqTilRbkRx8Jz kiCJtSj86dF0myLDy+0gWwFwHGkW/QAs4vfFy/BcVDBX2Nx94tesODHBbB0TXaJGl1Ge opt9V+HU1IkivmTz2QrV1hPNUd0nR6xQQrbaj5boRg349+jWzfdUBcC4C03fXOio8SNH g6F1ewfnKN9IIQni+iSB/3zgSbJi95Ukrz36uOjiLRpCqzxtacsqMyPh0efX2I1L36uw 3TxVtZEJt3N4B8NTVxlUtetEV30D8r7qUukmKCEDZaDLZJHpnyiz8dIYasvtJRR603Dq SgYg== 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=6/CD3Yv31GR8y8GlEUTCAOWsPgz1l4zxLQQTTW1e5nA=; b=UwYBXeBougUhQGMc/N67a08+KTxoVgca8nkgOUGpTrFxEFIAuKKAtfGnsdSLQl3WXZ urEbaIapXiTQ+y+lZ24rqwrJwFqlJ1IK1EKwwZdXqaEybMq+EV5V41lQmGXAW4xwN1R7 RczOqkErOsqKgliNqDXlBQC+jegroTFgpE2zky2tw9fuj/LPL/mSySeFPGisYQ1fOKlu 572+D/1xUTmYu9YIv5Ki++Py9P1bs7oDy0nHsX1VOt/InIy3PQkdGDzht3eoPfFabkXj MDVX5pnxgNv+1jirrbgatzUZr9NI+Q5jbd08OC9SsCEWNhDZYFNihfr6CcR0A70EkiOx fB7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eMhJF7gr; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn42si13406183ejc.902.2022.02.01.07.11.26; Tue, 01 Feb 2022 07:11:51 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=eMhJF7gr; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356969AbiA3Xhd (ORCPT + 99 others); Sun, 30 Jan 2022 18:37:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234816AbiA3Xh3 (ORCPT ); Sun, 30 Jan 2022 18:37:29 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE943C061714; Sun, 30 Jan 2022 15:37:28 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id x7so23275967lfu.8; Sun, 30 Jan 2022 15:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6/CD3Yv31GR8y8GlEUTCAOWsPgz1l4zxLQQTTW1e5nA=; b=eMhJF7grCwjcHhcO0w6NJcJWCpwGV9U0gCsMg0TGwobGBXDG7Vx/L97nAcGbsxn/0t lOUlBHMB48PlUMU15vUurm7j0pvN5BFXkJhFXzQtsg8F+BsiLTVvb3ey/9EANWthyhTT we8glm85/CmQP0QZ8+T+Lm4inD6Om2LbGaB9R6csyvcPXIEYpw/bulY/B/lTyYKOPz5Q wxGxNLfaFVrUEh4p7rOa6O9dbsq2pKYOYPMchljsZ3p2oxyKvQjmDp8knc5kaAt3dCPj bpgTHYROYSaO5OyxFwKNgiQ6VFzTC+FU7O5VMWWPycH5YgdBO3xjR5PNbDcl/bJI2s7Z GBBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6/CD3Yv31GR8y8GlEUTCAOWsPgz1l4zxLQQTTW1e5nA=; b=oCwx0ZXBJ/7z/xQwXxzQsTAlRF+VAiOdQBJ4WlMFoFzuUE2dH/Jd4evzAHQ7NZ7Mak KGmyoUhpwcaO1ZcPscU69TIif/u6GXx4XCxghi3RzvC1WvsvD6mJwzEbQ9W4VOkHDg2G E2uruOzmyXcGWMl8b6OU94M4kaIh7fEMNIKB6O0W7KUPTmbH135Kyy8pDYjwNBjqE29J ekpspjDZ7V/A5JIvSYDdv/zTwK/8Abp3z3hXZ6xPpEVqwtMEexHW3T07Pci6NeAJgKmw JZpDc6PY6KZuIPHXlLEGtJuKsOR1sQZOtOQBT3J6xyHxcf4b8OaFnR1Km+Y+0ifhKTes m/vA== X-Gm-Message-State: AOAM532bVBMNhKjIqzo/2M1LAbS7ae0Q1z2QPRubSx2jB3XcejPsSbGv H4s2pCh9lNQaI1RxUEIGPnI= X-Received: by 2002:a05:6512:38a6:: with SMTP id o6mr13194842lft.4.1643585847142; Sun, 30 Jan 2022 15:37:27 -0800 (PST) Received: from localhost.localdomain (109-252-138-126.dynamic.spd-mgts.ru. [109.252.138.126]) by smtp.gmail.com with ESMTPSA id a24sm1262950ljp.112.2022.01.30.15.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jan 2022 15:37:26 -0800 (PST) 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 , alankao@andestech.com, "K . C . Kuen-Chern Lin" , =?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 v6 01/21] notifier: Add blocking_notifier_call_chain_is_empty() Date: Mon, 31 Jan 2022 02:36:58 +0300 Message-Id: <20220130233718.21544-2-digetx@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220130233718.21544-1-digetx@gmail.com> References: <20220130233718.21544-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.34.1