summaryrefslogtreecommitdiff
path: root/drivers/staging/media/imx/imx-media-vdic.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-07-11 09:18:35 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-08-08 06:48:58 -0400
commit0b2e9e7947e7bfd08c512e15ae02645cf9cd38c5 (patch)
tree37962095290331e18b3dd37721eadc03f96682d9 /drivers/staging/media/imx/imx-media-vdic.c
parent05ad2b6dbbb03031a7761e6607a152deafbc39e9 (diff)
media: staging/imx: remove confusing IS_ERR_OR_NULL usage
While looking at a compiler warning, I noticed the use of IS_ERR_OR_NULL, which is generally a sign of a bad API design and should be avoided. In this driver, this is fairly easy, we can simply stop storing error pointers in persistent structures, and change the two functions that might return either a NULL pointer or an error code to consistently return error pointers when failing. of_parse_subdev() now separates the error code and the pointer it looks up, to clarify the interface. There are two cases where this function originally returns 'NULL', and I have changed that to '0' for success to keep the current behavior, though returning an error would also make sense there. Fixes: e130291212df ("[media] media: Add i.MX media core driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Steve Longerbeam <steve_longerbeam@mentor.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/staging/media/imx/imx-media-vdic.c')
-rw-r--r--drivers/staging/media/imx/imx-media-vdic.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c
index 7eabdc4aa79f..433474d58e3e 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -126,15 +126,15 @@ struct vdic_priv {
static void vdic_put_ipu_resources(struct vdic_priv *priv)
{
- if (!IS_ERR_OR_NULL(priv->vdi_in_ch_p))
+ if (priv->vdi_in_ch_p)
ipu_idmac_put(priv->vdi_in_ch_p);
priv->vdi_in_ch_p = NULL;
- if (!IS_ERR_OR_NULL(priv->vdi_in_ch))
+ if (priv->vdi_in_ch)
ipu_idmac_put(priv->vdi_in_ch);
priv->vdi_in_ch = NULL;
- if (!IS_ERR_OR_NULL(priv->vdi_in_ch_n))
+ if (priv->vdi_in_ch_n)
ipu_idmac_put(priv->vdi_in_ch_n);
priv->vdi_in_ch_n = NULL;
@@ -146,40 +146,43 @@ static void vdic_put_ipu_resources(struct vdic_priv *priv)
static int vdic_get_ipu_resources(struct vdic_priv *priv)
{
int ret, err_chan;
+ struct ipuv3_channel *ch;
+ struct ipu_vdi *vdi;
priv->ipu = priv->md->ipu[priv->ipu_id];
- priv->vdi = ipu_vdi_get(priv->ipu);
- if (IS_ERR(priv->vdi)) {
+ vdi = ipu_vdi_get(priv->ipu);
+ if (IS_ERR(vdi)) {
v4l2_err(&priv->sd, "failed to get VDIC\n");
- ret = PTR_ERR(priv->vdi);
+ ret = PTR_ERR(vdi);
goto out;
}
+ priv->vdi = vdi;
if (!priv->csi_direct) {
- priv->vdi_in_ch_p = ipu_idmac_get(priv->ipu,
- IPUV3_CHANNEL_MEM_VDI_PREV);
- if (IS_ERR(priv->vdi_in_ch_p)) {
+ ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_PREV);
+ if (IS_ERR(ch)) {
err_chan = IPUV3_CHANNEL_MEM_VDI_PREV;
- ret = PTR_ERR(priv->vdi_in_ch_p);
+ ret = PTR_ERR(ch);
goto out_err_chan;
}
+ priv->vdi_in_ch_p = ch;
- priv->vdi_in_ch = ipu_idmac_get(priv->ipu,
- IPUV3_CHANNEL_MEM_VDI_CUR);
- if (IS_ERR(priv->vdi_in_ch)) {
+ ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_CUR);
+ if (IS_ERR(ch)) {
err_chan = IPUV3_CHANNEL_MEM_VDI_CUR;
- ret = PTR_ERR(priv->vdi_in_ch);
+ ret = PTR_ERR(ch);
goto out_err_chan;
}
+ priv->vdi_in_ch = ch;
- priv->vdi_in_ch_n = ipu_idmac_get(priv->ipu,
- IPUV3_CHANNEL_MEM_VDI_NEXT);
+ ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_NEXT);
if (IS_ERR(priv->vdi_in_ch_n)) {
err_chan = IPUV3_CHANNEL_MEM_VDI_NEXT;
- ret = PTR_ERR(priv->vdi_in_ch_n);
+ ret = PTR_ERR(ch);
goto out_err_chan;
}
+ priv->vdi_in_ch_n = ch;
}
return 0;