From patchwork Mon Apr 25 02:50:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 8922501 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: X-Original-To: patchwork-linux-clk@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A9BEF9F1D3 for ; Mon, 25 Apr 2016 02:50:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42FDA20138 for ; Mon, 25 Apr 2016 02:50:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5C9520120 for ; Mon, 25 Apr 2016 02:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751826AbcDYCuZ (ORCPT ); Sun, 24 Apr 2016 22:50:25 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:51683 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbcDYCuZ (ORCPT ); Sun, 24 Apr 2016 22:50:25 -0400 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id u3P2nqJL012862; Mon, 25 Apr 2016 11:49:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com u3P2nqJL012862 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1461552593; bh=o22D5gcKM1KSzA2EMAnAEALOyT/RL75y8cvjJYicPx8=; h=From:To:Cc:Subject:Date:From; b=IRuAFV9DW7OTq991rYZ5dE5hkqKGW36I5L5ar9hGj2IbngdIzdvvCn5BgD8emCx9a YzoVNxPRaFXcNaDZePXNgc4sh8MBVXOygtgCB1dymhNqlDgTmeyUpLzHyeCmAnxY7Z VoFORqhSd9RWE0fuOIb/6BBYuWWk7SgYN/H7I3F2SJc5lWx1PN3gL6Xece2jY1I1fT sl5GmBom3A2mbBKrpU1e8Wx2F6v6tAbD3Uc9NTDA2mJHtRhEWMYVlq1FjXKi4j3C8R 1K+Evmk3giNDA1K6OgPXeib+FKy0353FR4gQqur0Ss3ZFhn2q6d4UfHvi4gaLwepxh A02wt4WELOEfA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-clk@vger.kernel.org Cc: Masahiro Yamada , Stephen Boyd , Michael Turquette , linux-kernel@vger.kernel.org Subject: [PATCH] clk: fix member type of struct clk_hw_onecell_data Date: Mon, 25 Apr 2016 11:50:42 +0900 Message-Id: <1461552642-10732-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 We cannot assign any value to an array type variable. So, hw_data->hws = kcalloc(hw_data->num, sizeof(struct clk_hw *), GFP_KERNEL); fails with "invalid use of flexible array member" error. There are two ways to fix this issue. [1] Make it a double-pointer struct clk_hw_onecell_data { size_t num; struct clk_hw **hws; }; This works as struct clk_onecell_data does. [2] Make it a zero-sized array struct clk_hw_onecell_data { size_t num; struct clk_hw *hws[0]; }; This allows one-shot memory allocation like this: hw_data = kmalloc(sizeof(*hw_data) + clk_num * sizeof(struct clk_hw *), GFP_KERNEL); This commit adopts [2] because it looks like Stephen's intention (he moved hws[] to the bottom of struct clk_hw_onecell_data). Fixes: 0861e5b8cf80 ("clk: Add clk_hw OF clk providers") Signed-off-by: Masahiro Yamada --- include/linux/clk-provider.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index fd2ccd5..1850e25 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -769,7 +769,7 @@ struct clk_onecell_data { struct clk_hw_onecell_data { size_t num; - struct clk_hw *hws[]; + struct clk_hw *hws[0]; }; extern struct of_device_id __clk_of_table;