From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99EFD225DA; Tue, 13 Feb 2024 10:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819936; cv=none; b=hFKrSj/QUzAdZo5nTZr2v6Bmd4JSz9/71CAnYdwB6BqSHVQbDwwZyccVoE8ag4AQVKmrxgGoPFfKxH/FqdaUygE9z08lJgU+Y8+83Ynz51y9ff0HomiAmrIXze7WP3I76rJRv449Kg4Fpxk1TGMhJ9x7poA3BadH3yRxPmPzQDk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707819936; c=relaxed/simple; bh=+XtzId9m0katE1bX/fV/aC/LwyQ0Y6TQgq6b1bfmyKo=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nGWGmDkGW8efTUNOvPgVv/mbHXw3eWW/yWs5nGnGHwiDB6OO2WNQeuCZGg3YGv1aZ6psTSWQs+qzZGEZuTfWvLoOZiw0BbctMeTjFPEwzMO+3P9ZVAi9pIJKEFo55Uoogr/Z5bkRJkAAwxKBAEFDgYTnlFaT14y+6rdDVjNlefA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TYy726SGSz6D92Z; Tue, 13 Feb 2024 18:22:06 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 7D98C140519; Tue, 13 Feb 2024 18:25:31 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 13 Feb 2024 10:25:30 +0000 Date: Tue, 13 Feb 2024 10:25:29 +0000 From: Jonathan Cameron To: Andy Shevchenko CC: Jonathan Cameron , , "Rafael J . Wysocki" , Len Brown , , Greg Kroah-Hartman , Daniel Scally , "Heikki Krogerus" , Sakari Ailus , Julia Lawall , Nuno =?ISO-8859-1?Q?S=E1?= , Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Peter Zijlstra Subject: Re: [PATCH v2 03/14] device property: Introduce device_for_each_child_node_scoped() Message-ID: <20240213102529.00003bf2@Huawei.com> In-Reply-To: References: <20240211192540.340682-1-jic23@kernel.org> <20240211192540.340682-4-jic23@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To lhrpeml500005.china.huawei.com (7.191.163.240) On Mon, 12 Feb 2024 14:10:57 +0200 Andy Shevchenko wrote: > On Sun, Feb 11, 2024 at 07:25:29PM +0000, Jonathan Cameron wrote: > > From: Jonathan Cameron > > > > Similar to recently propose for_each_child_of_node_scoped() this > > new version of the loop macro instantiates a new local > > struct fwnode_handle * that uses the __free(fwnode_handle) auto > > cleanup handling so that if a reference to a node is held on early > > exit from the loop the reference will be released. If the loop > > runs to completion, the child pointer will be NULL and no action will > > be taken. > > > > The reason this is useful is that it removes the need for > > fwnode_handle_put() on early loop exits. If there is a need > > to retain the reference, then return_ptr(child) or no_free_ptr(child) > > may be used to safely disable the auto cleanup. > > ... > > > +#define device_for_each_child_node_scoped(dev, child)\ > > Missing space before backslash, but I would rather to make them to be TABed to > the same column. Oops. I spotted I messed this up bug clearly failed to fix it before sending out. > > > + for (struct fwnode_handle *child __free(fwnode_handle) = \ > > + device_get_next_child_node(dev, NULL); child; \ > > Please, move child to a separate line, so we will easily see the all three > parameters of the for-loop. That said, indent the assignment to the right as > well. Indent makes sense - but (to save another respin) how far? Next tab stop will be a bit random looking but I guess nothing else makes more sense. > > > + child = device_get_next_child_node(dev, child)) > > With the above addressed, > Reviewed-by: Andy Shevchenko Thanks, >