From patchwork Sun Sep 18 16:54:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9337981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8E126022E for ; Sun, 18 Sep 2016 16:54:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6FD928993 for ; Sun, 18 Sep 2016 16:54:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C971228C63; Sun, 18 Sep 2016 16:54:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 248F628993 for ; Sun, 18 Sep 2016 16:54:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 602176E117; Sun, 18 Sep 2016 16:54:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [217.72.192.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6E0F36E117 for ; Sun, 18 Sep 2016 16:54:33 +0000 (UTC) Received: from [192.168.1.2] ([77.181.85.138]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0Lheij-1bH3eC1O1R-00mwdh; Sun, 18 Sep 2016 18:54:25 +0200 Subject: [PATCH 5/5] drm/amdgpu: Adjust checks for null pointers in nine functions To: dri-devel@lists.freedesktop.org, Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , Chunming Zhou , David Airlie , Monk Liu , Tom St Denis References: <566ABCD9.1060404@users.sourceforge.net> <8d614254-1cba-0379-cf84-52ad9bd9f3a7@users.sourceforge.net> From: SF Markus Elfring Message-ID: <1dfb0d04-4752-8a85-8835-c4eb8fc1ba7c@users.sourceforge.net> Date: Sun, 18 Sep 2016 18:54:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <8d614254-1cba-0379-cf84-52ad9bd9f3a7@users.sourceforge.net> X-Provags-ID: V03:K0:Hx7cVg4ZBddcOOSiunwbsju+/4zWDgNhV51QjhxO6LzEhdHFkIp qiZpH8JCVHcT1tdMY2yGx0cjs2zIqWoPDHF9YIIYA4dHLHPLM+tE/NiR/lIbcQc0cgMODrn QwAC+/Wy0DmjTzQW7SAWAnV3EuolEty1NyaiHMjf0C1nQ+ejSJRqhmNA/ZbWR7dLFoqRM3m gsGLMbF4E1Krtuu7b9sAQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:iysVnVKv4ig=:h5mtFCjRgXvD6YLGDcNFkE 6nh5SUQKIxG2sDAa5uRlO89qXa12yST0gDSogjkpjjBrakx/SUe1h265CpzaGCB49kdvc6GLT 0BS9Cbo8KEq0X7woQ0TabpVydJRcNSP7gKarcRkhg+y5Agp62w/ArXJIpdPYysMxwAx7HfAIX tTq3rqBs4zTVBqrfjP9q9V9NwIsWHuEaTshWnm472LJHjCj5JM5PmqF7NgGkWDWD1nwcvTrkr Rn40c1qth6hZT1N/EVvqsxGuyOUSm4sNRmsFPXnfW3r6O0QB6jGivX4FI6UxtygejE2cKzk7Y RwOgBKYBTHOpkpj67h0dOMJzuljnEl5eu0ppu/mN73fVzXArbYZLB4qdcCpchUdfCGOxwERXb V5A+CoucesVJb72ViY48oulM6jTlZYc8uTU9SQZmFfxhX+BsEIxqnwvjHUJKZS3vhvo3Qu4N5 LhMMqmR/Y/pFT56NaJTX66DohhkMufzElb+VIaIkI5X8pAxIsSfJ5+p3UBHtUffuF3pjn7kL7 x+vZgC3OEkuk//9wrhleaqI66f+qNA+shW8PXpE4KeGtzyjgCnl8/JPS66TxpYIcZJrW07CBJ vh+xTwRa4M84KMMQQ2XLqRv4NI/+4MI8UZR3vpzXwjopqEOVSWKUDUcife1greEbGlv8i/pl6 wTtv6T7Oall49KccOHzuGqUrmqbBgMUSVx4LXNxNulbcW3RME320M/dm8iWT6gkGoUYfjQBWA Wnd02jL+dJIU6owZew1LAbcqoiSyApaBMg3afkllOUUR2pIGXyqTsAAndL3KqRR4v64RBLPTb uf+mwu4 Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 18 Sep 2016 18:32:28 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * The script "checkpatch.pl" can point information out like the following. Comparison to NULL could be written !… Thus fix the affected source code places. * Do also not use curly brackets at corresponding source code places where a single statement should be sufficient. Signed-off-by: Markus Elfring --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index fed4854..b5b7cfb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -251,7 +251,7 @@ static int amdgpu_vram_scratch_init(struct amdgpu_device *adev) { int r; - if (adev->vram_scratch.robj == NULL) { + if (!adev->vram_scratch.robj) { r = amdgpu_bo_create(adev, AMDGPU_GPU_PAGE_SIZE, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM, AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED, @@ -283,9 +283,9 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev) { int r; - if (adev->vram_scratch.robj == NULL) { + if (!adev->vram_scratch.robj) return; - } + r = amdgpu_bo_reserve(adev->vram_scratch.robj, false); if (likely(r == 0)) { amdgpu_bo_kunmap(adev->vram_scratch.robj); @@ -359,9 +359,9 @@ static int amdgpu_doorbell_init(struct amdgpu_device *adev) return -EINVAL; adev->doorbell.ptr = ioremap(adev->doorbell.base, adev->doorbell.num_doorbells * sizeof(u32)); - if (adev->doorbell.ptr == NULL) { + if (!adev->doorbell.ptr) return -ENOMEM; - } + DRM_INFO("doorbell mmio base: 0x%08X\n", (uint32_t)adev->doorbell.base); DRM_INFO("doorbell mmio size: %u\n", (unsigned)adev->doorbell.size); @@ -456,7 +456,7 @@ static int amdgpu_wb_init(struct amdgpu_device *adev) { int r; - if (adev->wb.wb_obj == NULL) { + if (!adev->wb.wb_obj) { r = amdgpu_bo_create(adev, AMDGPU_MAX_WB * 4, PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, &adev->wb.wb_obj); @@ -657,7 +657,7 @@ int amdgpu_dummy_page_init(struct amdgpu_device *adev) if (adev->dummy_page.page) return 0; adev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO); - if (adev->dummy_page.page == NULL) + if (!adev->dummy_page.page) return -ENOMEM; adev->dummy_page.addr = pci_map_page(adev->pdev, adev->dummy_page.page, 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); @@ -679,7 +679,7 @@ int amdgpu_dummy_page_init(struct amdgpu_device *adev) */ void amdgpu_dummy_page_fini(struct amdgpu_device *adev) { - if (adev->dummy_page.page == NULL) + if (!adev->dummy_page.page) return; pci_unmap_page(adev->pdev, adev->dummy_page.addr, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); @@ -1226,10 +1226,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev) adev->ip_block_status = kcalloc(adev->num_ip_blocks, sizeof(*adev->ip_block_status), GFP_KERNEL); - if (adev->ip_block_status == NULL) + if (!adev->ip_block_status) return -ENOMEM; - if (adev->ip_blocks == NULL) { + if (!adev->ip_blocks) { DRM_ERROR("No IP blocks found!\n"); return r; } @@ -1525,9 +1525,9 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->rmmio_base = pci_resource_start(adev->pdev, 5); adev->rmmio_size = pci_resource_len(adev->pdev, 5); adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size); - if (adev->rmmio == NULL) { + if (!adev->rmmio) return -ENOMEM; - } + DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)adev->rmmio_base); DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size); @@ -1542,7 +1542,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, break; } } - if (adev->rio_mem == NULL) + if (!adev->rio_mem) DRM_ERROR("Unable to find PCI I/O BAR\n"); /* early init functions */ @@ -1758,9 +1758,8 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) struct drm_connector *connector; int r; - if (dev == NULL || dev->dev_private == NULL) { + if (!dev || !dev->dev_private) return -ENODEV; - } adev = dev->dev_private; @@ -1791,9 +1790,9 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon) } } - if (rfb == NULL || rfb->obj == NULL) { + if (!rfb || !rfb->obj) continue; - } + robj = gem_to_amdgpu_bo(rfb->obj); /* don't unpin kernel fb objects */ if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {