Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/ati_pcigart: Fix error code in drm_ati_pcigart_init()

The drm_ati_pcigart_init() function was originally suppose to return one
on success and zero on failure, but these days it returns a mix of
zero, one and -ENOMEM on failure.

This patch cleans it up and modifies the caller so now the function
returns zero on success and negative error codes on failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20181217070344.GC12159@kadam

authored by

Dan Carpenter and committed by
Daniel Vetter
c27889ca 705c8160

+7 -5
+4 -3
drivers/gpu/drm/ati_pcigart.c
··· 103 103 unsigned long pages; 104 104 u32 *pci_gart = NULL, page_base, gart_idx; 105 105 dma_addr_t bus_address = 0; 106 - int i, j, ret = 0; 106 + int i, j, ret = -ENOMEM; 107 107 int max_ati_pages, max_real_pages; 108 108 109 109 if (!entry) { ··· 117 117 if (pci_set_dma_mask(dev->pdev, gart_info->table_mask)) { 118 118 DRM_ERROR("fail to set dma mask to 0x%Lx\n", 119 119 (unsigned long long)gart_info->table_mask); 120 - ret = 1; 120 + ret = -EFAULT; 121 121 goto done; 122 122 } 123 123 ··· 160 160 drm_ati_pcigart_cleanup(dev, gart_info); 161 161 address = NULL; 162 162 bus_address = 0; 163 + ret = -ENOMEM; 163 164 goto done; 164 165 } 165 166 page_base = (u32) entry->busaddr[i]; ··· 189 188 page_base += ATI_PCIGART_PAGE_SIZE; 190 189 } 191 190 } 192 - ret = 1; 191 + ret = 0; 193 192 194 193 #if defined(__i386__) || defined(__x86_64__) 195 194 wbinvd();
+3 -2
drivers/gpu/drm/r128/r128_cce.c
··· 560 560 dev_priv->gart_info.addr = NULL; 561 561 dev_priv->gart_info.bus_addr = 0; 562 562 dev_priv->gart_info.gart_reg_if = DRM_ATI_GART_PCI; 563 - if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) { 563 + rc = drm_ati_pcigart_init(dev, &dev_priv->gart_info); 564 + if (rc) { 564 565 DRM_ERROR("failed to init PCI GART!\n"); 565 566 dev->dev_private = (void *)dev_priv; 566 567 r128_do_cleanup_cce(dev); 567 - return -ENOMEM; 568 + return rc; 568 569 } 569 570 R128_WRITE(R128_PCI_GART_PAGE, dev_priv->gart_info.bus_addr); 570 571 #if IS_ENABLED(CONFIG_AGP)