Skip to contentSkip to conversation

make i2c_register_board_info() a NOP when CONFIG_I2C=n

PATCH In review David Brownell 2 participants 4 messages Feb 22, 2008 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make i2c_register_board_info() a NOP when CONFIG_I2C=n

Don't require platform code to be #ifdeffed according to whether I2C is enabled or not ... if it's not enabled, let GCC compile out all I2C device declarations. (Issue noted on an NSLU2 build that didn't configure I2C.)

---
 include/linux/i2c.h |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/i2c.h +8 -1
@@ -271,9 +271,16 @@ extern void i2c_unregister_device(struct
  * This is done at arch_initcall time, before declaring any i2c adapters.
  * Modules for add-on boards must use other calls.
  */
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 extern int
 i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
-
+#else
+static inline int
+i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n)
+{
+	return 0;
+}
+#endif
 
 /*
  * The following structs are for those who like to implement new bus drivers:

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): 200802220023.16643.david-b-yBeKhBN/[email protected]

#2 lore raw

Hi David,

Quoted 13 lines · David Brownell

Don't require platform code to be #ifdeffed according to whether I2C is enabled or not ... if it's not enabled, let GCC compile out all I2C device declarations. (Issue noted on an NSLU2 build that didn't configure I2C.)

---
 include/linux/i2c.h |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

include/linux/i2c.h extern void i2c_unregister_device(struct · line 274

Quoted 4 lines
include/linux/i2c.h +1 -0
@@ -271,9 +271,16 @@ extern void i2c_unregister_device(struct
  * This is done at arch_initcall time, before declaring any i2c adapters.
  * Modules for add-on boards must use other calls.
  */
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)

I'm fairly certain that #ifdef CONFIG_I2C is enough.

include/linux/i2c.h extern void i2c_unregister_device(struct · line 286

Quoted 13 lines
include/linux/i2c.h +7 -1
 extern int
 i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
-
+#else
+static inline int
+i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n)
+{
+	return 0;
+}
+#endif
 
 /*
  * The following structs are for those who like to implement new bus drivers:

Other than that I am fine with this patch. Want it in 2.6.25 or 2.6.26 is enough?

Signature · 6 lines
Jean Delvare

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 13 lines · Jean Delvare

Hi David,

Quoted 10 lines · David Brownell

Don't require platform code to be #ifdeffed according to whether I2C is enabled or not ... if it's not enabled, let GCC compile out all I2C device declarations. (Issue noted on an NSLU2 build that didn't configure I2C.)

---
 include/linux/i2c.h |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Quoted 9 lines

include/linux/i2c.h extern void i2c_unregister_device(struct · line 274

Quoted 7 lines
include/linux/i2c.h +1 -0
@@ -271,9 +271,16 @@ extern void i2c_unregister_device(struct
  * This is done at arch_initcall time, before declaring any i2c adapters.
  * Modules for add-on boards must use other calls.
  */
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)

I'm fairly certain that #ifdef CONFIG_I2C is enough.

No; if I2C is modular, CONFIG_I2C isn't defined.

Though maybe it could use CONFIG_I2C_BOARDINFO, which is defined as boolean. In fact that's what the I2C Makefile uses, but it'd be less obvious here.

Quoted 11 lines
Quoted 11 lines
include/linux/i2c.h +7 -1
 extern int
 i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
-
+#else
+static inline int
+i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n)
+{
+	return 0;
+}
+#endif
 
Quoted 5 lines

include/linux/i2c.h extern void i2c_unregister_device(struct · line 286

Quoted 2 lines
include/linux/i2c.h +0 -0
 /*
  * The following structs are for those who like to implement new bus drivers:

Other than that I am fine with this patch. Want it in 2.6.25 or 2.6.26 is enough?

I'd go for 2.6.25, since it's a build fix.

- Dave

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

A message that is not in the archive (sent off-list or not yet received): 200802220222.18270.david-b-yBeKhBN/[email protected]

#6 lore raw
Quoted 24 lines · David Brownell
Quoted 13 lines · Jean Delvare

Hi David,

Quoted 10 lines · David Brownell

Don't require platform code to be #ifdeffed according to whether I2C is enabled or not ... if it's not enabled, let GCC compile out all I2C device declarations. (Issue noted on an NSLU2 build that didn't configure I2C.)

---
 include/linux/i2c.h |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Quoted 9 lines

include/linux/i2c.h extern void i2c_unregister_device(struct · line 274

Quoted 7 lines
include/linux/i2c.h +1 -0
@@ -271,9 +271,16 @@ extern void i2c_unregister_device(struct
  * This is done at arch_initcall time, before declaring any i2c adapters.
  * Modules for add-on boards must use other calls.
  */
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)

I'm fairly certain that #ifdef CONFIG_I2C is enough.

Quoted 1 line

No; if I2C is modular, CONFIG_I2C isn't defined.

Mpff, you're right. I wonder why it was done this way, sounds totally stupid to me given that in 99% of the cases you don't care if the thing is modular or not. Oh well.

Quoted 3 lines

Though maybe it could use CONFIG_I2C_BOARDINFO, which is defined as boolean. In fact that's what the I2C Makefile uses, but it'd be less obvious here.

Now that you mention it, given that i2c_register_board_info() is defined in i2c-boardinfo.c, it would indeed make a lot of sense to make the conditional depend on CONFIG_I2C_BOARDINFO rather that CONFIG_I2C.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
include/linux/i2c.h +7 -1
 extern int
 i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n);
-
+#else
+static inline int
+i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n)
+{
+	return 0;
+}
+#endif
 
Quoted 7 lines
Quoted 5 lines

include/linux/i2c.h extern void i2c_unregister_device(struct · line 286

Quoted 2 lines
include/linux/i2c.h +0 -0
 /*
  * The following structs are for those who like to implement new bus drivers:

Other than that I am fine with this patch. Want it in 2.6.25 or 2.6.26 is enough?

I'd go for 2.6.25, since it's a build fix.

OK, will do.

Signature · 6 lines
Jean Delvare

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c