From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0127.outbound.protection.outlook.com ([104.47.36.127]:18752 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729115AbeIOGts (ORCPT ); Sat, 15 Sep 2018 02:49:48 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Enrico Scholz , Jan Luebbe , Philipp Zabel , Sasha Levin Subject: [PATCH AUTOSEL 4.14 23/57] gpu: ipu-v3: csi: pass back mbus_code_to_bus_cfg error codes Date: Sat, 15 Sep 2018 01:32:44 +0000 Message-ID: <20180915013223.179909-23-alexander.levin@microsoft.com> References: <20180915013223.179909-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013223.179909-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Enrico Scholz [ Upstream commit d36d0e6309dd8137cf438cbb680e72eb63c81425 ] mbus_code_to_bus_cfg() can fail on unknown mbus codes; pass back the error to the caller. Signed-off-by: Enrico Scholz Signed-off-by: Jan Luebbe [p.zabel@pengutronix.de - renamed rc to ret for consistency] Signed-off-by: Philipp Zabel Signed-off-by: Sasha Levin --- drivers/gpu/ipu-v3/ipu-csi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index 24e12b87a0cb..2bc51d4d3f1e 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -316,13 +316,17 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_co= nfig *cfg, u32 mbus_code) /* * Fill a CSI bus config struct from mbus_config and mbus_framefmt. */ -static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, +static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, struct v4l2_mbus_config *mbus_cfg, struct v4l2_mbus_framefmt *mbus_fmt) { + int ret; + memset(csicfg, 0, sizeof(*csicfg)); =20 - mbus_code_to_bus_cfg(csicfg, mbus_fmt->code); + ret =3D mbus_code_to_bus_cfg(csicfg, mbus_fmt->code); + if (ret < 0) + return ret; =20 switch (mbus_cfg->type) { case V4L2_MBUS_PARALLEL: @@ -353,6 +357,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config = *csicfg, /* will never get here, keep compiler quiet */ break; } + + return 0; } =20 int ipu_csi_init_interface(struct ipu_csi *csi, @@ -362,8 +368,11 @@ int ipu_csi_init_interface(struct ipu_csi *csi, struct ipu_csi_bus_config cfg; unsigned long flags; u32 width, height, data =3D 0; + int ret; =20 - fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + ret =3D fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + if (ret < 0) + return ret; =20 /* set default sensor frame width and height */ width =3D mbus_fmt->width; @@ -584,11 +593,14 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u3= 2 vc, struct ipu_csi_bus_config cfg; unsigned long flags; u32 temp; + int ret; =20 if (vc > 3) return -EINVAL; =20 - mbus_code_to_bus_cfg(&cfg, mbus_fmt->code); + ret =3D mbus_code_to_bus_cfg(&cfg, mbus_fmt->code); + if (ret < 0) + return ret; =20 spin_lock_irqsave(&csi->lock, flags); =20 --=20 2.17.1