Commit 1aed9509 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/fb-helper: Remove return value from drm_fbdev_generic_setup()

Generic fbdev emulation is a DRM client. Drivers should invoke the
setup function, but not depend on its success. Hence remove the return
value.

v3:
	* document stricter requirements for call sequence
v2:
	* warn if fbdev device has not been registered yet
	* document the new behavior
	* convert the existing warning to the new dev_ interface
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Reviewed-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200408082641.590-11-tzimmermann@suse.de
parent 3662cd19
...@@ -2170,6 +2170,8 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = { ...@@ -2170,6 +2170,8 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = {
* *
* This function sets up generic fbdev emulation for drivers that supports * This function sets up generic fbdev emulation for drivers that supports
* dumb buffers with a virtual address and that can be mmap'ed. * dumb buffers with a virtual address and that can be mmap'ed.
* drm_fbdev_generic_setup() shall be called after the DRM driver registered
* the new DRM device with drm_dev_register().
* *
* Restore, hotplug events and teardown are all taken care of. Drivers that do * Restore, hotplug events and teardown are all taken care of. Drivers that do
* suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves. * suspend/resume need to call drm_fb_helper_set_suspend_unlocked() themselves.
...@@ -2186,29 +2188,30 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = { ...@@ -2186,29 +2188,30 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = {
* Setup will be retried on the next hotplug event. * Setup will be retried on the next hotplug event.
* *
* The fbdev is destroyed by drm_dev_unregister(). * The fbdev is destroyed by drm_dev_unregister().
*
* Returns:
* Zero on success or negative error code on failure.
*/ */
int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) void drm_fbdev_generic_setup(struct drm_device *dev,
unsigned int preferred_bpp)
{ {
struct drm_fb_helper *fb_helper; struct drm_fb_helper *fb_helper;
int ret; int ret;
WARN(dev->fb_helper, "fb_helper is already set!\n"); drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
if (!drm_fbdev_emulation) if (!drm_fbdev_emulation)
return 0; return;
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL); fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
if (!fb_helper) if (!fb_helper) {
return -ENOMEM; drm_err(dev, "Failed to allocate fb_helper\n");
return;
}
ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs); ret = drm_client_init(dev, &fb_helper->client, "fbdev", &drm_fbdev_client_funcs);
if (ret) { if (ret) {
kfree(fb_helper); kfree(fb_helper);
drm_err(dev, "Failed to register client: %d\n", ret); drm_err(dev, "Failed to register client: %d\n", ret);
return ret; return;
} }
if (!preferred_bpp) if (!preferred_bpp)
...@@ -2222,8 +2225,6 @@ int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) ...@@ -2222,8 +2225,6 @@ int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); drm_dbg_kms(dev, "client hotplug ret=%d\n", ret);
drm_client_register(&fb_helper->client); drm_client_register(&fb_helper->client);
return 0;
} }
EXPORT_SYMBOL(drm_fbdev_generic_setup); EXPORT_SYMBOL(drm_fbdev_generic_setup);
......
...@@ -269,7 +269,8 @@ int drm_fb_helper_debug_leave(struct fb_info *info); ...@@ -269,7 +269,8 @@ int drm_fb_helper_debug_leave(struct fb_info *info);
void drm_fb_helper_lastclose(struct drm_device *dev); void drm_fb_helper_lastclose(struct drm_device *dev);
void drm_fb_helper_output_poll_changed(struct drm_device *dev); void drm_fb_helper_output_poll_changed(struct drm_device *dev);
int drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp); void drm_fbdev_generic_setup(struct drm_device *dev,
unsigned int preferred_bpp);
#else #else
static inline void drm_fb_helper_prepare(struct drm_device *dev, static inline void drm_fb_helper_prepare(struct drm_device *dev,
struct drm_fb_helper *helper, struct drm_fb_helper *helper,
...@@ -443,7 +444,7 @@ static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev) ...@@ -443,7 +444,7 @@ static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev)
{ {
} }
static inline int static inline void
drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp)
{ {
return 0; return 0;
......
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