From patchwork Tue Sep 15 10:23:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 7183511 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 BC062BEEC1 for ; Tue, 15 Sep 2015 10:23:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC150206E9 for ; Tue, 15 Sep 2015 10:23:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1008206E5 for ; Tue, 15 Sep 2015 10:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbbIOKXM (ORCPT ); Tue, 15 Sep 2015 06:23:12 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34183 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbbIOKXL (ORCPT ); Tue, 15 Sep 2015 06:23:11 -0400 Received: by padhy16 with SMTP id hy16so173064395pad.1; Tue, 15 Sep 2015 03:23:10 -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=tUdS+nyMnsX3cqpoKCmsn/v9KcLy2w7asdOMWEkHLGY=; b=mo9RsIRrCqbZOU/laUIdXoSl0D2fpjW2YeuqvsH35dDwL+Ke5afqNIDw6VvLi7Zq90 Zhv0V7R55V36FLwuquFJRANUKSGupYZ+PPF4cw57UDg0HXL+w3VJC5SB8gDuyBZ+a6Ei Mh3pkdqNsrXxl1mvT8iHbvjSJ9NvSEjy6qFRIjvv8VBcd5h3vqv/ed/gUSYJcOlRJjaN Qde7bFTY6doKCyHq730pIisUmm5wn1E+0cWXbqz9Pex8COUpNSQMWwchZPqSKjoOXnO0 QhWQ/d6f/Lp4Fuw0SmCH0D6oJxYqOR2tKR9HlgZR7VAD5J+wr7EIj4P9biQ/xAbVCkci ncvg== X-Received: by 10.66.97.102 with SMTP id dz6mr46598331pab.29.1442312590703; Tue, 15 Sep 2015 03:23:10 -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 yq2sm19045823pbb.39.2015.09.15.03.23.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2015 03:23:09 -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:23:07 +0900 Message-Id: <20150915102307.15716.26976.sendpatchset@little-apple> In-Reply-To: <20150915102238.15716.91170.sendpatchset@little-apple> References: <20150915102238.15716.91170.sendpatchset@little-apple> Subject: [PATCH 03/05][RFC] clk: Allow NULL as parent names 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 Relax the parent name requirement now when struct clk_init_data allows passing in an array of parent clocks during registration. With this patch the parent name pointer can be set to NULL in case parent clocks instead are passed in the parent array. TODO: Check if kfree_const() cleanup code needs to be updated. Signed-off-by: Magnus Damm --- drivers/clk/clk.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 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 --- 0003/drivers/clk/clk.c +++ work/drivers/clk/clk.c 2015-09-15 18:32:55.420513000 +0900 @@ -1081,7 +1081,8 @@ static int clk_fetch_parent_index(struct if (core->parents[i]) continue; - if (!strcmp(core->parent_names[i], parent->name)) { + if (core->parent_names[i] && !strcmp(core->parent_names[i], + parent->name)) { core->parents[i] = clk_core_lookup(parent->name); return i; } @@ -1675,7 +1676,7 @@ static struct clk_core *__clk_init_paren if (core->num_parents == 1) { if (IS_ERR_OR_NULL(core->parent)) - core->parent = clk_core_lookup(core->parent_names[0]); + core->parent = clk_core_get_parent_by_index(core, 0); ret = core->parent; goto out; } @@ -1749,7 +1750,8 @@ bool clk_has_parent(struct clk *clk, str return true; for (i = 0; i < core->num_parents; i++) - if (strcmp(core->parent_names[i], parent_core->name) == 0) + if (core->parent_names[i] && strcmp(core->parent_names[i], + parent_core->name) == 0) return true; return false; @@ -2337,7 +2339,7 @@ static int __clk_init(struct device *dev /* throw a WARN if any entries in parent_names are NULL */ for (i = 0; i < core->num_parents; i++) - WARN(!core->parent_names[i], + WARN(!core->parents && !core->parent_names[i], "%s: invalid NULL in %s's .parent_names\n", __func__, core->name); @@ -2437,13 +2439,15 @@ static int __clk_init(struct device *dev hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { if (orphan->num_parents && orphan->ops->get_parent) { i = orphan->ops->get_parent(orphan->hw); - if (!strcmp(core->name, orphan->parent_names[i])) + if (orphan->parent_names[i] && + !strcmp(core->name, orphan->parent_names[i])) clk_core_reparent(orphan, core); continue; } for (i = 0; i < orphan->num_parents; i++) - if (!strcmp(core->name, orphan->parent_names[i])) { + if (orphan->parent_names[i] && + !strcmp(core->name, orphan->parent_names[i])) { clk_core_reparent(orphan, core); break; } @@ -2555,6 +2559,9 @@ struct clk *clk_register(struct device * /* copy each string name in case parent_names is __initdata */ for (i = 0; i < core->num_parents; i++) { + if (!hw->init->parent_names[i]) + continue; + core->parent_names[i] = kstrdup_const(hw->init->parent_names[i], GFP_KERNEL); if (!core->parent_names[i]) {