From 96a4763f03b8f347b85b75e20adc2967e8f80231 Mon Sep 17 00:00:00 2001 From: Archit Taneja Date: Wed, 19 Aug 2015 17:31:23 +0530 Subject: [PATCH] drm/mipi_dsi: check for used channels We don't check whether a previous mipi_dsi_device under the same host shares the same virtual channel. Before registering, check if any of the registered devices doesn't already have the same virtual channel. Signed-off-by: Archit Taneja --- drivers/gpu/drm/drm_mipi_dsi.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 583b3bc10495..3a507fe534fd 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -108,6 +108,22 @@ struct mipi_dsi_device_info { struct device_node *node; }; +static int __dsi_check_chan_busy(struct device *dev, void *data) +{ + struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); + u32 reg = *(u32 *) data; + + if (dsi && dsi->channel == reg) + return -EBUSY; + + return 0; +} + +static int mipi_dsi_check_chan_busy(struct mipi_dsi_host *host, u32 reg) +{ + return device_for_each_child(&host->dev, ®, __dsi_check_chan_busy); +} + static struct mipi_dsi_device * mipi_dsi_device_new(struct mipi_dsi_host *host, struct mipi_dsi_device_info *info) @@ -136,13 +152,18 @@ mipi_dsi_device_new(struct mipi_dsi_host *host, dev_set_name(&dsi->dev, "%s.%d", dev_name(host->dev), info->reg); + r = mipi_dsi_check_chan_busy(host, info->reg); + if (r) + goto err; + r = device_register(&dsi->dev); - if (r) { - kfree(dsi); - return ERR_PTR(r); - } + if (r) + goto err; return dsi; +err: + kfree(dsi); + return ERR_PTR(r); } static struct mipi_dsi_device * -- 2.39.5