Commit cce13ff7 authored by Chris Wilson's avatar Chris Wilson Committed by Dave Airlie

drm: Propagate error code from fb_create()

Change the interface to expect a PTR_ERR specifing the real error code
as opposed to assuming a NULL return => -EINVAL. Just once the user may
not be at fault!
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 0d18abed
...@@ -1682,9 +1682,9 @@ int drm_mode_addfb(struct drm_device *dev, ...@@ -1682,9 +1682,9 @@ int drm_mode_addfb(struct drm_device *dev,
/* TODO setup destructor callback */ /* TODO setup destructor callback */
fb = dev->mode_config.funcs->fb_create(dev, file_priv, r); fb = dev->mode_config.funcs->fb_create(dev, file_priv, r);
if (!fb) { if (IS_ERR(fb)) {
DRM_ERROR("could not create framebuffer\n"); DRM_ERROR("could not create framebuffer\n");
ret = -EINVAL; ret = PTR_ERR(fb);
goto out; goto out;
} }
......
...@@ -5312,18 +5312,18 @@ intel_user_framebuffer_create(struct drm_device *dev, ...@@ -5312,18 +5312,18 @@ intel_user_framebuffer_create(struct drm_device *dev,
obj = drm_gem_object_lookup(dev, filp, mode_cmd->handle); obj = drm_gem_object_lookup(dev, filp, mode_cmd->handle);
if (!obj) if (!obj)
return NULL; return ERR_PTR(-ENOENT);
intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
if (!intel_fb) if (!intel_fb)
return NULL; return ERR_PTR(-ENOMEM);
ret = intel_framebuffer_init(dev, intel_fb, ret = intel_framebuffer_init(dev, intel_fb,
mode_cmd, obj); mode_cmd, obj);
if (ret) { if (ret) {
drm_gem_object_unreference_unlocked(obj); drm_gem_object_unreference_unlocked(obj);
kfree(intel_fb); kfree(intel_fb);
return NULL; return ERR_PTR(ret);
} }
return &intel_fb->base; return &intel_fb->base;
......
...@@ -119,7 +119,9 @@ static int intelfb_create(struct intel_fbdev *ifbdev, ...@@ -119,7 +119,9 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
info->par = ifbdev; info->par = ifbdev;
intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, fbo); ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, fbo);
if (ret)
goto out_unpin;
fb = &ifbdev->ifb.base; fb = &ifbdev->ifb.base;
......
...@@ -84,16 +84,16 @@ nouveau_user_framebuffer_create(struct drm_device *dev, ...@@ -84,16 +84,16 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handle); gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handle);
if (!gem) if (!gem)
return NULL; return ERR_PTR(-ENOENT);
nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL); nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL);
if (!nouveau_fb) if (!nouveau_fb)
return NULL; return ERR_PTR(-ENOMEM);
ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem)); ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem));
if (ret) { if (ret) {
drm_gem_object_unreference(gem); drm_gem_object_unreference(gem);
return NULL; return ERR_PTR(ret);
} }
return &nouveau_fb->base; return &nouveau_fb->base;
......
...@@ -888,13 +888,12 @@ radeon_user_framebuffer_create(struct drm_device *dev, ...@@ -888,13 +888,12 @@ radeon_user_framebuffer_create(struct drm_device *dev,
if (obj == NULL) { if (obj == NULL) {
dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, " dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, "
"can't create framebuffer\n", mode_cmd->handle); "can't create framebuffer\n", mode_cmd->handle);
return NULL; return ERR_PTR(-ENOENT);
} }
radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL); radeon_fb = kzalloc(sizeof(*radeon_fb), GFP_KERNEL);
if (radeon_fb == NULL) { if (radeon_fb == NULL)
return NULL; return ERR_PTR(-ENOMEM);
}
radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj); radeon_framebuffer_init(dev, radeon_fb, mode_cmd, obj);
......
...@@ -737,7 +737,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ...@@ -737,7 +737,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
if (ret) { if (ret) {
DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
return NULL; return ERR_PTR(ret);
} }
return &vfb->base; return &vfb->base;
...@@ -747,7 +747,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ...@@ -747,7 +747,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo); ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo);
if (ret) { if (ret) {
DRM_ERROR("failed to find buffer: %i\n", ret); DRM_ERROR("failed to find buffer: %i\n", ret);
return NULL; return ERR_PTR(-ENOENT);
} }
ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb, ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb,
...@@ -758,7 +758,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ...@@ -758,7 +758,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
if (ret) { if (ret) {
DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret); DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
return NULL; return ERR_PTR(ret);
} }
return &vfb->base; return &vfb->base;
...@@ -768,7 +768,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev, ...@@ -768,7 +768,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
/* vmw_user_surface_lookup takes one ref */ /* vmw_user_surface_lookup takes one ref */
vmw_surface_unreference(&surface); vmw_surface_unreference(&surface);
return NULL; return ERR_PTR(-EINVAL);
} }
static struct drm_mode_config_funcs vmw_kms_funcs = { static struct drm_mode_config_funcs vmw_kms_funcs = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment