Linux Media Controller development
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	mchehab@kernel.org, linus.walleij@linaro.org, brgl@bgdev.pl,
	linux-media@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-5.15] media: em28xx: add special case for legacy gpiolib interface
Date: Sat, 25 Oct 2025 11:55:49 -0400	[thread overview]
Message-ID: <20251025160905.3857885-118-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

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);
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:53 ` [PATCH AUTOSEL 6.17] media: nxp: imx8-isi: Fix streaming cleanup on release Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17] drm/xe: improve dma-resv handling for backup object Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Only validate format in querystd Sasha Levin
2025-10-25 15:54 ` [PATCH AUTOSEL 6.17-6.6] media: ov08x40: Fix the horizontal flip control Sasha Levin
2025-10-25 15:55 ` Sasha Levin [this message]
2025-10-27  9:24   ` [PATCH AUTOSEL 6.17-5.15] media: em28xx: add special case for legacy gpiolib interface Arnd Bergmann
2025-11-04 13:55     ` Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Do not write format to device in set_fmt Sasha Levin
2025-10-25 15:56 ` [PATCH AUTOSEL 6.17] media: imx-mipi-csis: Only set clock rate when specified in DT Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17] media: qcom: camss: csiphy-3ph: Add CSIPHY 2ph DPHY v2.0.1 init sequence Sasha Levin
2025-10-25 15:57 ` [PATCH AUTOSEL 6.17-5.4] media: redrat3: use int type to store negative error codes Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: pci: ivtv: Don't create fake v4l2_fh Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.4] media: imon: make send_packet() more robust Sasha Levin
2025-10-25 15:58 ` [PATCH AUTOSEL 6.17-5.15] media: adv7180: Add missing lock in suspend callback Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: verisilicon: Explicitly disable selection api ioctls for decoders Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: pci: mgb4: Fix timings comparison in VIDIOC_S_DV_TIMINGS Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.12] media: ipu6: isys: Set embedded data type correctly for metadata formats Sasha Levin
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-6.1] media: i2c: og01a1b: Specify monochrome media bus format instead of Bayer Sasha Levin
2025-10-25 16:00 ` [PATCH AUTOSEL 6.17-6.1] media: amphion: Delete v4l2_fh synchronously in .release() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251025160905.3857885-118-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=arnd@arndb.de \
    --cc=brgl@bgdev.pl \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox