From patchwork Wed Sep 2 07:17:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 7108771 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5312ABEEC1 for ; Wed, 2 Sep 2015 07:13:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63FAB205E7 for ; Wed, 2 Sep 2015 07:13:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B1E220642 for ; Wed, 2 Sep 2015 07:13:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752777AbbIBHNQ (ORCPT ); Wed, 2 Sep 2015 03:13:16 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35463 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752432AbbIBHNP (ORCPT ); Wed, 2 Sep 2015 03:13:15 -0400 Received: by pacfv12 with SMTP id fv12so1897919pac.2; Wed, 02 Sep 2015 00:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=f4F08puGqDRMexr3lMAVdY2EAea1UBbx56xFyqpBA5g=; b=JOk102DekkdDRzsU5MdqasyB1MuNzPbB2ySx6/sT/fSYk3nRZ09Ixe72IUzcQAVLQi weeVhGqD+djUyhh0J0vTGQH4TAC1VXmxNLDe38rIr2AgFQ9Ivq0MEX0FTylXEfVZ4ZCy bCdJW4ccfc9SFW2MJqvBXGW05LVCymtoIPpRN+w6vNTD4TxEBVEWGvdaL+SXJtYDOKXw oqvR6V+rxoJTXqrPR847aapc06j0LM1gwR3Vh0QV89zlD6HEtPCIGjZJ/Cg29sAHb4WY aU1E8WdR3YNw14Tt4VY3Mnj31SZAyXfqrIWwD0LVm5PKzy3NCXx2fybAXTmqEj36eBZa HVUw== X-Received: by 10.68.225.228 with SMTP id rn4mr53174659pbc.25.1441177994584; Wed, 02 Sep 2015 00:13:14 -0700 (PDT) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by smtp.gmail.com with ESMTPSA id qp5sm20446289pbc.0.2015.09.02.00.13.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Sep 2015 00:13:12 -0700 (PDT) From: Magnus Damm To: linux-clk@vger.kernel.org Cc: kuninori.morimoto.gx@renesas.com, linux-sh@vger.kernel.org, mturquette@baylibre.com, gaku.inami.xw@bp.renesas.com, sboyd@codeaurora.org, horms@verge.net.au, geert@linux-m68k.org, laurent.pinchart@ideasonboard.com, Magnus Damm Date: Wed, 02 Sep 2015 16:17:28 +0900 Message-Id: <20150902071728.10870.32730.sendpatchset@little-apple> In-Reply-To: <20150902071657.10870.37652.sendpatchset@little-apple> References: <20150902071657.10870.37652.sendpatchset@little-apple> Subject: [PATCH v6 03/05] clk: shmobile: Make MSTP clock-output-names optional Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm This patch updates the MSTP driver to make the "clock-output-names" DT property optional instead of mandatory. In case the DT property is omitted then the function clk_register_clkdev() is skipped. The default for new SoCs is to not use "clock-output-names". Signed-off-by: Magnus Damm --- Changes since V5: - Simplified code using const char *allocated_name - thanks Geert! Changes since V4: - None Changes since V3: - Added support for multiple MSTP bits. =) drivers/clk/shmobile/clk-mstp.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/clk/shmobile/clk-mstp.c +++ work/drivers/clk/shmobile/clk-mstp.c 2015-09-02 11:52:02.182366518 +0900 @@ -193,26 +193,26 @@ static void __init cpg_mstp_clocks_init( for (i = 0; i < MSTP_MAX_CLOCKS; ++i) { const char *parent_name; const char *name; + const char *allocated_name = NULL; u32 clkidx; int ret; - /* Skip clocks with no name. */ - ret = of_property_read_string_index(np, "clock-output-names", - i, &name); - if (ret < 0 || strlen(name) == 0) - continue; - parent_name = of_clk_get_parent_name(np, i); ret = of_property_read_u32_index(np, idxname, i, &clkidx); if (parent_name == NULL || ret < 0) break; if (clkidx >= MSTP_MAX_CLOCKS) { - pr_err("%s: invalid clock %s %s index %u)\n", - __func__, np->name, name, clkidx); + pr_err("%s: invalid clock %s index %u)\n", + __func__, np->name, clkidx); continue; } + if (of_property_read_string_index(np, "clock-output-names", + i, &name) < 0) + allocated_name = name = kasprintf(GFP_KERNEL, "%s.%u", + np->name, clkidx); + clks[clkidx] = cpg_mstp_clock_register(name, parent_name, clkidx, group); if (!IS_ERR(clks[clkidx])) { @@ -225,12 +225,18 @@ static void __init cpg_mstp_clocks_init( * * FIXME: Remove this when all devices that require a * clock will be instantiated from DT. + * + * We currently register clkdev only when the DT + * property clock-output-names is present. */ - clk_register_clkdev(clks[clkidx], name, NULL); + if (!allocated_name) + clk_register_clkdev(clks[clkidx], name, NULL); } else { pr_err("%s: failed to register %s %s clock (%ld)\n", __func__, np->name, name, PTR_ERR(clks[clkidx])); } + + kfree(allocated_name); } of_clk_add_provider(np, of_clk_src_onecell_get, &group->data);