Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753597AbbK3Ied (ORCPT ); Mon, 30 Nov 2015 03:34:33 -0500 Received: from conssluserg002.nifty.com ([202.248.44.40]:35450 "EHLO conssluserg002-v.nifty.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753568AbbK3Ie3 (ORCPT ); Mon, 30 Nov 2015 03:34:29 -0500 X-Nifty-SrcIP: [209.85.160.179] MIME-Version: 1.0 In-Reply-To: <20151124005324.GM19156@codeaurora.org> References: <1448004981-11133-1-git-send-email-yamada.masahiro@socionext.com> <1448004981-11133-2-git-send-email-yamada.masahiro@socionext.com> <20151120174509.GQ32672@codeaurora.org> <20151124005324.GM19156@codeaurora.org> Date: Mon, 30 Nov 2015 17:34:24 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] clk: let of_clk_get_parent_name() fail for invalid clock-indices From: Masahiro Yamada To: Stephen Boyd Cc: linux-clk@vger.kernel.org, Michael Turquette , Linux Kernel Mailing List , Ben Dooks Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1704 Lines: 61 Hi Stephen, >> >> Of course we can, although we have to mention "clock-indices" twice. >> >> A good thing for of_get_property() is that we can get both the value >> and the length >> at the same time. >> > > Ok. Well if we don't want to count them again, perhaps a goto > jump over an unconditional return NULL would be better? > > of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) { > if (index == pv) { > index = count; > goto found; > } > count++; > } > > return NULL; > found: > > Or since the macro for of_property_for_each_u32() tests the vp > poitner for NULL, we can check that pointer too... > > of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) { > if (index == pv) { > index = count; > break; > } > count++; > } > > /* We didn't find anything */ > if (!vp) > return NULL; > > I guess I prefer the latter approach here. > No. Neither of your two suggestions works because they are false positive. With your way, if "clock-indices" does not exist, of_clk_get_parent_name() would return NULL; in this case it should just parse "clock-output-names", assuming that the clock names are simply indexed from zero. -- Best Regards Masahiro Yamada -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/