diff options
Diffstat (limited to 'drivers/of/of_i2c.c')
-rw-r--r-- | drivers/of/of_i2c.c | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c index 344e1b03dd8..6a98dc8aa30 100644 --- a/drivers/of/of_i2c.c +++ b/drivers/of/of_i2c.c | |||
@@ -16,62 +16,6 @@ | |||
16 | #include <linux/of_i2c.h> | 16 | #include <linux/of_i2c.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | struct i2c_driver_device { | ||
20 | char *of_device; | ||
21 | char *i2c_type; | ||
22 | }; | ||
23 | |||
24 | static struct i2c_driver_device i2c_devices[] = { | ||
25 | }; | ||
26 | |||
27 | static int of_find_i2c_driver(struct device_node *node, | ||
28 | struct i2c_board_info *info) | ||
29 | { | ||
30 | int i, cplen; | ||
31 | const char *compatible; | ||
32 | const char *p; | ||
33 | |||
34 | /* 1. search for exception list entry */ | ||
35 | for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { | ||
36 | if (!of_device_is_compatible(node, i2c_devices[i].of_device)) | ||
37 | continue; | ||
38 | if (strlcpy(info->type, i2c_devices[i].i2c_type, | ||
39 | I2C_NAME_SIZE) >= I2C_NAME_SIZE) | ||
40 | return -ENOMEM; | ||
41 | |||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | compatible = of_get_property(node, "compatible", &cplen); | ||
46 | if (!compatible) | ||
47 | return -ENODEV; | ||
48 | |||
49 | /* 2. search for linux,<i2c-type> entry */ | ||
50 | p = compatible; | ||
51 | while (cplen > 0) { | ||
52 | if (!strncmp(p, "linux,", 6)) { | ||
53 | p += 6; | ||
54 | if (strlcpy(info->type, p, | ||
55 | I2C_NAME_SIZE) >= I2C_NAME_SIZE) | ||
56 | return -ENOMEM; | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | i = strlen(p) + 1; | ||
61 | p += i; | ||
62 | cplen -= i; | ||
63 | } | ||
64 | |||
65 | /* 3. take fist compatible entry and strip manufacturer */ | ||
66 | p = strchr(compatible, ','); | ||
67 | if (!p) | ||
68 | return -ENODEV; | ||
69 | p++; | ||
70 | if (strlcpy(info->type, p, I2C_NAME_SIZE) >= I2C_NAME_SIZE) | ||
71 | return -ENOMEM; | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | void of_register_i2c_devices(struct i2c_adapter *adap, | 19 | void of_register_i2c_devices(struct i2c_adapter *adap, |
76 | struct device_node *adap_node) | 20 | struct device_node *adap_node) |
77 | { | 21 | { |
@@ -83,6 +27,9 @@ void of_register_i2c_devices(struct i2c_adapter *adap, | |||
83 | const u32 *addr; | 27 | const u32 *addr; |
84 | int len; | 28 | int len; |
85 | 29 | ||
30 | if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) | ||
31 | continue; | ||
32 | |||
86 | addr = of_get_property(node, "reg", &len); | 33 | addr = of_get_property(node, "reg", &len); |
87 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { | 34 | if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { |
88 | printk(KERN_ERR | 35 | printk(KERN_ERR |
@@ -92,11 +39,6 @@ void of_register_i2c_devices(struct i2c_adapter *adap, | |||
92 | 39 | ||
93 | info.irq = irq_of_parse_and_map(node, 0); | 40 | info.irq = irq_of_parse_and_map(node, 0); |
94 | 41 | ||
95 | if (of_find_i2c_driver(node, &info) < 0) { | ||
96 | irq_dispose_mapping(info.irq); | ||
97 | continue; | ||
98 | } | ||
99 | |||
100 | info.addr = *addr; | 42 | info.addr = *addr; |
101 | 43 | ||
102 | request_module(info.type); | 44 | request_module(info.type); |