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 73AC0C4332F for ; Thu, 28 Oct 2021 11:01:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52A376115C for ; Thu, 28 Oct 2021 11:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbhJ1LDk (ORCPT ); Thu, 28 Oct 2021 07:03:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:7883 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230126AbhJ1LDi (ORCPT ); Thu, 28 Oct 2021 07:03:38 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10150"; a="291216588" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="291216588" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 04:01:11 -0700 X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="447649034" 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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