From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] i2c: allow building emev2 without slave mode again
Date: Mon, 14 Dec 2015 23:27:22 +0100 [thread overview]
Message-ID: <13702087.6o87OAVdIx@wuerfel> (raw)
In-Reply-To: <20151214135206.GA1520@katana>
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
next prev parent reply other threads:[~2015-12-14 22:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 13:14 [PATCH] i2c: allow building emev2 without slave mode again Arnd Bergmann
2015-12-10 13:34 ` Wolfram Sang
2015-12-10 13:51 ` Arnd Bergmann
2015-12-10 14:54 ` kbuild test robot
2015-12-10 15:06 ` Arnd Bergmann
2015-12-10 15:17 ` Wolfram Sang
2015-12-12 16:20 ` Wolfram Sang
2015-12-12 21:05 ` Arnd Bergmann
2015-12-13 9:09 ` Wolfram Sang
2015-12-14 12:02 ` Arnd Bergmann
2015-12-14 13:52 ` Wolfram Sang
2015-12-14 22:27 ` Arnd Bergmann [this message]
2015-12-17 12:01 ` Wolfram Sang
2015-12-17 14:48 ` Arnd Bergmann
2015-12-17 19:40 ` Wolfram Sang
2015-12-17 19:57 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13702087.6o87OAVdIx@wuerfel \
--to=arnd@arndb.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox