From patchwork Tue Sep 15 10:22:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 7183491 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 57F95BEEC1 for ; Tue, 15 Sep 2015 10:23:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57F27206EE for ; Tue, 15 Sep 2015 10:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B628206EB for ; Tue, 15 Sep 2015 10:23:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751687AbbIOKXD (ORCPT ); Tue, 15 Sep 2015 06:23:03 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:32814 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbbIOKXB (ORCPT ); Tue, 15 Sep 2015 06:23:01 -0400 Received: by pacex6 with SMTP id ex6so173495659pac.0; Tue, 15 Sep 2015 03:23:01 -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=iJHwS7xv0YnizGpvjq0UR/uCV3i3ACEwkxmyWO8XijQ=; b=ONYcN93REajpq/gUfkOz/k9DDjSIdXhrzo8NHQ1+86Y9rRdAGSdKSRgT+0x+J5q/Tw ERS7QREBUZsKDsnmR9DQVWuA6qNdo7lrIRdyTWQJZGo/VyyZodDGel57neYNip7+/qNz 6BBnX1KqDWv5DSTmlin225nuZMbzL6t3NKswrYl+4FKz3qVN1tfhNeZWd2j3K3PCVTQz PlUslADI9pI5OgdV3wufPyAbobqEDztmbS5V6Ksn+ixF37vJFH7YmeLvc6GbpqUM1fNE 79t3h44jBriUS8zPV9wB2FS6HZ+sunfnF6XgSEZPCUomrIkgfn8f5U7+epiiQUenAfiW 5lZg== X-Received: by 10.68.233.5 with SMTP id ts5mr45896362pbc.58.1442312581326; Tue, 15 Sep 2015 03:23:01 -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 xv12sm21278166pac.38.2015.09.15.03.22.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 03:23:00 -0700 (PDT) From: Magnus Damm To: linux-clk@vger.kernel.org Cc: linux-sh@vger.kernel.org, mturquette@baylibre.com, sboyd@codeaurora.org, horms@verge.net.au, geert@linux-m68k.org, laurent.pinchart@ideasonboard.com, Magnus Damm Date: Tue, 15 Sep 2015 19:22:58 +0900 Message-Id: <20150915102258.15716.22991.sendpatchset@little-apple> In-Reply-To: <20150915102238.15716.91170.sendpatchset@little-apple> References: <20150915102238.15716.91170.sendpatchset@little-apple> Subject: [PATCH 02/05][RFC] clk: Add parent array to struct clk_init_data 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 Add an optional array of parent clocks to struct clk_init_data to allow relying on clock pointers instead of strings during registration of clocks. Using this parent array the clock providers step over the line to become clock consumers since they can use of_clk_get() to get the parent clock and pass it during registration. Good or bad. Clock providers that register clocks may use the parent array pre-populate parent clocks to not have to rely on strings lookup. This in turn makes it possible to have clock providers using a single DT node with several clock-indices but omitting the clock-output-names property. As it is today the clock index is not taken into consideration when generating a default parent name in case clock-output-names is missing. TODO: Figure out how to deal with ref counting and if clock providers should use clk_put() or not. Signed-off-by: Magnus Damm --- drivers/clk/clk.c | 14 +++++++++++--- include/linux/clk-provider.h | 2 ++ 2 files changed, 13 insertions(+), 3 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/clk.c +++ work/drivers/clk/clk.c 2015-09-15 18:30:36.390513000 +0900 @@ -2360,8 +2360,8 @@ static int __clk_init(struct device *dev * for a NULL pointer. We can always perform lazy lookups for * missing parents later on. */ - if (core->parents) - for (i = 0; i < core->num_parents; i++) + for (i = 0; i < core->num_parents; i++) + if (core->parents && !core->parents[i]) core->parents[i] = clk_core_lookup(core->parent_names[i]); } @@ -2549,7 +2549,9 @@ struct clk *clk_register(struct device * ret = -ENOMEM; goto fail_parent_names; } - + if (hw->init->parents) + core->parents = kcalloc(core->num_parents, sizeof(struct clk *), + GFP_KERNEL); /* copy each string name in case parent_names is __initdata */ for (i = 0; i < core->num_parents; i++) { @@ -2561,6 +2563,11 @@ struct clk *clk_register(struct device * } } + /* convert each parent pointer to struct clk_core */ + for (i = 0; i < core->num_parents; i++) + if (core->parents && !IS_ERR(hw->init->parents[i])) + core->parents[i] = hw->init->parents[i]->core; + INIT_HLIST_HEAD(&core->clks); hw->clk = __clk_create_clk(hw, NULL, NULL); @@ -2577,6 +2584,7 @@ struct clk *clk_register(struct device * hw->clk = NULL; fail_parent_names_copy: + kfree(core->parents); while (--i >= 0) kfree_const(core->parent_names[i]); kfree(core->parent_names); --- 0001/include/linux/clk-provider.h +++ work/include/linux/clk-provider.h 2015-09-15 18:17:15.000000000 +0900 @@ -222,6 +222,7 @@ struct clk_ops { * @name: clock name * @ops: operations this clock supports * @parent_names: array of string names for all possible parents + * @parents: array of pointers to all possible parents * @num_parents: number of possible parents * @flags: framework-level hints and quirks */ @@ -229,6 +230,7 @@ struct clk_init_data { const char *name; const struct clk_ops *ops; const char * const *parent_names; + struct clk **parents; u8 num_parents; unsigned long flags; };