Skip to contentSkip to conversation

i2c: core: Add stub for i2c_verify_client() if !CONFIG_I2C

PATCH In review Jonathan Cameron 4 participants 6 messages May 26, 2021 – Jun 3, 2021

Subsystems (3)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH 1/1 i2c: core: Add stub for i2c_verify_client() if !CONFIG_I2C

From: Jonathan Cameron <[email protected]>

If I2C is not compiled, there is no way we should see a call to i2c_verify_client() on a device that is an i2c client. As such, provide a stub to return NULL to resolve an associated build failure.

The build is failing with this link error
ld: fxls8962af-core.o: in function `fxls8962af_fifo_transfer':
fxls8962af-core.c: undefined reference to `i2c_verify_client'

Fixes 68068fad0e1c ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
Cc Sean Nyekjaer <[email protected]>
Cc Wolfram Sang <[email protected]>

---

Note the broken patch is only in the IIO/togreg branch at the moment.

 include/linux/i2c.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/i2c.h +7 -0
index e8f2ac8c9c3d..aa52738b9c46 100644
@@ -343,7 +343,14 @@ struct i2c_client {
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
 
+#if IS_ENABLED(CONFIG_I2C)
 struct i2c_client *i2c_verify_client(struct device *dev);
+#else
+static inline struct i2c_client *i2c_verify_client(struct device *dev)
+{
+	return NULL;
+}
+#endif
 struct i2c_adapter *i2c_verify_adapter(struct device *dev);
 const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
 					 const struct i2c_client *client);
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

If I2C is not compiled, there is no way we should see a call to i2c_verify_client() on a device that is an i2c client. As such, provide a stub to return NULL to resolve an associated build failure.

The build is failing with this link error
ld: fxls8962af-core.o: in function `fxls8962af_fifo_transfer':
fxls8962af-core.c: undefined reference to `i2c_verify_client'

Quoted 5 lines
Fixes 68068fad0e1c ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
Cc Sean Nyekjaer <[email protected]>
Cc Wolfram Sang <[email protected]>
Quoted 3 lines

---

Note the broken patch is only in the IIO/togreg branch at the moment.

Didn't quite get that the stub was should go in linux/i2c.h, thought I had to make a stub in the driver. But this seems appropriate :)

/Sean

#2 lore raw
In reply to Jonathan Cameron

Hi Jonathan,

Quoted 6 lines
Fixes 68068fad0e1c ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
Cc Sean Nyekjaer <[email protected]>
Cc Wolfram Sang <[email protected]>

---

Note the broken patch is only in the IIO/togreg branch at the moment.

Then the fixes tag should be removed. It is only for upstream commits. It means we will have a merge dependency the next cycle, so I will send my pull request early.

include/linux/i2c.h struct i2c_client { · line 346

Quoted 13 lines
 include/linux/i2c.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/i2c.h +1 -0
index e8f2ac8c9c3d..aa52738b9c46 100644
@@ -343,7 +343,14 @@ struct i2c_client {
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
 
+#if IS_ENABLED(CONFIG_I2C)

Hmm, can't we move this into an already existing IS_ENABLED block?

#3 lore raw
Quoted 10 lines · On Thu, 27 May 2021 22:23:34 +0200 Wolfram Sang <[email protected]> wrote:

Hi Jonathan,

Quoted 6 lines
Fixes 68068fad0e1c ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads")
Cc Sean Nyekjaer <[email protected]>
Cc Wolfram Sang <[email protected]>

---

Note the broken patch is only in the IIO/togreg branch at the moment.

Then the fixes tag should be removed. It is only for upstream commits.

Ok, so that is there because my assumption was that mostly like I'd take this patch through IIO, in which case it's directly valid and necessary for backport information purposes. I'm guessing this one is unlikely to cause merge conflicts given how localized it is...

You would do an immutable branch that I can pull into IIO. I'd really like to avoid rebasing the IIO tree unless absolutely necessary as people are working on top if it.

Quoted 2 lines

It means we will have a merge dependency the next cycle, so I will send my pull request early.

Doesn't work. There is a high chance the original patch will get ported back to earlier kernels and there is no reference to let anyone know they also need this one to avoid potential build issues on the stable kernel.

So, if you want to take this through I2C, the path forwards would be.
1) You take this one through I2C
2) I apply the original fix (which #ifdefs the relevant code out in the driver).
3) Once (1) is in mainline next cycle, I can revert (2) on the basis it is no longer necessary.

I'm fine with doing it this way as it avoids any cross dependencies.

Quoted 13 lines
Quoted 13 lines

 include/linux/i2c.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/i2c.h +0 -0
index e8f2ac8c9c3d..aa52738b9c46 100644
@@ -343,7 +343,14 @@ struct i2c_client {
 };
 #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
 
Quoted 3 lines

include/linux/i2c.h struct i2c_client { · line 346

Quoted 1 line
include/linux/i2c.h +1 -0
+#if IS_ENABLED(CONFIG_I2C)  

Hmm, can't we move this into an already existing IS_ENABLED block?

There aren't any similar #if / #else blocks for CONFIG_I2C in i2c.h so it seemed neater to just add one around this individual element and not destroy the general organization of the file.

Jonathan

Quoted 2 lines
#4 lore raw

Hi Jonathan

Quoted 4 lines

Ok, so that is there because my assumption was that mostly like I'd take this patch through IIO, in which case it's directly valid and necessary for backport information purposes. I'm guessing this one is unlikely to cause merge conflicts given how localized it is...

I see. Makes sense.

Quoted 3 lines

You would do an immutable branch that I can pull into IIO. I'd really like to avoid rebasing the IIO tree unless absolutely necessary as people are working on top if it.

Sure, let's avoid rebasing.

Quoted 4 lines

Doesn't work. There is a high chance the original patch will get ported back to earlier kernels and there is no reference to let anyone know they also need this one to avoid potential build issues on the stable kernel.

Quoted 8 lines

So, if you want to take this through I2C, the path forwards would be.
1) You take this one through I2C
2) I apply the original fix (which #ifdefs the relevant code out in the driver).
3) Once (1) is in mainline next cycle, I can revert (2) on the basis it is no longer necessary.

I'm fine with doing it this way as it avoids any cross dependencies.

The other solution is that you make an immutable branch for me? IIUC, this would be easiest? It would work for me.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

+#if IS_ENABLED(CONFIG_I2C)

Hmm, can't we move this into an already existing IS_ENABLED block?

There aren't any similar #if / #else blocks for CONFIG_I2C in i2c.h so it seemed neater to just add one around this individual element and not destroy the general organization of the file.

Could be argued. I'd still prefer to add it at line 480 (5.13-rc3) with the #else branch added if you don't mind.

Thanks and kind regards,

Wolfram

#5 lore raw
Quoted 26 lines · On Thu, 3 Jun 2021 13:55:59 +0200 Wolfram Sang <[email protected]> wrote:

Hi Jonathan

Quoted 4 lines

Ok, so that is there because my assumption was that mostly like I'd take this patch through IIO, in which case it's directly valid and necessary for backport information purposes. I'm guessing this one is unlikely to cause merge conflicts given how localized it is...

I see. Makes sense.

Quoted 3 lines

You would do an immutable branch that I can pull into IIO. I'd really like to avoid rebasing the IIO tree unless absolutely necessary as people are working on top if it.

Sure, let's avoid rebasing.

Quoted 11 lines

Doesn't work. There is a high chance the original patch will get ported back to earlier kernels and there is no reference to let anyone know they also need this one to avoid potential build issues on the stable kernel.

So, if you want to take this through I2C, the path forwards would be.
1) You take this one through I2C
2) I apply the original fix (which #ifdefs the relevant code out in the driver).
3) Once (1) is in mainline next cycle, I can revert (2) on the basis it is no longer necessary.

Quoted 4 lines
Quoted 1 line

I'm fine with doing it this way as it avoids any cross dependencies.

The other solution is that you make an immutable branch for me? IIUC, this would be easiest? It would work for me.

Sure, I'll do that once we've agreed a v2

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

+#if IS_ENABLED(CONFIG_I2C)

Hmm, can't we move this into an already existing IS_ENABLED block?

There aren't any similar #if / #else blocks for CONFIG_I2C in i2c.h so it seemed neater to just add one around this individual element and not destroy the general organization of the file.

Could be argued. I'd still prefer to add it at line 480 (5.13-rc3) with the #else branch added if you don't mind.

Sure, I'll move it.

Jonathan

Quoted 6 lines

Thanks and kind regards,

Wolfram