diff options
author | Sebastian Reichel <sre@kernel.org> | 2016-06-28 13:56:54 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2016-06-28 13:56:54 -0400 |
commit | 411ef2be439abae8e187e1c608b0a8c24a758adc (patch) | |
tree | f93a9a91b5858ca11bdb64e2b7617bd13fb564c6 | |
parent | 2e05b518c89714d60000dfe0cd39490da68763e0 (diff) | |
parent | 830ae442202e314c2bdf7cb4c7cc64d76db0e197 (diff) |
Merge remote-tracking branch 'chanwoo-extcon/ib-extcon-powersupply-4.8' into psy-next
-rw-r--r-- | drivers/extcon/extcon.c | 201 | ||||
-rw-r--r-- | drivers/power/axp288_charger.c | 77 | ||||
-rw-r--r-- | include/linux/extcon.h | 80 |
3 files changed, 100 insertions, 258 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 21a123cadf78..4fef9ab4b148 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c | |||
@@ -127,38 +127,6 @@ static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id | |||
127 | return -EINVAL; | 127 | return -EINVAL; |
128 | } | 128 | } |
129 | 129 | ||
130 | static int find_cable_id_by_name(struct extcon_dev *edev, const char *name) | ||
131 | { | ||
132 | int id = -EINVAL; | ||
133 | int i = 0; | ||
134 | |||
135 | /* Find the id of extcon cable */ | ||
136 | while (extcon_name[i]) { | ||
137 | if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { | ||
138 | id = i; | ||
139 | break; | ||
140 | } | ||
141 | i++; | ||
142 | } | ||
143 | |||
144 | return id; | ||
145 | } | ||
146 | |||
147 | static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) | ||
148 | { | ||
149 | int id; | ||
150 | |||
151 | if (edev->max_supported == 0) | ||
152 | return -EINVAL; | ||
153 | |||
154 | /* Find the the number of extcon cable */ | ||
155 | id = find_cable_id_by_name(edev, name); | ||
156 | if (id < 0) | ||
157 | return id; | ||
158 | |||
159 | return find_cable_index_by_id(edev, id); | ||
160 | } | ||
161 | |||
162 | static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached) | 130 | static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached) |
163 | { | 131 | { |
164 | if (((prev >> idx) & 0x1) != ((new >> idx) & 0x1)) { | 132 | if (((prev >> idx) & 0x1) != ((new >> idx) & 0x1)) { |
@@ -374,25 +342,6 @@ int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id) | |||
374 | EXPORT_SYMBOL_GPL(extcon_get_cable_state_); | 342 | EXPORT_SYMBOL_GPL(extcon_get_cable_state_); |
375 | 343 | ||
376 | /** | 344 | /** |
377 | * extcon_get_cable_state() - Get the status of a specific cable. | ||
378 | * @edev: the extcon device that has the cable. | ||
379 | * @cable_name: cable name. | ||
380 | * | ||
381 | * Note that this is slower than extcon_get_cable_state_. | ||
382 | */ | ||
383 | int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name) | ||
384 | { | ||
385 | int id; | ||
386 | |||
387 | id = find_cable_id_by_name(edev, cable_name); | ||
388 | if (id < 0) | ||
389 | return id; | ||
390 | |||
391 | return extcon_get_cable_state_(edev, id); | ||
392 | } | ||
393 | EXPORT_SYMBOL_GPL(extcon_get_cable_state); | ||
394 | |||
395 | /** | ||
396 | * extcon_set_cable_state_() - Set the status of a specific cable. | 345 | * extcon_set_cable_state_() - Set the status of a specific cable. |
397 | * @edev: the extcon device that has the cable. | 346 | * @edev: the extcon device that has the cable. |
398 | * @id: the unique id of each external connector | 347 | * @id: the unique id of each external connector |
@@ -422,28 +371,6 @@ int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, | |||
422 | EXPORT_SYMBOL_GPL(extcon_set_cable_state_); | 371 | EXPORT_SYMBOL_GPL(extcon_set_cable_state_); |
423 | 372 | ||
424 | /** | 373 | /** |
425 | * extcon_set_cable_state() - Set the status of a specific cable. | ||
426 | * @edev: the extcon device that has the cable. | ||
427 | * @cable_name: cable name. | ||
428 | * @cable_state: the new cable status. The default semantics is | ||
429 | * true: attached / false: detached. | ||
430 | * | ||
431 | * Note that this is slower than extcon_set_cable_state_. | ||
432 | */ | ||
433 | int extcon_set_cable_state(struct extcon_dev *edev, | ||
434 | const char *cable_name, bool cable_state) | ||
435 | { | ||
436 | int id; | ||
437 | |||
438 | id = find_cable_id_by_name(edev, cable_name); | ||
439 | if (id < 0) | ||
440 | return id; | ||
441 | |||
442 | return extcon_set_cable_state_(edev, id, cable_state); | ||
443 | } | ||
444 | EXPORT_SYMBOL_GPL(extcon_set_cable_state); | ||
445 | |||
446 | /** | ||
447 | * extcon_get_extcon_dev() - Get the extcon device instance from the name | 374 | * extcon_get_extcon_dev() - Get the extcon device instance from the name |
448 | * @extcon_name: The extcon name provided with extcon_dev_register() | 375 | * @extcon_name: The extcon name provided with extcon_dev_register() |
449 | */ | 376 | */ |
@@ -467,105 +394,6 @@ out: | |||
467 | EXPORT_SYMBOL_GPL(extcon_get_extcon_dev); | 394 | EXPORT_SYMBOL_GPL(extcon_get_extcon_dev); |
468 | 395 | ||
469 | /** | 396 | /** |
470 | * extcon_register_interest() - Register a notifier for a state change of a | ||
471 | * specific cable, not an entier set of cables of a | ||
472 | * extcon device. | ||
473 | * @obj: an empty extcon_specific_cable_nb object to be returned. | ||
474 | * @extcon_name: the name of extcon device. | ||
475 | * if NULL, extcon_register_interest will register | ||
476 | * every cable with the target cable_name given. | ||
477 | * @cable_name: the target cable name. | ||
478 | * @nb: the notifier block to get notified. | ||
479 | * | ||
480 | * Provide an empty extcon_specific_cable_nb. extcon_register_interest() sets | ||
481 | * the struct for you. | ||
482 | * | ||
483 | * extcon_register_interest is a helper function for those who want to get | ||
484 | * notification for a single specific cable's status change. If a user wants | ||
485 | * to get notification for any changes of all cables of a extcon device, | ||
486 | * he/she should use the general extcon_register_notifier(). | ||
487 | * | ||
488 | * Note that the second parameter given to the callback of nb (val) is | ||
489 | * "old_state", not the current state. The current state can be retrieved | ||
490 | * by looking at the third pameter (edev pointer)'s state value. | ||
491 | */ | ||
492 | int extcon_register_interest(struct extcon_specific_cable_nb *obj, | ||
493 | const char *extcon_name, const char *cable_name, | ||
494 | struct notifier_block *nb) | ||
495 | { | ||
496 | unsigned long flags; | ||
497 | int ret; | ||
498 | |||
499 | if (!obj || !cable_name || !nb) | ||
500 | return -EINVAL; | ||
501 | |||
502 | if (extcon_name) { | ||
503 | obj->edev = extcon_get_extcon_dev(extcon_name); | ||
504 | if (!obj->edev) | ||
505 | return -ENODEV; | ||
506 | |||
507 | obj->cable_index = find_cable_index_by_name(obj->edev, | ||
508 | cable_name); | ||
509 | if (obj->cable_index < 0) | ||
510 | return obj->cable_index; | ||
511 | |||
512 | obj->user_nb = nb; | ||
513 | |||
514 | spin_lock_irqsave(&obj->edev->lock, flags); | ||
515 | ret = raw_notifier_chain_register( | ||
516 | &obj->edev->nh[obj->cable_index], | ||
517 | obj->user_nb); | ||
518 | spin_unlock_irqrestore(&obj->edev->lock, flags); | ||
519 | } else { | ||
520 | struct class_dev_iter iter; | ||
521 | struct extcon_dev *extd; | ||
522 | struct device *dev; | ||
523 | |||
524 | if (!extcon_class) | ||
525 | return -ENODEV; | ||
526 | class_dev_iter_init(&iter, extcon_class, NULL, NULL); | ||
527 | while ((dev = class_dev_iter_next(&iter))) { | ||
528 | extd = dev_get_drvdata(dev); | ||
529 | |||
530 | if (find_cable_index_by_name(extd, cable_name) < 0) | ||
531 | continue; | ||
532 | |||
533 | class_dev_iter_exit(&iter); | ||
534 | return extcon_register_interest(obj, extd->name, | ||
535 | cable_name, nb); | ||
536 | } | ||
537 | |||
538 | ret = -ENODEV; | ||
539 | } | ||
540 | |||
541 | return ret; | ||
542 | } | ||
543 | EXPORT_SYMBOL_GPL(extcon_register_interest); | ||
544 | |||
545 | /** | ||
546 | * extcon_unregister_interest() - Unregister the notifier registered by | ||
547 | * extcon_register_interest(). | ||
548 | * @obj: the extcon_specific_cable_nb object returned by | ||
549 | * extcon_register_interest(). | ||
550 | */ | ||
551 | int extcon_unregister_interest(struct extcon_specific_cable_nb *obj) | ||
552 | { | ||
553 | unsigned long flags; | ||
554 | int ret; | ||
555 | |||
556 | if (!obj) | ||
557 | return -EINVAL; | ||
558 | |||
559 | spin_lock_irqsave(&obj->edev->lock, flags); | ||
560 | ret = raw_notifier_chain_unregister( | ||
561 | &obj->edev->nh[obj->cable_index], obj->user_nb); | ||
562 | spin_unlock_irqrestore(&obj->edev->lock, flags); | ||
563 | |||
564 | return ret; | ||
565 | } | ||
566 | EXPORT_SYMBOL_GPL(extcon_unregister_interest); | ||
567 | |||
568 | /** | ||
569 | * extcon_register_notifier() - Register a notifiee to get notified by | 397 | * extcon_register_notifier() - Register a notifiee to get notified by |
570 | * any attach status changes from the extcon. | 398 | * any attach status changes from the extcon. |
571 | * @edev: the extcon device that has the external connecotr. | 399 | * @edev: the extcon device that has the external connecotr. |
@@ -582,14 +410,33 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, | |||
582 | unsigned long flags; | 410 | unsigned long flags; |
583 | int ret, idx; | 411 | int ret, idx; |
584 | 412 | ||
585 | if (!edev || !nb) | 413 | if (!nb) |
586 | return -EINVAL; | 414 | return -EINVAL; |
587 | 415 | ||
588 | idx = find_cable_index_by_id(edev, id); | 416 | if (edev) { |
417 | idx = find_cable_index_by_id(edev, id); | ||
589 | 418 | ||
590 | spin_lock_irqsave(&edev->lock, flags); | 419 | spin_lock_irqsave(&edev->lock, flags); |
591 | ret = raw_notifier_chain_register(&edev->nh[idx], nb); | 420 | ret = raw_notifier_chain_register(&edev->nh[idx], nb); |
592 | spin_unlock_irqrestore(&edev->lock, flags); | 421 | spin_unlock_irqrestore(&edev->lock, flags); |
422 | } else { | ||
423 | struct extcon_dev *extd; | ||
424 | |||
425 | mutex_lock(&extcon_dev_list_lock); | ||
426 | list_for_each_entry(extd, &extcon_dev_list, entry) { | ||
427 | idx = find_cable_index_by_id(extd, id); | ||
428 | if (idx >= 0) | ||
429 | break; | ||
430 | } | ||
431 | mutex_unlock(&extcon_dev_list_lock); | ||
432 | |||
433 | if (idx >= 0) { | ||
434 | edev = extd; | ||
435 | return extcon_register_notifier(extd, id, nb); | ||
436 | } else { | ||
437 | ret = -ENODEV; | ||
438 | } | ||
439 | } | ||
593 | 440 | ||
594 | return ret; | 441 | return ret; |
595 | } | 442 | } |
diff --git a/drivers/power/axp288_charger.c b/drivers/power/axp288_charger.c index e4d569f57acc..4030eeb7cf65 100644 --- a/drivers/power/axp288_charger.c +++ b/drivers/power/axp288_charger.c | |||
@@ -129,10 +129,6 @@ | |||
129 | 129 | ||
130 | #define AXP288_EXTCON_DEV_NAME "axp288_extcon" | 130 | #define AXP288_EXTCON_DEV_NAME "axp288_extcon" |
131 | 131 | ||
132 | #define AXP288_EXTCON_SLOW_CHARGER "SLOW-CHARGER" | ||
133 | #define AXP288_EXTCON_DOWNSTREAM_CHARGER "CHARGE-DOWNSTREAM" | ||
134 | #define AXP288_EXTCON_FAST_CHARGER "FAST-CHARGER" | ||
135 | |||
136 | enum { | 132 | enum { |
137 | VBUS_OV_IRQ = 0, | 133 | VBUS_OV_IRQ = 0, |
138 | CHARGE_DONE_IRQ, | 134 | CHARGE_DONE_IRQ, |
@@ -158,7 +154,7 @@ struct axp288_chrg_info { | |||
158 | /* OTG/Host mode */ | 154 | /* OTG/Host mode */ |
159 | struct { | 155 | struct { |
160 | struct work_struct work; | 156 | struct work_struct work; |
161 | struct extcon_specific_cable_nb cable; | 157 | struct extcon_dev *cable; |
162 | struct notifier_block id_nb; | 158 | struct notifier_block id_nb; |
163 | bool id_short; | 159 | bool id_short; |
164 | } otg; | 160 | } otg; |
@@ -586,17 +582,15 @@ static void axp288_charger_extcon_evt_worker(struct work_struct *work) | |||
586 | bool old_connected = info->cable.connected; | 582 | bool old_connected = info->cable.connected; |
587 | 583 | ||
588 | /* Determine cable/charger type */ | 584 | /* Determine cable/charger type */ |
589 | if (extcon_get_cable_state(edev, AXP288_EXTCON_SLOW_CHARGER) > 0) { | 585 | if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_SDP) > 0) { |
590 | dev_dbg(&info->pdev->dev, "USB SDP charger is connected"); | 586 | dev_dbg(&info->pdev->dev, "USB SDP charger is connected"); |
591 | info->cable.connected = true; | 587 | info->cable.connected = true; |
592 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB; | 588 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB; |
593 | } else if (extcon_get_cable_state(edev, | 589 | } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_CDP) > 0) { |
594 | AXP288_EXTCON_DOWNSTREAM_CHARGER) > 0) { | ||
595 | dev_dbg(&info->pdev->dev, "USB CDP charger is connected"); | 590 | dev_dbg(&info->pdev->dev, "USB CDP charger is connected"); |
596 | info->cable.connected = true; | 591 | info->cable.connected = true; |
597 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP; | 592 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB_CDP; |
598 | } else if (extcon_get_cable_state(edev, | 593 | } else if (extcon_get_cable_state_(edev, EXTCON_CHG_USB_DCP) > 0) { |
599 | AXP288_EXTCON_FAST_CHARGER) > 0) { | ||
600 | dev_dbg(&info->pdev->dev, "USB DCP charger is connected"); | 594 | dev_dbg(&info->pdev->dev, "USB DCP charger is connected"); |
601 | info->cable.connected = true; | 595 | info->cable.connected = true; |
602 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP; | 596 | info->cable.chg_type = POWER_SUPPLY_TYPE_USB_DCP; |
@@ -692,8 +686,8 @@ static int axp288_charger_handle_otg_evt(struct notifier_block *nb, | |||
692 | { | 686 | { |
693 | struct axp288_chrg_info *info = | 687 | struct axp288_chrg_info *info = |
694 | container_of(nb, struct axp288_chrg_info, otg.id_nb); | 688 | container_of(nb, struct axp288_chrg_info, otg.id_nb); |
695 | struct extcon_dev *edev = param; | 689 | struct extcon_dev *edev = info->otg.cable; |
696 | int usb_host = extcon_get_cable_state(edev, "USB-Host"); | 690 | int usb_host = extcon_get_cable_state_(edev, EXTCON_USB_HOST); |
697 | 691 | ||
698 | dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n", | 692 | dev_dbg(&info->pdev->dev, "external connector USB-Host is %s\n", |
699 | usb_host ? "attached" : "detached"); | 693 | usb_host ? "attached" : "detached"); |
@@ -848,10 +842,33 @@ static int axp288_charger_probe(struct platform_device *pdev) | |||
848 | /* Register for extcon notification */ | 842 | /* Register for extcon notification */ |
849 | INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); | 843 | INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker); |
850 | info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; | 844 | info->cable.nb.notifier_call = axp288_charger_handle_cable_evt; |
851 | ret = extcon_register_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); | 845 | ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
846 | &info->cable.nb); | ||
847 | if (ret) { | ||
848 | dev_err(&info->pdev->dev, | ||
849 | "failed to register extcon notifier for SDP %d\n", ret); | ||
850 | return ret; | ||
851 | } | ||
852 | |||
853 | ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, | ||
854 | &info->cable.nb); | ||
855 | if (ret) { | ||
856 | dev_err(&info->pdev->dev, | ||
857 | "failed to register extcon notifier for CDP %d\n", ret); | ||
858 | extcon_unregister_notifier(info->cable.edev, | ||
859 | EXTCON_CHG_USB_SDP, &info->cable.nb); | ||
860 | return ret; | ||
861 | } | ||
862 | |||
863 | ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, | ||
864 | &info->cable.nb); | ||
852 | if (ret) { | 865 | if (ret) { |
853 | dev_err(&info->pdev->dev, | 866 | dev_err(&info->pdev->dev, |
854 | "failed to register extcon notifier %d\n", ret); | 867 | "failed to register extcon notifier for DCP %d\n", ret); |
868 | extcon_unregister_notifier(info->cable.edev, | ||
869 | EXTCON_CHG_USB_SDP, &info->cable.nb); | ||
870 | extcon_unregister_notifier(info->cable.edev, | ||
871 | EXTCON_CHG_USB_CDP, &info->cable.nb); | ||
855 | return ret; | 872 | return ret; |
856 | } | 873 | } |
857 | 874 | ||
@@ -871,14 +888,14 @@ static int axp288_charger_probe(struct platform_device *pdev) | |||
871 | /* Register for OTG notification */ | 888 | /* Register for OTG notification */ |
872 | INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); | 889 | INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); |
873 | info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; | 890 | info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; |
874 | ret = extcon_register_interest(&info->otg.cable, NULL, "USB-Host", | 891 | ret = extcon_register_notifier(info->otg.cable, EXTCON_USB_HOST, |
875 | &info->otg.id_nb); | 892 | &info->otg.id_nb); |
876 | if (ret) | 893 | if (ret) |
877 | dev_warn(&pdev->dev, "failed to register otg notifier\n"); | 894 | dev_warn(&pdev->dev, "failed to register otg notifier\n"); |
878 | 895 | ||
879 | if (info->otg.cable.edev) | 896 | if (info->otg.cable) |
880 | info->otg.id_short = extcon_get_cable_state( | 897 | info->otg.id_short = extcon_get_cable_state_( |
881 | info->otg.cable.edev, "USB-Host"); | 898 | info->otg.cable, EXTCON_USB_HOST); |
882 | 899 | ||
883 | /* Register charger interrupts */ | 900 | /* Register charger interrupts */ |
884 | for (i = 0; i < CHRG_INTR_END; i++) { | 901 | for (i = 0; i < CHRG_INTR_END; i++) { |
@@ -905,11 +922,17 @@ static int axp288_charger_probe(struct platform_device *pdev) | |||
905 | return 0; | 922 | return 0; |
906 | 923 | ||
907 | intr_reg_failed: | 924 | intr_reg_failed: |
908 | if (info->otg.cable.edev) | 925 | if (info->otg.cable) |
909 | extcon_unregister_interest(&info->otg.cable); | 926 | extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST, |
927 | &info->otg.id_nb); | ||
910 | power_supply_unregister(info->psy_usb); | 928 | power_supply_unregister(info->psy_usb); |
911 | psy_reg_failed: | 929 | psy_reg_failed: |
912 | extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); | 930 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
931 | &info->cable.nb); | ||
932 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, | ||
933 | &info->cable.nb); | ||
934 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, | ||
935 | &info->cable.nb); | ||
913 | return ret; | 936 | return ret; |
914 | } | 937 | } |
915 | 938 | ||
@@ -917,10 +940,16 @@ static int axp288_charger_remove(struct platform_device *pdev) | |||
917 | { | 940 | { |
918 | struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev); | 941 | struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev); |
919 | 942 | ||
920 | if (info->otg.cable.edev) | 943 | if (info->otg.cable) |
921 | extcon_unregister_interest(&info->otg.cable); | 944 | extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST, |
945 | &info->otg.id_nb); | ||
922 | 946 | ||
923 | extcon_unregister_notifier(info->cable.edev, EXTCON_NONE, &info->cable.nb); | 947 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP, |
948 | &info->cable.nb); | ||
949 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP, | ||
950 | &info->cable.nb); | ||
951 | extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP, | ||
952 | &info->cable.nb); | ||
924 | power_supply_unregister(info->psy_usb); | 953 | power_supply_unregister(info->psy_usb); |
925 | 954 | ||
926 | return 0; | 955 | return 0; |
diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 7abf674c388c..cec5c543afc6 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h | |||
@@ -146,22 +146,6 @@ struct extcon_cable { | |||
146 | struct attribute *attrs[3]; /* to be fed to attr_g.attrs */ | 146 | struct attribute *attrs[3]; /* to be fed to attr_g.attrs */ |
147 | }; | 147 | }; |
148 | 148 | ||
149 | /** | ||
150 | * struct extcon_specific_cable_nb - An internal data for | ||
151 | * extcon_register_interest(). | ||
152 | * @user_nb: user provided notifier block for events from | ||
153 | * a specific cable. | ||
154 | * @cable_index: the target cable. | ||
155 | * @edev: the target extcon device. | ||
156 | * @previous_value: the saved previous event value. | ||
157 | */ | ||
158 | struct extcon_specific_cable_nb { | ||
159 | struct notifier_block *user_nb; | ||
160 | int cable_index; | ||
161 | struct extcon_dev *edev; | ||
162 | unsigned long previous_value; | ||
163 | }; | ||
164 | |||
165 | #if IS_ENABLED(CONFIG_EXTCON) | 149 | #if IS_ENABLED(CONFIG_EXTCON) |
166 | 150 | ||
167 | /* | 151 | /* |
@@ -207,23 +191,6 @@ extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id); | |||
207 | extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, | 191 | extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, |
208 | bool cable_state); | 192 | bool cable_state); |
209 | 193 | ||
210 | extern int extcon_get_cable_state(struct extcon_dev *edev, | ||
211 | const char *cable_name); | ||
212 | extern int extcon_set_cable_state(struct extcon_dev *edev, | ||
213 | const char *cable_name, bool cable_state); | ||
214 | |||
215 | /* | ||
216 | * Following APIs are for notifiees (those who want to be notified) | ||
217 | * to register a callback for events from a specific cable of the extcon. | ||
218 | * Notifiees are the connected device drivers wanting to get notified by | ||
219 | * a specific external port of a connection device. | ||
220 | */ | ||
221 | extern int extcon_register_interest(struct extcon_specific_cable_nb *obj, | ||
222 | const char *extcon_name, | ||
223 | const char *cable_name, | ||
224 | struct notifier_block *nb); | ||
225 | extern int extcon_unregister_interest(struct extcon_specific_cable_nb *nb); | ||
226 | |||
227 | /* | 194 | /* |
228 | * Following APIs are to monitor every action of a notifier. | 195 | * Following APIs are to monitor every action of a notifier. |
229 | * Registrar gets notified for every external port of a connection device. | 196 | * Registrar gets notified for every external port of a connection device. |
@@ -246,6 +213,7 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, | |||
246 | /* Following API to get information of extcon device */ | 213 | /* Following API to get information of extcon device */ |
247 | extern const char *extcon_get_edev_name(struct extcon_dev *edev); | 214 | extern const char *extcon_get_edev_name(struct extcon_dev *edev); |
248 | 215 | ||
216 | |||
249 | #else /* CONFIG_EXTCON */ | 217 | #else /* CONFIG_EXTCON */ |
250 | static inline int extcon_dev_register(struct extcon_dev *edev) | 218 | static inline int extcon_dev_register(struct extcon_dev *edev) |
251 | { | 219 | { |
@@ -306,18 +274,6 @@ static inline int extcon_set_cable_state_(struct extcon_dev *edev, | |||
306 | return 0; | 274 | return 0; |
307 | } | 275 | } |
308 | 276 | ||
309 | static inline int extcon_get_cable_state(struct extcon_dev *edev, | ||
310 | const char *cable_name) | ||
311 | { | ||
312 | return 0; | ||
313 | } | ||
314 | |||
315 | static inline int extcon_set_cable_state(struct extcon_dev *edev, | ||
316 | const char *cable_name, int state) | ||
317 | { | ||
318 | return 0; | ||
319 | } | ||
320 | |||
321 | static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) | 277 | static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) |
322 | { | 278 | { |
323 | return NULL; | 279 | return NULL; |
@@ -337,24 +293,34 @@ static inline int extcon_unregister_notifier(struct extcon_dev *edev, | |||
337 | return 0; | 293 | return 0; |
338 | } | 294 | } |
339 | 295 | ||
340 | static inline int extcon_register_interest(struct extcon_specific_cable_nb *obj, | 296 | static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, |
341 | const char *extcon_name, | 297 | int index) |
342 | const char *cable_name, | ||
343 | struct notifier_block *nb) | ||
344 | { | 298 | { |
345 | return 0; | 299 | return ERR_PTR(-ENODEV); |
346 | } | 300 | } |
301 | #endif /* CONFIG_EXTCON */ | ||
347 | 302 | ||
348 | static inline int extcon_unregister_interest(struct extcon_specific_cable_nb | 303 | /* |
349 | *obj) | 304 | * Following structure and API are deprecated. EXTCON remains the function |
305 | * definition to prevent the build break. | ||
306 | */ | ||
307 | struct extcon_specific_cable_nb { | ||
308 | struct notifier_block *user_nb; | ||
309 | int cable_index; | ||
310 | struct extcon_dev *edev; | ||
311 | unsigned long previous_value; | ||
312 | }; | ||
313 | |||
314 | static inline int extcon_register_interest(struct extcon_specific_cable_nb *obj, | ||
315 | const char *extcon_name, const char *cable_name, | ||
316 | struct notifier_block *nb) | ||
350 | { | 317 | { |
351 | return 0; | 318 | return -EINVAL; |
352 | } | 319 | } |
353 | 320 | ||
354 | static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, | 321 | static inline int extcon_unregister_interest(struct extcon_specific_cable_nb |
355 | int index) | 322 | *obj) |
356 | { | 323 | { |
357 | return ERR_PTR(-ENODEV); | 324 | return -EINVAL; |
358 | } | 325 | } |
359 | #endif /* CONFIG_EXTCON */ | ||
360 | #endif /* __LINUX_EXTCON_H__ */ | 326 | #endif /* __LINUX_EXTCON_H__ */ |