Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2422193pxu; Fri, 18 Dec 2020 12:54:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzt1pLBwn5IU07vswZnNx0MNQtku/4DJGGrYuws6ZAECRb/gm8QqUM2qoAhRvnedP33TYqW X-Received: by 2002:a17:906:b24c:: with SMTP id ce12mr5745165ejb.89.1608324849283; Fri, 18 Dec 2020 12:54:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608324849; cv=none; d=google.com; s=arc-20160816; b=XaVU4odXmXsmU39BtdLJcxSEmVJJqH1lowhyd635VFguT01ZD2VrLH/YiPmOyPqgwa MLv7YxIP73EiCtPI/gxa9JQkidMugy7oFLE46PUmK7b8bNScP/2tOf2ph8DvY9EgL6kV 9NcldZcnXDDfo2iUKYAHRYwJbAoOacF/cdtIljeTwh/CxhKuprCsgoGSOb2HGcMhCnlY 0zSJPQT9NCswI9loBOuIyHT6+CB6l42RwLlqmMELh1M+Hn5f9kF07OnkPExWPUgkdRNP cawIISFkJn+k/WnBqGe5UOz0qT34+8uqZkSotH/JIrRepOZt7ioJVO1u2uAO9cRQe15F 373Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=QfML8gMtbYjonmuYo1Aw5IBZXePfgcp4p1eXT6nN7TM=; b=QohKppZt2lMY9kW2EobXdfvLW7t3UXPqY1hWnjpdaLG3YgG6fxP9CWzlfK4vi3fUzV B86koi4OvavBRidzDsPpzce3uPO4W8f9bGxGhTo5oHakQ1yMM1GTHCAmjchoSS6DmBhV 1cu2+fMxxKOXWQpr+Aq0tdT5HNhL+QD/wRQETGU4qg8yB95YDT9eqRvdnK/TXVhscGO4 osa9DU5w5PcsXgNIv8WlELQZCEArCq+AsIAebc4C5NEV/mP2CwbBPKdCqAZD3L7io4De 26G50FbWdwyne5yL7AoOzTxnkUvigl6xmK93l0anFYv2j3YcJlNaFu1HgVTzJ1Zlbkpv GkTA== 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 r4si7184557edq.6.2020.12.18.12.53.47; Fri, 18 Dec 2020 12:54:09 -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 S1727665AbgLRUaG (ORCPT + 99 others); Fri, 18 Dec 2020 15:30:06 -0500 Received: from mga14.intel.com ([192.55.52.115]:19583 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbgLRUaF (ORCPT ); Fri, 18 Dec 2020 15:30:05 -0500 IronPort-SDR: b9D8wMx1upnFcVhD3e6kWypbC1InLGntCAWm7L+ZS4WxxnsLSnBy8fSY+l2q/EhcwhlwXGbwFk UZGJmALVJoSg== X-IronPort-AV: E=McAfee;i="6000,8403,9839"; a="174729217" X-IronPort-AV: E=Sophos;i="5.78,431,1599548400"; d="scan'208";a="174729217" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 12:28:20 -0800 IronPort-SDR: 5yzWuNenkCaVFwsIYBAgOCyEqtf5UoT9DU/IvUUlQXz7LRAixKI587sSRmBBFJYsY6pOfWGTbZ WI4B8tg9PQkQ== X-IronPort-AV: E=Sophos;i="5.78,431,1599548400"; d="scan'208";a="393914420" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 12:28:15 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1kqMNI-00FgGS-2m; Fri, 18 Dec 2020 22:29:16 +0200 Date: Fri, 18 Dec 2020 22:29:16 +0200 From: Andy Shevchenko 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, sakari.ailus@linux.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, linux@rasmusvillemoes.dk, laurent.pinchart+renesas@ideasonboard.com, jacopo+renesas@jmondi.org, kieran.bingham+renesas@ideasonboard.com, linus.walleij@linaro.org, heikki.krogerus@linux.intel.com, kitakar@gmail.com, jorhand@linux.microsoft.com Subject: Re: [PATCH v2 04/12] software_node: Enforce parent before child ordering of nodes arrays Message-ID: <20201218202916.GA4077@smile.fi.intel.com> References: <20201217234337.1983732-1-djrscally@gmail.com> <20201217234337.1983732-5-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201217234337.1983732-5-djrscally@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 17, 2020 at 11:43:29PM +0000, Daniel Scally wrote: > Registering software_nodes with the .parent member set to point to a > currently unregistered software_node has the potential for problems, > so enforce parent -> child ordering in arrays passed in to > software_node_register_nodes(). > > Software nodes that are children of another software node should be > unregistered before their parent. To allow easy unregistering of an array > of software_nodes ordered parent to child, reverse the order in which > software_node_unregister_nodes() unregisters software_nodes. ... > + * Register multiple software nodes at once. If any node in the array > + * has it's .parent pointer set, then it's parent **must** have been it's => its in both cases? > + * registered before it is; either outside of this function or by > + * ordering the array such that parent comes before child. > */ ... > + const struct software_node *parent = nodes[i].parent; > + > + if (parent && !software_node_to_swnode(parent)) { Can we have parent of swnode in an array not being an swnode? Either comment that parent for swnode can be swnode only (Heikki, was it an idea?) or check if parent is of swnode type and only that apply this requirement. > + ret = -EINVAL; > + goto err_unregister_nodes; > } ... > + * Unregister multiple software nodes at once. If parent pointers are set up > + * in any of the software nodes then the array MUST be ordered such that > + * parents come before their children. Shouldn't be consistent with above, i.e. **must** ? -- With Best Regards, Andy Shevchenko