Re: [PATCH v2 2/3] acpi: allow building without CONFIG_HAS_IOPORT
From: Andy Shevchenko
Date: Fri Oct 11 2024 - 05:56:03 EST
On Fri, Oct 11, 2024 at 06:18:18AM +0000, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> CONFIG_HAS_IOPORT will soon become optional and cause a build time
> failure when it is disabled but a driver calls inb()/outb(). At the
> moment, all architectures that can support ACPI have port I/O, but this
> is not necessarily the case in the future on non-x86 architectures.
> The result is a set of errors like:
>
> drivers/acpi/osl.c: In function 'acpi_os_read_port':
> include/asm-generic/io.h:542:14: error: call to '_inb' declared with attribute error: inb()) requires CONFIG_HAS_IOPORT
>
> Nothing should actually call these functions in this configuration,
> and if it does, the result would be undefined behavior today, possibly
> a NULL pointer dereference.
>
> Change the low-level functions to return a proper error code when
> HAS_IOPORT is disabled.
...
> + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
> + *value = BIT_MASK(width);
> + return AE_NOT_IMPLEMENTED;
Perhaps it has already been discussed, but why do we need to file value with
semi-garbage when we know it's invalid anyway?
> + }
--
With Best Regards,
Andy Shevchenko