From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Thu, 28 Oct 2021 11:00:31 +0000 Subject: Re: [PATCH v2 03/45] notifier: Add atomic/blocking_notifier_has_unique_priority() Message-Id: List-Id: References: <20211027211715.12671-1-digetx@gmail.com> <20211027211715.12671-4-digetx@gmail.com> In-Reply-To: <20211027211715.12671-4-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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