diff options
Diffstat (limited to 'drivers/extcon/extcon.c')
-rw-r--r-- | drivers/extcon/extcon.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index cb38c2747684..8bff5fd18185 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c | |||
@@ -1336,6 +1336,28 @@ void extcon_dev_unregister(struct extcon_dev *edev) | |||
1336 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); | 1336 | EXPORT_SYMBOL_GPL(extcon_dev_unregister); |
1337 | 1337 | ||
1338 | #ifdef CONFIG_OF | 1338 | #ifdef CONFIG_OF |
1339 | |||
1340 | /* | ||
1341 | * extcon_find_edev_by_node - Find the extcon device from devicetree. | ||
1342 | * @node : OF node identifying edev | ||
1343 | * | ||
1344 | * Return the pointer of extcon device if success or ERR_PTR(err) if fail. | ||
1345 | */ | ||
1346 | struct extcon_dev *extcon_find_edev_by_node(struct device_node *node) | ||
1347 | { | ||
1348 | struct extcon_dev *edev; | ||
1349 | |||
1350 | mutex_lock(&extcon_dev_list_lock); | ||
1351 | list_for_each_entry(edev, &extcon_dev_list, entry) | ||
1352 | if (edev->dev.parent && edev->dev.parent->of_node == node) | ||
1353 | goto out; | ||
1354 | edev = ERR_PTR(-EPROBE_DEFER); | ||
1355 | out: | ||
1356 | mutex_unlock(&extcon_dev_list_lock); | ||
1357 | |||
1358 | return edev; | ||
1359 | } | ||
1360 | |||
1339 | /* | 1361 | /* |
1340 | * extcon_get_edev_by_phandle - Get the extcon device from devicetree. | 1362 | * extcon_get_edev_by_phandle - Get the extcon device from devicetree. |
1341 | * @dev : the instance to the given device | 1363 | * @dev : the instance to the given device |
@@ -1363,25 +1385,27 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | |||
1363 | return ERR_PTR(-ENODEV); | 1385 | return ERR_PTR(-ENODEV); |
1364 | } | 1386 | } |
1365 | 1387 | ||
1366 | mutex_lock(&extcon_dev_list_lock); | 1388 | edev = extcon_find_edev_by_node(node); |
1367 | list_for_each_entry(edev, &extcon_dev_list, entry) { | ||
1368 | if (edev->dev.parent && edev->dev.parent->of_node == node) { | ||
1369 | mutex_unlock(&extcon_dev_list_lock); | ||
1370 | of_node_put(node); | ||
1371 | return edev; | ||
1372 | } | ||
1373 | } | ||
1374 | mutex_unlock(&extcon_dev_list_lock); | ||
1375 | of_node_put(node); | 1389 | of_node_put(node); |
1376 | 1390 | ||
1377 | return ERR_PTR(-EPROBE_DEFER); | 1391 | return edev; |
1378 | } | 1392 | } |
1393 | |||
1379 | #else | 1394 | #else |
1395 | |||
1396 | struct extcon_dev *extcon_find_edev_by_node(struct device_node *node) | ||
1397 | { | ||
1398 | return ERR_PTR(-ENOSYS); | ||
1399 | } | ||
1400 | |||
1380 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | 1401 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) |
1381 | { | 1402 | { |
1382 | return ERR_PTR(-ENOSYS); | 1403 | return ERR_PTR(-ENOSYS); |
1383 | } | 1404 | } |
1405 | |||
1384 | #endif /* CONFIG_OF */ | 1406 | #endif /* CONFIG_OF */ |
1407 | |||
1408 | EXPORT_SYMBOL_GPL(extcon_find_edev_by_node); | ||
1385 | EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); | 1409 | EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); |
1386 | 1410 | ||
1387 | /** | 1411 | /** |