]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
soc: qcom: smd: Implement id_table driver matching
authorBjorn Andersson <bjorn.andersson@sonymobile.com>
Fri, 28 Aug 2015 17:39:20 +0000 (10:39 -0700)
committerAndy Gross <agross@codeaurora.org>
Wed, 14 Oct 2015 19:51:20 +0000 (14:51 -0500)
Implement a id_table based driver maching mechanism for drivers that
binds to fixed channels and doesn't need any additional configuration,
e.g. IPCRTR and DIAG.

Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: Andy Gross <agross@codeaurora.org>
drivers/soc/qcom/smd.c
include/linux/soc/qcom/smd.h

index a6155c917d52d03a088a2ccbbd5a25220f392c60..d883c16d177522b337a6d8859369d13b1416d384 100644 (file)
@@ -727,6 +727,19 @@ static struct qcom_smd_driver *to_smd_driver(struct device *dev)
 
 static int qcom_smd_dev_match(struct device *dev, struct device_driver *drv)
 {
+       struct qcom_smd_device *qsdev = to_smd_device(dev);
+       struct qcom_smd_driver *qsdrv = container_of(drv, struct qcom_smd_driver, driver);
+       const struct qcom_smd_id *match = qsdrv->smd_match_table;
+       const char *name = qsdev->channel->name;
+
+       if (match) {
+               while (match->name[0]) {
+                       if (!strcmp(match->name, name))
+                               return 1;
+                       match++;
+               }
+       }
+
        return of_driver_match_device(dev, drv);
 }
 
@@ -880,19 +893,17 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)
        if (channel->qsdev)
                return -EEXIST;
 
-       node = qcom_smd_match_channel(edge->of_node, channel->name);
-       if (!node) {
-               dev_dbg(smd->dev, "no match for '%s'\n", channel->name);
-               return -ENXIO;
-       }
-
        dev_dbg(smd->dev, "registering '%s'\n", channel->name);
 
        qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL);
        if (!qsdev)
                return -ENOMEM;
 
-       dev_set_name(&qsdev->dev, "%s.%s", edge->of_node->name, node->name);
+       node = qcom_smd_match_channel(edge->of_node, channel->name);
+       dev_set_name(&qsdev->dev, "%s.%s",
+                    edge->of_node->name,
+                    node ? node->name : channel->name);
+
        qsdev->dev.parent = smd->dev;
        qsdev->dev.bus = &qcom_smd_bus;
        qsdev->dev.release = qcom_smd_release_device;
index d7e50aa6a4ac09884008377f7db668c5bac555bf..d0cb6d189a0a02bd28459c7b143229563f23c4e4 100644 (file)
@@ -8,6 +8,14 @@ struct qcom_smd;
 struct qcom_smd_channel;
 struct qcom_smd_lookup;
 
+/**
+ * struct qcom_smd_id - struct used for matching a smd device
+ * @name:      name of the channel
+ */
+struct qcom_smd_id {
+       char name[20];
+};
+
 /**
  * struct qcom_smd_device - smd device struct
  * @dev:       the device struct
@@ -21,6 +29,7 @@ struct qcom_smd_device {
 /**
  * struct qcom_smd_driver - smd driver struct
  * @driver:    underlying device driver
+ * @smd_match_table: static channel match table
  * @probe:     invoked when the smd channel is found
  * @remove:    invoked when the smd channel is closed
  * @callback:  invoked when an inbound message is received on the channel,
@@ -29,6 +38,8 @@ struct qcom_smd_device {
  */
 struct qcom_smd_driver {
        struct device_driver driver;
+       const struct qcom_smd_id *smd_match_table;
+
        int (*probe)(struct qcom_smd_device *dev);
        void (*remove)(struct qcom_smd_device *dev);
        int (*callback)(struct qcom_smd_device *, const void *, size_t);