AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 5/9] amdgpu/dc: cleanup construct returns in gpio.
Date: Fri, 29 Sep 2017 14:34:38 +1000	[thread overview]
Message-ID: <20170929043442.7984-5-airlied@gmail.com> (raw)
In-Reply-To: <20170929043442.7984-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

From: Dave Airlie <airlied@redhat.com>

This is similiar to previous patches, don't return when we don't
need to, also do error checking before allocating memory, makes
it simpler to cleanup after.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c  | 33 +++++++------------
 drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c |  4 +--
 drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h |  2 +-
 drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c  | 47 ++++++++++-----------------
 4 files changed, 30 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
index 7b6efa4..310f489 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
@@ -199,25 +199,14 @@ static const struct hw_gpio_pin_funcs funcs = {
 	.close = dal_hw_gpio_close,
 };
 
-static bool construct(
+static void construct(
 	struct hw_ddc *ddc,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if (!dal_hw_gpio_construct(&ddc->base, id, en, ctx)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
+	dal_hw_gpio_construct(&ddc->base, id, en, ctx);
 	ddc->base.base.funcs = &funcs;
-
-	return true;
 }
 
 struct hw_gpio_pin *dal_hw_ddc_create(
@@ -225,19 +214,19 @@ struct hw_gpio_pin *dal_hw_ddc_create(
 	enum gpio_id id,
 	uint32_t en)
 {
-	struct hw_ddc *pin = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
+	struct hw_ddc *pin;
 
-	if (!pin) {
+	if ((en < GPIO_DDC_LINE_MIN) || (en > GPIO_DDC_LINE_MAX)) {
 		ASSERT_CRITICAL(false);
 		return NULL;
 	}
 
-	if (construct(pin, id, en, ctx))
-		return &pin->base.base;
-
-	ASSERT_CRITICAL(false);
-
-	kfree(pin);
+	pin = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
+	if (!pin) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	return NULL;
+	construct(pin, id, en, ctx);
+	return &pin->base.base;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
index 4cdcdfb..6605108 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.c
@@ -176,7 +176,7 @@ enum gpio_result dal_hw_gpio_config_mode(
 	}
 }
 
-bool dal_hw_gpio_construct(
+void dal_hw_gpio_construct(
 	struct hw_gpio *pin,
 	enum gpio_id id,
 	uint32_t en,
@@ -194,8 +194,6 @@ bool dal_hw_gpio_construct(
 	pin->store.mux = 0;
 
 	pin->mux_supported = false;
-
-	return true;
 }
 
 void dal_hw_gpio_destruct(
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
index fb41ee2..bca0cef 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_gpio.h
@@ -109,7 +109,7 @@ struct hw_gpio {
 #define HW_GPIO_FROM_BASE(hw_gpio_pin) \
 	container_of((hw_gpio_pin), struct hw_gpio, base)
 
-bool dal_hw_gpio_construct(
+void dal_hw_gpio_construct(
 	struct hw_gpio *pin,
 	enum gpio_id id,
 	uint32_t en,
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
index 0c255c0..784fecc 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/hw_hpd.c
@@ -41,15 +41,13 @@
 #define REG(reg)\
 	(hpd->regs->reg)
 
-static bool dal_hw_hpd_construct(
+static void dal_hw_hpd_construct(
 	struct hw_hpd *pin,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if (!dal_hw_gpio_construct(&pin->base, id, en, ctx))
-		return false;
-	return true;
+	dal_hw_gpio_construct(&pin->base, id, en, ctx);
 }
 
 static void dal_hw_hpd_destruct(
@@ -126,30 +124,14 @@ static const struct hw_gpio_pin_funcs funcs = {
 	.close = dal_hw_gpio_close,
 };
 
-static bool construct(
+static void construct(
 	struct hw_hpd *hpd,
 	enum gpio_id id,
 	uint32_t en,
 	struct dc_context *ctx)
 {
-	if (id != GPIO_ID_HPD) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
-	if (!dal_hw_hpd_construct(hpd, id, en, ctx)) {
-		ASSERT_CRITICAL(false);
-		return false;
-	}
-
+	dal_hw_hpd_construct(hpd, id, en, ctx);
 	hpd->base.base.funcs = &funcs;
-
-	return true;
 }
 
 struct hw_gpio_pin *dal_hw_hpd_create(
@@ -157,19 +139,24 @@ struct hw_gpio_pin *dal_hw_hpd_create(
 	enum gpio_id id,
 	uint32_t en)
 {
-	struct hw_hpd *hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
+	struct hw_hpd *hpd;
 
-	if (!hpd) {
+	if (id != GPIO_ID_HPD) {
 		ASSERT_CRITICAL(false);
 		return NULL;
 	}
 
-	if (construct(hpd, id, en, ctx))
-		return &hpd->base.base;
-
-	ASSERT_CRITICAL(false);
+	if ((en < GPIO_HPD_MIN) || (en > GPIO_HPD_MAX)) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	kfree(hpd);
+	hpd = kzalloc(sizeof(struct hw_hpd), GFP_KERNEL);
+	if (!hpd) {
+		ASSERT_CRITICAL(false);
+		return NULL;
+	}
 
-	return NULL;
+	construct(hpd, id, en, ctx);
+	return &hpd->base.base;
 }
-- 
2.9.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-09-29  4:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29  4:34 [PATCH 1/9] amdgpu/dc: make get_audio_clock_info return void Dave Airlie
     [not found] ` <20170929043442.7984-1-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-29  4:34   ` [PATCH 2/9] amdgpu/dc: make program_regamma_pwl " Dave Airlie
2017-09-29  4:34   ` [PATCH 3/9] amdgpu/dc: make some audio functions " Dave Airlie
2017-09-29  4:34   ` [PATCH 4/9] amdgpu/dc: remove pointless returns in the i2caux constructor paths Dave Airlie
2017-09-29  4:34   ` Dave Airlie [this message]
2017-09-29  4:34   ` [PATCH 6/9] amdgpu/dc: another round of dce/dcn construct cleanups Dave Airlie
2017-09-29  4:34   ` [PATCH 7/9] amdgpu/dc: remove pointless return from build_pipe_hw_param Dave Airlie
2017-09-29  4:34   ` [PATCH 8/9] amdgpu: fixup construct to void paths on some more dc objects Dave Airlie
2017-09-29  4:34   ` [PATCH 9/9] amdgpu/dc: fix construct return values on irq service Dave Airlie
     [not found]     ` <20170929043442.7984-9-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-09-29 14:27       ` Harry Wentland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170929043442.7984-5-airlied@gmail.com \
    --to=airlied-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox