From: Arnd Bergmann arnd@arndb.de
[ Upstream commit d5d299e7e7f6b4ead31383d4abffca34e4296df0 ]
The em28xx driver uses the old-style gpio_request_one() interface to switch the lna on the PCTV 290E card.
This interface is becoming optional and should no longer be called by portable drivers. As I could not figure out an obvious replacement, select the new GPIOLIB_LEGACY symbol as a workaround.
Signed-off-by: Arnd Bergmann arnd@arndb.de Signed-off-by: Hans Verkuil hverkuil+cisco@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- What it fixes: Prevents build breakage when `GPIOLIB=y` but the legacy GPIO consumer API is disabled. `gpio_request_one()` is only declared when `CONFIG_GPIOLIB_LEGACY` is enabled (see `include/linux/gpio.h:88`), so compiling code guarded only by `CONFIG_GPIOLIB` fails if legacy support is off.
- Code changes (small and contained): - Guards updated to match the actual availability of `gpio_request_one()`: - `drivers/media/usb/em28xx/em28xx-dvb.c:730` switches `#ifdef CONFIG_GPIOLIB` to `#ifdef CONFIG_GPIOLIB_LEGACY` in `em28xx_pctv_290e_set_lna()`, so the legacy-only API is used only when the legacy interface is present. - `drivers/media/usb/em28xx/em28xx-dvb.c:1708` does the same in `em28xx_dvb_init()` where the LNA is enabled on init for the PCTV 290E. - Kconfig ensures the legacy API is pulled in when this driver configuration requires it: - `drivers/media/usb/em28xx/Kconfig:71` adds `select GPIOLIB_LEGACY if GPIOLIB && DVB_CXD2820R`.
- Behavior and scope: - If `GPIOLIB_LEGACY` is available, functionality is unchanged: the driver still toggles the LNA via `gpio_request_one()` and frees it. - If `GPIOLIB=y` but `GPIOLIB_LEGACY=n`, the code now cleanly compiles and falls back to a warning and no-op in `em28xx_pctv_290e_set_lna()` (see `drivers/media/usb/em28xx/em28xx- dvb.c:750`), avoiding a build error. - The Kconfig `select` line actively keeps legacy enabled for this combo, preserving LNA control where it mattered before.
- Risk assessment: - No architectural changes; purely Kconfig and preprocessor guards. - Touches only the em28xx media USB driver and its Kconfig. - Aligns with the tree-wide pattern where `gpio_request_one()` and friends are guarded by `CONFIG_GPIOLIB_LEGACY` (e.g., `include/linux/gpio.h:88`, multiple existing users throughout the tree). - Minimal regression risk; at worst, adds the tiny legacy gpiolib- legacy code when selected by Kconfig.
- Stable criteria fit: - Fixes a real user-facing problem (build failure in valid configs). - Small, targeted, and low risk. - No new features; purely compatibility/build fix.
Note: Backport is relevant for stable series where `CONFIG_GPIOLIB_LEGACY` exists and can be disabled. Older stable series lacking this symbol won’t need (or may not accept) the Kconfig/guard changes.
drivers/media/usb/em28xx/Kconfig | 1 + drivers/media/usb/em28xx/em28xx-dvb.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig index cb61fd6cc6c61..3122d4bdfc596 100644 --- a/drivers/media/usb/em28xx/Kconfig +++ b/drivers/media/usb/em28xx/Kconfig @@ -68,6 +68,7 @@ config VIDEO_EM28XX_DVB select MEDIA_TUNER_XC5000 if MEDIA_SUBDRV_AUTOSELECT select MEDIA_TUNER_MT2060 if MEDIA_SUBDRV_AUTOSELECT select DVB_MXL692 if MEDIA_SUBDRV_AUTOSELECT + select GPIOLIB_LEGACY if GPIOLIB && DVB_CXD2820R help This adds support for DVB cards based on the Empiatech em28xx chips. diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 9fce59979e3bd..b94f5c70ab750 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -727,7 +727,7 @@ static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct em28xx_i2c_bus *i2c_bus = fe->dvb->priv; struct em28xx *dev = i2c_bus->dev; -#ifdef CONFIG_GPIOLIB +#ifdef CONFIG_GPIOLIB_LEGACY struct em28xx_dvb *dvb = dev->dvb; int ret; unsigned long flags; @@ -1705,7 +1705,7 @@ static int em28xx_dvb_init(struct em28xx *dev) goto out_free; }
-#ifdef CONFIG_GPIOLIB +#ifdef CONFIG_GPIOLIB_LEGACY /* enable LNA for DVB-T, DVB-T2 and DVB-C */ result = gpio_request_one(dvb->lna_gpio, GPIOF_OUT_INIT_LOW, NULL);