Re: [PATCH 12/36] media: remove conditional return with no effect
From: Sakari Ailus
Date: Mon Aug 10 2026 - 05:41:45 EST
Hi Laurent, Sang-Heon,
On Fri, Aug 07, 2026 at 03:28:25PM +0300, Laurent Pinchart wrote:
> On Fri, Jul 24, 2026 at 03:45:14AM +0900, Sang-Heon Jeon wrote:
> > Both branches of the check return the same value, so the check has
> > no effect. Remove it and return the value directly.
> >
> > This is the result of running the Coccinelle script from
> > scripts/coccinelle/misc/cond_return_no_effect.cocci.
> >
> > Signed-off-by: Sang-Heon Jeon <ekffu200098@xxxxxxxxx>
> > ---
> > drivers/media/i2c/mt9p031.c | 6 +-----
> > .../media/platform/microchip/microchip-sama7g5-isc.c | 7 +------
> > drivers/media/platform/qcom/iris/iris_resources.c | 6 +-----
> > drivers/media/platform/qcom/venus/pm_helpers.c | 7 +------
> > drivers/media/platform/renesas/rcar-csi2.c | 6 +-----
> > .../media/platform/samsung/s3c-camif/camif-core.c | 7 +------
> > drivers/media/usb/dvb-usb-v2/mxl111sf.c | 12 ++----------
> > drivers/media/usb/gspca/jl2005bcd.c | 7 +------
> > 8 files changed, 9 insertions(+), 49 deletions(-)
> >
> > diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> > index d21510caf45a..2b09e8315c8e 100644
> > --- a/drivers/media/i2c/mt9p031.c
> > +++ b/drivers/media/i2c/mt9p031.c
> > @@ -452,11 +452,7 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)
> > ret = mt9p031_write(client, MT9P031_HORIZONTAL_BLANK, hblank - 1);
> > if (ret < 0)
> > return ret;
> > - ret = mt9p031_write(client, MT9P031_VERTICAL_BLANK, vblank - 1);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return ret;
>
> I would have just replaced the last line with a
>
> return 0;
>
> as I find it easier to read code that has multiple error paths when all
> the error paths look the same. It's a small personal preference though
> (and ths best option would be to convert this driver to the CCI
> helpers), so I'm OK with this change as-is.
I wouldn't make an exception here, but obviously CCI is the way to go.
>
> > + return mt9p031_write(client, MT9P031_VERTICAL_BLANK, vblank - 1);
> > }
> >
> > static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
> > diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
> > index b0302dfc3278..7383341ec51d 100644
> > --- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
> > +++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
> > @@ -598,13 +598,8 @@ static int __maybe_unused xisc_runtime_suspend(struct device *dev)
> > static int __maybe_unused xisc_runtime_resume(struct device *dev)
> > {
> > struct isc_device *isc = dev_get_drvdata(dev);
> > - int ret;
> > -
> > - ret = clk_prepare_enable(isc->hclock);
> > - if (ret)
> > - return ret;
> >
> > - return ret;
> > + return clk_prepare_enable(isc->hclock);
>
> Here the change looks good, there's a single error paths so a direct
> return is fine.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
>
> > }
> >
> > static const struct dev_pm_ops microchip_xisc_dev_pm_ops = {
> > diff --git a/drivers/media/platform/qcom/iris/iris_resources.c b/drivers/media/platform/qcom/iris/iris_resources.c
> > index 773f6548370a..872bd09656b1 100644
> > --- a/drivers/media/platform/qcom/iris/iris_resources.c
> > +++ b/drivers/media/platform/qcom/iris/iris_resources.c
> > @@ -78,11 +78,7 @@ int iris_enable_power_domains(struct iris_core *core, struct device *pd_dev)
> > if (ret)
> > return ret;
> >
> > - ret = pm_runtime_get_sync(pd_dev);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return ret;
> > + return pm_runtime_get_sync(pd_dev);
The patch no longer applies after commit
f87d7eda07fca21efe4b96169ae59007db46e60e .
> > }
> >
> > int iris_disable_power_domains(struct iris_core *core, struct device *pd_dev)
> > diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> > index be1cbd5cfe84..e88e66be4f6d 100644
> > --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> > +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> > @@ -781,7 +781,6 @@ static int decide_core(struct venus_inst *inst)
> > unsigned long max_freq = ULONG_MAX;
> > struct device *dev = core->dev;
> > struct dev_pm_opp *opp;
> > - int ret = 0;
> >
> > if (legacy_binding) {
> > if (inst->session_type == VIDC_SESSION_TYPE_DEC)
> > @@ -829,11 +828,7 @@ static int decide_core(struct venus_inst *inst)
> > }
> >
> > done:
> > - ret = hfi_session_set_property(inst, ptype, &cu);
> > - if (ret)
> > - return ret;
> > -
> > - return ret;
> > + return hfi_session_set_property(inst, ptype, &cu);
> > }
> >
> > static int acquire_core(struct venus_inst *inst)
> > diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
> > index 7305cc4a04cb..6635f5782175 100644
> > --- a/drivers/media/platform/renesas/rcar-csi2.c
> > +++ b/drivers/media/platform/renesas/rcar-csi2.c
> > @@ -2273,11 +2273,7 @@ static int rcsi2_init_phtw_v3u(struct rcar_csi2 *priv,
> > return ret;
> > }
> >
> > - ret = rcsi2_phtw_write_array(priv, step4, ARRAY_SIZE(step4));
> > - if (ret)
> > - return ret;
> > -
> > - return ret;
> > + return rcsi2_phtw_write_array(priv, step4, ARRAY_SIZE(step4));
> > }
> >
> > /* -----------------------------------------------------------------------------
> > diff --git a/drivers/media/platform/samsung/s3c-camif/camif-core.c b/drivers/media/platform/samsung/s3c-camif/camif-core.c
> > index 14eedd1ceb27..bb06847f3a63 100644
> > --- a/drivers/media/platform/samsung/s3c-camif/camif-core.c
> > +++ b/drivers/media/platform/samsung/s3c-camif/camif-core.c
> > @@ -301,7 +301,6 @@ static int camif_media_dev_init(struct camif_dev *camif)
> > struct media_device *md = &camif->media_dev;
> > struct v4l2_device *v4l2_dev = &camif->v4l2_dev;
> > unsigned int ip_rev = camif->variant->ip_revision;
> > - int ret;
> >
> > memset(md, 0, sizeof(*md));
> > snprintf(md->model, sizeof(md->model), "Samsung S3C%s CAMIF",
> > @@ -316,11 +315,7 @@ static int camif_media_dev_init(struct camif_dev *camif)
> >
> > media_device_init(md);
> >
> > - ret = v4l2_device_register(camif->dev, v4l2_dev);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return ret;
> > + return v4l2_device_register(camif->dev, v4l2_dev);
> > }
> >
> > static void camif_clk_put(struct camif_dev *camif)
> > diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
> > index 870ac3c8b085..6404eb74db32 100644
> > --- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
> > +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
> > @@ -987,11 +987,7 @@ static int mxl111sf_frontend_attach_atsc_mh(struct dvb_usb_adapter *adap)
> > if (ret < 0)
> > return ret;
> >
> > - ret = mxl111sf_lg2160_frontend_attach(adap, 2);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return ret;
> > + return mxl111sf_lg2160_frontend_attach(adap, 2);
> > }
> >
> > static int mxl111sf_frontend_attach_mercury(struct dvb_usb_adapter *adap)
> > @@ -1007,11 +1003,7 @@ static int mxl111sf_frontend_attach_mercury(struct dvb_usb_adapter *adap)
> > if (ret < 0)
> > return ret;
> >
> > - ret = mxl111sf_lg2161_ep6_frontend_attach(adap, 2);
> > - if (ret < 0)
> > - return ret;
> > -
> > - return ret;
> > + return mxl111sf_lg2161_ep6_frontend_attach(adap, 2);
> > }
> >
> > static int mxl111sf_frontend_attach_mercury_mh(struct dvb_usb_adapter *adap)
> > diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c
> > index a408fcc3a060..4988fbf5005e 100644
> > --- a/drivers/media/usb/gspca/jl2005bcd.c
> > +++ b/drivers/media/usb/gspca/jl2005bcd.c
> > @@ -148,17 +148,12 @@ static int jl2005c_start_new_frame(struct gspca_dev *gspca_dev)
> > static int jl2005c_write_reg(struct gspca_dev *gspca_dev, unsigned char reg,
> > unsigned char value)
> > {
> > - int retval;
> > u8 instruction[2];
> >
> > instruction[0] = reg;
> > instruction[1] = value;
> >
> > - retval = jl2005c_write2(gspca_dev, instruction);
> > - if (retval < 0)
> > - return retval;
> > -
> > - return retval;
> > + return jl2005c_write2(gspca_dev, instruction);
> > }
> >
> > static int jl2005c_get_firmware_id(struct gspca_dev *gspca_dev)
>
--
Regards,
Sakari Ailus