From: Jean Delvare <jdelvare@suse.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-i2c@vger.kernel.org, Biwen Li <biwen.li@nxp.com>
Subject: Re: [PATCH] i2c: avoid ifdeffery in I2C drivers with optional slave support
Date: Wed, 15 Apr 2020 11:51:42 +0200 [thread overview]
Message-ID: <20200415115142.06bc4ea7@endymion> (raw)
In-Reply-To: <20200415051619.GP27288@pengutronix.de>
On Wed, 15 Apr 2020 07:16:19 +0200, Sascha Hauer wrote:
> On Tue, Apr 14, 2020 at 04:40:09PM +0200, Jean Delvare wrote:
> > Sorry but you lost me here. How can I2C slave support be "optional" and
> > at the same time going without ifdefs?
>
> static int i2c_imx_reg_slave(struct i2c_client *client)
> {
> if (!IS_ENABLED(CONFIG_I2C_SLAVE))
> return -ESOMETHING;
> ...
> }
>
> The code is gone without CONFIG_I2C_SLAVE enabled, yet the compile coverage
> is there.
OK, *now* I see where you were going from the beginning ;-) And that
makes sense, for drivers which want optional I2C slave support.
Now I think this is down to 2 questions:
1* Does the i2c-imx driver actually need optional slave support, or can
this support be included unconditionally? Which distributions or
builds include this driver, and do they typically enable I2C_SLAVE?
I took a look at the SUSE kernel configs and we already have
I2C_SLAVE enabled on armv7 and arm64, so it will make no difference
there. Only our armv6 config includes this driver without I2C_SLAVE,
so that's the only one for which keeping the slave support optional
would help. My point is: you stated that you never used slave
support, and neither did I, but that's not really relevant. What is
relevant is whether kernels including these drivers are being built
with I2C_SLAVE or not in practice. If they are then it doesn't
matter if individual drivers go the conditional or unconditional
way, unless they add their own Kconfig option to explicitly enable
slave support (see below).
2* More generally, how many drivers would benefit from your proposed
change? At the moment I count 8 drivers selecting I2C_SLAVE, 3 of
these have a separate Kconfig option for including slave support
which actually makes slave support optional too but in a different
way. 1 driver (i2c-slave-eeprom) depends on I2C_SLAVE, and 1 driver
(i2c-aspeed) has #ifdefs for optional slave support. So we have a
total of 6 drivers which support slave mode unconditionally and 4
drivers which have conditional support. That doesn't mean that they
are right doing what they do though. Their authors may have gone for
unconditional just because they don't like ifdefs, or they may have
gone for conditional to play it safe. I'm also wondering why the 3
drivers which have a dedicated Kconfig option
(I2C_AT91_SLAVE_EXPERIMENTAL, I2C_DESIGNWARE_SLAVE and
I2C_PXA_SLAVE) did it that way. Is it on purpose because they
actually want to be able to force slave mode off even if support is
available at i2c core level? Is it by politeness to not forcibly
enable slave mode as soon as the driver is enabled? It matters
because in the former case, your proposed change is of no interest to
them, while in the latter case it is.
Unfortunately that's a lot of questions in the end and I do not know
the answers nor am I willing to spend time finding them, sorry.
> The patch I sent was a suggestion to do it like that. If that's not
> wanted I am fine with that and happily select CONFIG_I2C_SLAVE from the
> driver entry in Kconfig, or better, suggest Biwen Li
> (https://patchwork.kernel.org/patch/11271067/) to do this.
Well, there are advantages to both approaches, and without answers to
the questions above, I see no reason to favor one or the other. In such
situation I tend to stick to what we have. But of course the decision
is Wolfram's not mine.
--
Jean Delvare
SUSE L3 Support
next prev parent reply other threads:[~2020-04-15 9:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191204095348.9192-1-s.hauer@pengutronix.de>
2020-04-09 13:40 ` [PATCH] i2c: avoid ifdeffery in I2C drivers with optional slave support Wolfram Sang
2020-04-10 9:29 ` Jean Delvare
2020-04-14 11:56 ` Sascha Hauer
2020-04-14 14:40 ` Jean Delvare
2020-04-15 5:16 ` Sascha Hauer
2020-04-15 9:51 ` Jean Delvare [this message]
2020-04-17 14:00 ` Jean Delvare
2020-04-20 6:12 ` Sascha Hauer
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=20200415115142.06bc4ea7@endymion \
--to=jdelvare@suse.de \
--cc=biwen.li@nxp.com \
--cc=linux-i2c@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=wsa@the-dreams.de \
/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