summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-09-29 14:34:38 +1000
committerAlex Deucher <alexander.deucher@amd.com>2017-09-29 13:02:28 -0400
commit0e1c42fd181e7359be5c97655198551b6660f028 (patch)
treeb6a02e881b311c807f1f4ce9b77f0d3dcc4b037a /drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
parentb08c3ca4e90d03b3a120f4e60dba4b2b5e087433 (diff)
downloadlinux-0e1c42fd181e7359be5c97655198551b6660f028.tar.gz
linux-0e1c42fd181e7359be5c97655198551b6660f028.tar.bz2
linux-0e1c42fd181e7359be5c97655198551b6660f028.zip
amdgpu/dc: cleanup construct returns in gpio.
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> Reviewed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c')
-rw-r--r--drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c33
1 files changed, 11 insertions, 22 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 7b6efa4f2efd..310f48965b27 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;
}