summaryrefslogtreecommitdiff
path: root/drivers/staging/imx-drm/imx-drm-core.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-11-24 17:02:52 +0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2014-02-24 16:04:00 +0400
commite76171b046e95e45266f3a4f4b900a5647e80d70 (patch)
tree5be58ff4ff51bb58120710b2e87ca7df48ea6da8 /drivers/staging/imx-drm/imx-drm-core.c
parentcf83eb24d22f3a9580fb86ee64e2830c65df062a (diff)
downloadlinux-e76171b046e95e45266f3a4f4b900a5647e80d70.tar.xz
imx-drm: imx-drm-core: sanitise imx_drm_encoder_get_mux_id()
Address the following issues: - imx_drm_encoder_get_mux_id() searches the CRTC list for the matching CRTC, and returns the position within this list as the MUX programming value for encoders. This is sub-optimal for two reasons: 1. It relies upon the CRTC list not changing during the lifetime of the driver. 2. It is dependent on the initialisation order of the CRTCs. We address (1) in this patch, leaving (2) until a better solution can be found, as (2) requires larger changes. - imx_drm_encoder is unused. Instead, pass the drm_encoder which is slightly more useful; all callers pass encoder->crtc as the required crtc, so move this inside the function. Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Shawn Guo <shawn.guo@linaro.org> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/staging/imx-drm/imx-drm-core.c')
-rw-r--r--drivers/staging/imx-drm/imx-drm-core.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c
index 236ed66f116a..92fde89f58ac 100644
--- a/drivers/staging/imx-drm/imx-drm-core.c
+++ b/drivers/staging/imx-drm/imx-drm-core.c
@@ -53,6 +53,7 @@ struct imx_drm_crtc {
struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs;
struct module *owner;
struct crtc_cookie cookie;
+ int mux_id;
};
struct imx_drm_encoder {
@@ -503,7 +504,7 @@ int imx_drm_add_crtc(struct drm_crtc *crtc,
imx_drm_crtc->pipe = imxdrm->pipes++;
imx_drm_crtc->cookie.cookie = cookie;
imx_drm_crtc->cookie.id = id;
-
+ imx_drm_crtc->mux_id = imx_drm_crtc->pipe;
imx_drm_crtc->crtc = crtc;
imx_drm_crtc->imxdrm = imxdrm;
@@ -657,22 +658,16 @@ int imx_drm_encoder_add_possible_crtcs(
}
EXPORT_SYMBOL_GPL(imx_drm_encoder_add_possible_crtcs);
-int imx_drm_encoder_get_mux_id(struct imx_drm_encoder *imx_drm_encoder,
- struct drm_crtc *crtc)
+int imx_drm_encoder_get_mux_id(struct drm_encoder *encoder)
{
struct imx_drm_device *imxdrm = __imx_drm_device();
struct imx_drm_crtc *imx_crtc;
- int i = 0;
- list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list) {
- if (imx_crtc->crtc == crtc)
- goto found;
- i++;
- }
+ list_for_each_entry(imx_crtc, &imxdrm->crtc_list, list)
+ if (imx_crtc->crtc == encoder->crtc)
+ return imx_crtc->mux_id;
return -EINVAL;
-found:
- return i;
}
EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id);