i2c: Include GPIO consumer header in main include

Message ID 20171208133934.18038-1-linus.walleij@linaro.org
State Rejected
Headers show
Series
  • i2c: Include GPIO consumer header in main include
Related show

Commit Message

Linus Walleij Dec. 8, 2017, 1:39 p.m.
It seems most users of <linux/i2c.h> pick up their
dependency of <linux/gpio/consumer.h> from other paths but
that is not a universal law, so include the header
explicitly so we have struct gpio_desc available.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 include/linux/i2c.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Wolfram Sang Dec. 12, 2017, 10:33 p.m. | #1
On Fri, Dec 08, 2017 at 02:39:34PM +0100, Linus Walleij wrote:
> It seems most users of <linux/i2c.h> pick up their
> dependency of <linux/gpio/consumer.h> from other paths but
> that is not a universal law, so include the header
> explicitly so we have struct gpio_desc available.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Not sure. Having GPIOs is not really a requirement for I2C. I tend to
think drivers using it should include this explicitly?
Wolfram Sang Jan. 15, 2018, 6:03 p.m. | #2
On Fri, Dec 08, 2017 at 02:39:34PM +0100, Linus Walleij wrote:
> It seems most users of <linux/i2c.h> pick up their
> dependency of <linux/gpio/consumer.h> from other paths but
> that is not a universal law, so include the header
> explicitly so we have struct gpio_desc available.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

I still think drivers needing GPIO should include it explicitly.
So, NAK until further arguments arrive...
Linus Walleij Jan. 16, 2018, 9:47 a.m. | #3
On Mon, Jan 15, 2018 at 7:03 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Fri, Dec 08, 2017 at 02:39:34PM +0100, Linus Walleij wrote:
>> It seems most users of <linux/i2c.h> pick up their
>> dependency of <linux/gpio/consumer.h> from other paths but
>> that is not a universal law, so include the header
>> explicitly so we have struct gpio_desc available.
>>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> I still think drivers needing GPIO should include it explicitly.
> So, NAK until further arguments arrive...

What I mean is that they must be doing that currently since this
file uses struct gpio_desc (for recovert), else the build would fail.

So that is why I think it should be made explicit.

Another option is to just forward-declare struct gpio_desc;

Yours,
Linus Walleij

Patch

diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 5d7f3c1853ae..8b968c44ddfa 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -34,6 +34,7 @@ 
 #include <linux/irqdomain.h>		/* for Host Notify IRQ */
 #include <linux/of.h>		/* for struct device_node */
 #include <linux/swab.h>		/* for swab16 */
+#include <linux/gpio/consumer.h>
 #include <uapi/linux/i2c.h>
 
 extern struct bus_type i2c_bus_type;