diff options
-rw-r--r-- | drivers/gpu/drm/drm_mipi_dsi.c | 29 |
1 files 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 * |