Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Behan Webster <behanw@converseincode.com>
Cc: mturquette@linaro.org, t-kristo@ti.com,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org
Subject: Re: [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition
Date: Fri, 26 Sep 2014 19:55:06 -0500	[thread overview]
Message-ID: <20140927005506.GB25432@saruman> (raw)
In-Reply-To: <1411777908-16016-1-git-send-email-behanw@converseincode.com>

[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]

On Fri, Sep 26, 2014 at 05:31:48PM -0700, Behan Webster wrote:
> As written, the __init for ti_clk_get_div_table is in the middle of the return
> type.
> 
> The gcc documentation indicates that section attributes should be added to the
> end of the function declaration:
> 
>   extern void foobar (void) __attribute__ ((section ("bar")));
> 
> However gcc seems to be very permissive with where attributes can be placed.
> clang on the other hand isn't so permissive, and fails if you put the section
> definition in the middle of the return type:
> 
> drivers/clk/ti/divider.c:298:28: error: expected ';' after struct
> static struct clk_div_table
>                            ^
>                            ;
> drivers/clk/ti/divider.c:298:1: warning: 'static' ignored on this
>       declaration [-Wmissing-declarations]
> static struct clk_div_table
> ^
> drivers/clk/ti/divider.c:299:9: error: type specifier missing,
>       defaults to 'int' [-Werror,-Wimplicit-int]
> __init *ti_clk_get_div_table(struct device_node *node)
> ~~~~~~  ^
> drivers/clk/ti/divider.c:345:9: warning: incompatible pointer types
>       returning 'struct clk_div_table *' from a function with result type 'int *' [-Wincompatible-pointer-types]
>         return table;
>                ^~~~~
> drivers/clk/ti/divider.c:419:9: warning: incompatible pointer types
>       assigning to 'const struct clk_div_table *' from 'int *' [-Wincompatible-pointer-types]
>         *table = ti_clk_get_div_table(node);
>                ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
> 3 warnings and 2 errors generated.
> 
> By convention, most of the kernel code puts section attributes between the
> return type and function name. In the case where the return type is a pointer,
> it's important to place the '*' on left of the __init.
> 
> This updated code works for both gcc and clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Reviewed-by: Mark Charlebois <charlebm@gmail.com>

makes sense to me:

Reviewed-by: Felipe Balbi <balbi@ti.com>

I wonder if we should add this a Sparse or Coccinelle rule.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-09-27  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-27  0:31 [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition Behan Webster
2014-09-27  0:55 ` Felipe Balbi [this message]
2014-09-27  0:57   ` Behan Webster
2014-09-29 11:44     ` Tero Kristo

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=20140927005506.GB25432@saruman \
    --to=balbi@ti.com \
    --cc=behanw@converseincode.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=t-kristo@ti.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox