From be31cc0bc9e6d24d7bd069a4eae81aa9fcf5d2cd Mon Sep 17 00:00:00 2001 From: Alexey Khoroshilov Date: Mon, 5 Nov 2012 17:11:41 +0900 Subject: extcon: arizona: unlock mutex on error path in arizona_micdet() If regmap_read() failed, arizona_micdet() returns IRQ_NONE leaving &info->lock mutex locked as opposed to all other return paths. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Mark Brown Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-arizona.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index cdab9e59829..d876a54a8bd 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c @@ -166,6 +166,7 @@ static irqreturn_t arizona_micdet(int irq, void *data) ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); if (ret != 0) { dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); + mutex_unlock(&info->lock); return IRQ_NONE; } -- cgit v1.2.3 From c0c078c363a578543826bb8bfc9af47c7cc9321b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 16:30:31 +0900 Subject: extcon: Fix return value in extcon-class.c Return the value obtained from the function extcon_register_interest instead of -ENODEV. Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index d398821097f..60adc04b056 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -472,7 +472,7 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj, obj->cable_index = extcon_find_cable_index(obj->edev, cable_name); if (obj->cable_index < 0) - return -ENODEV; + return obj->cable_index; obj->user_nb = nb; -- cgit v1.2.3 From 68c9274d0fd1f66c6d105c52a61268d943e30862 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:41 +0900 Subject: extcon: max8997: Fix incorrect error check and return value irq_create_mapping() returns 0 if it fails to provide a valid irq number. 'ret' needs to be updated with a negative error code before returning from probe to signal probe failure. While at it, also corrected the 'virq' type to unsigned from signed. Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max8997.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index 77b66b0cc8f..a46c82f3183 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -450,11 +450,13 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { struct max8997_muic_irq *muic_irq = &muic_irqs[i]; - int virq = 0; + unsigned int virq = 0; virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq); - if (!virq) + if (!virq) { + ret = -EINVAL; goto err_irq; + } muic_irq->virq = virq; ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler, -- cgit v1.2.3 From 00af4b16e098f7899d78c7009f0b525c9c512f94 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:44 +0900 Subject: extcon: max77693: Fix incorrect error check and return value irq_create_mapping() returns 0 if it fails to provide a valid irq number. 'ret' needs to be updated with a negative error code before returning from probe to signal probe failure. While at it, also corrected the 'virq' type to unsigned from signed. Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max77693.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index a17d0d91ada..2a0f397885f 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -686,11 +686,13 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) /* Support irq domain for MAX77693 MUIC device */ for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { struct max77693_muic_irq *muic_irq = &muic_irqs[i]; - int virq = 0; + unsigned int virq = 0; virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq); - if (!virq) + if (!virq) { + ret = -EINVAL; goto err_irq; + } muic_irq->virq = virq; ret = request_threaded_irq(virq, NULL, @@ -702,8 +704,6 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) " error :%d)\n", muic_irq->irq, ret); - for (i = i - 1; i >= 0; i--) - free_irq(muic_irq->virq, info); goto err_irq; } } @@ -768,6 +768,8 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) err_extcon: kfree(info->edev); err_irq: + while (--i >= 0) + free_irq(muic_irqs[i].virq, info); err_regmap: kfree(info); err_kfree: -- cgit v1.2.3 From 1967fa08d902cbf1967a29acd2e82628cfb7c7f4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 21 Nov 2012 10:04:58 +0530 Subject: extcon: max77693: Fix coding style As per kernel coding style, if one branch of conditional statement has braces, the other one should have too. Signed-off-by: Sachin Kamat --- drivers/extcon/extcon-max77693.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 2a0f397885f..d844be3009f 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -665,9 +665,9 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) } info->dev = &pdev->dev; info->max77693 = max77693; - if (info->max77693->regmap_muic) + if (info->max77693->regmap_muic) { dev_dbg(&pdev->dev, "allocate register map\n"); - else { + } else { info->max77693->regmap_muic = devm_regmap_init_i2c( info->max77693->muic, &max77693_muic_regmap_config); -- cgit v1.2.3 From 8117cc3a0cf31533b31fb106663c2529410726df Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:30 +0900 Subject: extcon: max8997: Fix checkpatch error Fixes the following checkpatch error: ERROR: space required after that ',' (ctx:VxV) 460: FILE: extcon/extcon-max8997.c:460: ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler, ^ Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index a46c82f3183..f06e60a3cb8 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -459,7 +459,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) } muic_irq->virq = virq; - ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler, + ret = request_threaded_irq(virq, NULL, max8997_muic_irq_handler, 0, muic_irq->name, info); if (ret) { dev_err(&pdev->dev, -- cgit v1.2.3 From 2ca36f4afd0b0c3b9f99e1c03bbfafeb39516cf6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:33 +0900 Subject: extcon: max8997: Fix a typo Electrnoics -> Electronics Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max8997.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index f06e60a3cb8..ffdbe8c962a 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -1,7 +1,7 @@ /* * extcon-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC * - * Copyright (C) 2012 Samsung Electrnoics + * Copyright (C) 2012 Samsung Electronics * Donggeun Kim * * This program is free software; you can redistribute it and/or modify -- cgit v1.2.3 From 0b672e9b21942fdfa63519fb66df4a40d6fafe35 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:47 +0900 Subject: extcon: max8997: Use devm_kzalloc devm_kzalloc() is a device managed function. It makes error handling and cleanup code a bit simpler. Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max8997.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c index ffdbe8c962a..8059325ce7d 100644 --- a/drivers/extcon/extcon-max8997.c +++ b/drivers/extcon/extcon-max8997.c @@ -433,11 +433,11 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) struct max8997_muic_info *info; int ret, i; - info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL); + info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info), + GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to allocate memory\n"); - ret = -ENOMEM; - goto err_kfree; + return -ENOMEM; } info->dev = &pdev->dev; @@ -471,7 +471,8 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) } /* External connector */ - info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); + info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), + GFP_KERNEL); if (!info->edev) { dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); ret = -ENOMEM; @@ -482,7 +483,7 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) ret = extcon_dev_register(info->edev, NULL); if (ret) { dev_err(&pdev->dev, "failed to register extcon device\n"); - goto err_extcon; + goto err_irq; } /* Initialize registers according to platform data */ @@ -500,13 +501,9 @@ static int __devinit max8997_muic_probe(struct platform_device *pdev) return ret; -err_extcon: - kfree(info->edev); err_irq: while (--i >= 0) free_irq(muic_irqs[i].virq, info); - kfree(info); -err_kfree: return ret; } @@ -521,9 +518,6 @@ static int __devexit max8997_muic_remove(struct platform_device *pdev) extcon_dev_unregister(info->edev); - kfree(info->edev); - kfree(info); - return 0; } -- cgit v1.2.3 From f4bb5cb54eb97fee9b4e076df8df68b91861b934 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 20 Nov 2012 15:46:50 +0900 Subject: extcon: max77693: Use devm_kzalloc devm_kzalloc() is a device managed function. It makes error handling and cleanup code a bit simpler. Signed-off-by: Sachin Kamat Signed-off-by: Chanwoo Choi Signed-off-by: Myungjoo Ham --- drivers/extcon/extcon-max77693.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index d844be3009f..93ca93f26f4 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -657,11 +657,11 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) int ret, i; u8 id; - info = kzalloc(sizeof(struct max77693_muic_info), GFP_KERNEL); + info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info), + GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to allocate memory\n"); - ret = -ENOMEM; - goto err_kfree; + return -ENOMEM; } info->dev = &pdev->dev; info->max77693 = max77693; @@ -672,10 +672,9 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) info->max77693->muic, &max77693_muic_regmap_config); if (IS_ERR(info->max77693->regmap_muic)) { - ret = PTR_ERR(info->max77693->regmap_muic); dev_err(max77693->dev, "failed to allocate register map: %d\n", ret); - goto err_regmap; + return PTR_ERR(info->max77693->regmap_muic); } } platform_set_drvdata(pdev, info); @@ -709,7 +708,8 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) } /* Initialize extcon device */ - info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); + info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev), + GFP_KERNEL); if (!info->edev) { dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); ret = -ENOMEM; @@ -720,7 +720,7 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) ret = extcon_dev_register(info->edev, NULL); if (ret) { dev_err(&pdev->dev, "failed to register extcon device\n"); - goto err_extcon; + goto err_irq; } /* Initialize MUIC register by using platform data */ @@ -753,7 +753,7 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) MAX77693_MUIC_REG_ID, &id); if (ret < 0) { dev_err(&pdev->dev, "failed to read revision number\n"); - goto err_extcon; + goto err_irq; } dev_info(info->dev, "device ID : 0x%x\n", id); @@ -765,14 +765,9 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) return ret; -err_extcon: - kfree(info->edev); err_irq: while (--i >= 0) free_irq(muic_irqs[i].virq, info); -err_regmap: - kfree(info); -err_kfree: return ret; } @@ -785,8 +780,6 @@ static int __devexit max77693_muic_remove(struct platform_device *pdev) free_irq(muic_irqs[i].virq, info); cancel_work_sync(&info->irq_work); extcon_dev_unregister(info->edev); - kfree(info->edev); - kfree(info); return 0; } -- cgit v1.2.3 From 3bf742ffd48e7d1cea864741a123203207b33b80 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 21 Nov 2012 10:04:57 +0530 Subject: extcon: max77693: Fix uninitialised variable warning Signed-off-by: Sachin Kamat --- drivers/extcon/extcon-max77693.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/extcon') diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 93ca93f26f4..8bf5e4835b4 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c @@ -672,9 +672,10 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev) info->max77693->muic, &max77693_muic_regmap_config); if (IS_ERR(info->max77693->regmap_muic)) { + ret = PTR_ERR(info->max77693->regmap_muic); dev_err(max77693->dev, "failed to allocate register map: %d\n", ret); - return PTR_ERR(info->max77693->regmap_muic); + return ret; } } platform_set_drvdata(pdev, info); -- cgit v1.2.3