Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1583059

[PATCH 7/7] drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes

From Chen-Yu Tsai <wens@csie.org>
Newsgroups linux.kernel
Subject [PATCH 7/7] drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes
Date 2017-02-17 04:20 +0100
Message-ID <tbHfs-77T-29@gated-at.bofh.it> (permalink)
References <tbHfr-77T-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


sun4i_crtc_init can fail for a number of reasons. Instead of returning
a NULL pointer when it fails, pass back the encountered error using
ERR_PTR.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/gpu/drm/sun4i/sun4i_crtc.c | 4 ++--
 drivers/gpu/drm/sun4i/sun4i_drv.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_crtc.c b/drivers/gpu/drm/sun4i/sun4i_crtc.c
index 4a192210574f..4e2e89c3104f 100644
--- a/drivers/gpu/drm/sun4i/sun4i_crtc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_crtc.c
@@ -121,7 +121,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
 
 	scrtc = devm_kzalloc(drm->dev, sizeof(*scrtc), GFP_KERNEL);
 	if (!scrtc)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	scrtc->drv = drv;
 
 	ret = drm_crtc_init_with_planes(drm, &scrtc->crtc,
@@ -131,7 +131,7 @@ struct sun4i_crtc *sun4i_crtc_init(struct drm_device *drm)
 					NULL);
 	if (ret) {
 		dev_err(drm->dev, "Couldn't init DRM CRTC\n");
-		return NULL;
+		return ERR_PTR(ret);
 	}
 
 	drm_crtc_helper_add(&scrtc->crtc, &sun4i_crtc_helper_funcs);
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 63c46643fdd1..fc6ef4066c59 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -153,9 +153,9 @@ static int sun4i_drv_bind(struct device *dev)
 
 	/* Create our CRTC */
 	drv->crtc = sun4i_crtc_init(drm);
-	if (!drv->crtc) {
+	if (IS_ERR(drv->crtc)) {
 		dev_err(drm->dev, "Couldn't create the CRTC\n");
-		ret = -EINVAL;
+		ret = PTR_ERR(drv->crtc);
 		goto cleanup_mode_config;
 	}
 	drm->irq_enabled = true;
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] drm/sun4i: Various fixes and cleanups part 1 Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
  [PATCH 4/7] drm/sun4i: Fix kcalloc element size in sun4i_layers_init Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 4/7] drm/sun4i: Fix kcalloc element size in  sun4i_layers_init Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 23:20 +0100
  [PATCH 1/7] drm/sun4i: Move drm_mode_config_cleanup call to main driver Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 1/7] drm/sun4i: Move drm_mode_config_cleanup call to main  driver Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 21:30 +0100
  [PATCH 5/7] drm/sun4i: Drop useless assignment in sun4i_layers_init Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 5/7] drm/sun4i: Drop useless assignment in  sun4i_layers_init Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 23:20 +0100
  [PATCH 3/7] drm/sun4i: Check return value of drm_vblank_init Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 3/7] drm/sun4i: Check return value of drm_vblank_init Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 23:20 +0100
  [PATCH 6/7] drm/sun4i: Save newly created layer in layers array in sun4i_layers_init Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 6/7] drm/sun4i: Save newly created layer in layers array  in sun4i_layers_init Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 23:20 +0100
  [PATCH 7/7] drm/sun4i: Make sun4i_crtc_init return ERR_PTR style error codes Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 7/7] drm/sun4i: Make sun4i_crtc_init return ERR_PTR style  error codes Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 23:20 +0100
  [PATCH 2/7] drm/sun4i: Fix up error path cleanup for master bind function Chen-Yu Tsai <wens@csie.org> - 2017-02-17 04:20 +0100
    Re: [PATCH 2/7] drm/sun4i: Fix up error path cleanup for master bind  function Maxime Ripard <maxime.ripard@free-electrons.com> - 2017-02-21 21:30 +0100

csiph-web