[PATCH v1 2/7] media: em28xx: Split em28xx_pctv_290e_set_lna_gpio() helper
Andy Shevchenko <[email protected]> Wed, 15 Jul 2026 20:46:42 +0200
| Newsgroups | org.kernel.vger.linux-mips,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-doc,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-media |
|---|---|
| Message-ID | <[email protected]> |
Split em28xx_pctv_290e_set_lna_gpio() helper in order to deduplicate the GPIO request and setting. Signed-off-by: Andy Shevchenko <[email protected]> --- drivers/media/usb/em28xx/em28xx-dvb.c | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 8482fc4045ea..ef148a27c94d 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -737,17 +737,14 @@ static void pctv_520e_init(struct em28xx *dev) regs[i].r, regs[i].len); }; -static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) +static int em28xx_pctv_290e_set_lna_gpio(struct em28xx *dev, u32 lna) { - 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_LEGACY struct em28xx_dvb *dvb = dev->dvb; int ret; unsigned long flags; - if (c->lna == 1) + if (lna == 1) flags = GPIOF_OUT_INIT_HIGH; /* enable LNA */ else flags = GPIOF_OUT_INIT_LOW; /* disable LNA */ @@ -761,11 +758,20 @@ static int em28xx_pctv_290e_set_lna(struct dvb_frontend *fe) return ret; #else dev_warn(&dev->intf->dev, "%s: LNA control is disabled (lna=%u)\n", - KBUILD_MODNAME, c->lna); + KBUILD_MODNAME, lna); return 0; #endif } +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; + + return em28xx_pctv_290e_set_lna_gpio(dev, c->lna); +} + static int em28xx_pctv_292e_set_lna(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; @@ -1920,19 +1926,10 @@ static int em28xx_dvb_init(struct em28xx *dev) goto out_free; } -#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); - if (result) - dev_err(&dev->intf->dev, - "gpio request failed %d\n", - result); - else - gpio_free(dvb->lna_gpio); + em28xx_pctv_290e_set_lna_gpio(dev, 0); - result = 0; /* continue even set LNA fails */ -#endif + /* continue even set LNA fails */ dvb->fe[0]->ops.set_lna = em28xx_pctv_290e_set_lna; } -- 2.50.1