From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 902913DAAC3; Wed, 26 Aug 2026 09:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787737915; cv=none; b=EPRVu7+x/TuW9pDgh0v4CP93eoQ6iPJKvgqYSRfAko3CKK0nSxqIVwhzfC4Rh+wzyUon2NDFMynvzD6deHudDD5jH+2tDCO8D4aGOQlrM3RW1+7Nafgmd9RtxLTI3cMxPjv1W3YGNNKXSwHM4a5+fPgdQzgMlLWPXQD3mPIiUbk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787737915; c=relaxed/simple; bh=im4eZW+9wIZ9JGZTAfMHMVs13K7x67s6Foy9WlnlbNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iX6i5zeZDTpbnvxCUh+sAPHXkO/JroMZf8xvi3NJ9G0T6Y41bMUjLYh/uwNR6Xd8CaCyL5jPyEJWp0dW9G46GCV9KRMbKE4txSqBIL/q1H5VhKQlB5dcQcxBTt7sS1LbjUu+2RPqPvhDebxJ525ZtafZl1KtHtIGNpHJMIh1bmY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OVZL3pHv; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OVZL3pHv" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BF37C4E413BC; Wed, 26 Aug 2026 09:51:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 93C39604EC; Wed, 26 Aug 2026 09:51:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id CCACC11C7AD5A; Wed, 26 Aug 2026 11:51:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1787737909; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=pUjQSxF5HYREAJufTO0xLlCZpiys5dw7UOklKZJrfoE=; b=OVZL3pHvOgiU9C78i7kotsIyjE7HYeMP8zak34gA39kAQ+CT/AodtXechSyw8F/He2I4F9 InfoVIdfAWZ+TMdCKChbAI7/ZemoeWz9loB2uurf/ARZSvGMGr/+8GB+t+nelxTEiq7TSy hSC0hGDi9+uZ1g1ShE2wxki1XkaPAs1gHCwrZbdAMY99rtUnxNipuV5ZWTPc9F7Z9Pal2f A8CF4wQ9vH+4e7C0Vlu9xaBVN7IbA5z1MqybOQm22GAOMajEFt19zdJWB1jhvhcQ+d92m9 2FCR/SidlHu3ilCCYFHDy7V9z3LW96uHUaZRBju+446/O5SmfGZD0Ie1P2gBoA== From: Herve Codina To: David Gibson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Laurent Pinchart , David Lechner , Ayush Singh , Geert Uytterhoeven , devicetree-compiler@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree-spec@vger.kernel.org, Hui Pu , Ian Ray , Luca Ceresoli , Thomas Petazzoni , Herve Codina Subject: [RFC PATCH v2 23/74] dtc: Add support for export symbols sorting Date: Wed, 26 Aug 2026 11:48:52 +0200 Message-ID: <20260826094950.1088288-24-herve.codina@bootlin.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260826094950.1088288-1-herve.codina@bootlin.com> References: <20260826094950.1088288-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: devicetree-spec@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 dtc can sort items when the command line --sort option is set. Add support for export symbols sorting when this option is used. Signed-off-by: Herve Codina --- livetree.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/livetree.c b/livetree.c index 35cf1de5..fe0f300b 100644 --- a/livetree.c +++ b/livetree.c @@ -1028,6 +1028,42 @@ static void sort_properties(struct node *node) free(tbl); } +static int cmp_symbol(const void *ax, const void *bx) +{ + const struct symbol *a, *b; + + a = *((const struct symbol * const *)ax); + b = *((const struct symbol * const *)bx); + + return strcmp(a->name, b->name); +} + +static void sort_exportsyms(struct node *node) +{ + int n = 0, i = 0; + struct symbol *symbol, **tbl; + + for_each_symbol(node->exportsymlist, symbol) + n++; + + if (n == 0) + return; + + tbl = xmalloc(n * sizeof(*tbl)); + + for_each_symbol(node->exportsymlist, symbol) + tbl[i++] = symbol; + + qsort(tbl, n, sizeof(*tbl), cmp_symbol); + + node->exportsymlist = tbl[0]; + for (i = 0; i < (n-1); i++) + tbl[i]->next = tbl[i+1]; + tbl[n-1]->next = NULL; + + free(tbl); +} + static int cmp_subnode(const void *ax, const void *bx) { const struct node *a, *b; @@ -1069,6 +1105,7 @@ static void sort_node(struct node *node) struct node *c; sort_properties(node); + sort_exportsyms(node); sort_subnodes(node); for_each_child_withdel(node, c) sort_node(c); -- 2.55.0