Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp389515lqm; Wed, 1 May 2024 04:04:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZJmuoDRQhvcUe85LE7pLKuBUYe70r82mfPhZvXD2dTWdn027EG0WPM7b6rS1iu+z3wtf8LvX+t+mfzOPBNRGi3UdvIPJUZMcUTOlclQ== X-Google-Smtp-Source: AGHT+IGBGl/XFUsATJtGBLPkTKy0FNU0+UHZvmGB16JzgzPWAXC6qhD7knHSsLorcBkfd33KsEbg X-Received: by 2002:a17:90b:895:b0:2af:8959:2cc with SMTP id bj21-20020a17090b089500b002af895902ccmr2052181pjb.9.1714561466648; Wed, 01 May 2024 04:04:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714561466; cv=pass; d=google.com; s=arc-20160816; b=PYriTSQyVEbdnX6LEBIQJx3tfC0nu1ydij/PWfJSOZxMfDEDa5/jSMVGqtQBMOVcXZ 2n/J3u7M7dGF0DuTMyZCaTdwIEpee6wu5/MPTTrvSM1w8ctRrbOMOt9kWlHTPJ6xsYUP i8/u0d2mQjICXXWzDkYV7/O8ZVrTybEOCTL0Ui7xt5kfJwxFJ4snYAnI35C+7f39Dp4j niiJNetdl+51960kg2AlqGIxgbVbfjUggRKglo6DO595S6Vn2+fbMOdX6QFqsKVGxjp6 wn2DH3n2qlf2bsXCXmX8cbP2wJGavG1hGSZKuQgQA03/AdsrNAFFGtJbJ/Ka+EALI/kU dVdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=2Fj+d1MZbcD0GX5YabyMrU7kzy1y6wTgx8pUaDtyYv8=; fh=bQlqM4dxJClNQA0xX5mpfXFh9jKlQj77DZ2dE4Ht6lU=; b=cn6yqcmrHs8JqsVSowXdCMCl6Rt+yvU+nXrdvmK+FNi1mz553OEZwexqS+UnpXDpYF Ft+w4I0KIRd3VgisszM1ZnlCA3pepG3Cturap6TFNf9TA8WYr61ufzyGDeDzGiVeITG5 9WA61lxsGMBIv7ATRFQyx3zEQDDLY4Obs7gqqvV7udHZ6b+XjZzxC/Eh43hv5Exfo6TN aLI9xVKbvYEdBkx9y00UFNRk0xKfgpKgEPnQub5K1OzbLhRkZ1TvohyBkD/MHmb62kfh 8SXx8L9Aak1Gj6oJzbDNFpT4sWeekj6E0XM3GTHb1G+3XgWNq7hlofWbQQ7rqFHJE8er JmeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165163-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165163-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j15-20020a17090ae60f00b002b2723bafdesi1266926pjy.103.2024.05.01.04.04.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 04:04:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165163-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-165163-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165163-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C45332856B6 for ; Wed, 1 May 2024 11:04:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 028A756452; Wed, 1 May 2024 11:04:17 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D3B048CE0 for ; Wed, 1 May 2024 11:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561456; cv=none; b=SjdUq3O4WRFZNkjeJwhrjozWK+qo7SQ1huJ5mLtlvV274hMP8mN8HLUeaEN5+rqVQMQ1Ve0BLKEVHo36cGyjG1rzKiddVv50HtvZuZ7RKC/hi5Hp+NMfDZOqfcibamW/h5ArV5Pe6JYcpxaEi73Zku8FAy64dUL/yY9RokiHkIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561456; c=relaxed/simple; bh=BMvyK2ejIFFU2gxEqBo7gg/tUhjpicT6PIvc8ob7Ttg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rf8+syI0VJf0SKrgq8K6TjeCTnSJCQiotFEVMqZeKRWAFRQ/fUtEEpsQ+KVst+FubxqRYKWXcEKl4up52SHYRQkGq8uJ039YmwNo391hsIR14IqVXokQBCIASNyYF5HHy3PRIYJ7tfAVTztLNn4e/sjX1pAHtuhdhVCwizdtBOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0BF32F4; Wed, 1 May 2024 04:04:33 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD70B3F793; Wed, 1 May 2024 04:04:06 -0700 (PDT) Date: Wed, 1 May 2024 12:04:04 +0100 From: Sudeep Holla To: Vincenzo Mezzela Cc: gregkh@linuxfoundation.org, javier.carrasco.cruz@gmail.com, Sudeep Holla , julia.lawall@inria.fr, linux-kernel@vger.kernel.org, rafael@kernel.org, skhan@linuxfoundation.org Subject: Re: [PATCH 1/2 v3] drivers: reorganize do-while loops Message-ID: References: <20240424125401.oxvt5n64d7a57ge3@bogus> <20240501094313.407820-1-vincenzo.mezzela@gmail.com> <20240501094313.407820-2-vincenzo.mezzela@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501094313.407820-2-vincenzo.mezzela@gmail.com> Hi, $subject seems to be too generic. Please change it to something like drivers: arch_topology: Refactor do-while loops On Wed, May 01, 2024 at 11:43:12AM +0200, Vincenzo Mezzela wrote: > Test c = of_get_child_by_name() failures using "if(!c) break;" instead of > having the body of the loop all within the "if(c){ }" body. > Drop the above description which is clear from the code. Just mention it as refactor do-while look to move the break condition inside the loop. > This modification is required s/required/in preparation/ > to move the declaration of the device_node > directly within the loop and take advantage of the automatic cleanup > feature provided by the __free(device_node) attribute. > > Signed-off-by: Vincenzo Mezzela > --- > drivers/base/arch_topology.c | 107 ++++++++++++++++++----------------- > 1 file changed, 55 insertions(+), 52 deletions(-) > > diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c > index 024b78a0cfc1..ea8836f0bb4b 100644 > --- a/drivers/base/arch_topology.c > +++ b/drivers/base/arch_topology.c [...] > @@ -599,48 +600,48 @@ static int __init parse_cluster(struct device_node *cluster, int package_id, > do { > snprintf(name, sizeof(name), "cluster%d", i); > c = of_get_child_by_name(cluster, name); > - if (c) { > - leaf = false; > - ret = parse_cluster(c, package_id, i, depth + 1); > - if (depth > 0) > - pr_warn("Topology for clusters of clusters not yet supported\n"); > - of_node_put(c); > - if (ret != 0) > - return ret; > - } > + if (!c) > + break; > + > + leaf = false; > + ret = parse_cluster(c, package_id, i, depth + 1); > + if (depth > 0) > + pr_warn("Topology for clusters of clusters not yet supported\n"); > + of_node_put(c); > + if (ret != 0) > + return ret; > i++; > - } while (c); > + } while (1); > > /* Now check for cores */ > i = 0; > do { > snprintf(name, sizeof(name), "core%d", i); > c = of_get_child_by_name(cluster, name); > - if (c) { > - has_cores = true; > - > - if (depth == 0) { > - pr_err("%pOF: cpu-map children should be clusters\n", > - c); > - of_node_put(c); > - return -EINVAL; > - } > + if (!c) > + break; > > - if (leaf) { > - ret = parse_core(c, package_id, cluster_id, > - core_id++); > - } else { > - pr_err("%pOF: Non-leaf cluster with core %s\n", > - cluster, name); > - ret = -EINVAL; > - } > + has_cores = true; > > + if (depth == 0) { > + pr_err("%pOF: cpu-map children should be clusters\n", c); > of_node_put(c); > - if (ret != 0) > - return ret; > + return -EINVAL; > } > + > + if (leaf) { > + ret = parse_core(c, package_id, cluster_id, core_id++); > + } else { > + pr_err("%pOF: Non-leaf cluster with core %s\n", > + cluster, name); Extra space before 'cluster' ? checkpatch must have complain if I am not reading this correctly. -- Regards, Sudeep