* [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition
@ 2014-09-27 0:31 Behan Webster
2014-09-27 0:55 ` Felipe Balbi
0 siblings, 1 reply; 4+ messages in thread
From: Behan Webster @ 2014-09-27 0:31 UTC (permalink / raw)
To: mturquette, t-kristo; +Cc: behanw, linux-kernel, linux-omap
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>
---
drivers/clk/ti/divider.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
index a837f70..bff2b5b 100644
--- a/drivers/clk/ti/divider.c
+++ b/drivers/clk/ti/divider.c
@@ -300,8 +300,8 @@ static struct clk *_register_divider(struct device *dev, const char *name,
return clk;
}
-static struct clk_div_table
-__init *ti_clk_get_div_table(struct device_node *node)
+static struct clk_div_table *
+__init ti_clk_get_div_table(struct device_node *node)
{
struct clk_div_table *table;
const __be32 *divspec;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition
2014-09-27 0:31 [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition Behan Webster
@ 2014-09-27 0:55 ` Felipe Balbi
2014-09-27 0:57 ` Behan Webster
0 siblings, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2014-09-27 0:55 UTC (permalink / raw)
To: Behan Webster; +Cc: mturquette, t-kristo, linux-kernel, linux-omap
[-- 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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition
2014-09-27 0:55 ` Felipe Balbi
@ 2014-09-27 0:57 ` Behan Webster
2014-09-29 11:44 ` Tero Kristo
0 siblings, 1 reply; 4+ messages in thread
From: Behan Webster @ 2014-09-27 0:57 UTC (permalink / raw)
To: balbi; +Cc: mturquette, t-kristo, linux-kernel, linux-omap
On 09/26/14 17:55, Felipe Balbi wrote:
> 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>
Thank you.
> I wonder if we should add this a Sparse or Coccinelle rule.
+1
I'm hoping it can be added to checkpatch as well.
Behan
--
Behan Webster
behanw@converseincode.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition
2014-09-27 0:57 ` Behan Webster
@ 2014-09-29 11:44 ` Tero Kristo
0 siblings, 0 replies; 4+ messages in thread
From: Tero Kristo @ 2014-09-29 11:44 UTC (permalink / raw)
To: Behan Webster, balbi; +Cc: mturquette, linux-kernel, linux-omap
On 09/27/2014 03:57 AM, Behan Webster wrote:
> On 09/26/14 17:55, Felipe Balbi wrote:
>> 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>
> Thank you.
>
>> I wonder if we should add this a Sparse or Coccinelle rule.
> +1
>
> I'm hoping it can be added to checkpatch as well.
>
> Behan
>
Thanks, patch applied to for-v3.18/ti-clk-drv.
-Tero
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-29 11:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-27 0:31 [PATCH] clk, ti, LLVMLinux: Move __init outside of type definition Behan Webster
2014-09-27 0:55 ` Felipe Balbi
2014-09-27 0:57 ` Behan Webster
2014-09-29 11:44 ` Tero Kristo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).