diff options
author | Bjorn Andersson <bjorn.andersson@sonymobile.com> | 2015-08-28 13:39:20 -0400 |
---|---|---|
committer | Andy Gross <agross@codeaurora.org> | 2015-10-14 15:51:20 -0400 |
commit | 1a7caca20ed56a80cea045327deaeb4e4379cbd1 (patch) | |
tree | abccd232c7af826a7d6807fb0203ff83c01adc13 | |
parent | f1fed8c054a22dcb88c0ded986c80aa7019e5098 (diff) |
soc: qcom: smd: Implement id_table driver matching
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>
-rw-r--r-- | drivers/soc/qcom/smd.c | 25 | ||||
-rw-r--r-- | include/linux/soc/qcom/smd.h | 11 |
2 files changed, 29 insertions, 7 deletions
diff --git a/drivers/soc/qcom/smd.c b/drivers/soc/qcom/smd.c index a6155c917d52..d883c16d1775 100644 --- a/drivers/soc/qcom/smd.c +++ b/drivers/soc/qcom/smd.c | |||
@@ -727,6 +727,19 @@ static struct qcom_smd_driver *to_smd_driver(struct device *dev) | |||
727 | 727 | ||
728 | static int qcom_smd_dev_match(struct device *dev, struct device_driver *drv) | 728 | static int qcom_smd_dev_match(struct device *dev, struct device_driver *drv) |
729 | { | 729 | { |
730 | struct qcom_smd_device *qsdev = to_smd_device(dev); | ||
731 | struct qcom_smd_driver *qsdrv = container_of(drv, struct qcom_smd_driver, driver); | ||
732 | const struct qcom_smd_id *match = qsdrv->smd_match_table; | ||
733 | const char *name = qsdev->channel->name; | ||
734 | |||
735 | if (match) { | ||
736 | while (match->name[0]) { | ||
737 | if (!strcmp(match->name, name)) | ||
738 | return 1; | ||
739 | match++; | ||
740 | } | ||
741 | } | ||
742 | |||
730 | return of_driver_match_device(dev, drv); | 743 | return of_driver_match_device(dev, drv); |
731 | } | 744 | } |
732 | 745 | ||
@@ -880,19 +893,17 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel) | |||
880 | if (channel->qsdev) | 893 | if (channel->qsdev) |
881 | return -EEXIST; | 894 | return -EEXIST; |
882 | 895 | ||
883 | node = qcom_smd_match_channel(edge->of_node, channel->name); | ||
884 | if (!node) { | ||
885 | dev_dbg(smd->dev, "no match for '%s'\n", channel->name); | ||
886 | return -ENXIO; | ||
887 | } | ||
888 | |||
889 | dev_dbg(smd->dev, "registering '%s'\n", channel->name); | 896 | dev_dbg(smd->dev, "registering '%s'\n", channel->name); |
890 | 897 | ||
891 | qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); | 898 | qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); |
892 | if (!qsdev) | 899 | if (!qsdev) |
893 | return -ENOMEM; | 900 | return -ENOMEM; |
894 | 901 | ||
895 | dev_set_name(&qsdev->dev, "%s.%s", edge->of_node->name, node->name); | 902 | node = qcom_smd_match_channel(edge->of_node, channel->name); |
903 | dev_set_name(&qsdev->dev, "%s.%s", | ||
904 | edge->of_node->name, | ||
905 | node ? node->name : channel->name); | ||
906 | |||
896 | qsdev->dev.parent = smd->dev; | 907 | qsdev->dev.parent = smd->dev; |
897 | qsdev->dev.bus = &qcom_smd_bus; | 908 | qsdev->dev.bus = &qcom_smd_bus; |
898 | qsdev->dev.release = qcom_smd_release_device; | 909 | qsdev->dev.release = qcom_smd_release_device; |
diff --git a/include/linux/soc/qcom/smd.h b/include/linux/soc/qcom/smd.h index d7e50aa6a4ac..d0cb6d189a0a 100644 --- a/include/linux/soc/qcom/smd.h +++ b/include/linux/soc/qcom/smd.h | |||
@@ -9,6 +9,14 @@ struct qcom_smd_channel; | |||
9 | struct qcom_smd_lookup; | 9 | struct qcom_smd_lookup; |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * struct qcom_smd_id - struct used for matching a smd device | ||
13 | * @name: name of the channel | ||
14 | */ | ||
15 | struct qcom_smd_id { | ||
16 | char name[20]; | ||
17 | }; | ||
18 | |||
19 | /** | ||
12 | * struct qcom_smd_device - smd device struct | 20 | * struct qcom_smd_device - smd device struct |
13 | * @dev: the device struct | 21 | * @dev: the device struct |
14 | * @channel: handle to the smd channel for this device | 22 | * @channel: handle to the smd channel for this device |
@@ -21,6 +29,7 @@ struct qcom_smd_device { | |||
21 | /** | 29 | /** |
22 | * struct qcom_smd_driver - smd driver struct | 30 | * struct qcom_smd_driver - smd driver struct |
23 | * @driver: underlying device driver | 31 | * @driver: underlying device driver |
32 | * @smd_match_table: static channel match table | ||
24 | * @probe: invoked when the smd channel is found | 33 | * @probe: invoked when the smd channel is found |
25 | * @remove: invoked when the smd channel is closed | 34 | * @remove: invoked when the smd channel is closed |
26 | * @callback: invoked when an inbound message is received on the channel, | 35 | * @callback: invoked when an inbound message is received on the channel, |
@@ -29,6 +38,8 @@ struct qcom_smd_device { | |||
29 | */ | 38 | */ |
30 | struct qcom_smd_driver { | 39 | struct qcom_smd_driver { |
31 | struct device_driver driver; | 40 | struct device_driver driver; |
41 | const struct qcom_smd_id *smd_match_table; | ||
42 | |||
32 | int (*probe)(struct qcom_smd_device *dev); | 43 | int (*probe)(struct qcom_smd_device *dev); |
33 | void (*remove)(struct qcom_smd_device *dev); | 44 | void (*remove)(struct qcom_smd_device *dev); |
34 | int (*callback)(struct qcom_smd_device *, const void *, size_t); | 45 | int (*callback)(struct qcom_smd_device *, const void *, size_t); |