All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: linux-clk@vger.kernel.org
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Michael Turquette <mturquette@baylibre.com>,
	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	[thread overview]
Message-ID: <1461552642-10732-1-git-send-email-yamada.masahiro@socionext.com> (raw)

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 <yamada.masahiro@socionext.com>
---

 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;
-- 
1.9.1

             reply	other threads:[~2016-04-25  2:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25  2:50 Masahiro Yamada [this message]
2016-04-25 22:27 ` [PATCH] clk: fix member type of struct clk_hw_onecell_data Stephen Boyd
2016-04-26  6:19   ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461552642-10732-1-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.