Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp205140ybz; Tue, 21 Apr 2020 18:49:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLrm4jILiG/uL83chE8Bfk11I6Gi7Bywklxq1YANkGta4YzUR4MBiwuI1BSz0Z0OlcbN5E3 X-Received: by 2002:a17:906:a3ca:: with SMTP id ca10mr24710566ejb.298.1587520183711; Tue, 21 Apr 2020 18:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587520183; cv=none; d=google.com; s=arc-20160816; b=MVcvx6N7Bihr+CrAK4WJOQ3GFbfodiJ6Mn/PNi2uLSI/hQB3tX5jjVEFbWWWZ9wWdc ByPCbBOYpF0rDZXAQ6/ysckfjayt013gfTwwg0tSJacT90iR++sg6N8ZSul9pts2xS5i J5y3cQBQy3I36Vyn4CI6kkV4IYNsCjus1/I9Uv/GTgTtGQbQxSyXej6ISe7boh1K0w2Z gzIADf/kkyv6wvU8RZJtJzO6gdplScz4eBYGqyF4klCfUwbmCOigLP0NsDqttFwBXoVk 4Htb/egdv2Nv14Cx+YzPeZa/Zh9MObLO3nP29rYUVoAfpgGHXM9Sj9RUJCzdGLZJXq4N LENg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=79FXLpvZdWyz17odcti2wcE6meaOaWppB9VXkaTOKgY=; b=ITyhgVBPXX6VdZmVhwCGr2/X0MwsTpFdKDFEqBHKbgpgiLwQJLu1miJgu+Izb6+3kw KNeCjg7ov/lrdV5DKisJVOKVbF+Yrez5P++BcoxWCz/gXoBbMzmKLGP4N+iT22tlGiZu WSWprMQxRAB+MbeJWraN84ORW1TgoSoZ1E3p23yLgDdt2Bv21DD+SGTUr4azhytEvbhc yEIaa0DGMIoypxUTlzQ0SfB0/ESiS1dzwaNFJXG3xYSsFS3nhLlIZ5uwzWn68CtoosbW nLjaInXDYBrf4C1lrYgvDqHfTX9GPw5IbVXvTYL4gX5kSoeqSQdKwgnQVi8JTYva6tFx V5Zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si2643391edy.24.2020.04.21.18.49.02; Tue, 21 Apr 2020 18:49:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726337AbgDVBqc (ORCPT + 99 others); Tue, 21 Apr 2020 21:46:32 -0400 Received: from m176115.mail.qiye.163.com ([59.111.176.115]:4702 "EHLO m176115.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbgDVBqc (ORCPT ); Tue, 21 Apr 2020 21:46:32 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id 30EAF6633BC; Wed, 22 Apr 2020 09:46:26 +0800 (CST) From: Bernard Zhao To: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH v5] drm/amdgpu: cleanup coding style in amdkfd a bit Date: Tue, 21 Apr 2020 18:46:18 -0700 Message-Id: <20200422014618.4020-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZTlVIQkpCQkJMSUpOSUxKWVdZKFlBSE 83V1ktWUFJV1kJDhceCFlBWTU0KTY6NyQpLjc#WQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pj46NRw4TDg4KAINLUMYET4e K04KC0JVSlVKTkNMTkpCQkNCTktJVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSEhLSTcG X-HM-Tid: 0a719f909ad89373kuws30eaf6633bc Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the code a bit more readable by using a common error handling pattern. With that done the patch is Reviewed-by: Christian König . Signed-off-by: Bernard Zhao Changes since V1: *commit message improve *code style refactoring Changes since V2: *code style adjust Changes since V3: *find the best way to merge unnecessary if/else check branch Changes since V4: *Improve the subject line and commit message Link for V1: *https://lore.kernel.org/patchwork/patch/1226587/ --- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 9dff792c9290..acb612c53b9c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -660,15 +660,15 @@ static int reserve_bo_and_vm(struct kgd_mem *mem, ret = ttm_eu_reserve_buffers(&ctx->ticket, &ctx->list, false, &ctx->duplicates); - if (!ret) - ctx->reserved = true; - else { - pr_err("Failed to reserve buffers in ttm\n"); + if (ret) { + pr_err("Failed to reserve buffers in ttm.\n"); kfree(ctx->vm_pd); ctx->vm_pd = NULL; + return ret; } - return ret; + ctx->reserved = true; + return 0; } /** @@ -733,17 +733,15 @@ static int reserve_bo_and_cond_vms(struct kgd_mem *mem, ret = ttm_eu_reserve_buffers(&ctx->ticket, &ctx->list, false, &ctx->duplicates); - if (!ret) - ctx->reserved = true; - else - pr_err("Failed to reserve buffers in ttm.\n"); - if (ret) { + pr_err("Failed to reserve buffers in ttm.\n"); kfree(ctx->vm_pd); ctx->vm_pd = NULL; + return ret; } - return ret; + ctx->reserved = true; + return 0; } /** -- 2.26.2