Den 21.01.2019 07.11, skrev Sam Ravnborg: > Hi Noralf. > > On Sun, Jan 20, 2019 at 12:43:08PM +0100, Noralf Trønnes wrote: >> This adds resource managed (devres) versions of drm_dev_init() and >> drm_dev_register(). >> >> Also added is devm_drm_dev_register_with_fbdev() which sets up generic >> fbdev emulation as well. >> >> devm_drm_dev_register() isn't exported since there are no users. > Is it relevant to use it outside this patchset - then it should be > documented/exported now to enable use. As a rule we don't export functions that doesn't have any users. It can be exported when a user shows up. But maybe it would make sense to put all the documentation in devm_drm_dev_register() instead of duplicating it all in the two functions when they are both in use. Or it can be moved to devm_drm_dev_register() when it gets a user. I'm good with either, don't know what Daniel prefers. > >> >> Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx> >> --- >> Documentation/driver-model/devres.txt | 4 + >> drivers/gpu/drm/drm_drv.c | 106 ++++++++++++++++++++++++++ >> include/drm/drm_drv.h | 6 ++ >> 3 files changed, 116 insertions(+) >> >> diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt >> index b277cafce71e..6eebc28d4c21 100644 >> --- a/Documentation/driver-model/devres.txt >> +++ b/Documentation/driver-model/devres.txt >> @@ -254,6 +254,10 @@ DMA >> dmam_pool_create() >> dmam_pool_destroy() >> >> +DRM >> + devm_drm_dev_init() >> + devm_drm_dev_register_with_fbdev() >> + >> GPIO >> devm_gpiod_get() >> devm_gpiod_get_index() >> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c >> index 381581b01d48..12129772be45 100644 >> --- a/drivers/gpu/drm/drm_drv.c >> +++ b/drivers/gpu/drm/drm_drv.c >> @@ -36,6 +36,7 @@ >> >> #include <drm/drm_client.h> >> #include <drm/drm_drv.h> >> +#include <drm/drm_fb_helper.h> >> #include <drm/drmP.h> >> >> #include "drm_crtc_internal.h" >> @@ -871,6 +872,111 @@ void drm_dev_unregister(struct drm_device *dev) >> } >> EXPORT_SYMBOL(drm_dev_unregister); >> >> +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 released on driver detach. You must supply a >> + * &drm_driver.release callback to control the finalization explicitly. >> + * >> + * Note: This function must be used together with >> + * devm_drm_dev_register_with_fbdev(). > *must* be used, or can be used? > Reading the code this looks like something drivers that do not offer > fbdev emulation could also benefit from. They must be used together to not break ref counting. When devm_drm_dev_register() gets a user it will read: * Note: This function must be used together with * devm_drm_dev_register() or devm_drm_dev_register_with_fbdev(). Noralf. > > With the two comments processed this has: > Reviewed-by: Sam Ravnborg <sam@xxxxxxxxxxxx> > > Sam > _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel