From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55BA0C433F5 for ; Thu, 28 Oct 2021 11:01:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E675610F8 for ; Thu, 28 Oct 2021 11:01:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E675610F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.217857.378062 (Exim 4.92) (envelope-from ) id 1mg39n-0005FT-SF; Thu, 28 Oct 2021 11:01:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 217857.378062; Thu, 28 Oct 2021 11:01:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mg39n-0005FM-Nd; Thu, 28 Oct 2021 11:01:15 +0000 Received: by outflank-mailman (input) for mailman id 217857; Thu, 28 Oct 2021 11:01:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mg39m-0005F6-JP for xen-devel@lists.xenproject.org; Thu, 28 Oct 2021 11:01:14 +0000 Received: from mga07.intel.com (unknown [134.134.136.100]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5cc50fd4-37de-11ec-849d-12813bfff9fa; Thu, 28 Oct 2021 11:01:13 +0000 (UTC) Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 04:01:11 -0700 Received: from smile.fi.intel.com ([10.237.72.184]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 04:00:54 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1mg395-001jY2-If; Thu, 28 Oct 2021 14:00:31 +0300 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5cc50fd4-37de-11ec-849d-12813bfff9fa X-IronPort-AV: E=McAfee;i="6200,9189,10150"; a="293839153" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="293839153" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="447649034" Date: Thu, 28 Oct 2021 14:00:31 +0300 From: Andy Shevchenko To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Lee Jones , "Rafael J . Wysocki" , Mark Brown , Andrew Morton , Guenter Roeck , Russell King , Daniel Lezcano , Ulf Hansson , Catalin Marinas , Will Deacon , Guo Ren , Geert Uytterhoeven , Greg Ungerer , Joshua Thompson , Thomas Bogendoerfer , Nick Hu , 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 , Len Brown , Santosh Shilimkar , Krzysztof Kozlowski , Linus Walleij , Chen-Yu Tsai , Jonathan =?iso-8859-1?Q?Neusch=E4fer?= , Tony Lindgren , Liam Girdwood , Philipp Zabel , Vladimir Zapolskiy , Avi Fishman , Tomer Maimon , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , Pavel Machek , linux-arm-kernel@lists.infradead.org, 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, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, xen-devel@lists.xenproject.org, linux-acpi@vger.kernel.org, linux-omap@vger.kernel.org, openbmc@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v2 03/45] notifier: Add atomic/blocking_notifier_has_unique_priority() Message-ID: References: <20211027211715.12671-1-digetx@gmail.com> <20211027211715.12671-4-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211027211715.12671-4-digetx@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Thu, Oct 28, 2021 at 12:16:33AM +0300, Dmitry Osipenko wrote: > Add atomic/blocking_notifier_has_unique_priority() helpers which return > true if given handler has unique priority. ... > +/** > + * atomic_notifier_has_unique_priority - Checks whether notifier's priority is unique > + * @nh: Pointer to head of the atomic notifier chain > + * @n: Entry in notifier chain to check > + * > + * Checks whether there is another notifier in the chain with the same priority. > + * Must be called in process context. > + * > + * Returns true if priority is unique, false otherwise. Why this indentation? > + */ > +bool atomic_notifier_has_unique_priority(struct atomic_notifier_head *nh, > + struct notifier_block *n) > +{ > + struct notifier_block **nl = &nh->head; > + unsigned long flags; > + bool ret = true; > + > + spin_lock_irqsave(&nh->lock, flags); > + > + while ((*nl) != NULL && (*nl)->priority >= n->priority) { ' != NULL' is redundant. > + if ((*nl)->priority == n->priority && (*nl) != n) { > + ret = false; > + break; > + } > + > + nl = &((*nl)->next); > + } > + > + spin_unlock_irqrestore(&nh->lock, flags); > + > + return ret; > +} ... > + /* > + * This code gets used during boot-up, when task switching is > + * not yet working and interrupts must remain disabled. At One space is enough. > + * such times we must not call down_write(). > + */ > + while ((*nl) != NULL && (*nl)->priority >= n->priority) { ' != NULL' is not needed. > + if ((*nl)->priority == n->priority && (*nl) != n) { > + ret = false; > + break; > + } > + > + nl = &((*nl)->next); > + } -- With Best Regards, Andy Shevchenko