]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/mipi_dsi: check for used channels
authorArchit Taneja <architt@codeaurora.org>
Wed, 19 Aug 2015 12:01:23 +0000 (17:31 +0530)
committerSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Mon, 11 Jan 2016 09:54:41 +0000 (09:54 +0000)
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 <architt@codeaurora.org>
drivers/gpu/drm/drm_mipi_dsi.c

index 583b3bc10495e67d9a551465b9c5085fe59aa54f..3a507fe534fdd891ca6eefcfb80f936c5666d201 100644 (file)
@@ -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, &reg, __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 *