Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bjorn Andersson and committed by
Andy Gross
1a7caca2 f1fed8c0

+29 -7
+18 -7
drivers/soc/qcom/smd.c
··· 727 727 728 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 743 return of_driver_match_device(dev, drv); 731 744 } 732 745 ··· 893 880 if (channel->qsdev) 894 881 return -EEXIST; 895 882 896 - node = qcom_smd_match_channel(edge->of_node, channel->name); 897 - if (!node) { 898 - dev_dbg(smd->dev, "no match for '%s'\n", channel->name); 899 - return -ENXIO; 900 - } 901 - 902 883 dev_dbg(smd->dev, "registering '%s'\n", channel->name); 903 884 904 885 qsdev = kzalloc(sizeof(*qsdev), GFP_KERNEL); 905 886 if (!qsdev) 906 887 return -ENOMEM; 907 888 908 - dev_set_name(&qsdev->dev, "%s.%s", edge->of_node->name, node->name); 889 + node = qcom_smd_match_channel(edge->of_node, channel->name); 890 + dev_set_name(&qsdev->dev, "%s.%s", 891 + edge->of_node->name, 892 + node ? node->name : channel->name); 893 + 909 894 qsdev->dev.parent = smd->dev; 910 895 qsdev->dev.bus = &qcom_smd_bus; 911 896 qsdev->dev.release = qcom_smd_release_device;
+11
include/linux/soc/qcom/smd.h
··· 9 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 20 * struct qcom_smd_device - smd device struct 13 21 * @dev: the device struct 14 22 * @channel: handle to the smd channel for this device ··· 29 21 /** 30 22 * struct qcom_smd_driver - smd driver struct 31 23 * @driver: underlying device driver 24 + * @smd_match_table: static channel match table 32 25 * @probe: invoked when the smd channel is found 33 26 * @remove: invoked when the smd channel is closed 34 27 * @callback: invoked when an inbound message is received on the channel, ··· 38 29 */ 39 30 struct qcom_smd_driver { 40 31 struct device_driver driver; 32 + const struct qcom_smd_id *smd_match_table; 33 + 41 34 int (*probe)(struct qcom_smd_device *dev); 42 35 void (*remove)(struct qcom_smd_device *dev); 43 36 int (*callback)(struct qcom_smd_device *, const void *, size_t);