* [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled
@ 2026-05-21 15:33 Hugo Villeneuve
2026-05-25 17:43 ` Randy Dunlap
0 siblings, 1 reply; 4+ messages in thread
From: Hugo Villeneuve @ 2026-05-21 15:33 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Hugo Villeneuve
Cc: hugo, kernel test robot, linux-kernel, linux-serial
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Since commit 20ffe4b3330a8 ("serial: max310x: allow driver to be built with
SPI or I2C"), if I2C is enabled and SPI_MASTER is disabled, we have these
compile errors:
drivers/tty/serial/max310x.c: In function 'max310x_uart_init':
drivers/tty/serial/max310x.c: error: 'max310x_spi_driver' undeclared...
drivers/tty/serial/max310x.c: In function ‘max310x_uart_init’:
drivers/tty/serial/max310x.c: error: label ‘err_spi_register’
defined but not used...
drivers/tty/serial/max310x.c: error: ‘regcfg’ defined but not used
Fix by properly encapsulating i2c/spi code/variables in their respective
context with IS_ENABLED() macros for CONFIG_I2C and CONFIG_SPI_MASTER.
Also fix link failure with SERIAL_MAX310X=y and I2C=m by modifying Kconfig
depends.
Fixes: 20ffe4b3330a8 ("serial: max310x: allow driver to be built with SPI or I2C")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605121847.N9DVLNg2-lkp@intel.com/
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
note: not Cc-ing stable as the commit is still in tty-next, and even if the
errors originate from original commit that added I2C support, they were not
trigerred because the driver could not be selected/compiled if
CONFIG_SPI_MASTER was disabled.
Changes for v3:
- Fix link failure with SERIAL_MAX310X=y and I2C=m (Arnd Bergmann)
Changes for v2:
- replace #ifdef with #if IS_ENABLED() to suppoirt both built-in and modules
options
---
drivers/tty/serial/Kconfig | 2 +-
drivers/tty/serial/max310x.c | 48 +++++++++++++++++++-----------------
2 files changed, 27 insertions(+), 23 deletions(-)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index f834e5d292fd7..4accbfa75074c 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -321,7 +321,7 @@ config SERIAL_MAX3100
config SERIAL_MAX310X
tristate "MAX310X support"
- depends on SPI_MASTER || I2C
+ depends on (SPI_MASTER && !I2C) || I2C
select SERIAL_CORE
select REGMAP_SPI if SPI_MASTER
select REGMAP_I2C if I2C
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 9f423b3b4201d..bad5329a0c84c 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -16,6 +16,7 @@
#include <linux/device.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
+#include <linux/kconfig.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
@@ -1507,6 +1508,21 @@ static const struct of_device_id __maybe_unused max310x_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, max310x_dt_ids);
+static const char *max310x_regmap_name(u8 port_id)
+{
+ switch (port_id) {
+ case 0: return "port0";
+ case 1: return "port1";
+ case 2: return "port2";
+ case 3: return "port3";
+ default:
+ WARN_ON(true);
+ return NULL;
+ }
+}
+
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+
static struct regmap_config regcfg = {
.reg_bits = 8,
.val_bits = 8,
@@ -1522,20 +1538,6 @@ static struct regmap_config regcfg = {
.max_raw_write = MAX310X_FIFO_SIZE,
};
-static const char *max310x_regmap_name(u8 port_id)
-{
- switch (port_id) {
- case 0: return "port0";
- case 1: return "port1";
- case 2: return "port2";
- case 3: return "port3";
- default:
- WARN_ON(true);
- return NULL;
- }
-}
-
-#ifdef CONFIG_SPI_MASTER
static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
{
struct max310x_port *s = dev_get_drvdata(dev);
@@ -1606,7 +1608,8 @@ static struct spi_driver max310x_spi_driver = {
};
#endif
-#ifdef CONFIG_I2C
+#if IS_ENABLED(CONFIG_I2C)
+
static int max310x_i2c_extended_reg_enable(struct device *dev, bool enable)
{
return 0;
@@ -1726,13 +1729,13 @@ static int __init max310x_uart_init(void)
if (ret)
return ret;
-#ifdef CONFIG_SPI_MASTER
+#if IS_ENABLED(CONFIG_SPI_MASTER)
ret = spi_register_driver(&max310x_spi_driver);
if (ret)
goto err_spi_register;
#endif
-#ifdef CONFIG_I2C
+#if IS_ENABLED(CONFIG_I2C)
ret = i2c_add_driver(&max310x_i2c_driver);
if (ret)
goto err_i2c_register;
@@ -1740,12 +1743,13 @@ static int __init max310x_uart_init(void)
return 0;
-#ifdef CONFIG_I2C
+#if IS_ENABLED(CONFIG_I2C)
err_i2c_register:
- spi_unregister_driver(&max310x_spi_driver);
#endif
-
+#if IS_ENABLED(CONFIG_SPI_MASTER)
+ spi_unregister_driver(&max310x_spi_driver);
err_spi_register:
+#endif
uart_unregister_driver(&max310x_uart);
return ret;
@@ -1754,11 +1758,11 @@ module_init(max310x_uart_init);
static void __exit max310x_uart_exit(void)
{
-#ifdef CONFIG_I2C
+#if IS_ENABLED(CONFIG_I2C)
i2c_del_driver(&max310x_i2c_driver);
#endif
-#ifdef CONFIG_SPI_MASTER
+#if IS_ENABLED(CONFIG_SPI_MASTER)
spi_unregister_driver(&max310x_spi_driver);
#endif
base-commit: 16e95bfb79b5d9d01dc7651d98caf3c2ace331cd
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled
2026-05-21 15:33 [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled Hugo Villeneuve
@ 2026-05-25 17:43 ` Randy Dunlap
2026-05-26 13:34 ` Hugo Villeneuve
0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2026-05-25 17:43 UTC (permalink / raw)
To: Hugo Villeneuve, Greg Kroah-Hartman, Jiri Slaby, Hugo Villeneuve
Cc: kernel test robot, linux-kernel, linux-serial
On 5/21/26 8:33 AM, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>
> Since commit 20ffe4b3330a8 ("serial: max310x: allow driver to be built with
> SPI or I2C"), if I2C is enabled and SPI_MASTER is disabled, we have these
> compile errors:
>
> drivers/tty/serial/max310x.c: In function 'max310x_uart_init':
> drivers/tty/serial/max310x.c: error: 'max310x_spi_driver' undeclared...
> drivers/tty/serial/max310x.c: In function ‘max310x_uart_init’:
> drivers/tty/serial/max310x.c: error: label ‘err_spi_register’
> defined but not used...
> drivers/tty/serial/max310x.c: error: ‘regcfg’ defined but not used
>
> Fix by properly encapsulating i2c/spi code/variables in their respective
> context with IS_ENABLED() macros for CONFIG_I2C and CONFIG_SPI_MASTER.
>
> Also fix link failure with SERIAL_MAX310X=y and I2C=m by modifying Kconfig
> depends.
>
> Fixes: 20ffe4b3330a8 ("serial: max310x: allow driver to be built with SPI or I2C")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605121847.N9DVLNg2-lkp@intel.com/
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> ---
> note: not Cc-ing stable as the commit is still in tty-next, and even if the
> errors originate from original commit that added I2C support, they were not
> trigerred because the driver could not be selected/compiled if
> CONFIG_SPI_MASTER was disabled.
>
> Changes for v3:
> - Fix link failure with SERIAL_MAX310X=y and I2C=m (Arnd Bergmann)
>
> Changes for v2:
> - replace #ifdef with #if IS_ENABLED() to suppoirt both built-in and modules
> options
> ---
> drivers/tty/serial/Kconfig | 2 +-
> drivers/tty/serial/max310x.c | 48 +++++++++++++++++++-----------------
> 2 files changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index f834e5d292fd7..4accbfa75074c 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -321,7 +321,7 @@ config SERIAL_MAX3100
>
> config SERIAL_MAX310X
> tristate "MAX310X support"
> - depends on SPI_MASTER || I2C
> + depends on (SPI_MASTER && !I2C) || I2C
> select SERIAL_CORE
> select REGMAP_SPI if SPI_MASTER
> select REGMAP_I2C if I2C
Other than preferring Arnd's Kconfig dependencies (easier to
read/understand IMO), this is all good.
Thanks.
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
--
~Randy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled
2026-05-25 17:43 ` Randy Dunlap
@ 2026-05-26 13:34 ` Hugo Villeneuve
2026-05-26 16:19 ` Randy Dunlap
0 siblings, 1 reply; 4+ messages in thread
From: Hugo Villeneuve @ 2026-05-26 13:34 UTC (permalink / raw)
To: Randy Dunlap
Cc: Greg Kroah-Hartman, Jiri Slaby, Hugo Villeneuve,
kernel test robot, linux-kernel, linux-serial
On Mon, 25 May 2026 10:43:40 -0700
Randy Dunlap <rdunlap@infradead.org> wrote:
>
>
> On 5/21/26 8:33 AM, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> >
> > Since commit 20ffe4b3330a8 ("serial: max310x: allow driver to be built with
> > SPI or I2C"), if I2C is enabled and SPI_MASTER is disabled, we have these
> > compile errors:
> >
> > drivers/tty/serial/max310x.c: In function 'max310x_uart_init':
> > drivers/tty/serial/max310x.c: error: 'max310x_spi_driver' undeclared...
> > drivers/tty/serial/max310x.c: In function ‘max310x_uart_init’:
> > drivers/tty/serial/max310x.c: error: label ‘err_spi_register’
> > defined but not used...
> > drivers/tty/serial/max310x.c: error: ‘regcfg’ defined but not used
> >
> > Fix by properly encapsulating i2c/spi code/variables in their respective
> > context with IS_ENABLED() macros for CONFIG_I2C and CONFIG_SPI_MASTER.
> >
> > Also fix link failure with SERIAL_MAX310X=y and I2C=m by modifying Kconfig
> > depends.
> >
> > Fixes: 20ffe4b3330a8 ("serial: max310x: allow driver to be built with SPI or I2C")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202605121847.N9DVLNg2-lkp@intel.com/
> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > ---
> > note: not Cc-ing stable as the commit is still in tty-next, and even if the
> > errors originate from original commit that added I2C support, they were not
> > trigerred because the driver could not be selected/compiled if
> > CONFIG_SPI_MASTER was disabled.
> >
> > Changes for v3:
> > - Fix link failure with SERIAL_MAX310X=y and I2C=m (Arnd Bergmann)
> >
> > Changes for v2:
> > - replace #ifdef with #if IS_ENABLED() to suppoirt both built-in and modules
> > options
> > ---
> > drivers/tty/serial/Kconfig | 2 +-
> > drivers/tty/serial/max310x.c | 48 +++++++++++++++++++-----------------
> > 2 files changed, 27 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> > index f834e5d292fd7..4accbfa75074c 100644
> > --- a/drivers/tty/serial/Kconfig
> > +++ b/drivers/tty/serial/Kconfig
> > @@ -321,7 +321,7 @@ config SERIAL_MAX3100
> >
> > config SERIAL_MAX310X
> > tristate "MAX310X support"
> > - depends on SPI_MASTER || I2C
> > + depends on (SPI_MASTER && !I2C) || I2C
> > select SERIAL_CORE
> > select REGMAP_SPI if SPI_MASTER
> > select REGMAP_I2C if I2C
>
> Other than preferring Arnd's Kconfig dependencies (easier to
> read/understand IMO), this is all good.
> Thanks.
Hi Randy,
thank you for testing this.
I personnaly think both syntaxes are confusing :)
I have a long term goal of converting this driver to core and
I2C/SPI parts eventually, like I did for the sc16is7xx...
Hugo.
>
> Acked-by: Randy Dunlap <rdunlap@infradead.org>
> Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
>
> --
> ~Randy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled
2026-05-26 13:34 ` Hugo Villeneuve
@ 2026-05-26 16:19 ` Randy Dunlap
0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2026-05-26 16:19 UTC (permalink / raw)
To: Hugo Villeneuve
Cc: Greg Kroah-Hartman, Jiri Slaby, Hugo Villeneuve,
kernel test robot, linux-kernel, linux-serial
On 5/26/26 6:34 AM, Hugo Villeneuve wrote:
> On Mon, 25 May 2026 10:43:40 -0700
> Randy Dunlap <rdunlap@infradead.org> wrote:
>
>>
>>
>> On 5/21/26 8:33 AM, Hugo Villeneuve wrote:
>>> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>>>
>>> Since commit 20ffe4b3330a8 ("serial: max310x: allow driver to be built with
>>> SPI or I2C"), if I2C is enabled and SPI_MASTER is disabled, we have these
>>> compile errors:
>>>
>>> drivers/tty/serial/max310x.c: In function 'max310x_uart_init':
>>> drivers/tty/serial/max310x.c: error: 'max310x_spi_driver' undeclared...
>>> drivers/tty/serial/max310x.c: In function ‘max310x_uart_init’:
>>> drivers/tty/serial/max310x.c: error: label ‘err_spi_register’
>>> defined but not used...
>>> drivers/tty/serial/max310x.c: error: ‘regcfg’ defined but not used
>>>
>>> Fix by properly encapsulating i2c/spi code/variables in their respective
>>> context with IS_ENABLED() macros for CONFIG_I2C and CONFIG_SPI_MASTER.
>>>
>>> Also fix link failure with SERIAL_MAX310X=y and I2C=m by modifying Kconfig
>>> depends.
>>>
>>> Fixes: 20ffe4b3330a8 ("serial: max310x: allow driver to be built with SPI or I2C")
>>> Reported-by: kernel test robot <lkp@intel.com>
>>> Closes: https://lore.kernel.org/oe-kbuild-all/202605121847.N9DVLNg2-lkp@intel.com/
>>> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>>> ---
>>> note: not Cc-ing stable as the commit is still in tty-next, and even if the
>>> errors originate from original commit that added I2C support, they were not
>>> trigerred because the driver could not be selected/compiled if
>>> CONFIG_SPI_MASTER was disabled.
>>>
>>> Changes for v3:
>>> - Fix link failure with SERIAL_MAX310X=y and I2C=m (Arnd Bergmann)
>>>
>>> Changes for v2:
>>> - replace #ifdef with #if IS_ENABLED() to suppoirt both built-in and modules
>>> options
>>> ---
>>> drivers/tty/serial/Kconfig | 2 +-
>>> drivers/tty/serial/max310x.c | 48 +++++++++++++++++++-----------------
>>> 2 files changed, 27 insertions(+), 23 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
>>> index f834e5d292fd7..4accbfa75074c 100644
>>> --- a/drivers/tty/serial/Kconfig
>>> +++ b/drivers/tty/serial/Kconfig
>>> @@ -321,7 +321,7 @@ config SERIAL_MAX3100
>>>
>>> config SERIAL_MAX310X
>>> tristate "MAX310X support"
>>> - depends on SPI_MASTER || I2C
>>> + depends on (SPI_MASTER && !I2C) || I2C
>>> select SERIAL_CORE
>>> select REGMAP_SPI if SPI_MASTER
>>> select REGMAP_I2C if I2C
>>
>> Other than preferring Arnd's Kconfig dependencies (easier to
>> read/understand IMO), this is all good.
>> Thanks.
>
> Hi Randy,
> thank you for testing this.
>
> I personnaly think both syntaxes are confusing :)
>
> I have a long term goal of converting this driver to core and
> I2C/SPI parts eventually, like I did for the sc16is7xx...
Yes, I've noticed that some similar drivers are actually 2 drivers.
For the Kconfig, another option is:
depends on SPI_MASTER || I2C
depends on I2C if I2C # limits this config to m if I2C=m
(not tested :)
but it's not necessarily better, just different.
--
~Randy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-26 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-21 15:33 [PATCH v3] serial: max310x: fix compile errors if CONFIG_SPI_MASTER is disabled Hugo Villeneuve
2026-05-25 17:43 ` Randy Dunlap
2026-05-26 13:34 ` Hugo Villeneuve
2026-05-26 16:19 ` Randy Dunlap
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®