diff options
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/as3711.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/mfd/as3711.c b/drivers/mfd/as3711.c index e994c9691124..01e414162702 100644 --- a/drivers/mfd/as3711.c +++ b/drivers/mfd/as3711.c | |||
@@ -112,16 +112,34 @@ static const struct regmap_config as3711_regmap_config = { | |||
112 | .cache_type = REGCACHE_RBTREE, | 112 | .cache_type = REGCACHE_RBTREE, |
113 | }; | 113 | }; |
114 | 114 | ||
115 | #ifdef CONFIG_OF | ||
116 | static struct of_device_id as3711_of_match[] = { | ||
117 | {.compatible = "ams,as3711",}, | ||
118 | {} | ||
119 | }; | ||
120 | MODULE_DEVICE_TABLE(of, as3711_of_match); | ||
121 | #endif | ||
122 | |||
115 | static int as3711_i2c_probe(struct i2c_client *client, | 123 | static int as3711_i2c_probe(struct i2c_client *client, |
116 | const struct i2c_device_id *id) | 124 | const struct i2c_device_id *id) |
117 | { | 125 | { |
118 | struct as3711 *as3711; | 126 | struct as3711 *as3711; |
119 | struct as3711_platform_data *pdata = client->dev.platform_data; | 127 | struct as3711_platform_data *pdata; |
120 | unsigned int id1, id2; | 128 | unsigned int id1, id2; |
121 | int ret; | 129 | int ret; |
122 | 130 | ||
123 | if (!pdata) | 131 | if (!client->dev.of_node) { |
124 | dev_dbg(&client->dev, "Platform data not found\n"); | 132 | pdata = client->dev.platform_data; |
133 | if (!pdata) | ||
134 | dev_dbg(&client->dev, "Platform data not found\n"); | ||
135 | } else { | ||
136 | pdata = devm_kzalloc(&client->dev, | ||
137 | sizeof(*pdata), GFP_KERNEL); | ||
138 | if (!pdata) { | ||
139 | dev_err(&client->dev, "Failed to allocate pdata\n"); | ||
140 | return -ENOMEM; | ||
141 | } | ||
142 | } | ||
125 | 143 | ||
126 | as3711 = devm_kzalloc(&client->dev, sizeof(struct as3711), GFP_KERNEL); | 144 | as3711 = devm_kzalloc(&client->dev, sizeof(struct as3711), GFP_KERNEL); |
127 | if (!as3711) { | 145 | if (!as3711) { |
@@ -193,7 +211,8 @@ static struct i2c_driver as3711_i2c_driver = { | |||
193 | .driver = { | 211 | .driver = { |
194 | .name = "as3711", | 212 | .name = "as3711", |
195 | .owner = THIS_MODULE, | 213 | .owner = THIS_MODULE, |
196 | }, | 214 | .of_match_table = of_match_ptr(as3711_of_match), |
215 | }, | ||
197 | .probe = as3711_i2c_probe, | 216 | .probe = as3711_i2c_probe, |
198 | .remove = as3711_i2c_remove, | 217 | .remove = as3711_i2c_remove, |
199 | .id_table = as3711_i2c_id, | 218 | .id_table = as3711_i2c_id, |