Commit 0f288605 authored by Tom Gundersen's avatar Tom Gundersen Committed by Sean Paul

drm: Don't swallow error codes in drm_dev_alloc()

There are many reasons other than ENOMEM that drm_dev_init() can
fail. Return ERR_PTR rather than NULL to be able to distinguish
these in the caller.
Signed-off-by: default avatarTom Gundersen <teg@jklm.no>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20160921145919.13754-2-teg@jklm.no
parent c6bf811a
......@@ -198,8 +198,8 @@ static int arcpgu_probe(struct platform_device *pdev)
int ret;
drm = drm_dev_alloc(&arcpgu_drm_driver, &pdev->dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
ret = arcpgu_load(drm);
if (ret)
......
......@@ -326,8 +326,8 @@ static int hdlcd_drm_bind(struct device *dev)
return -ENOMEM;
drm = drm_dev_alloc(&hdlcd_driver, dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
drm->dev_private = hdlcd;
dev_set_drvdata(dev, drm);
......
......@@ -311,8 +311,8 @@ static int malidp_bind(struct device *dev)
return ret;
drm = drm_dev_alloc(&malidp_driver, dev);
if (!drm) {
ret = -ENOMEM;
if (IS_ERR(drm)) {
ret = PTR_ERR(drm);
goto alloc_fail;
}
......
......@@ -797,8 +797,8 @@ static int atmel_hlcdc_dc_drm_probe(struct platform_device *pdev)
int ret;
ddev = drm_dev_alloc(&atmel_hlcdc_dc_driver, &pdev->dev);
if (!ddev)
return -ENOMEM;
if (IS_ERR(ddev))
return PTR_ERR(ddev);
ret = atmel_hlcdc_dc_load(ddev);
if (ret)
......
......@@ -591,7 +591,7 @@ EXPORT_SYMBOL(drm_dev_init);
* own struct should look at using drm_dev_init() instead.
*
* RETURNS:
* Pointer to new DRM device, or NULL if out of memory.
* Pointer to new DRM device, or ERR_PTR on failure.
*/
struct drm_device *drm_dev_alloc(struct drm_driver *driver,
struct device *parent)
......@@ -601,12 +601,12 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return NULL;
return ERR_PTR(-ENOMEM);
ret = drm_dev_init(dev, driver, parent);
if (ret) {
kfree(dev);
return NULL;
return ERR_PTR(ret);
}
return dev;
......
......@@ -236,8 +236,8 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
DRM_DEBUG("\n");
dev = drm_dev_alloc(driver, &pdev->dev);
if (!dev)
return -ENOMEM;
if (IS_ERR(dev))
return PTR_ERR(dev);
ret = pci_enable_device(pdev);
if (ret)
......
......@@ -48,8 +48,8 @@ static int drm_get_platform_dev(struct platform_device *platdev,
DRM_DEBUG("\n");
dev = drm_dev_alloc(driver, &platdev->dev);
if (!dev)
return -ENOMEM;
if (IS_ERR(dev))
return PTR_ERR(dev);
dev->platformdev = platdev;
......
......@@ -529,8 +529,8 @@ static int etnaviv_bind(struct device *dev)
int ret;
drm = drm_dev_alloc(&etnaviv_drm_driver, dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
......
......@@ -402,8 +402,8 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
fsl_dev->tcon = fsl_tcon_init(dev);
drm = drm_dev_alloc(driver, dev);
if (!drm) {
ret = -ENOMEM;
if (IS_ERR(drm)) {
ret = PTR_ERR(drm);
goto disable_pix_clk;
}
......
......@@ -207,8 +207,8 @@ static int kirin_drm_bind(struct device *dev)
int ret;
drm_dev = drm_dev_alloc(driver, dev);
if (!drm_dev)
return -ENOMEM;
if (IS_ERR(drm_dev))
return PTR_ERR(drm_dev);
drm_dev->platformdev = to_platform_device(dev);
......
......@@ -294,8 +294,8 @@ static int mtk_drm_bind(struct device *dev)
int ret;
drm = drm_dev_alloc(&mtk_drm_driver, dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
drm->dev_private = private;
private->drm = drm;
......
......@@ -347,9 +347,9 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
int ret;
ddev = drm_dev_alloc(drv, dev);
if (!ddev) {
if (IS_ERR(ddev)) {
dev_err(dev, "failed to allocate drm_device\n");
return -ENOMEM;
return PTR_ERR(ddev);
}
platform_set_drvdata(pdev, ddev);
......
......@@ -1067,8 +1067,8 @@ nouveau_platform_device_create(const struct nvkm_device_tegra_func *func,
goto err_free;
drm = drm_dev_alloc(&driver_platform, &pdev->dev);
if (!drm) {
err = -ENOMEM;
if (IS_ERR(drm)) {
err = PTR_ERR(drm);
goto err_free;
}
......
......@@ -316,8 +316,8 @@ static int rcar_du_probe(struct platform_device *pdev)
rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev);
if (!ddev)
return -ENOMEM;
if (IS_ERR(ddev))
return PTR_ERR(ddev);
rcdu->ddev = ddev;
ddev->dev_private = rcdu;
......
......@@ -143,8 +143,8 @@ static int rockchip_drm_bind(struct device *dev)
int ret;
drm_dev = drm_dev_alloc(&rockchip_drm_driver, dev);
if (!drm_dev)
return -ENOMEM;
if (IS_ERR(drm_dev))
return PTR_ERR(drm_dev);
dev_set_drvdata(dev, drm_dev);
......
......@@ -365,8 +365,8 @@ static int sti_bind(struct device *dev)
int ret;
ddev = drm_dev_alloc(&sti_driver, dev);
if (!ddev)
return -ENOMEM;
if (IS_ERR(ddev))
return PTR_ERR(ddev);
ddev->platformdev = to_platform_device(dev);
......
......@@ -121,8 +121,8 @@ static int sun4i_drv_bind(struct device *dev)
int ret;
drm = drm_dev_alloc(&sun4i_drv_driver, dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
if (!drv) {
......
......@@ -983,8 +983,8 @@ static int host1x_drm_probe(struct host1x_device *dev)
int err;
drm = drm_dev_alloc(driver, &dev->dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
dev_set_drvdata(&dev->dev, drm);
......
......@@ -86,8 +86,8 @@ static int udl_usb_probe(struct usb_interface *interface,
int r;
dev = drm_dev_alloc(&driver, &interface->dev);
if (!dev)
return -ENOMEM;
if (IS_ERR(dev))
return PTR_ERR(dev);
r = drm_dev_register(dev, (unsigned long)udev);
if (r)
......
......@@ -233,8 +233,8 @@ static int vc4_drm_bind(struct device *dev)
return -ENOMEM;
drm = drm_dev_alloc(&vc4_drm_driver, dev);
if (!drm)
return -ENOMEM;
if (IS_ERR(drm))
return PTR_ERR(drm);
platform_set_drvdata(pdev, drm);
vc4->dev = drm;
drm->dev_private = vc4;
......
......@@ -334,8 +334,8 @@ static int __init vgem_init(void)
int ret;
vgem_device = drm_dev_alloc(&vgem_driver, NULL);
if (!vgem_device) {
ret = -ENOMEM;
if (IS_ERR(vgem_device)) {
ret = PTR_ERR(vgem_device);
goto out;
}
......
......@@ -54,8 +54,8 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev)
int ret;
dev = drm_dev_alloc(driver, &vdev->dev);
if (!dev)
return -ENOMEM;
if (IS_ERR(dev))
return PTR_ERR(dev);
dev->virtdev = vdev;
vdev->priv = dev;
......
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