Fix of_gpio compat shim build with CONFIG_OF_GPIO - #1288
Open
ElXreno wants to merge 1 commit into
Open
Conversation
The compat of_get_named_gpio() added for kernels that no longer ship
linux/of_gpio.h (removed by commit 51aaf65bbd21, "gpio: of: Remove
<linux/of_gpio.h>", v7.1-rc1) declares its __to_hwgpio() helper as taking
a const struct gpio_device *. gpio_device_get_chip() has taken a mutable
struct gpio_device * ever since it was introduced by commit 9b418780844c
("gpiolib: reluctantly provide gpio_device_get_chip()"), so the call
inside the CONFIG_OF_GPIO block discards the qualifier:
common/inc/nv-linux.h:1737:51: error: passing 'const struct gpio_device *'
to parameter of type 'struct gpio_device *' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
That block is only reachable on kernels >= 7.1 built with CONFIG_OF_GPIO,
which is why the desktop x86 configurations do not hit it.
The const buys nothing: the only caller, the compat of_get_named_gpio()
right below, holds a mutable gdev from gpio_device_find_by_fwnode(). Drop
it rather than casting it away.
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kernel-openfails to build against Linux 7.1 with clang when the kernel is configured withCONFIG_OF_GPIO=y.610.57.04 added a compat
of_get_named_gpio()for kernels that no longer shiplinux/of_gpio.h(removed by51aaf65bbd21, "gpio: of: Remove<linux/of_gpio.h>", v7.1-rc1). Its helper__to_hwgpio()takes aconst struct gpio_device *, butgpio_device_get_chip()has taken a mutablestruct gpio_device *ever since9b418780844c("gpiolib: reluctantly provide gpio_device_get_chip()"), so the call inside theCONFIG_OF_GPIOblock discards the qualifier:Three conditions have to line up, which is presumably why it slipped through:
linux/of_gpio.his absent, i.e. on kernels >= 7.1;CONFIG_OF_GPIO=y, which the usual x86 configurations leave off (it isdef_bool yunderCONFIG_OF, and distributions that enable device tree support on x86 for overlays get it implicitly);scripts/Makefile.warnadds-Werror=incompatible-pointer-typesunconditionally, and clang has-Wincompatible-pointer-types-discards-qualifiersinside that group. GCC reports the same code under the separate-Wdiscarded-qualifiers, which the flag does not cover, so GCC builds only warn.WARNINGS_AS_ERRORSis not involved.The
constis not load-bearing: the only caller is the compatof_get_named_gpio()a few lines below, and it holds a mutablegdevfromgpio_device_find_by_fwnode(). Dropping the qualifier is preferable to casting it away at the call site. The only consumer ofof_get_named_gpio()in the tree isnvidia/nv-dsi-parse-panel-props.c, which is Tegra-only, so x86 behaviour is unaffected either way.Verified by building the open modules of 610.57.04 against Linux 7.1.6 with clang 21 and
CONFIG_OF_GPIO=y: the build fails as above without this change and completes with it.