Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9183224pxu; Mon, 28 Dec 2020 08:39:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjyK2NrOnlWRVcEN8JKP9JsQXJWyQSRMh1qHhhVOA2yZSfRh5ncMkUzj6F0cQZoWqxZKxo X-Received: by 2002:a17:906:2d42:: with SMTP id e2mr43406935eji.292.1609173574502; Mon, 28 Dec 2020 08:39:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173574; cv=none; d=google.com; s=arc-20160816; b=pc8lmWHYQOCMfhGthcobswWkBZ82fiOnoewgy6wCFuXvSpM6JgzJUrAVjvJf5e9ldV 8aQb2SlBAd4l48U1shb9sEN/nl/6sIPs7NivX/6LpEL7vrkrifi3/qpkvZRq44I5sAXK qNnU9sgdb4p61IwAXpzBeRQ2upxDQ4F/vqeZL+USi52Bde4KN2E3hKT+Z+z0LVXHOrzA 3N976fRrwFcCCNm7auUgjwRlyYVGyOu1PgDLOVS1szdlYM9GDqwyV2Kh2xzttgKJMl1N chCGyGwPv02kvtreJprzVtEPk9hrWCdTEyz1+HKSflAuaqc4wUn77Lae4CSGn/HM2Swi Z+ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=2plufXKZuBbmAlRf683ZzJefX4EwJGJE95O8VJ2AOjo=; b=Vac2hMTAGblktFClxszA9/sVcTOx3Qz9EQRX5wb5YAmNku+U4Zr2qdbv7slE0BlURN qu6R/MVHU5AJIYPKFWPqxhous3j+Om3UUGDegfuMNyW5DVSPU1gn9liPXFwEyWPSbKcU Rm5R4KT3AXHAnB6Z2QTRsOfdTDVo4NX97yacgqnLMRis9a7vBjMWSlo5o0TmoZsEhl8A I4HRB92TTuA5gKTHA1W4wPKAMB1Nc66mXaWaAZjp0bPLteo9bBW+Ad0fECKY2NIEvl7R jYsK+qmlD6hQEV9SIbCCriSubJBH8PpYaH0L7ebg4MgZL1ErZPiV/k8gDidFqMjgwMZ8 p90A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si22529781edq.432.2020.12.28.08.39.12; Mon, 28 Dec 2020 08:39:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731879AbgL1QhL (ORCPT + 99 others); Mon, 28 Dec 2020 11:37:11 -0500 Received: from mga14.intel.com ([192.55.52.115]:36250 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441103AbgL1QgF (ORCPT ); Mon, 28 Dec 2020 11:36:05 -0500 IronPort-SDR: 8elH/iUiOfTs1DIlPIHiCPdiqrUwmwxmeE02PqGVi6exeAcSJR1iGM8/G2yUQF4uF38DNlhzdJ V7h6g+oddIZw== X-IronPort-AV: E=McAfee;i="6000,8403,9848"; a="175625333" X-IronPort-AV: E=Sophos;i="5.78,455,1599548400"; d="scan'208";a="175625333" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 08:34:19 -0800 IronPort-SDR: b35JriF62zCofJ9ZL8YXIcOBbyZDYqOLX87t5r6MJ5OD/E6aBCqRI65Jbsfmd2sHOqg9Galo8v HbMJkot5cJDA== X-IronPort-AV: E=Sophos;i="5.78,455,1599548400"; d="scan'208";a="343785389" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Dec 2020 08:34:12 -0800 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id 84608207BF; Mon, 28 Dec 2020 18:34:10 +0200 (EET) Date: Mon, 28 Dec 2020 18:34:10 +0200 From: Sakari Ailus To: Daniel Scally Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-media@vger.kernel.org, devel@acpica.org, rjw@rjwysocki.net, lenb@kernel.org, gregkh@linuxfoundation.org, yong.zhi@intel.com, bingbu.cao@intel.com, tian.shu.qiu@intel.com, mchehab@kernel.org, robert.moore@intel.com, erik.kaneda@intel.com, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, hverkuil-cisco@xs4all.nl, m.felsch@pengutronix.de, niklas.soderlund+renesas@ragnatech.se, slongerbeam@gmail.com, heikki.krogerus@linux.intel.com, linus.walleij@linaro.org, kernel test robot , Dan Carpenter , Laurent Pinchart Subject: Re: [PATCH v3 05/14] software_node: unregister software_nodes in reverse order Message-ID: <20201228163410.GX26370@paasikivi.fi.intel.com> References: <20201224010907.263125-1-djrscally@gmail.com> <20201224010907.263125-6-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201224010907.263125-6-djrscally@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, On Thu, Dec 24, 2020 at 01:08:58AM +0000, Daniel Scally wrote: > To maintain consistency with software_node_unregister_nodes(), reverse > the order in which the software_node_unregister_node_group() function > unregisters nodes. > > Reported-by: kernel test robot > Reported-by: Dan Carpenter > Reviewed-by: Laurent Pinchart > Suggested-by: Andy Shevchenko > Signed-off-by: Daniel Scally > --- > Changes in v3 > - Fixed the dereference of the terminating NULL entry > - Comment cleanup > > drivers/base/swnode.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c > index ade49173ff8d..2d07eb04c6c8 100644 > --- a/drivers/base/swnode.c > +++ b/drivers/base/swnode.c > @@ -779,16 +779,22 @@ EXPORT_SYMBOL_GPL(software_node_register_node_group); > * software_node_unregister_node_group - Unregister a group of software nodes > * @node_group: NULL terminated array of software node pointers to be unregistered > * > - * Unregister multiple software nodes at once. > + * Unregister multiple software nodes at once. The array will be unwound in > + * reverse order (i.e. last entry first) and thus if any member of the array > + * has its .parent member set then they should appear later in the array such > + * that they are unregistered first. > */ > void software_node_unregister_node_group(const struct software_node **node_group) With this line wrapped, Reviewed-by: Sakari Ailus > { > - unsigned int i; > + unsigned int i = 0; > > if (!node_group) > return; > > - for (i = 0; node_group[i]; i++) > + while (node_group[i]) > + i++; > + > + while (i--) > software_node_unregister(node_group[i]); > } > EXPORT_SYMBOL_GPL(software_node_unregister_node_group); -- Kind regards, Sakari Ailus