Commit 962b686c450493adb8596e813bdfd0e1613482e6
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
Merge tag 'pull_req_20121122' of git://git.kernel.org/pub/scm/linux/kernel/git/m…
…zx/extcon into char-misc-next MyungJoo writes: "extcon pull request targetting Linux 3.8 for Greg KH on 2012.11.22 This is based on Linux 3.7 rc6"
Showing 5 changed files Side-by-side Diff
drivers/extcon/extcon-arizona.c
drivers/extcon/extcon-class.c
drivers/extcon/extcon-max77693.c
... | ... | @@ -657,17 +657,17 @@ |
657 | 657 | int ret, i; |
658 | 658 | u8 id; |
659 | 659 | |
660 | - info = kzalloc(sizeof(struct max77693_muic_info), GFP_KERNEL); | |
660 | + info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), | |
661 | + GFP_KERNEL); | |
661 | 662 | if (!info) { |
662 | 663 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
663 | - ret = -ENOMEM; | |
664 | - goto err_kfree; | |
664 | + return -ENOMEM; | |
665 | 665 | } |
666 | 666 | info->dev = &pdev->dev; |
667 | 667 | info->max77693 = max77693; |
668 | - if (info->max77693->regmap_muic) | |
668 | + if (info->max77693->regmap_muic) { | |
669 | 669 | dev_dbg(&pdev->dev, "allocate register map\n"); |
670 | - else { | |
670 | + } else { | |
671 | 671 | info->max77693->regmap_muic = devm_regmap_init_i2c( |
672 | 672 | info->max77693->muic, |
673 | 673 | &max77693_muic_regmap_config); |
... | ... | @@ -675,7 +675,7 @@ |
675 | 675 | ret = PTR_ERR(info->max77693->regmap_muic); |
676 | 676 | dev_err(max77693->dev, |
677 | 677 | "failed to allocate register map: %d\n", ret); |
678 | - goto err_regmap; | |
678 | + return ret; | |
679 | 679 | } |
680 | 680 | } |
681 | 681 | platform_set_drvdata(pdev, info); |
682 | 682 | |
683 | 683 | |
... | ... | @@ -686,11 +686,13 @@ |
686 | 686 | /* Support irq domain for MAX77693 MUIC device */ |
687 | 687 | for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { |
688 | 688 | struct max77693_muic_irq *muic_irq = &muic_irqs[i]; |
689 | - int virq = 0; | |
689 | + unsigned int virq = 0; | |
690 | 690 | |
691 | 691 | virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq); |
692 | - if (!virq) | |
692 | + if (!virq) { | |
693 | + ret = -EINVAL; | |
693 | 694 | goto err_irq; |
695 | + } | |
694 | 696 | muic_irq->virq = virq; |
695 | 697 | |
696 | 698 | ret = request_threaded_irq(virq, NULL, |
697 | 699 | |
... | ... | @@ -702,14 +704,13 @@ |
702 | 704 | " error :%d)\n", |
703 | 705 | muic_irq->irq, ret); |
704 | 706 | |
705 | - for (i = i - 1; i >= 0; i--) | |
706 | - free_irq(muic_irq->virq, info); | |
707 | 707 | goto err_irq; |
708 | 708 | } |
709 | 709 | } |
710 | 710 | |
711 | 711 | /* Initialize extcon device */ |
712 | - info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); | |
712 | + info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), | |
713 | + GFP_KERNEL); | |
713 | 714 | if (!info->edev) { |
714 | 715 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
715 | 716 | ret = -ENOMEM; |
... | ... | @@ -720,7 +721,7 @@ |
720 | 721 | ret = extcon_dev_register(info->edev, NULL); |
721 | 722 | if (ret) { |
722 | 723 | dev_err(&pdev->dev, "failed to register extcon device\n"); |
723 | - goto err_extcon; | |
724 | + goto err_irq; | |
724 | 725 | } |
725 | 726 | |
726 | 727 | /* Initialize MUIC register by using platform data */ |
... | ... | @@ -753,7 +754,7 @@ |
753 | 754 | MAX77693_MUIC_REG_ID, &id); |
754 | 755 | if (ret < 0) { |
755 | 756 | dev_err(&pdev->dev, "failed to read revision number\n"); |
756 | - goto err_extcon; | |
757 | + goto err_irq; | |
757 | 758 | } |
758 | 759 | dev_info(info->dev, "device ID : 0x%x\n", id); |
759 | 760 | |
760 | 761 | |
... | ... | @@ -765,12 +766,9 @@ |
765 | 766 | |
766 | 767 | return ret; |
767 | 768 | |
768 | -err_extcon: | |
769 | - kfree(info->edev); | |
770 | 769 | err_irq: |
771 | -err_regmap: | |
772 | - kfree(info); | |
773 | -err_kfree: | |
770 | + while (--i >= 0) | |
771 | + free_irq(muic_irqs[i].virq, info); | |
774 | 772 | return ret; |
775 | 773 | } |
776 | 774 | |
... | ... | @@ -783,8 +781,6 @@ |
783 | 781 | free_irq(muic_irqs[i].virq, info); |
784 | 782 | cancel_work_sync(&info->irq_work); |
785 | 783 | extcon_dev_unregister(info->edev); |
786 | - kfree(info->edev); | |
787 | - kfree(info); | |
788 | 784 | |
789 | 785 | return 0; |
790 | 786 | } |
drivers/extcon/extcon-max8997.c
1 | 1 | /* |
2 | 2 | * extcon-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC |
3 | 3 | * |
4 | - * Copyright (C) 2012 Samsung Electrnoics | |
4 | + * Copyright (C) 2012 Samsung Electronics | |
5 | 5 | * Donggeun Kim <dg77.kim@samsung.com> |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | |
... | ... | @@ -433,11 +433,11 @@ |
433 | 433 | struct max8997_muic_info *info; |
434 | 434 | int ret, i; |
435 | 435 | |
436 | - info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL); | |
436 | + info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), | |
437 | + GFP_KERNEL); | |
437 | 438 | if (!info) { |
438 | 439 | dev_err(&pdev->dev, "failed to allocate memory\n"); |
439 | - ret = -ENOMEM; | |
440 | - goto err_kfree; | |
440 | + return -ENOMEM; | |
441 | 441 | } |
442 | 442 | |
443 | 443 | info->dev = &pdev->dev; |
444 | 444 | |
445 | 445 | |
446 | 446 | |
... | ... | @@ -450,14 +450,16 @@ |
450 | 450 | |
451 | 451 | for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { |
452 | 452 | struct max8997_muic_irq *muic_irq = &muic_irqs[i]; |
453 | - int virq = 0; | |
453 | + unsigned int virq = 0; | |
454 | 454 | |
455 | 455 | virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq); |
456 | - if (!virq) | |
456 | + if (!virq) { | |
457 | + ret = -EINVAL; | |
457 | 458 | goto err_irq; |
459 | + } | |
458 | 460 | muic_irq->virq = virq; |
459 | 461 | |
460 | - ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler, | |
462 | + ret = request_threaded_irq(virq, NULL, max8997_muic_irq_handler, | |
461 | 463 | 0, muic_irq->name, info); |
462 | 464 | if (ret) { |
463 | 465 | dev_err(&pdev->dev, |
... | ... | @@ -469,7 +471,8 @@ |
469 | 471 | } |
470 | 472 | |
471 | 473 | /* External connector */ |
472 | - info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); | |
474 | + info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), | |
475 | + GFP_KERNEL); | |
473 | 476 | if (!info->edev) { |
474 | 477 | dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); |
475 | 478 | ret = -ENOMEM; |
... | ... | @@ -480,7 +483,7 @@ |
480 | 483 | ret = extcon_dev_register(info->edev, NULL); |
481 | 484 | if (ret) { |
482 | 485 | dev_err(&pdev->dev, "failed to register extcon device\n"); |
483 | - goto err_extcon; | |
486 | + goto err_irq; | |
484 | 487 | } |
485 | 488 | |
486 | 489 | /* Initialize registers according to platform data */ |
487 | 490 | |
... | ... | @@ -498,13 +501,9 @@ |
498 | 501 | |
499 | 502 | return ret; |
500 | 503 | |
501 | -err_extcon: | |
502 | - kfree(info->edev); | |
503 | 504 | err_irq: |
504 | 505 | while (--i >= 0) |
505 | 506 | free_irq(muic_irqs[i].virq, info); |
506 | - kfree(info); | |
507 | -err_kfree: | |
508 | 507 | return ret; |
509 | 508 | } |
510 | 509 | |
... | ... | @@ -518,9 +517,6 @@ |
518 | 517 | cancel_work_sync(&info->irq_work); |
519 | 518 | |
520 | 519 | extcon_dev_unregister(info->edev); |
521 | - | |
522 | - kfree(info->edev); | |
523 | - kfree(info); | |
524 | 520 | |
525 | 521 | return 0; |
526 | 522 | } |
include/linux/extcon.h
... | ... | @@ -23,7 +23,9 @@ |
23 | 23 | #ifndef __LINUX_EXTCON_H__ |
24 | 24 | #define __LINUX_EXTCON_H__ |
25 | 25 | |
26 | +#include <linux/device.h> | |
26 | 27 | #include <linux/notifier.h> |
28 | +#include <linux/sysfs.h> | |
27 | 29 | |
28 | 30 | #define SUPPORTED_CABLE_MAX 32 |
29 | 31 | #define CABLE_NAME_MAX 30 |
30 | 32 | |
31 | 33 | |
... | ... | @@ -74,12 +76,12 @@ |
74 | 76 | |
75 | 77 | /** |
76 | 78 | * struct extcon_dev - An extcon device represents one external connector. |
77 | - * @name The name of this extcon device. Parent device name is used | |
79 | + * @name: The name of this extcon device. Parent device name is used | |
78 | 80 | * if NULL. |
79 | - * @supported_cable Array of supported cable names ending with NULL. | |
81 | + * @supported_cable: Array of supported cable names ending with NULL. | |
80 | 82 | * If supported_cable is NULL, cable name related APIs |
81 | 83 | * are disabled. |
82 | - * @mutually_exclusive Array of mutually exclusive set of cables that cannot | |
84 | + * @mutually_exclusive: Array of mutually exclusive set of cables that cannot | |
83 | 85 | * be attached simultaneously. The array should be |
84 | 86 | * ending with NULL or be NULL (no mutually exclusive |
85 | 87 | * cables). For example, if it is { 0x7, 0x30, 0}, then, |
86 | 88 | |
87 | 89 | |
88 | 90 | |
89 | 91 | |
90 | 92 | |
... | ... | @@ -87,21 +89,21 @@ |
87 | 89 | * be attached simulataneously. {0x7, 0} is equivalent to |
88 | 90 | * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there |
89 | 91 | * can be no simultaneous connections. |
90 | - * @print_name An optional callback to override the method to print the | |
92 | + * @print_name: An optional callback to override the method to print the | |
91 | 93 | * name of the extcon device. |
92 | - * @print_state An optional callback to override the method to print the | |
94 | + * @print_state: An optional callback to override the method to print the | |
93 | 95 | * status of the extcon device. |
94 | - * @dev Device of this extcon. Do not provide at register-time. | |
95 | - * @state Attach/detach state of this extcon. Do not provide at | |
96 | + * @dev: Device of this extcon. Do not provide at register-time. | |
97 | + * @state: Attach/detach state of this extcon. Do not provide at | |
96 | 98 | * register-time |
97 | - * @nh Notifier for the state change events from this extcon | |
98 | - * @entry To support list of extcon devices so that users can search | |
99 | + * @nh: Notifier for the state change events from this extcon | |
100 | + * @entry: To support list of extcon devices so that users can search | |
99 | 101 | * for extcon devices based on the extcon name. |
100 | - * @lock | |
101 | - * @max_supported Internal value to store the number of cables. | |
102 | - * @extcon_dev_type Device_type struct to provide attribute_groups | |
102 | + * @lock: | |
103 | + * @max_supported: Internal value to store the number of cables. | |
104 | + * @extcon_dev_type: Device_type struct to provide attribute_groups | |
103 | 105 | * customized for each extcon device. |
104 | - * @cables Sysfs subdirectories. Each represents one cable. | |
106 | + * @cables: Sysfs subdirectories. Each represents one cable. | |
105 | 107 | * |
106 | 108 | * In most cases, users only need to provide "User initializing data" of |
107 | 109 | * this struct when registering an extcon. In some exceptional cases, |
... | ... | @@ -137,12 +139,12 @@ |
137 | 139 | |
138 | 140 | /** |
139 | 141 | * struct extcon_cable - An internal data for each cable of extcon device. |
140 | - * @edev The extcon device | |
141 | - * @cable_index Index of this cable in the edev | |
142 | - * @attr_g Attribute group for the cable | |
143 | - * @attr_name "name" sysfs entry | |
144 | - * @attr_state "state" sysfs entry | |
145 | - * @attrs Array pointing to attr_name and attr_state for attr_g | |
142 | + * @edev: The extcon device | |
143 | + * @cable_index: Index of this cable in the edev | |
144 | + * @attr_g: Attribute group for the cable | |
145 | + * @attr_name: "name" sysfs entry | |
146 | + * @attr_state: "state" sysfs entry | |
147 | + * @attrs: Array pointing to attr_name and attr_state for attr_g | |
146 | 148 | */ |
147 | 149 | struct extcon_cable { |
148 | 150 | struct extcon_dev *edev; |
... | ... | @@ -158,11 +160,11 @@ |
158 | 160 | /** |
159 | 161 | * struct extcon_specific_cable_nb - An internal data for |
160 | 162 | * extcon_register_interest(). |
161 | - * @internal_nb a notifier block bridging extcon notifier and cable notifier. | |
162 | - * @user_nb user provided notifier block for events from a specific cable. | |
163 | - * @cable_index the target cable. | |
164 | - * @edev the target extcon device. | |
165 | - * @previous_value the saved previous event value. | |
163 | + * @internal_nb: a notifier block bridging extcon notifier and cable notifier. | |
164 | + * @user_nb: user provided notifier block for events from a specific cable. | |
165 | + * @cable_index: the target cable. | |
166 | + * @edev: the target extcon device. | |
167 | + * @previous_value: the saved previous event value. | |
166 | 168 | */ |
167 | 169 | struct extcon_specific_cable_nb { |
168 | 170 | struct notifier_block internal_nb; |