Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1291615
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] i2c: allow building emev2 without slave mode again |
| Date | 2015-12-14 23:30 +0100 |
| Message-ID | <qFJN1-3NK-29@gated-at.bofh.it> (permalink) |
| References | <qEaRj-7yx-3@gated-at.bofh.it> <qFA70-5XO-21@gated-at.bofh.it> <qFBPt-6Uj-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Monday 14 December 2015 14:52:06 Wolfram Sang wrote:
> > > What about not ifdeffing the inline function and keep the build error
> > > whenever someone uses it without I2C_SLAVE being selected?
> >
> > The inline function is only added there for the case that I2C_SLAVE is
> > disabled, so that would be pointless.
> >
> > However, what we could do is move the extern declaration outside of
> > the #ifdef to make it always visible. The if(IS_ENABLED(CONFIG_I2C_SLAVE))
> > check should then ensure that it never actually gets called, and we
> > get a link error if some driver gets it wrong.
>
> Yes, that's what I meant: move the whole function (as it was before your
> patch) out of the CONFIG_I2C_SLAVE block. We should get a compiler error
> even, because for !I2C_SLAVE, the client struct will not have the
> slave_cb member.
>
But we don't want a compile-error for randconfig builds, and we don't
want unnecessary #ifdef in the driver.
This change on top of my earlier patch should do what I meant:
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 0236e5f2b5be..536641bad92d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -265,15 +265,15 @@ enum i2c_slave_event {
extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb);
extern int i2c_slave_unregister(struct i2c_client *client);
+#if IS_ENABLED(CONFIG_I2C_SLAVE)
static inline int i2c_slave_event(struct i2c_client *client,
enum i2c_slave_event event, u8 *val)
{
-#if IS_ENABLED(CONFIG_I2C_SLAVE)
return client->slave_cb(client, event, val);
+}
#else
- return 0;
+extern int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val);
#endif
-}
/**
* struct i2c_board_info - template for device creation
Arnd
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-12 17:30 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-12 22:10 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-13 10:20 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-14 13:10 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-14 15:00 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-14 23:30 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-17 13:10 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-17 15:50 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Wolfram Sang <wsa@the-dreams.de> - 2015-12-17 20:50 +0100
Re: [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann <arnd@arndb.de> - 2015-12-17 21:00 +0100
csiph-web