public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
@ 2012-03-09 20:18 Stephen Warren
  2012-03-09 20:32 ` Paul Gortmaker
  2012-03-12 19:44 ` Linus Walleij
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Warren @ 2012-03-09 20:18 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Paul Gortmaker, linux-kernel, Stephen Warren

Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
<linux/bug.h>. Include that so that every .c file using the pinctrl macros
doesn't have to do that itself.

Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
---
 include/linux/pinctrl/machine.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index fee4349..012731a 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -12,7 +12,9 @@
 #ifndef __LINUX_PINCTRL_MACHINE_H
 #define __LINUX_PINCTRL_MACHINE_H
 
-#include "pinctrl-state.h"
+#include <linux/bug.h>
+
+#include "pinctrl.h"
 
 enum pinctrl_map_type {
 	PIN_MAP_TYPE_INVALID,
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-09 20:18 [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors Stephen Warren
@ 2012-03-09 20:32 ` Paul Gortmaker
  2012-03-09 20:43   ` Stephen Warren
  2012-03-12 19:44 ` Linus Walleij
  1 sibling, 1 reply; 7+ messages in thread
From: Paul Gortmaker @ 2012-03-09 20:32 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Linus Walleij, linux-kernel

[[PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors] On 09/03/2012 (Fri 13:18) Stephen Warren wrote:

> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
> doesn't have to do that itself.

Which C files are failing?  The approach was to be adding it only
for headers with static inlines which use it, and add it to C files
that are actually *deploying* the macros.

Thanks,
Paul.

> 
> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
>  include/linux/pinctrl/machine.h |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
> index fee4349..012731a 100644
> --- a/include/linux/pinctrl/machine.h
> +++ b/include/linux/pinctrl/machine.h
> @@ -12,7 +12,9 @@
>  #ifndef __LINUX_PINCTRL_MACHINE_H
>  #define __LINUX_PINCTRL_MACHINE_H
>  
> -#include "pinctrl-state.h"
> +#include <linux/bug.h>
> +
> +#include "pinctrl.h"
>  
>  enum pinctrl_map_type {
>  	PIN_MAP_TYPE_INVALID,
> -- 
> 1.7.0.4
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-09 20:32 ` Paul Gortmaker
@ 2012-03-09 20:43   ` Stephen Warren
  2012-03-09 21:29     ` Paul Gortmaker
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2012-03-09 20:43 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: Linus Walleij, linux-kernel

On 03/09/2012 01:32 PM, Paul Gortmaker wrote:
> [[PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors] On 09/03/2012 (Fri 13:18) Stephen Warren wrote:
> 
>> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
>> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
>> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
>> doesn't have to do that itself.
> 
> Which C files are failing?  The approach was to be adding it only
> for headers with static inlines which use it, and add it to C files
> that are actually *deploying* the macros.

For me, the files that are failing haven't been committed upstream yet;
I expect them to be very soon after the 3.4 merge window completes.

However, I expect you'll see this issue with arch/arm/mach-u300/core.c,
since it uses the same macros defined in pinctrl/machine.h that cause
the problem for me, unless one of the include files there picks up bug.h
already.

As a general statement though, once pinctrl becomes more widely adopted,
I expect to see many files start to use macros from pinctrl/machine.h,
and hence implicitly use ARRAY_SIZE(), and hence even more implicitly
depend on linux/bug.h. I don't think it's at all reasonable to force the
author of every one of those files to track down 3 or 4 levels of header
file dependencies to find that they need linux/bug.h even though they
make no direct use of its features, when it's known that almost any user
of pinctrl/machine.h is going to hit this issue.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-09 20:43   ` Stephen Warren
@ 2012-03-09 21:29     ` Paul Gortmaker
  2012-03-09 23:09       ` Stephen Warren
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Gortmaker @ 2012-03-09 21:29 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Linus Walleij, linux-kernel

On Fri, Mar 9, 2012 at 3:43 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 03/09/2012 01:32 PM, Paul Gortmaker wrote:
>> [[PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors] On 09/03/2012 (Fri 13:18) Stephen Warren wrote:
>>
>>> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
>>> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
>>> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
>>> doesn't have to do that itself.
>>
>> Which C files are failing?  The approach was to be adding it only
>> for headers with static inlines which use it, and add it to C files
>> that are actually *deploying* the macros.
>
> For me, the files that are failing haven't been committed upstream yet;
> I expect them to be very soon after the 3.4 merge window completes.
>
> However, I expect you'll see this issue with arch/arm/mach-u300/core.c,
> since it uses the same macros defined in pinctrl/machine.h that cause
> the problem for me, unless one of the include files there picks up bug.h
> already.
>
> As a general statement though, once pinctrl becomes more widely adopted,
> I expect to see many files start to use macros from pinctrl/machine.h,
> and hence implicitly use ARRAY_SIZE(), and hence even more implicitly
> depend on linux/bug.h. I don't think it's at all reasonable to force the
> author of every one of those files to track down 3 or 4 levels of header
> file dependencies to find that they need linux/bug.h even though they
> make no direct use of its features, when it's known that almost any user
> of pinctrl/machine.h is going to hit this issue.

There was a similar discussion before, where there was concern over
"every one of those files" but in the end the number is a fraction of
a percent.   There is no harm in the author knowing they are making
_use_ of BUG stuff -- in fact if you happened to be trying to write some
fault tolerant code, you might really be glad to know, so you could take
steps to avoid it....

Paul.


> --
> 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-09 21:29     ` Paul Gortmaker
@ 2012-03-09 23:09       ` Stephen Warren
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2012-03-09 23:09 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: Linus Walleij, linux-kernel

On 03/09/2012 02:29 PM, Paul Gortmaker wrote:
> On Fri, Mar 9, 2012 at 3:43 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> On 03/09/2012 01:32 PM, Paul Gortmaker wrote:
>>> [[PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors] On 09/03/2012 (Fri 13:18) Stephen Warren wrote:
>>>
>>>> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
>>>> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
>>>> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
>>>> doesn't have to do that itself.
>>>
>>> Which C files are failing?  The approach was to be adding it only
>>> for headers with static inlines which use it, and add it to C files
>>> that are actually *deploying* the macros.
>>
>> For me, the files that are failing haven't been committed upstream yet;
>> I expect them to be very soon after the 3.4 merge window completes.
>>
>> However, I expect you'll see this issue with arch/arm/mach-u300/core.c,
>> since it uses the same macros defined in pinctrl/machine.h that cause
>> the problem for me, unless one of the include files there picks up bug.h
>> already.
>>
>> As a general statement though, once pinctrl becomes more widely adopted,
>> I expect to see many files start to use macros from pinctrl/machine.h,
>> and hence implicitly use ARRAY_SIZE(), and hence even more implicitly
>> depend on linux/bug.h. I don't think it's at all reasonable to force the
>> author of every one of those files to track down 3 or 4 levels of header
>> file dependencies to find that they need linux/bug.h even though they
>> make no direct use of its features, when it's known that almost any user
>> of pinctrl/machine.h is going to hit this issue.
> 
> There was a similar discussion before, where there was concern over
> "every one of those files" but in the end the number is a fraction of
> a percent.   There is no harm in the author knowing they are making
> _use_ of BUG stuff -- in fact if you happened to be trying to write some
> fault tolerant code, you might really be glad to know, so you could take
> steps to avoid it....

The primary purpose for pinctrl/machine.h is files that define a certain
data structure that will almost invariably be initialized using the
macros in that header. Size those macros use ARRAY_SIZE, every one of
those .c files will require bug.h.

There are 1 or 2 files in drivers/pinctrl that include pinctrl/machine.h
solely for the data structure definitions or function prototypes, and
won't use those macros, but those are the exception rather than the rule
for this one header at least.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-09 20:18 [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors Stephen Warren
  2012-03-09 20:32 ` Paul Gortmaker
@ 2012-03-12 19:44 ` Linus Walleij
  2012-03-12 20:55   ` Stephen Warren
  1 sibling, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2012-03-12 19:44 UTC (permalink / raw)
  To: Stephen Warren; +Cc: Paul Gortmaker, linux-kernel

On Fri, Mar 9, 2012 at 9:18 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:

> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
> doesn't have to do that itself.

I get this part...

> Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
> ---
>  include/linux/pinctrl/machine.h |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
> index fee4349..012731a 100644
> --- a/include/linux/pinctrl/machine.h
> +++ b/include/linux/pinctrl/machine.h
> @@ -12,7 +12,9 @@
>  #ifndef __LINUX_PINCTRL_MACHINE_H
>  #define __LINUX_PINCTRL_MACHINE_H
>
> -#include "pinctrl-state.h"

?

> +#include <linux/bug.h>
> +
> +#include "pinctrl.h"

?

But I moved the states out of machine.h and pinctrl.h just so
that we shouldn't have to include pinctrl.h into machine.h?

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors
  2012-03-12 19:44 ` Linus Walleij
@ 2012-03-12 20:55   ` Stephen Warren
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2012-03-12 20:55 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Paul Gortmaker, linux-kernel

On 03/12/2012 01:44 PM, Linus Walleij wrote:
> On Fri, Mar 9, 2012 at 9:18 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> 
>> Macros in <linux/pinctrl/machine.h> call ARRAY_SIZE(), the definition of
>> which eventually calls BUILD_BUG_ON_ZERO(), which is defined in
>> <linux/bug.h>. Include that so that every .c file using the pinctrl macros
>> doesn't have to do that itself.
> 
> I get this part...
...
>> diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
...
>> -#include "pinctrl-state.h"
> 
> ?
> 
>> +#include <linux/bug.h>
>> +
>> +#include "pinctrl.h"
> 
> ?
> 
> But I moved the states out of machine.h and pinctrl.h just so
> that we shouldn't have to include pinctrl.h into machine.h?

Oops. Looks like I completely screwed up a rebase there.

If Paul acks the concept of the patch, I'll repost.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-12 20:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09 20:18 [PATCH] pinctrl: Include <linux/bug.h> to prevent compile errors Stephen Warren
2012-03-09 20:32 ` Paul Gortmaker
2012-03-09 20:43   ` Stephen Warren
2012-03-09 21:29     ` Paul Gortmaker
2012-03-09 23:09       ` Stephen Warren
2012-03-12 19:44 ` Linus Walleij
2012-03-12 20:55   ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox