linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe
@ 2014-09-23 10:20 Pramod Gurav
  2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
  2014-09-23 12:43 ` [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Ludovic Desroches
  0 siblings, 2 replies; 12+ messages in thread
From: Pramod Gurav @ 2014-09-23 10:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pramod Gurav, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

This change uses managed resource APIs to allocate resources such as,
clk, gpio, io in order to simplify the driver unload or failure cases.
Hence does away with release statements of the same resorces in error
lables and remove function.

Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Chris Ball <chris@printf.net>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

---
Changes since v1:
- Dropped using devm_request_irq as suggested by Ludovic Desroches
  as it seems there are race conditions seen with them.
- Added another patch to fix failure path in probe to call atmci_cleanup_slot
  after dma_alloc_coherent() fails to release mmc_host resources.
---
 drivers/mmc/host/atmel-mci.c |   41 ++++++++++++++---------------------------
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index bb585d9..36212fb 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -17,6 +17,7 @@
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	/* Assume card is present initially */
 	set_bit(ATMCI_CARD_PRESENT, &slot->flags);
 	if (gpio_is_valid(slot->detect_pin)) {
-		if (gpio_request(slot->detect_pin, "mmc_detect")) {
+		if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
+				      "mmc_detect")) {
 			dev_dbg(&mmc->class_dev, "no detect pin available\n");
 			slot->detect_pin = -EBUSY;
 		} else if (gpio_get_value(slot->detect_pin) ^
@@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 		mmc->caps |= MMC_CAP_NEEDS_POLL;
 
 	if (gpio_is_valid(slot->wp_pin)) {
-		if (gpio_request(slot->wp_pin, "mmc_wp")) {
+		if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
+				      "mmc_wp")) {
 			dev_dbg(&mmc->class_dev, "no WP pin available\n");
 			slot->wp_pin = -EBUSY;
 		}
@@ -2232,7 +2235,6 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 			dev_dbg(&mmc->class_dev,
 				"could not request IRQ %d for detect pin\n",
 				gpio_to_irq(slot->detect_pin));
-			gpio_free(slot->detect_pin);
 			slot->detect_pin = -EBUSY;
 		}
 	}
@@ -2257,10 +2259,7 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 		free_irq(gpio_to_irq(pin), slot);
 		del_timer_sync(&slot->detect_timer);
-		gpio_free(pin);
 	}
-	if (gpio_is_valid(slot->wp_pin))
-		gpio_free(slot->wp_pin);
 
 	slot->host->slot[id] = NULL;
 	mmc_free_host(slot->mmc);
@@ -2395,7 +2394,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
+	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
 	if (!host)
 		return -ENOMEM;
 
@@ -2403,20 +2402,18 @@ static int __init atmci_probe(struct platform_device *pdev)
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
 
-	host->mck = clk_get(&pdev->dev, "mci_clk");
-	if (IS_ERR(host->mck)) {
-		ret = PTR_ERR(host->mck);
-		goto err_clk_get;
-	}
+	host->mck = devm_clk_get(&pdev->dev, "mci_clk");
+	if (IS_ERR(host->mck))
+		return PTR_ERR(host->mck);
 
-	ret = -ENOMEM;
-	host->regs = ioremap(regs->start, resource_size(regs));
+	host->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
 	if (!host->regs)
-		goto err_ioremap;
+		return -ENOMEM;
 
 	ret = clk_prepare_enable(host->mck);
 	if (ret)
-		goto err_request_irq;
+		return ret;
+
 	atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
 	host->bus_hz = clk_get_rate(host->mck);
 	clk_disable_unprepare(host->mck);
@@ -2427,7 +2424,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 
 	ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
 	if (ret)
-		goto err_request_irq;
+		return ret;
 
 	/* Get MCI capabilities and set operations according to it */
 	atmci_get_cap(host);
@@ -2499,12 +2496,6 @@ err_init_slot:
 	if (host->dma.chan)
 		dma_release_channel(host->dma.chan);
 	free_irq(irq, host);
-err_request_irq:
-	iounmap(host->regs);
-err_ioremap:
-	clk_put(host->mck);
-err_clk_get:
-	kfree(host);
 	return ret;
 }
 
@@ -2532,10 +2523,6 @@ static int __exit atmci_remove(struct platform_device *pdev)
 		dma_release_channel(host->dma.chan);
 
 	free_irq(platform_get_irq(pdev, 0), host);
-	iounmap(host->regs);
-
-	clk_put(host->mck);
-	kfree(host);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure in probe
  2014-09-23 10:20 [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Pramod Gurav
@ 2014-09-23 10:20 ` Pramod Gurav
  2014-09-23 12:43   ` Ludovic Desroches
                     ` (2 more replies)
  2014-09-23 12:43 ` [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Ludovic Desroches
  1 sibling, 3 replies; 12+ messages in thread
From: Pramod Gurav @ 2014-09-23 10:20 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pramod Gurav, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

This change takes care of releasing mmc resources on error cases in
probe function which was missing. Also release timer in remove function.

Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Chris Ball <chris@printf.net>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
Changes since v1: None

 drivers/mmc/host/atmel-mci.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 36212fb..288bcc1 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2376,7 +2376,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 	struct resource			*regs;
 	unsigned int			nr_slots;
 	int				irq;
-	int				ret;
+	int				ret, i;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs)
@@ -2482,7 +2482,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 		if (!host->buffer) {
 			ret = -ENOMEM;
 			dev_err(&pdev->dev, "buffer allocation failed\n");
-			goto err_init_slot;
+			goto err_dma_alloc;
 		}
 	}
 
@@ -2492,7 +2492,13 @@ static int __init atmci_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_dma_alloc:
+	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
+		if (host->slot[i])
+			atmci_cleanup_slot(host->slot[i], i);
+	}
 err_init_slot:
+	del_timer_sync(&host->timer);
 	if (host->dma.chan)
 		dma_release_channel(host->dma.chan);
 	free_irq(irq, host);
@@ -2519,6 +2525,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
 	atmci_readl(host, ATMCI_SR);
 	clk_disable_unprepare(host->mck);
 
+	del_timer_sync(&host->timer);
 	if (host->dma.chan)
 		dma_release_channel(host->dma.chan);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe
  2014-09-23 10:20 [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Pramod Gurav
  2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
@ 2014-09-23 12:43 ` Ludovic Desroches
  1 sibling, 0 replies; 12+ messages in thread
From: Ludovic Desroches @ 2014-09-23 12:43 UTC (permalink / raw)
  To: Pramod Gurav
  Cc: linux-kernel, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

On Tue, Sep 23, 2014 at 03:50:05PM +0530, Pramod Gurav wrote:
> This change uses managed resource APIs to allocate resources such as,
> clk, gpio, io in order to simplify the driver unload or failure cases.
> Hence does away with release statements of the same resorces in error
/s/resorces/resources
> lables and remove function.
/s/lables/labels

Otherwise

Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Thanks

> 
> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Chris Ball <chris@printf.net>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> 
> ---
> Changes since v1:
> - Dropped using devm_request_irq as suggested by Ludovic Desroches
>   as it seems there are race conditions seen with them.
> - Added another patch to fix failure path in probe to call atmci_cleanup_slot
>   after dma_alloc_coherent() fails to release mmc_host resources.
> ---
>  drivers/mmc/host/atmel-mci.c |   41 ++++++++++++++---------------------------
>  1 file changed, 14 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index bb585d9..36212fb 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -17,6 +17,7 @@
>  #include <linux/gpio.h>
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
> +#include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> @@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	/* Assume card is present initially */
>  	set_bit(ATMCI_CARD_PRESENT, &slot->flags);
>  	if (gpio_is_valid(slot->detect_pin)) {
> -		if (gpio_request(slot->detect_pin, "mmc_detect")) {
> +		if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
> +				      "mmc_detect")) {
>  			dev_dbg(&mmc->class_dev, "no detect pin available\n");
>  			slot->detect_pin = -EBUSY;
>  		} else if (gpio_get_value(slot->detect_pin) ^
> @@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  		mmc->caps |= MMC_CAP_NEEDS_POLL;
>  
>  	if (gpio_is_valid(slot->wp_pin)) {
> -		if (gpio_request(slot->wp_pin, "mmc_wp")) {
> +		if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
> +				      "mmc_wp")) {
>  			dev_dbg(&mmc->class_dev, "no WP pin available\n");
>  			slot->wp_pin = -EBUSY;
>  		}
> @@ -2232,7 +2235,6 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  			dev_dbg(&mmc->class_dev,
>  				"could not request IRQ %d for detect pin\n",
>  				gpio_to_irq(slot->detect_pin));
> -			gpio_free(slot->detect_pin);
>  			slot->detect_pin = -EBUSY;
>  		}
>  	}
> @@ -2257,10 +2259,7 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
>  
>  		free_irq(gpio_to_irq(pin), slot);
>  		del_timer_sync(&slot->detect_timer);
> -		gpio_free(pin);
>  	}
> -	if (gpio_is_valid(slot->wp_pin))
> -		gpio_free(slot->wp_pin);
>  
>  	slot->host->slot[id] = NULL;
>  	mmc_free_host(slot->mmc);
> @@ -2395,7 +2394,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	if (irq < 0)
>  		return irq;
>  
> -	host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
> +	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
>  	if (!host)
>  		return -ENOMEM;
>  
> @@ -2403,20 +2402,18 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	spin_lock_init(&host->lock);
>  	INIT_LIST_HEAD(&host->queue);
>  
> -	host->mck = clk_get(&pdev->dev, "mci_clk");
> -	if (IS_ERR(host->mck)) {
> -		ret = PTR_ERR(host->mck);
> -		goto err_clk_get;
> -	}
> +	host->mck = devm_clk_get(&pdev->dev, "mci_clk");
> +	if (IS_ERR(host->mck))
> +		return PTR_ERR(host->mck);
>  
> -	ret = -ENOMEM;
> -	host->regs = ioremap(regs->start, resource_size(regs));
> +	host->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
>  	if (!host->regs)
> -		goto err_ioremap;
> +		return -ENOMEM;
>  
>  	ret = clk_prepare_enable(host->mck);
>  	if (ret)
> -		goto err_request_irq;
> +		return ret;
> +
>  	atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
>  	host->bus_hz = clk_get_rate(host->mck);
>  	clk_disable_unprepare(host->mck);
> @@ -2427,7 +2424,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>  
>  	ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
>  	if (ret)
> -		goto err_request_irq;
> +		return ret;
>  
>  	/* Get MCI capabilities and set operations according to it */
>  	atmci_get_cap(host);
> @@ -2499,12 +2496,6 @@ err_init_slot:
>  	if (host->dma.chan)
>  		dma_release_channel(host->dma.chan);
>  	free_irq(irq, host);
> -err_request_irq:
> -	iounmap(host->regs);
> -err_ioremap:
> -	clk_put(host->mck);
> -err_clk_get:
> -	kfree(host);
>  	return ret;
>  }
>  
> @@ -2532,10 +2523,6 @@ static int __exit atmci_remove(struct platform_device *pdev)
>  		dma_release_channel(host->dma.chan);
>  
>  	free_irq(platform_get_irq(pdev, 0), host);
> -	iounmap(host->regs);
> -
> -	clk_put(host->mck);
> -	kfree(host);
>  
>  	return 0;
>  }
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure in probe
  2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
@ 2014-09-23 12:43   ` Ludovic Desroches
  2014-09-24  8:49   ` Ulf Hansson
  2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
  2 siblings, 0 replies; 12+ messages in thread
From: Ludovic Desroches @ 2014-09-23 12:43 UTC (permalink / raw)
  To: Pramod Gurav
  Cc: linux-kernel, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

On Tue, Sep 23, 2014 at 03:50:06PM +0530, Pramod Gurav wrote:
> This change takes care of releasing mmc resources on error cases in
> probe function which was missing. Also release timer in remove function.
> 

Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>

> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Chris Ball <chris@printf.net>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
> Changes since v1: None
> 
>  drivers/mmc/host/atmel-mci.c |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 36212fb..288bcc1 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2376,7 +2376,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>  	struct resource			*regs;
>  	unsigned int			nr_slots;
>  	int				irq;
> -	int				ret;
> +	int				ret, i;
>  
>  	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!regs)
> @@ -2482,7 +2482,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>  		if (!host->buffer) {
>  			ret = -ENOMEM;
>  			dev_err(&pdev->dev, "buffer allocation failed\n");
> -			goto err_init_slot;
> +			goto err_dma_alloc;
>  		}
>  	}
>  
> @@ -2492,7 +2492,13 @@ static int __init atmci_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> +err_dma_alloc:
> +	for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
> +		if (host->slot[i])
> +			atmci_cleanup_slot(host->slot[i], i);
> +	}
>  err_init_slot:
> +	del_timer_sync(&host->timer);
>  	if (host->dma.chan)
>  		dma_release_channel(host->dma.chan);
>  	free_irq(irq, host);
> @@ -2519,6 +2525,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
>  	atmci_readl(host, ATMCI_SR);
>  	clk_disable_unprepare(host->mck);
>  
> +	del_timer_sync(&host->timer);
>  	if (host->dma.chan)
>  		dma_release_channel(host->dma.chan);
>  
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure in probe
  2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
  2014-09-23 12:43   ` Ludovic Desroches
@ 2014-09-24  8:49   ` Ulf Hansson
  2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
  2 siblings, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2014-09-24  8:49 UTC (permalink / raw)
  To: Pramod Gurav; +Cc: linux-kernel, Ludovic Desroches, Chris Ball, linux-mmc

On 23 September 2014 12:20, Pramod Gurav <pramod.gurav@smartplayin.com> wrote:
> This change takes care of releasing mmc resources on error cases in
> probe function which was missing. Also release timer in remove function.
>
> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Chris Ball <chris@printf.net>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

Thanks! Applied for next.

Kind regards
Uffe

> ---
> Changes since v1: None
>
>  drivers/mmc/host/atmel-mci.c |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 36212fb..288bcc1 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2376,7 +2376,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>         struct resource                 *regs;
>         unsigned int                    nr_slots;
>         int                             irq;
> -       int                             ret;
> +       int                             ret, i;
>
>         regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>         if (!regs)
> @@ -2482,7 +2482,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>                 if (!host->buffer) {
>                         ret = -ENOMEM;
>                         dev_err(&pdev->dev, "buffer allocation failed\n");
> -                       goto err_init_slot;
> +                       goto err_dma_alloc;
>                 }
>         }
>
> @@ -2492,7 +2492,13 @@ static int __init atmci_probe(struct platform_device *pdev)
>
>         return 0;
>
> +err_dma_alloc:
> +       for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
> +               if (host->slot[i])
> +                       atmci_cleanup_slot(host->slot[i], i);
> +       }
>  err_init_slot:
> +       del_timer_sync(&host->timer);
>         if (host->dma.chan)
>                 dma_release_channel(host->dma.chan);
>         free_irq(irq, host);
> @@ -2519,6 +2525,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
>         atmci_readl(host, ATMCI_SR);
>         clk_disable_unprepare(host->mck);
>
> +       del_timer_sync(&host->timer);
>         if (host->dma.chan)
>                 dma_release_channel(host->dma.chan);
>
> --
> 1.7.9.5
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot
  2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
  2014-09-23 12:43   ` Ludovic Desroches
  2014-09-24  8:49   ` Ulf Hansson
@ 2014-09-26 19:34   ` Arnd Bergmann
  2014-09-27  3:15     ` Pramod Gurav
                       ` (2 more replies)
  2 siblings, 3 replies; 12+ messages in thread
From: Arnd Bergmann @ 2014-09-26 19:34 UTC (permalink / raw)
  To: Pramod Gurav
  Cc: linux-kernel, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

As of 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe"),
the atmci_probe() function calls atmci_cleanup_slot in the failure path.

This causes a new warning whenever the driver is built:

WARNING: drivers/mmc/host/built-in.o(.init.text+0xa04): Section mismatch in reference from the function atmci_probe() to the function .exit.text:atmci_cleanup_slot()
The function __init atmci_probe() references
a function __exit atmci_cleanup_slot().

Gcc correctly warns about this function getting dropped in the link stage
for the built-in case, which would cause undefined behavior when this error
path is hit. The solution is to simply drop the __exit annotation.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe")

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 772ef5b0e4d5..974626087732 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2244,7 +2244,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	return 0;
 }
 
-static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
+static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 		unsigned int id)
 {
 	/* Debugfs stuff is cleaned up by mmc core */

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot
  2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
@ 2014-09-27  3:15     ` Pramod Gurav
  2014-09-27 11:59       ` Arnd Bergmann
  2014-09-29  7:34     ` Ludovic Desroches
  2014-09-29  9:43     ` Ulf Hansson
  2 siblings, 1 reply; 12+ messages in thread
From: Pramod Gurav @ 2014-09-27  3:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Pramod Gurav, linux-kernel, Ludovic Desroches, Chris Ball,
	Ulf Hansson, linux-mmc

Hi Arnd,

On Sat, Sep 27, 2014 at 1:04 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> As of 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe"),
> the atmci_probe() function calls atmci_cleanup_slot in the failure path.
>
> This causes a new warning whenever the driver is built:
>
> WARNING: drivers/mmc/host/built-in.o(.init.text+0xa04): Section mismatch in reference from the function atmci_probe() to the function .exit.text:atmci_cleanup_slot()
> The function __init atmci_probe() references
> a function __exit atmci_cleanup_slot().
Thanks for this though I am not owner of the driver but the last
commit was mine.
but how come I did not see this warning? Any flag with compiler that
warned about this?
>
> Gcc correctly warns about this function getting dropped in the link stage
> for the built-in case, which would cause undefined behavior when this error
> path is hit. The solution is to simply drop the __exit annotation.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe")
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 772ef5b0e4d5..974626087732 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2244,7 +2244,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>         return 0;
>  }
>
> -static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
> +static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>                 unsigned int id)
>  {
>         /* Debugfs stuff is cleaned up by mmc core */
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
Thanks and Regards
Pramod

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot
  2014-09-27  3:15     ` Pramod Gurav
@ 2014-09-27 11:59       ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2014-09-27 11:59 UTC (permalink / raw)
  To: Pramod Gurav
  Cc: Pramod Gurav, linux-kernel, Ludovic Desroches, Chris Ball,
	Ulf Hansson, linux-mmc

On Saturday 27 September 2014 08:45:33 Pramod Gurav wrote:
> Hi Arnd,
> 
> On Sat, Sep 27, 2014 at 1:04 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > As of 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe"),
> > the atmci_probe() function calls atmci_cleanup_slot in the failure path.
> >
> > This causes a new warning whenever the driver is built:
> >
> > WARNING: drivers/mmc/host/built-in.o(.init.text+0xa04): Section mismatch in reference from the function atmci_probe() to the function .exit.text:atmci_cleanup_slot()
> > The function __init atmci_probe() references
> > a function __exit atmci_cleanup_slot().
> Thanks for this though I am not owner of the driver but the last
> commit was mine.
> but how come I did not see this warning? Any flag with compiler that
> warned about this?

The warning above is only enabled if CONFIG_DEBUG_SECTION_MISMATCH is set, otherwise
you get this one:

WARNING: modpost: Found 1 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'

	Arnd

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot
  2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
  2014-09-27  3:15     ` Pramod Gurav
@ 2014-09-29  7:34     ` Ludovic Desroches
  2014-09-29  9:43     ` Ulf Hansson
  2 siblings, 0 replies; 12+ messages in thread
From: Ludovic Desroches @ 2014-09-29  7:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Pramod Gurav, linux-kernel, Ludovic Desroches, Chris Ball,
	Ulf Hansson, linux-mmc

On Fri, Sep 26, 2014 at 09:34:58PM +0200, Arnd Bergmann wrote:
> As of 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe"),
> the atmci_probe() function calls atmci_cleanup_slot in the failure path.
> 
> This causes a new warning whenever the driver is built:
> 
> WARNING: drivers/mmc/host/built-in.o(.init.text+0xa04): Section mismatch in reference from the function atmci_probe() to the function .exit.text:atmci_cleanup_slot()
> The function __init atmci_probe() references
> a function __exit atmci_cleanup_slot().
> 
> Gcc correctly warns about this function getting dropped in the link stage
> for the built-in case, which would cause undefined behavior when this error
> path is hit. The solution is to simply drop the __exit annotation.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Thanks, I also missed this warning when compiling.

> Fixes: 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe")
> 
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 772ef5b0e4d5..974626087732 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2244,7 +2244,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>  	return 0;
>  }
>  
> -static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
> +static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>  		unsigned int id)
>  {
>  	/* Debugfs stuff is cleaned up by mmc core */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot
  2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
  2014-09-27  3:15     ` Pramod Gurav
  2014-09-29  7:34     ` Ludovic Desroches
@ 2014-09-29  9:43     ` Ulf Hansson
  2 siblings, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2014-09-29  9:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Pramod Gurav, linux-kernel, Ludovic Desroches, Chris Ball, linux-mmc

On 26 September 2014 21:34, Arnd Bergmann <arnd@arndb.de> wrote:
> As of 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe"),
> the atmci_probe() function calls atmci_cleanup_slot in the failure path.
>
> This causes a new warning whenever the driver is built:
>
> WARNING: drivers/mmc/host/built-in.o(.init.text+0xa04): Section mismatch in reference from the function atmci_probe() to the function .exit.text:atmci_cleanup_slot()
> The function __init atmci_probe() references
> a function __exit atmci_cleanup_slot().
>
> Gcc correctly warns about this function getting dropped in the link stage
> for the built-in case, which would cause undefined behavior when this error
> path is hit. The solution is to simply drop the __exit annotation.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 528bc7808f4e ("mmc: atmel-mci: Release mmc resources on failure in probe")

Thanks! Applied for next!

Kind regards
Uffe

>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 772ef5b0e4d5..974626087732 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -2244,7 +2244,7 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>         return 0;
>  }
>
> -static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
> +static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
>                 unsigned int id)
>  {
>         /* Debugfs stuff is cleaned up by mmc core */

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe
  2014-09-23 12:51 Pramod Gurav
@ 2014-09-24  8:48 ` Ulf Hansson
  0 siblings, 0 replies; 12+ messages in thread
From: Ulf Hansson @ 2014-09-24  8:48 UTC (permalink / raw)
  To: Pramod Gurav; +Cc: linux-kernel, Ludovic Desroches, Chris Ball, linux-mmc

On 23 September 2014 14:51, Pramod Gurav <pramod.gurav@smartplayin.com> wrote:
> This change uses managed resource APIs to allocate resources such as,
> clk, gpio, io in order to simplify the driver unload or failure cases.
> Hence does away with release statements of the same resources in error
> labels and remove function.
>
> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
> Cc: Chris Ball <chris@printf.net>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

Thanks! Applied for next.

You don't need this extensive list of "Cc" in the commit message for
future patches. It's also recommended to add acks etc in chronological
order, thus Ludovic's ack should have been put below your sob.

Kind regards
Uffe

>
> ---
> Changes since v1:
> - Dropped using devm_request_irq as suggested by Ludovic Desroches
>   as it seems there are race conditions seen with them.
> - Added another patch to fix failure path in probe to call atmci_cleanup_slot
>   after dma_alloc_coherent() fails to release mmc_host resources.
> - Fixed typos in commit message
> ---
>  drivers/mmc/host/atmel-mci.c |   41 ++++++++++++++---------------------------
>  1 file changed, 14 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index bb585d9..36212fb 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -17,6 +17,7 @@
>  #include <linux/gpio.h>
>  #include <linux/init.h>
>  #include <linux/interrupt.h>
> +#include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> @@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>         /* Assume card is present initially */
>         set_bit(ATMCI_CARD_PRESENT, &slot->flags);
>         if (gpio_is_valid(slot->detect_pin)) {
> -               if (gpio_request(slot->detect_pin, "mmc_detect")) {
> +               if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
> +                                     "mmc_detect")) {
>                         dev_dbg(&mmc->class_dev, "no detect pin available\n");
>                         slot->detect_pin = -EBUSY;
>                 } else if (gpio_get_value(slot->detect_pin) ^
> @@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>                 mmc->caps |= MMC_CAP_NEEDS_POLL;
>
>         if (gpio_is_valid(slot->wp_pin)) {
> -               if (gpio_request(slot->wp_pin, "mmc_wp")) {
> +               if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
> +                                     "mmc_wp")) {
>                         dev_dbg(&mmc->class_dev, "no WP pin available\n");
>                         slot->wp_pin = -EBUSY;
>                 }
> @@ -2232,7 +2235,6 @@ static int __init atmci_init_slot(struct atmel_mci *host,
>                         dev_dbg(&mmc->class_dev,
>                                 "could not request IRQ %d for detect pin\n",
>                                 gpio_to_irq(slot->detect_pin));
> -                       gpio_free(slot->detect_pin);
>                         slot->detect_pin = -EBUSY;
>                 }
>         }
> @@ -2257,10 +2259,7 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
>
>                 free_irq(gpio_to_irq(pin), slot);
>                 del_timer_sync(&slot->detect_timer);
> -               gpio_free(pin);
>         }
> -       if (gpio_is_valid(slot->wp_pin))
> -               gpio_free(slot->wp_pin);
>
>         slot->host->slot[id] = NULL;
>         mmc_free_host(slot->mmc);
> @@ -2395,7 +2394,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>         if (irq < 0)
>                 return irq;
>
> -       host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
> +       host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
>         if (!host)
>                 return -ENOMEM;
>
> @@ -2403,20 +2402,18 @@ static int __init atmci_probe(struct platform_device *pdev)
>         spin_lock_init(&host->lock);
>         INIT_LIST_HEAD(&host->queue);
>
> -       host->mck = clk_get(&pdev->dev, "mci_clk");
> -       if (IS_ERR(host->mck)) {
> -               ret = PTR_ERR(host->mck);
> -               goto err_clk_get;
> -       }
> +       host->mck = devm_clk_get(&pdev->dev, "mci_clk");
> +       if (IS_ERR(host->mck))
> +               return PTR_ERR(host->mck);
>
> -       ret = -ENOMEM;
> -       host->regs = ioremap(regs->start, resource_size(regs));
> +       host->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
>         if (!host->regs)
> -               goto err_ioremap;
> +               return -ENOMEM;
>
>         ret = clk_prepare_enable(host->mck);
>         if (ret)
> -               goto err_request_irq;
> +               return ret;
> +
>         atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
>         host->bus_hz = clk_get_rate(host->mck);
>         clk_disable_unprepare(host->mck);
> @@ -2427,7 +2424,7 @@ static int __init atmci_probe(struct platform_device *pdev)
>
>         ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
>         if (ret)
> -               goto err_request_irq;
> +               return ret;
>
>         /* Get MCI capabilities and set operations according to it */
>         atmci_get_cap(host);
> @@ -2499,12 +2496,6 @@ err_init_slot:
>         if (host->dma.chan)
>                 dma_release_channel(host->dma.chan);
>         free_irq(irq, host);
> -err_request_irq:
> -       iounmap(host->regs);
> -err_ioremap:
> -       clk_put(host->mck);
> -err_clk_get:
> -       kfree(host);
>         return ret;
>  }
>
> @@ -2532,10 +2523,6 @@ static int __exit atmci_remove(struct platform_device *pdev)
>                 dma_release_channel(host->dma.chan);
>
>         free_irq(platform_get_irq(pdev, 0), host);
> -       iounmap(host->regs);
> -
> -       clk_put(host->mck);
> -       kfree(host);
>
>         return 0;
>  }
> --
> 1.7.9.5
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe
@ 2014-09-23 12:51 Pramod Gurav
  2014-09-24  8:48 ` Ulf Hansson
  0 siblings, 1 reply; 12+ messages in thread
From: Pramod Gurav @ 2014-09-23 12:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pramod Gurav, Ludovic Desroches, Chris Ball, Ulf Hansson, linux-mmc

This change uses managed resource APIs to allocate resources such as,
clk, gpio, io in order to simplify the driver unload or failure cases.
Hence does away with release statements of the same resources in error
labels and remove function.

Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Chris Ball <chris@printf.net>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

---
Changes since v1:
- Dropped using devm_request_irq as suggested by Ludovic Desroches
  as it seems there are race conditions seen with them.
- Added another patch to fix failure path in probe to call atmci_cleanup_slot
  after dma_alloc_coherent() fails to release mmc_host resources.
- Fixed typos in commit message
---
 drivers/mmc/host/atmel-mci.c |   41 ++++++++++++++---------------------------
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index bb585d9..36212fb 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -17,6 +17,7 @@
 #include <linux/gpio.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -2195,7 +2196,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 	/* Assume card is present initially */
 	set_bit(ATMCI_CARD_PRESENT, &slot->flags);
 	if (gpio_is_valid(slot->detect_pin)) {
-		if (gpio_request(slot->detect_pin, "mmc_detect")) {
+		if (devm_gpio_request(&host->pdev->dev, slot->detect_pin,
+				      "mmc_detect")) {
 			dev_dbg(&mmc->class_dev, "no detect pin available\n");
 			slot->detect_pin = -EBUSY;
 		} else if (gpio_get_value(slot->detect_pin) ^
@@ -2208,7 +2210,8 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 		mmc->caps |= MMC_CAP_NEEDS_POLL;
 
 	if (gpio_is_valid(slot->wp_pin)) {
-		if (gpio_request(slot->wp_pin, "mmc_wp")) {
+		if (devm_gpio_request(&host->pdev->dev, slot->wp_pin,
+				      "mmc_wp")) {
 			dev_dbg(&mmc->class_dev, "no WP pin available\n");
 			slot->wp_pin = -EBUSY;
 		}
@@ -2232,7 +2235,6 @@ static int __init atmci_init_slot(struct atmel_mci *host,
 			dev_dbg(&mmc->class_dev,
 				"could not request IRQ %d for detect pin\n",
 				gpio_to_irq(slot->detect_pin));
-			gpio_free(slot->detect_pin);
 			slot->detect_pin = -EBUSY;
 		}
 	}
@@ -2257,10 +2259,7 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 		free_irq(gpio_to_irq(pin), slot);
 		del_timer_sync(&slot->detect_timer);
-		gpio_free(pin);
 	}
-	if (gpio_is_valid(slot->wp_pin))
-		gpio_free(slot->wp_pin);
 
 	slot->host->slot[id] = NULL;
 	mmc_free_host(slot->mmc);
@@ -2395,7 +2394,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	host = kzalloc(sizeof(struct atmel_mci), GFP_KERNEL);
+	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
 	if (!host)
 		return -ENOMEM;
 
@@ -2403,20 +2402,18 @@ static int __init atmci_probe(struct platform_device *pdev)
 	spin_lock_init(&host->lock);
 	INIT_LIST_HEAD(&host->queue);
 
-	host->mck = clk_get(&pdev->dev, "mci_clk");
-	if (IS_ERR(host->mck)) {
-		ret = PTR_ERR(host->mck);
-		goto err_clk_get;
-	}
+	host->mck = devm_clk_get(&pdev->dev, "mci_clk");
+	if (IS_ERR(host->mck))
+		return PTR_ERR(host->mck);
 
-	ret = -ENOMEM;
-	host->regs = ioremap(regs->start, resource_size(regs));
+	host->regs = devm_ioremap(&pdev->dev, regs->start, resource_size(regs));
 	if (!host->regs)
-		goto err_ioremap;
+		return -ENOMEM;
 
 	ret = clk_prepare_enable(host->mck);
 	if (ret)
-		goto err_request_irq;
+		return ret;
+
 	atmci_writel(host, ATMCI_CR, ATMCI_CR_SWRST);
 	host->bus_hz = clk_get_rate(host->mck);
 	clk_disable_unprepare(host->mck);
@@ -2427,7 +2424,7 @@ static int __init atmci_probe(struct platform_device *pdev)
 
 	ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host);
 	if (ret)
-		goto err_request_irq;
+		return ret;
 
 	/* Get MCI capabilities and set operations according to it */
 	atmci_get_cap(host);
@@ -2499,12 +2496,6 @@ err_init_slot:
 	if (host->dma.chan)
 		dma_release_channel(host->dma.chan);
 	free_irq(irq, host);
-err_request_irq:
-	iounmap(host->regs);
-err_ioremap:
-	clk_put(host->mck);
-err_clk_get:
-	kfree(host);
 	return ret;
 }
 
@@ -2532,10 +2523,6 @@ static int __exit atmci_remove(struct platform_device *pdev)
 		dma_release_channel(host->dma.chan);
 
 	free_irq(platform_get_irq(pdev, 0), host);
-	iounmap(host->regs);
-
-	clk_put(host->mck);
-	kfree(host);
 
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-09-29  9:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 10:20 [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Pramod Gurav
2014-09-23 10:20 ` [PATCH v2 2/2] mmc: atmel-mci: Release mmc resources on failure " Pramod Gurav
2014-09-23 12:43   ` Ludovic Desroches
2014-09-24  8:49   ` Ulf Hansson
2014-09-26 19:34   ` [PATCH] mmc: atmel-mci: fix mismatched section on atmci_cleanup_slot Arnd Bergmann
2014-09-27  3:15     ` Pramod Gurav
2014-09-27 11:59       ` Arnd Bergmann
2014-09-29  7:34     ` Ludovic Desroches
2014-09-29  9:43     ` Ulf Hansson
2014-09-23 12:43 ` [PATCH v2 1/2] mmc: atmel-mci: Switch to using managed resource in probe Ludovic Desroches
2014-09-23 12:51 Pramod Gurav
2014-09-24  8:48 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).