diff mbox series

[v1,2/2] Input: matrix_keypad - replace header inclusions by forward declarations

Message ID 20220923184632.2157-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit d5f7638eb5fed0eb12e45a127764c4111b11c50e
Headers show
Series [v1,1/2] Input: matrix_keypad - add missed header inclusion | expand

Commit Message

Andy Shevchenko Sept. 23, 2022, 6:46 p.m. UTC
When the data structure is only referred by pointer, compiler may not need
to see the contents of the data type. Thus, we may replace header inclusions
by respective forward declarations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/input/matrix_keypad.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Dmitry Torokhov Sept. 23, 2022, 7:03 p.m. UTC | #1
On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> When the data structure is only referred by pointer, compiler may not need
> to see the contents of the data type. Thus, we may replace header inclusions
> by respective forward declarations.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/input/matrix_keypad.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> index 9476768c3b90..b8d8d69eba29 100644
> --- a/include/linux/input/matrix_keypad.h
> +++ b/include/linux/input/matrix_keypad.h
> @@ -3,8 +3,9 @@
>  #define _MATRIX_KEYPAD_H
>  
>  #include <linux/types.h>
> -#include <linux/input.h>
> -#include <linux/of.h>
> +
> +struct device;
> +struct input_dev;

This results in a ton of compile errors. While I believe this change is
a good one, we need to fix users of this include first.

Thanks.
Andy Shevchenko Sept. 26, 2022, 10:56 a.m. UTC | #2
On Fri, Sep 23, 2022 at 12:03:00PM -0700, Dmitry Torokhov wrote:
> On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> > When the data structure is only referred by pointer, compiler may not need
> > to see the contents of the data type. Thus, we may replace header inclusions
> > by respective forward declarations.

...

> > +struct device;
> > +struct input_dev;
> 
> This results in a ton of compile errors. While I believe this change is
> a good one, we need to fix users of this include first.

Indeed, sorry for breaking things (I compile-tested with limited drivers
enabled). I will look into LKP reports and will fix the users.
Andy Shevchenko Sept. 26, 2022, 10:56 a.m. UTC | #3
On Mon, Sep 26, 2022 at 01:56:27PM +0300, Andy Shevchenko wrote:
> On Fri, Sep 23, 2022 at 12:03:00PM -0700, Dmitry Torokhov wrote:
> > On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> > > When the data structure is only referred by pointer, compiler may not need
> > > to see the contents of the data type. Thus, we may replace header inclusions
> > > by respective forward declarations.

...

> > > +struct device;
> > > +struct input_dev;
> > 
> > This results in a ton of compile errors. While I believe this change is
> > a good one, we need to fix users of this include first.
> 
> Indeed, sorry for breaking things (I compile-tested with limited drivers
> enabled). I will look into LKP reports and will fix the users.

Ah, thanks, I see your series for that!
Guenter Roeck Oct. 29, 2022, 2:25 p.m. UTC | #4
On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> When the data structure is only referred by pointer, compiler may not need
> to see the contents of the data type. Thus, we may replace header inclusions
> by respective forward declarations.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/input/matrix_keypad.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> index 9476768c3b90..b8d8d69eba29 100644
> --- a/include/linux/input/matrix_keypad.h
> +++ b/include/linux/input/matrix_keypad.h
> @@ -3,8 +3,9 @@
>  #define _MATRIX_KEYPAD_H
>  
>  #include <linux/types.h>
> -#include <linux/input.h>

Possibly, but may other drivers rely on those includes.
This results in widespread build failures such as

Building arm:allmodconfig ... failed
--------------
Error log:
In file included from include/linux/input/samsung-keypad.h:12,
                 from arch/arm/mach-s3c/keypad.h:12,
                 from arch/arm/mach-s3c/mach-crag6410.c:57:
arch/arm/mach-s3c/mach-crag6410.c:183:19: error: 'KEY_VOLUMEUP' undeclared here

Guenter
Dmitry Torokhov Oct. 29, 2022, 10:28 p.m. UTC | #5
On Sat, Oct 29, 2022 at 07:25:51AM -0700, Guenter Roeck wrote:
> On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> > When the data structure is only referred by pointer, compiler may not need
> > to see the contents of the data type. Thus, we may replace header inclusions
> > by respective forward declarations.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  include/linux/input/matrix_keypad.h | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> > index 9476768c3b90..b8d8d69eba29 100644
> > --- a/include/linux/input/matrix_keypad.h
> > +++ b/include/linux/input/matrix_keypad.h
> > @@ -3,8 +3,9 @@
> >  #define _MATRIX_KEYPAD_H
> >  
> >  #include <linux/types.h>
> > -#include <linux/input.h>
> 
> Possibly, but may other drivers rely on those includes.
> This results in widespread build failures such as
> 
> Building arm:allmodconfig ... failed
> --------------
> Error log:
> In file included from include/linux/input/samsung-keypad.h:12,
>                  from arch/arm/mach-s3c/keypad.h:12,
>                  from arch/arm/mach-s3c/mach-crag6410.c:57:
> arch/arm/mach-s3c/mach-crag6410.c:183:19: error: 'KEY_VOLUMEUP' undeclared here

I fixed this particular instance, hopefully it is one of the very
last of them...
Guenter Roeck Oct. 29, 2022, 11:02 p.m. UTC | #6
On 10/29/22 15:28, Dmitry Torokhov wrote:
> On Sat, Oct 29, 2022 at 07:25:51AM -0700, Guenter Roeck wrote:
>> On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
>>> When the data structure is only referred by pointer, compiler may not need
>>> to see the contents of the data type. Thus, we may replace header inclusions
>>> by respective forward declarations.
>>>
>>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>> ---
>>>   include/linux/input/matrix_keypad.h | 5 +++--
>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
>>> index 9476768c3b90..b8d8d69eba29 100644
>>> --- a/include/linux/input/matrix_keypad.h
>>> +++ b/include/linux/input/matrix_keypad.h
>>> @@ -3,8 +3,9 @@
>>>   #define _MATRIX_KEYPAD_H
>>>   
>>>   #include <linux/types.h>
>>> -#include <linux/input.h>
>>
>> Possibly, but may other drivers rely on those includes.
>> This results in widespread build failures such as
>>
>> Building arm:allmodconfig ... failed
>> --------------
>> Error log:
>> In file included from include/linux/input/samsung-keypad.h:12,
>>                   from arch/arm/mach-s3c/keypad.h:12,
>>                   from arch/arm/mach-s3c/mach-crag6410.c:57:
>> arch/arm/mach-s3c/mach-crag6410.c:183:19: error: 'KEY_VOLUMEUP' undeclared here
> 
> I fixed this particular instance, hopefully it is one of the very
> last of them...
> 

Sorry, I didn't bother listing all of them. There is at least one more.

Error log:
arch/arm/mach-pxa/spitz.c:410:11: error: 'EV_PWR' undeclared here (not in a function)
   410 |   .type = EV_PWR,
       |           ^~~~~~

with arm:pxa_defconfig.

Guenter
Dmitry Torokhov Oct. 30, 2022, 4:33 a.m. UTC | #7
On Sat, Oct 29, 2022 at 04:02:56PM -0700, Guenter Roeck wrote:
> On 10/29/22 15:28, Dmitry Torokhov wrote:
> > On Sat, Oct 29, 2022 at 07:25:51AM -0700, Guenter Roeck wrote:
> > > On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
> > > > When the data structure is only referred by pointer, compiler may not need
> > > > to see the contents of the data type. Thus, we may replace header inclusions
> > > > by respective forward declarations.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > > ---
> > > >   include/linux/input/matrix_keypad.h | 5 +++--
> > > >   1 file changed, 3 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
> > > > index 9476768c3b90..b8d8d69eba29 100644
> > > > --- a/include/linux/input/matrix_keypad.h
> > > > +++ b/include/linux/input/matrix_keypad.h
> > > > @@ -3,8 +3,9 @@
> > > >   #define _MATRIX_KEYPAD_H
> > > >   #include <linux/types.h>
> > > > -#include <linux/input.h>
> > > 
> > > Possibly, but may other drivers rely on those includes.
> > > This results in widespread build failures such as
> > > 
> > > Building arm:allmodconfig ... failed
> > > --------------
> > > Error log:
> > > In file included from include/linux/input/samsung-keypad.h:12,
> > >                   from arch/arm/mach-s3c/keypad.h:12,
> > >                   from arch/arm/mach-s3c/mach-crag6410.c:57:
> > > arch/arm/mach-s3c/mach-crag6410.c:183:19: error: 'KEY_VOLUMEUP' undeclared here
> > 
> > I fixed this particular instance, hopefully it is one of the very
> > last of them...
> > 
> 
> Sorry, I didn't bother listing all of them. There is at least one more.
> 
> Error log:
> arch/arm/mach-pxa/spitz.c:410:11: error: 'EV_PWR' undeclared here (not in a function)
>   410 |   .type = EV_PWR,
>       |           ^~~~~~
> 
> with arm:pxa_defconfig.

Ah, I see. Arnd is trying to delete bunch of PXA code, so I'll pull the
header change until after he merges his, and hopefully spitz will be
gone.

Do you have more examples by chance?

Thanks.
Guenter Roeck Oct. 30, 2022, 4:55 a.m. UTC | #8
On 10/29/22 21:33, Dmitry Torokhov wrote:
> On Sat, Oct 29, 2022 at 04:02:56PM -0700, Guenter Roeck wrote:
>> On 10/29/22 15:28, Dmitry Torokhov wrote:
>>> On Sat, Oct 29, 2022 at 07:25:51AM -0700, Guenter Roeck wrote:
>>>> On Fri, Sep 23, 2022 at 09:46:32PM +0300, Andy Shevchenko wrote:
>>>>> When the data structure is only referred by pointer, compiler may not need
>>>>> to see the contents of the data type. Thus, we may replace header inclusions
>>>>> by respective forward declarations.
>>>>>
>>>>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>>>> ---
>>>>>    include/linux/input/matrix_keypad.h | 5 +++--
>>>>>    1 file changed, 3 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
>>>>> index 9476768c3b90..b8d8d69eba29 100644
>>>>> --- a/include/linux/input/matrix_keypad.h
>>>>> +++ b/include/linux/input/matrix_keypad.h
>>>>> @@ -3,8 +3,9 @@
>>>>>    #define _MATRIX_KEYPAD_H
>>>>>    #include <linux/types.h>
>>>>> -#include <linux/input.h>
>>>>
>>>> Possibly, but may other drivers rely on those includes.
>>>> This results in widespread build failures such as
>>>>
>>>> Building arm:allmodconfig ... failed
>>>> --------------
>>>> Error log:
>>>> In file included from include/linux/input/samsung-keypad.h:12,
>>>>                    from arch/arm/mach-s3c/keypad.h:12,
>>>>                    from arch/arm/mach-s3c/mach-crag6410.c:57:
>>>> arch/arm/mach-s3c/mach-crag6410.c:183:19: error: 'KEY_VOLUMEUP' undeclared here
>>>
>>> I fixed this particular instance, hopefully it is one of the very
>>> last of them...
>>>
>>
>> Sorry, I didn't bother listing all of them. There is at least one more.
>>
>> Error log:
>> arch/arm/mach-pxa/spitz.c:410:11: error: 'EV_PWR' undeclared here (not in a function)
>>    410 |   .type = EV_PWR,
>>        |           ^~~~~~
>>
>> with arm:pxa_defconfig.
> 
> Ah, I see. Arnd is trying to delete bunch of PXA code, so I'll pull the
> header change until after he merges his, and hopefully spitz will be
> gone.
> 
> Do you have more examples by chance?
> 

No, but no guarantees - there are various other build failures in -next,
and I may have missed some.

Guenter
diff mbox series

Patch

diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 9476768c3b90..b8d8d69eba29 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -3,8 +3,9 @@ 
 #define _MATRIX_KEYPAD_H
 
 #include <linux/types.h>
-#include <linux/input.h>
-#include <linux/of.h>
+
+struct device;
+struct input_dev;
 
 #define MATRIX_MAX_ROWS		32
 #define MATRIX_MAX_COLS		32