]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpiolib: acpi: use min() instead of min_t()
authorDavid Laight <david.laight.linux@gmail.com>
Wed, 19 Nov 2025 22:41:14 +0000 (22:41 +0000)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 20 Nov 2025 08:08:27 +0000 (09:08 +0100)
min_t(u16, a, b) casts an 'unsigned long' to 'u16'.
Use min(a, b) instead as it promotes the both values to int
and so cannot discard significant bits.

In this case the values should be ok.

Detected by an extra check added to min_t().

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/gpio/gpiolib-acpi-core.c

index 284e762d92c4d48d9b55973b3bd1069ecadd2ee6..bcb8324d617de735e0888262cd66d1bdf833e2d0 100644 (file)
@@ -1096,7 +1096,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
                return AE_BAD_PARAMETER;
        }
 
-       length = min_t(u16, agpio->pin_table_length, pin_index + bits);
+       length = min(agpio->pin_table_length, pin_index + bits);
        for (i = pin_index; i < length; ++i) {
                unsigned int pin = agpio->pin_table[i];
                struct acpi_gpio_connection *conn;