Commit 9b1f1b6b authored by Noralf Trønnes's avatar Noralf Trønnes

drm: Add devm_drm_dev_init()

This adds a resource managed (devres) version of drm_dev_init().

v2: Remove devm_drm_dev_register() since we can't touch hw in devm
    release functions and drivers want to disable hw on driver module
    unload (Daniel Vetter, Greg KH)

Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190225144232.20761-3-noralf@tronnes.org
parent 56be6503
...@@ -254,6 +254,9 @@ DMA ...@@ -254,6 +254,9 @@ DMA
dmam_pool_create() dmam_pool_create()
dmam_pool_destroy() dmam_pool_destroy()
DRM
devm_drm_dev_init()
GPIO GPIO
devm_gpiod_get() devm_gpiod_get()
devm_gpiod_get_index() devm_gpiod_get_index()
......
...@@ -601,6 +601,45 @@ int drm_dev_init(struct drm_device *dev, ...@@ -601,6 +601,45 @@ int drm_dev_init(struct drm_device *dev,
} }
EXPORT_SYMBOL(drm_dev_init); EXPORT_SYMBOL(drm_dev_init);
static void devm_drm_dev_init_release(void *data)
{
drm_dev_put(data);
}
/**
* devm_drm_dev_init - Resource managed drm_dev_init()
* @parent: Parent device object
* @dev: DRM device
* @driver: DRM driver
*
* Managed drm_dev_init(). The DRM device initialized with this function is
* automatically put on driver detach using drm_dev_put(). You must supply a
* &drm_driver.release callback to control the finalization explicitly.
*
* RETURNS:
* 0 on success, or error code on failure.
*/
int devm_drm_dev_init(struct device *parent,
struct drm_device *dev,
struct drm_driver *driver)
{
int ret;
if (WARN_ON(!parent || !driver->release))
return -EINVAL;
ret = drm_dev_init(dev, driver, parent);
if (ret)
return ret;
ret = devm_add_action(parent, devm_drm_dev_init_release, dev);
if (ret)
devm_drm_dev_init_release(dev);
return ret;
}
EXPORT_SYMBOL(devm_drm_dev_init);
/** /**
* drm_dev_fini - Finalize a dead DRM device * drm_dev_fini - Finalize a dead DRM device
* @dev: DRM device * @dev: DRM device
......
...@@ -718,6 +718,9 @@ extern unsigned int drm_debug; ...@@ -718,6 +718,9 @@ extern unsigned int drm_debug;
int drm_dev_init(struct drm_device *dev, int drm_dev_init(struct drm_device *dev,
struct drm_driver *driver, struct drm_driver *driver,
struct device *parent); struct device *parent);
int devm_drm_dev_init(struct device *parent,
struct drm_device *dev,
struct drm_driver *driver);
void drm_dev_fini(struct drm_device *dev); void drm_dev_fini(struct drm_device *dev);
struct drm_device *drm_dev_alloc(struct drm_driver *driver, struct drm_device *drm_dev_alloc(struct drm_driver *driver,
......
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