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 5136BC433EF for ; Thu, 28 Oct 2021 11:19:50 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 C549F610FC for ; Thu, 28 Oct 2021 11:19:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C549F610FC 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.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Hg34N3Vd0z3c8s for ; Thu, 28 Oct 2021 22:19:48 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.intel.com (client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=andriy.shevchenko@linux.intel.com; receiver=) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Hg2hC1lPjz2xZL; Thu, 28 Oct 2021 22:02:17 +1100 (AEDT) X-IronPort-AV: E=McAfee;i="6200,9189,10150"; a="230235267" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="230235267" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.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 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 X-Mailman-Approved-At: Thu, 28 Oct 2021 22:18:33 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Rich Felker , linux-ia64@vger.kernel.org, Tomer Maimon , Santosh Shilimkar , "Rafael J . Wysocki" , Boris Ostrovsky , Catalin Marinas , Linus Walleij , Dave Hansen , x86@kernel.org, Tali Perry , "James E.J. Bottomley" , Thierry Reding , Guo Ren , Pavel Machek , "H. Peter Anvin" , linux-riscv@lists.infradead.org, Vincent Chen , Will Deacon , Greg Ungerer , Stefano Stabellini , Benjamin Fair , Yoshinori Sato , Krzysztof Kozlowski , linux-sh@vger.kernel.org, Lee Jones , Helge Deller , Daniel Lezcano , Russell King , linux-csky@vger.kernel.org, Jonathan Hunter , Tony Lindgren , Chen-Yu Tsai , Ingo Molnar , Geert Uytterhoeven , xen-devel@lists.xenproject.org, linux-mips@vger.kernel.org, Guenter Roeck , Len Brown , Albert Ou , linux-pm@vger.kernel.org, Jonathan =?iso-8859-1?Q?Neusch=E4fer?= , Vladimir Zapolskiy , linux-acpi@vger.kernel.org, linux-m68k@lists.linux-m68k.org, Mark Brown , Borislav Petkov , Greentime Hu , Paul Walmsley , linux-tegra@vger.kernel.org, Thomas Gleixner , linux-omap@vger.kernel.org, Nancy Yuen , linux-arm-kernel@lists.infradead.org, Juergen Gross , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, Nick Hu , Avi Fishman , Patrick Venture , Liam Girdwood , linux-kernel@vger.kernel.org, Palmer Dabbelt , Philipp Zabel , Paul Mackerras , Andrew Morton , linuxppc-dev@lists.ozlabs.org, openbmc@lists.ozlabs.org, Joshua Thompson Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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