From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: ilpo.jarvinen@linux.intel.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH v2] platform/x86: serial-multi-instantiate: Don't require both I2C and SPI
Date: Tue, 27 Aug 2024 11:05:25 +0200 [thread overview]
Message-ID: <65362768-f64b-42d9-8f74-e4f5190af95c@redhat.com> (raw)
In-Reply-To: <ZszhKCKYl9161RIP@surfacebook.localdomain>
Hi Andy,
On 8/26/24 10:10 PM, Andy Shevchenko wrote:
> Wed, Aug 14, 2024 at 02:29:39PM +0100, Richard Fitzgerald kirjoitti:
>> Change the Kconfig dependency so that it doesn't require both I2C and SPI
>> subsystems to be built. Make a few small changes to the code so that the
>> code for a bus is only called if the bus is being built.
>>
>> When SPI support was added to serial-multi-instantiate it created a
>> dependency that both CONFIG_I2C and CONFIG_SPI must be enabled.
>> Typically they are, but there's no reason why this should be a
>> requirement. A specific kernel build could have only I2C devices
>> or only SPI devices. It should be possible to use serial-multi-instantiate
>> if only I2C or only SPI is enabled.
>>
>> The dependency formula used is:
>>
>> depends on (I2C && !SPI) || (!I2C && SPI) || (I2C && SPI)
>>
>> The advantage of this approach is that if I2C=m or SPI=m then
>> SERIAL_MULTI_INSTANTIATE is limited to n/m.
>
> ...
>
>> static void smi_devs_unregister(struct smi *smi)
>> {
>> +#if IS_REACHABLE(CONFIG_I2C)
>
> There is no explanation why ugly ifdeffery is used here, while normal
> conditionals elsewhere.
Note that this has already been merged as is, as you've figured
out yourself the reason to use #ifdef here is because
there is no i2c_unregister_device() prototype declared when
CONFIG_I2C=n
>
>> while (smi->i2c_num--)
>> i2c_unregister_device(smi->i2c_devs[smi->i2c_num]);
>> +#endif
>>
>> - while (smi->spi_num--)
>> - spi_unregister_device(smi->spi_devs[smi->spi_num]);
>> + if (IS_REACHABLE(CONFIG_SPI)) {
>> + while (smi->spi_num--)
>> + spi_unregister_device(smi->spi_devs[smi->spi_num]);
>> + }
>> }
>
> There are ways to solve this:
> 1) add a stub for I2C=n for i2c_unregister_device();
Yes that would be an option to clean this up a bit as a follow-up
patch series.
Note no need for a stub, just move the declaration out of
the #if IS_ENABLED(CONFIG_I2C) block, using if (IS_REACHABLE)
only requires a prototype.
> 2) resplit this driver to have several built modules:
> core, I2C parts, SPI parts.
>
Regards,
Hans
prev parent reply other threads:[~2024-08-27 9:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 13:29 Richard Fitzgerald
2024-08-19 13:17 ` Hans de Goede
2024-08-26 20:10 ` Andy Shevchenko
2024-08-27 9:05 ` Hans de Goede [this message]
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=65362768-f64b-42d9-8f74-e4f5190af95c@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy.shevchenko@gmail.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rf@opensource.cirrus.com \
/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
all inboxes | Powered by JetHome®