* [PATCH] platform/x86: serial-multi-instantiate: Don't require both I2C and SPI
@ 2024-08-13 11:21 Richard Fitzgerald
2024-08-14 13:13 ` Richard Fitzgerald
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2024-08-13 11:21 UTC (permalink / raw)
To: hdegoede; +Cc: platform-driver-x86, linux-kernel, patches, Richard Fitzgerald
Change the Kconfig dependency to (I2C || SPI) so that it doesn't
require both bus subsystems to be enabled. 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.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
drivers/platform/x86/Kconfig | 2 +-
.../platform/x86/serial-multi-instantiate.c | 32 ++++++++++++++-----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 665fa9524986..c286742b34ba 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -999,7 +999,7 @@ config TOPSTAR_LAPTOP
config SERIAL_MULTI_INSTANTIATE
tristate "Serial bus multi instantiate pseudo device driver"
- depends on I2C && SPI && ACPI
+ depends on (I2C || SPI) && ACPI
help
Some ACPI-based systems list multiple devices in a single ACPI
firmware-node. This driver will instantiate separate clients
diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c
index 3be016cfe601..7c04cc9e5891 100644
--- a/drivers/platform/x86/serial-multi-instantiate.c
+++ b/drivers/platform/x86/serial-multi-instantiate.c
@@ -83,11 +83,15 @@ static int smi_get_irq(struct platform_device *pdev, struct acpi_device *adev,
static void smi_devs_unregister(struct smi *smi)
{
+#if IS_REACHABLE(CONFIG_I2C)
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]);
+ }
}
/**
@@ -258,9 +262,15 @@ static int smi_probe(struct platform_device *pdev)
switch (node->bus_type) {
case SMI_I2C:
- return smi_i2c_probe(pdev, smi, node->instances);
+ if (IS_REACHABLE(CONFIG_I2C))
+ return smi_i2c_probe(pdev, smi, node->instances);
+
+ return -ENODEV;
case SMI_SPI:
- return smi_spi_probe(pdev, smi, node->instances);
+ if (IS_REACHABLE(CONFIG_SPI))
+ return smi_spi_probe(pdev, smi, node->instances);
+
+ return -ENODEV;
case SMI_AUTO_DETECT:
/*
* For backwards-compatibility with the existing nodes I2C
@@ -270,10 +280,16 @@ static int smi_probe(struct platform_device *pdev)
* SpiSerialBus nodes that were previously ignored, and this
* preserves that behavior.
*/
- ret = smi_i2c_probe(pdev, smi, node->instances);
- if (ret != -ENOENT)
- return ret;
- return smi_spi_probe(pdev, smi, node->instances);
+ if (IS_REACHABLE(CONFIG_I2C)) {
+ ret = smi_i2c_probe(pdev, smi, node->instances);
+ if (ret != -ENOENT)
+ return ret;
+ }
+
+ if (IS_REACHABLE(CONFIG_SPI))
+ return smi_spi_probe(pdev, smi, node->instances);
+
+ return -ENODEV;
default:
return -EINVAL;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86: serial-multi-instantiate: Don't require both I2C and SPI
2024-08-13 11:21 [PATCH] platform/x86: serial-multi-instantiate: Don't require both I2C and SPI Richard Fitzgerald
@ 2024-08-14 13:13 ` Richard Fitzgerald
0 siblings, 0 replies; 2+ messages in thread
From: Richard Fitzgerald @ 2024-08-14 13:13 UTC (permalink / raw)
To: hdegoede; +Cc: platform-driver-x86, linux-kernel, patches
On 13/08/2024 12:21, Richard Fitzgerald wrote:
> Change the Kconfig dependency to (I2C || SPI) so that it doesn't
> require both bus subsystems to be enabled. 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.
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
> drivers/platform/x86/Kconfig | 2 +-
> .../platform/x86/serial-multi-instantiate.c | 32 ++++++++++++++-----
> 2 files changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 665fa9524986..c286742b34ba 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -999,7 +999,7 @@ config TOPSTAR_LAPTOP
>
> config SERIAL_MULTI_INSTANTIATE
> tristate "Serial bus multi instantiate pseudo device driver"
> - depends on I2C && SPI && ACPI
> + depends on (I2C || SPI) && ACPI
Please don't take this version.
It works better as:
depends on ACPI
depends on (I2C && !SPI) || (!I2C && SPI) || (I2C && SPI)
so if I2C or SPI =m then SERIAL_MULTI_INSTANTIATE must be
built as a module.
I will send a V2 with that change.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-14 13:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 11:21 [PATCH] platform/x86: serial-multi-instantiate: Don't require both I2C and SPI Richard Fitzgerald
2024-08-14 13:13 ` Richard Fitzgerald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox