I found this in my logs:

kernel: gpio gpiochip0: (gpio_aaeon): tried to insert a GPIO chip with zero lines
kernel: gpiochip_add_data_with_key: GPIOs 0..-1 (gpio_aaeon) failed to register, -22
kernel: gpio-aaeon: probe of gpio-aaeon.0 failed with error -22

What does it mean and how should I solve it?

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 21.04
Release:        21.04
Codename:       hirsute

Those messages are produced by the kernel General Purpose I/O code, apparently on trying to load the module that is introduced by this patch or its more developed equivalent.

Short version:

The module finds the WMI programming interface it's looking for, but overlooks the fact that the interface reports no controllable GPIO lines in your hardware. It should have stopped the registration attempt and rejected the module installation with a -ENODEV error code. You can get rid of the messages by blacklisting the gpio-aaeon module, i.e. by creating a file named e.g. /etc/modprobe.d/no-aaeon-gpio-here.conf with the following contents:

blacklist gpio-aaeon

You have found a bug in that kernel module, and might want to report it to the Linux GPIO developers. Your hardware seems to present an interesting "corner case" for testing the gpio_aaeon module, which the developers apparently haven't considered. This is understandable as the module seems to be fairly new: the patch I linked above was posted in late May of this year.

Long version:

The GPIO subsystem is complaining that the gpio_aaeon module attempted to register a chip that does not actually have any General Purpose I/O lines to control, so there is no point registering such a chip to the GPIO subsystem.

The registering happens in the probe function of the module:

+static int __init aaeon_gpio_probe(struct platform_device *pdev)
+   int err, i;
+   int dio_number = 0;
+   struct aaeon_gpio_data *data;
+   struct aaeon_gpio_bank *bank;
+   /* Prevent other drivers adding this platfom device */
+   if (!wmi_has_guid(AAEON_WMI_MGMT_GUID)) {
+       pr_debug("AAEON Management GUID not found\n");
+       return -ENODEV;
+   }
+   dio_number = aaeon_gpio_get_number();
+   if (dio_number < 0)
+       return -ENODEV;
+   data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+   if (!data)
+       return -ENOMEM;
+   data->nr_bank = ARRAY_SIZE(aaeon_gpio_bank);
+   data->bank = aaeon_gpio_bank;
+   platform_set_drvdata(pdev, data);
+   bank = &data->bank[0];
+   bank->chip.parent = &pdev->dev;
+   bank->chip.ngpio = dio_number;
+   bank->data = data;
+   err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank);
+   if (err)
+       pr_debug("Failed to register gpiochip %d: %d\n", i, err);
+   return err;

Since the attempt to load the module did not simply end with the -ENODEV error, your system apparently has the WMI management API this driver is looking for... but when queried, the API actually says it has nothing to control.

In other words, the module can proceed into the dio_number = aaeon_gpio_get_number(); call, which ends up just calling a WMI method to get a single integer number, which is apparently the number of GPIO lines available for control through this API. The WMI method returns no error... but the number of lines it reports is apparently 0.

The function proceeds into allocating some memory and starts building up the structures required by the Linux GPIO subsystem to register the GPIO lines for control. Once it's done that, it calls the devm_gpiochip_add_data() function of the GPIO subsystem to register a new GPIO chip... but the GPIO subsystem performs some sanity checking and notices those structures actually specify there is 0 GPIO lines to control in the chip.

According to Elixir.bootlin.com Linux kernel cross-referencer, the devm_gpiochip_add_data() is a macro that just calls the devm_gpiochip_add_data_with_key() function with the two last parameters NULLed out. That, in turn, calls the gpiochip_add_data_with_key() function, which will produce the first error message you're seeing on line #628.

The other messages after that get produced as the chain of function calls gets unwound as each function returns an error code to its caller.

If the value returned by the aaeon_gpio_get_number() is really the number of GPIO lines the WMI API can control, then the test:

+   if (dio_number < 0)
+       return -ENODEV;

should actually be:

+   if (dio_number < 1)
+       return -ENODEV;

But if the number returned by the WMI API actually means something subtly different, like "the 0-based number of the last controllable GPIO line" (i.e. value 0 would mean "there is just one GPIO line #0 and no others"), then using the dio_number as the value of bank->chip.ngpio results in an off-by-one error and the module would miss the last controllable GPIO line in all systems that have this WMI API for GPIOs.

So either way, there is something that needs to be fixed.


I had these same error messages trying to install Xubuntu 20.04 from a USB stick. I was using a Ryzen 5600X on an ASUS ROG STRIX R550-F motherboard. The problem was an nVidia graphics card. Once I selected the option with "safe graphics", it was able to start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.