aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon-arizona.c
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2014-04-21 07:47:31 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2014-04-28 20:50:55 -0400
commitef70a214b558184867e5943cf943a03293250ea7 (patch)
treec8f5db04e2ba5775be2076beabfce7c03eacc9eb /drivers/extcon/extcon-arizona.c
parent0604002cde72cd60a11013daf2d9f456d4895ce8 (diff)
extcon: arizona: Use devm_extcon_dev_allocate for extcon_dev
This patch use devm_extcon_dev_allocate() to simplify the memory control of extcon device. Cc: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Cc: Mark Brown <broonie@kernel.org> Cc: patches@opensource.wolfsonmicro.com Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Reviewed-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r--drivers/extcon/extcon-arizona.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index f63fa6feadb5..6c84e3d12043 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -91,7 +91,7 @@ struct arizona_extcon_info {
91 91
92 int hpdet_ip; 92 int hpdet_ip;
93 93
94 struct extcon_dev edev; 94 struct extcon_dev *edev;
95}; 95};
96 96
97static const struct arizona_micd_config micd_default_modes[] = { 97static const struct arizona_micd_config micd_default_modes[] = {
@@ -546,7 +546,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
546 } 546 }
547 547
548 /* If the cable was removed while measuring ignore the result */ 548 /* If the cable was removed while measuring ignore the result */
549 ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL); 549 ret = extcon_get_cable_state_(info->edev, ARIZONA_CABLE_MECHANICAL);
550 if (ret < 0) { 550 if (ret < 0) {
551 dev_err(arizona->dev, "Failed to check cable state: %d\n", 551 dev_err(arizona->dev, "Failed to check cable state: %d\n",
552 ret); 552 ret);
@@ -581,7 +581,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
581 else 581 else
582 report = ARIZONA_CABLE_HEADPHONE; 582 report = ARIZONA_CABLE_HEADPHONE;
583 583
584 ret = extcon_set_cable_state_(&info->edev, report, true); 584 ret = extcon_set_cable_state_(info->edev, report, true);
585 if (ret != 0) 585 if (ret != 0)
586 dev_err(arizona->dev, "Failed to report HP/line: %d\n", 586 dev_err(arizona->dev, "Failed to report HP/line: %d\n",
587 ret); 587 ret);
@@ -664,7 +664,7 @@ err:
664 ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); 664 ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
665 665
666 /* Just report headphone */ 666 /* Just report headphone */
667 ret = extcon_update_state(&info->edev, 667 ret = extcon_update_state(info->edev,
668 1 << ARIZONA_CABLE_HEADPHONE, 668 1 << ARIZONA_CABLE_HEADPHONE,
669 1 << ARIZONA_CABLE_HEADPHONE); 669 1 << ARIZONA_CABLE_HEADPHONE);
670 if (ret != 0) 670 if (ret != 0)
@@ -723,7 +723,7 @@ err:
723 ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC); 723 ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
724 724
725 /* Just report headphone */ 725 /* Just report headphone */
726 ret = extcon_update_state(&info->edev, 726 ret = extcon_update_state(info->edev,
727 1 << ARIZONA_CABLE_HEADPHONE, 727 1 << ARIZONA_CABLE_HEADPHONE,
728 1 << ARIZONA_CABLE_HEADPHONE); 728 1 << ARIZONA_CABLE_HEADPHONE);
729 if (ret != 0) 729 if (ret != 0)
@@ -764,7 +764,7 @@ static void arizona_micd_detect(struct work_struct *work)
764 mutex_lock(&info->lock); 764 mutex_lock(&info->lock);
765 765
766 /* If the cable was removed while measuring ignore the result */ 766 /* If the cable was removed while measuring ignore the result */
767 ret = extcon_get_cable_state_(&info->edev, ARIZONA_CABLE_MECHANICAL); 767 ret = extcon_get_cable_state_(info->edev, ARIZONA_CABLE_MECHANICAL);
768 if (ret < 0) { 768 if (ret < 0) {
769 dev_err(arizona->dev, "Failed to check cable state: %d\n", 769 dev_err(arizona->dev, "Failed to check cable state: %d\n",
770 ret); 770 ret);
@@ -812,7 +812,7 @@ static void arizona_micd_detect(struct work_struct *work)
812 if (info->detecting && (val & ARIZONA_MICD_LVL_8)) { 812 if (info->detecting && (val & ARIZONA_MICD_LVL_8)) {
813 arizona_identify_headphone(info); 813 arizona_identify_headphone(info);
814 814
815 ret = extcon_update_state(&info->edev, 815 ret = extcon_update_state(info->edev,
816 1 << ARIZONA_CABLE_MICROPHONE, 816 1 << ARIZONA_CABLE_MICROPHONE,
817 1 << ARIZONA_CABLE_MICROPHONE); 817 1 << ARIZONA_CABLE_MICROPHONE);
818 818
@@ -999,7 +999,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
999 999
1000 if (info->last_jackdet == present) { 1000 if (info->last_jackdet == present) {
1001 dev_dbg(arizona->dev, "Detected jack\n"); 1001 dev_dbg(arizona->dev, "Detected jack\n");
1002 ret = extcon_set_cable_state_(&info->edev, 1002 ret = extcon_set_cable_state_(info->edev,
1003 ARIZONA_CABLE_MECHANICAL, true); 1003 ARIZONA_CABLE_MECHANICAL, true);
1004 1004
1005 if (ret != 0) 1005 if (ret != 0)
@@ -1038,7 +1038,7 @@ static irqreturn_t arizona_jackdet(int irq, void *data)
1038 info->micd_ranges[i].key, 0); 1038 info->micd_ranges[i].key, 0);
1039 input_sync(info->input); 1039 input_sync(info->input);
1040 1040
1041 ret = extcon_update_state(&info->edev, 0xffffffff, 0); 1041 ret = extcon_update_state(info->edev, 0xffffffff, 0);
1042 if (ret != 0) 1042 if (ret != 0)
1043 dev_err(arizona->dev, "Removal report failed: %d\n", 1043 dev_err(arizona->dev, "Removal report failed: %d\n",
1044 ret); 1044 ret);
@@ -1150,11 +1150,15 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1150 break; 1150 break;
1151 } 1151 }
1152 1152
1153 info->edev.name = "Headset Jack"; 1153 info->edev = devm_extcon_dev_allocate(&pdev->dev, arizona_cable);
1154 info->edev.dev.parent = arizona->dev; 1154 if (IS_ERR(info->edev)) {
1155 info->edev.supported_cable = arizona_cable; 1155 dev_err(&pdev->dev, "failed to allocate extcon device\n");
1156 return -ENOMEM;
1157 }
1158 info->edev->name = "Headset Jack";
1159 info->edev->dev.parent = arizona->dev;
1156 1160
1157 ret = devm_extcon_dev_register(&pdev->dev, &info->edev); 1161 ret = devm_extcon_dev_register(&pdev->dev, info->edev);
1158 if (ret < 0) { 1162 if (ret < 0) {
1159 dev_err(arizona->dev, "extcon_dev_register() failed: %d\n", 1163 dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
1160 ret); 1164 ret);