Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4235981ybi; Tue, 11 Jun 2019 03:19:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPEghvvvsaK6F6i96V2q4Lhtp76QBlCg6DAp2eZOI2CD2/rwd9UvgrXoZQJ6c4yncXYXP9 X-Received: by 2002:a63:306:: with SMTP id 6mr6365569pgd.263.1560248351456; Tue, 11 Jun 2019 03:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560248351; cv=none; d=google.com; s=arc-20160816; b=hq3RDu3nv29c0//kz7Mp//Sjt9k4Y4hArViXl9XZCBrzky5G6f0UzczKk7vTYwGNbY dRV3vkXxwooOGcePzf+BVhdzpRQTCLzQ9WNnIkO7bXiy2sru2PELbCmdu4+ZjKHQnalR 4wvlsHFCS04xUpsJRD4T8fvEs6opTlAMVraoJCBggIllbly3RyDrddwmLhwPjxUwwsRo Q/FSzqyjwQ4ovP4/9PGTLadN4itp1w5rJDum3F/pHcYMTftbN1RSZqOLAW1BYUO0QU4L sv/4UsZjKiO10efiSokr30JuAc8+JToa7k5gWVi8bwxxixFQgZ4WUhRujUnKKT+gfXDd ewDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ddpPphI4L8QkhiyO6Hw+Z420+wpI3VLkQOXklBYbWeM=; b=enxTzP72bFonL4/5C2aW9IDmrDAaAKTibrFZTK+Ua9/YMjLgj5PzRlBcXVmm4xJjgR Gm8y/x59H7WAi9mTpixgh9RPd1n9dLJepSdPCbqhTjqSX/74QSP8L5VTG0lH66mi7KVO UeUh1gfdqNKaaEqugclss+riR6kOwObA/0KbQQaOQHce4UIbv98o5rnZ8J0Rro4eDx9N 6GdxNlwTAg2lC2K9HtP0y0fLH+XswPLrJj9NtUPJeGfYCe7Wsh+3rBClkysDr0ZNH36s JmHc2HTsVPkKzLGf8cEyKVfkDiBb5RaAeABTVwWfL6p0Mk/JuKiDPEKNFyON2tQRIAtr P2NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K2JiZayT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si2092520pjn.106.2019.06.11.03.18.56; Tue, 11 Jun 2019 03:19:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K2JiZayT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405328AbfFKKRZ (ORCPT + 99 others); Tue, 11 Jun 2019 06:17:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:45508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404766AbfFKKRW (ORCPT ); Tue, 11 Jun 2019 06:17:22 -0400 Received: from wens.tw (mirror2.csie.ntu.edu.tw [140.112.30.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AA17208E3; Tue, 11 Jun 2019 10:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560248241; bh=525aOxhqLv6Y8ZrnilCkqiBQziTal4f1DRT+iqnr65Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2JiZayT9S16Wgegak2Fw9lid9oEzQHR0gVib6XgxqJO4cIpqXPXpuT9Mdi1JbmeM 7rvC5A1n/JL8ggAaPY0SyaEx8vkqvkisLhvUUN2N/Yv2CzNAJ8UMm4D3PT6k+pb/jx efL6jGN9V7erjha1KNNEgZrrGDsEfsRjXU4YFMQ4= Received: by wens.tw (Postfix, from userid 1000) id 102045F92C; Tue, 11 Jun 2019 18:17:18 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Stephen Boyd , Michael Turquette Cc: Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai Subject: [PATCH v2 01/25] clk: Fix debugfs clk_possible_parents for clks without parent string names Date: Tue, 11 Jun 2019 18:16:34 +0800 Message-Id: <20190611101658.23855-2-wens@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611101658.23855-1-wens@kernel.org> References: <20190611101658.23855-1-wens@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen-Yu Tsai Following the commit fc0c209c147f ("clk: Allow parents to be specified without string names"), the parent name string is not always populated. Instead, fetch the parents clk_core struct using the appropriate helper, and read its name directly. If that fails, go through the possible sources of parent names. The order in which they are used is different from how parents are looked up, with the global name having precedence over local fw_name and indices. This makes more sense as a) the parent_maps structure does not differentiate between legacy global names and fallback global names, and b) global names likely provide more information than local fw_names. Fixes: fc0c209c147f ("clk: Allow parents to be specified without string names") Signed-off-by: Chen-Yu Tsai --- drivers/clk/clk.c | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index aa51756fd4d6..093161ca4dcc 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3000,12 +3000,50 @@ DEFINE_SHOW_ATTRIBUTE(clk_flags); static int possible_parents_show(struct seq_file *s, void *data) { struct clk_core *core = s->private; + struct clk_core *parent; int i; - for (i = 0; i < core->num_parents - 1; i++) - seq_printf(s, "%s ", core->parents[i].name); + /* + * Go through the following options to fetch a parent's name. + * + * 1. Fetch the registered parent clock and use its name + * 2. Use the global (fallback) name if specified + * 3. Use the local fw_name if provided + * 4. Fetch parent clock's clock-output-name if DT index was set + * + * This may still fail in some cases, such as when the parent is + * specified directly via a struct clk_hw pointer, but it isn't + * registered (yet). + */ + for (i = 0; i < core->num_parents - 1; i++) { + parent = clk_core_get_parent_by_index(core, i); + if (parent) + seq_printf(s, "%s ", parent->name); + else if (core->parents[i].name) + seq_printf(s, "%s ", core->parents[i].name); + else if (core->parents[i].fw_name) + seq_printf(s, "<%s>(fw) ", core->parents[i].fw_name); + else if (core->parents[i].index >= 0) + seq_printf(s, "%s ", + of_clk_get_parent_name(core->of_node, + core->parents[i].index)); + else + seq_puts(s, "(missing) "); + } - seq_printf(s, "%s\n", core->parents[i].name); + parent = clk_core_get_parent_by_index(core, i); + if (parent) + seq_printf(s, "%s", parent->name); + else if (core->parents[i].name) + seq_printf(s, "%s", core->parents[i].name); + else if (core->parents[i].fw_name) + seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); + else if (core->parents[i].index >= 0) + seq_printf(s, "%s", + of_clk_get_parent_name(core->of_node, + core->parents[i].index)); + else + seq_puts(s, "(missing)"); return 0; } -- 2.20.1