Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4563f6b authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Daniel Vetter
Browse files

drm: Rely on mode_config data for fb_helper initialization



Instead of receiving the num_crts as a parameter, we can read it
directly from the mode_config structure.  I audited the drivers that
invoke this helper and I believe all of them initialize the mode_config
struct accordingly, prior to calling the fb_helper.

I used the following coccinelle hack to make this transformation, except
for the function headers and comment updates.  The first and second
rules are split because I couldn't find a way to remove the unused
temporary variables at the same time I removed the parameter.

// <smpl>
@r@
expression A,B,D,E;
identifier C;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)

@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)

@@
identifier r.C;
type T;
expression V;
@@
- T C;
<...
when != C
- C = V;
...>
// </smpl>

Changes since v1:
 - Rebased on top of the tip of drm-misc-next.
 - Remove mention to sti since a proper fix got merged.

Suggested-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.co.uk>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170202162640.27261-1-krisman@collabora.co.uk
parent f30c9257
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -374,7 +374,6 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
			&amdgpu_fb_helper_funcs);

	ret = drm_fb_helper_init(adev->ddev, &rfbdev->helper,
				 adev->mode_info.num_crtc,
				 AMDGPUFB_CONN_LIMIT);
	if (ret) {
		kfree(rfbdev);
+1 −2
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ static int arcpgu_load(struct drm_device *drm)
	drm_kms_helper_poll_init(drm);

	arcpgu->fbdev = drm_fbdev_cma_init(drm, 16,
					      drm->mode_config.num_crtc,
					   drm->mode_config.num_connector);
	if (IS_ERR(arcpgu->fbdev)) {
		ret = PTR_ERR(arcpgu->fbdev);
+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ static int hdlcd_drm_bind(struct device *dev)
	drm_mode_config_reset(drm);
	drm_kms_helper_poll_init(drm);

	hdlcd->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc,
	hdlcd->fbdev = drm_fbdev_cma_init(drm, 32,
					  drm->mode_config.num_connector);

	if (IS_ERR(hdlcd->fbdev)) {
+1 −1
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ static int malidp_bind(struct device *dev)

	drm_mode_config_reset(drm);

	malidp->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc,
	malidp->fbdev = drm_fbdev_cma_init(drm, 32,
					   drm->mode_config.num_connector);

	if (IS_ERR(malidp->fbdev)) {
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ int armada_fbdev_init(struct drm_device *dev)

	drm_fb_helper_prepare(dev, fbh, &armada_fb_helper_funcs);

	ret = drm_fb_helper_init(dev, fbh, 1, 1);
	ret = drm_fb_helper_init(dev, fbh, 1);
	if (ret) {
		DRM_ERROR("failed to initialize drm fb helper\n");
		goto err_fb_helper;
Loading