All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: sdhci-s3c: Use mmc_gpio_request_cd fuction
@ 2013-11-05 11:48 Beomho Seo
  2013-11-18  5:15 ` Jaehoon Chung
  0 siblings, 1 reply; 3+ messages in thread
From: Beomho Seo @ 2013-11-05 11:48 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc@vger.kernel.org, Jaehoon Chung, myungjoo.ham

Hello all,

I have revised some issues of v1 revision.
This patch used mmc_gpio_request_cd function for detect card from cd-gpio pin.
Please give your feedback at that time.

Change from v2 to v1
	- Remove "return ret;" from "err_req_cd:".
	- Revised sdhci_s3c_remove function.

Subject: [PATCH] mmc: sdhci-s3c: Use mmc_gpio_request_cd function

Include slot-gpio header file.
Use mmc_gpio_request_cd function.
Remove sehci_s3c_setup_card_detect_gpio/card_detect_thread functions.

Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/host/sdhci-s3c.c |   56 +++++++++++-------------------------------
 1 file changed, 14 insertions(+), 42 deletions(-)

diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 6debda9..d8696d2 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -27,6 +27,7 @@
 #include <linux/pm_runtime.h>
 
 #include <linux/mmc/host.h>
+#include <linux/mmc/slot-gpio.h>
 
 #include "sdhci-s3c-regs.h"
 #include "sdhci.h"
@@ -400,44 +401,6 @@ static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
 	}
 }
 
-static irqreturn_t sdhci_s3c_gpio_card_detect_thread(int irq, void *dev_id)
-{
-	struct sdhci_s3c *sc = dev_id;
-	int status = gpio_get_value(sc->ext_cd_gpio);
-	if (sc->pdata->ext_cd_gpio_invert)
-		status = !status;
-	sdhci_s3c_notify_change(sc->pdev, status);
-	return IRQ_HANDLED;
-}
-
-static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
-{
-	struct s3c_sdhci_platdata *pdata = sc->pdata;
-	struct device *dev = &sc->pdev->dev;
-
-	if (devm_gpio_request(dev, pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) {
-		sc->ext_cd_gpio = pdata->ext_cd_gpio;
-		sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio);
-		if (sc->ext_cd_irq &&
-		    request_threaded_irq(sc->ext_cd_irq, NULL,
-					 sdhci_s3c_gpio_card_detect_thread,
-					 IRQF_TRIGGER_RISING |
-					 IRQF_TRIGGER_FALLING |
-					 IRQF_ONESHOT,
-					 dev_name(dev), sc) == 0) {
-			int status = gpio_get_value(sc->ext_cd_gpio);
-			if (pdata->ext_cd_gpio_invert)
-				status = !status;
-			sdhci_s3c_notify_change(sc->pdev, status);
-		} else {
-			dev_warn(dev, "cannot request irq for card detect\n");
-			sc->ext_cd_irq = 0;
-		}
-	} else {
-		dev_err(dev, "cannot request gpio for card detect\n");
-	}
-}
-
 #ifdef CONFIG_OF
 static int sdhci_s3c_parse_dt(struct device *dev,
 		struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
@@ -699,8 +662,14 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init)
 		pdata->ext_cd_init(&sdhci_s3c_notify_change);
 	if (pdata->cd_type == S3C_SDHCI_CD_GPIO &&
-	    gpio_is_valid(pdata->ext_cd_gpio))
-		sdhci_s3c_setup_card_detect_gpio(sc);
+	    gpio_is_valid(pdata->ext_cd_gpio)) {
+		ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio, 0);
+		if (ret) {
+			dev_err(dev,
+				"failed to request card detect gpio\n");
+			goto err_req_cd;
+		}
+	}
 
 #ifdef CONFIG_PM_RUNTIME
 	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
@@ -708,6 +677,9 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
 #endif
 	return 0;
 
+ err_req_cd:
+	mmc_gpio_free_cd(host->mmc);
+
  err_req_regs:
 #ifndef CONFIG_PM_RUNTIME
 	clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
@@ -731,8 +703,8 @@ static int sdhci_s3c_remove(struct platform_device *pdev)
 	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup)
 		pdata->ext_cd_cleanup(&sdhci_s3c_notify_change);
 
-	if (sc->ext_cd_irq)
-		free_irq(sc->ext_cd_irq, sc);
+	if (pdata->ext_cd_gpio)
+		mmc_gpio_free_cd(host->mmc);
 
 #ifdef CONFIG_PM_RUNTIME
 	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
-- 
1.7.9.5

-- 
Best Regards,

Beomho Seo, Assistant Engineer
System S/W Lab., S/W Platform Team, Software Center
Samsung Electronics

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

* Re: [PATCH v2] mmc: sdhci-s3c: Use mmc_gpio_request_cd fuction
  2013-11-05 11:48 [PATCH v2] mmc: sdhci-s3c: Use mmc_gpio_request_cd fuction Beomho Seo
@ 2013-11-18  5:15 ` Jaehoon Chung
  2013-11-18 20:03   ` Heiko Stübner
  0 siblings, 1 reply; 3+ messages in thread
From: Jaehoon Chung @ 2013-11-18  5:15 UTC (permalink / raw)
  To: Beomho Seo, Chris Ball
  Cc: linux-mmc@vger.kernel.org, Jaehoon Chung, myungjoo.ham,
	Heiko Stübner

Hi all,

Didn't have Any other comment for this patch?
If don't have any other comment, i want this patch is submitted at mmc-next.

We had tested this patch with exynos4 series.

CC'd Heiko.

Best Regards,
Jaehoon Chung

On 11/05/2013 08:48 PM, Beomho Seo wrote:
> Hello all,
> 
> I have revised some issues of v1 revision.
> This patch used mmc_gpio_request_cd function for detect card from cd-gpio pin.
> Please give your feedback at that time.
> 
> Change from v2 to v1
> 	- Remove "return ret;" from "err_req_cd:".
> 	- Revised sdhci_s3c_remove function.
> 
> Subject: [PATCH] mmc: sdhci-s3c: Use mmc_gpio_request_cd function
> 
> Include slot-gpio header file.
> Use mmc_gpio_request_cd function.
> Remove sehci_s3c_setup_card_detect_gpio/card_detect_thread functions.
> 
> Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
>  drivers/mmc/host/sdhci-s3c.c |   56 +++++++++++-------------------------------
>  1 file changed, 14 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> index 6debda9..d8696d2 100644
> --- a/drivers/mmc/host/sdhci-s3c.c
> +++ b/drivers/mmc/host/sdhci-s3c.c
> @@ -27,6 +27,7 @@
>  #include <linux/pm_runtime.h>
>  
>  #include <linux/mmc/host.h>
> +#include <linux/mmc/slot-gpio.h>
>  
>  #include "sdhci-s3c-regs.h"
>  #include "sdhci.h"
> @@ -400,44 +401,6 @@ static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
>  	}
>  }
>  
> -static irqreturn_t sdhci_s3c_gpio_card_detect_thread(int irq, void *dev_id)
> -{
> -	struct sdhci_s3c *sc = dev_id;
> -	int status = gpio_get_value(sc->ext_cd_gpio);
> -	if (sc->pdata->ext_cd_gpio_invert)
> -		status = !status;
> -	sdhci_s3c_notify_change(sc->pdev, status);
> -	return IRQ_HANDLED;
> -}
> -
> -static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
> -{
> -	struct s3c_sdhci_platdata *pdata = sc->pdata;
> -	struct device *dev = &sc->pdev->dev;
> -
> -	if (devm_gpio_request(dev, pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) {
> -		sc->ext_cd_gpio = pdata->ext_cd_gpio;
> -		sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio);
> -		if (sc->ext_cd_irq &&
> -		    request_threaded_irq(sc->ext_cd_irq, NULL,
> -					 sdhci_s3c_gpio_card_detect_thread,
> -					 IRQF_TRIGGER_RISING |
> -					 IRQF_TRIGGER_FALLING |
> -					 IRQF_ONESHOT,
> -					 dev_name(dev), sc) == 0) {
> -			int status = gpio_get_value(sc->ext_cd_gpio);
> -			if (pdata->ext_cd_gpio_invert)
> -				status = !status;
> -			sdhci_s3c_notify_change(sc->pdev, status);
> -		} else {
> -			dev_warn(dev, "cannot request irq for card detect\n");
> -			sc->ext_cd_irq = 0;
> -		}
> -	} else {
> -		dev_err(dev, "cannot request gpio for card detect\n");
> -	}
> -}
> -
>  #ifdef CONFIG_OF
>  static int sdhci_s3c_parse_dt(struct device *dev,
>  		struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
> @@ -699,8 +662,14 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
>  	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init)
>  		pdata->ext_cd_init(&sdhci_s3c_notify_change);
>  	if (pdata->cd_type == S3C_SDHCI_CD_GPIO &&
> -	    gpio_is_valid(pdata->ext_cd_gpio))
> -		sdhci_s3c_setup_card_detect_gpio(sc);
> +	    gpio_is_valid(pdata->ext_cd_gpio)) {
> +		ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio, 0);
> +		if (ret) {
> +			dev_err(dev,
> +				"failed to request card detect gpio\n");
> +			goto err_req_cd;
> +		}
> +	}
>  
>  #ifdef CONFIG_PM_RUNTIME
>  	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
> @@ -708,6 +677,9 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
>  #endif
>  	return 0;
>  
> + err_req_cd:
> +	mmc_gpio_free_cd(host->mmc);
> +
>   err_req_regs:
>  #ifndef CONFIG_PM_RUNTIME
>  	clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
> @@ -731,8 +703,8 @@ static int sdhci_s3c_remove(struct platform_device *pdev)
>  	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup)
>  		pdata->ext_cd_cleanup(&sdhci_s3c_notify_change);
>  
> -	if (sc->ext_cd_irq)
> -		free_irq(sc->ext_cd_irq, sc);
> +	if (pdata->ext_cd_gpio)
> +		mmc_gpio_free_cd(host->mmc);
>  
>  #ifdef CONFIG_PM_RUNTIME
>  	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
> 


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

* Re: [PATCH v2] mmc: sdhci-s3c: Use mmc_gpio_request_cd fuction
  2013-11-18  5:15 ` Jaehoon Chung
@ 2013-11-18 20:03   ` Heiko Stübner
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Stübner @ 2013-11-18 20:03 UTC (permalink / raw)
  To: Jaehoon Chung
  Cc: Beomho Seo, Chris Ball, linux-mmc@vger.kernel.org, myungjoo.ham

Hi Jaehoon,

Am Montag, 18. November 2013, 06:15:03 schrieb Jaehoon Chung:
> Didn't have Any other comment for this patch?
> If don't have any other comment, i want this patch is submitted at
> mmc-next.
> 
> We had tested this patch with exynos4 series.
> 
> CC'd Heiko.

I don't have access to my s3c2416 machine this week, so I'll be able to test 
this next week at the earliest.

I also found a small spelling mistake below.


Heiko



> 
> Best Regards,
> Jaehoon Chung
> 
> On 11/05/2013 08:48 PM, Beomho Seo wrote:
> > Hello all,
> > 
> > I have revised some issues of v1 revision.
> > This patch used mmc_gpio_request_cd function for detect card from cd-gpio
> > pin. Please give your feedback at that time.
> > 
> > Change from v2 to v1
> > 
> > 	- Remove "return ret;" from "err_req_cd:".
> > 	- Revised sdhci_s3c_remove function.
> > 
> > Subject: [PATCH] mmc: sdhci-s3c: Use mmc_gpio_request_cd function
> > 
> > Include slot-gpio header file.
> > Use mmc_gpio_request_cd function.
> > Remove sehci_s3c_setup_card_detect_gpio/card_detect_thread functions.
		      ^sdhci


> > 
> > Signed-off-by: Beomho Seo <beomho.seo@samsung.com>
> > Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> > ---
> > 
> >  drivers/mmc/host/sdhci-s3c.c |   56
> >  +++++++++++------------------------------- 1 file changed, 14
> >  insertions(+), 42 deletions(-)
> > 
> > diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
> > index 6debda9..d8696d2 100644
> > --- a/drivers/mmc/host/sdhci-s3c.c
> > +++ b/drivers/mmc/host/sdhci-s3c.c
> > @@ -27,6 +27,7 @@
> > 
> >  #include <linux/pm_runtime.h>
> >  
> >  #include <linux/mmc/host.h>
> > 
> > +#include <linux/mmc/slot-gpio.h>
> > 
> >  #include "sdhci-s3c-regs.h"
> >  #include "sdhci.h"
> > 
> > @@ -400,44 +401,6 @@ static void sdhci_s3c_notify_change(struct
> > platform_device *dev, int state)
> > 
> >  	}
> >  
> >  }
> > 
> > -static irqreturn_t sdhci_s3c_gpio_card_detect_thread(int irq, void
> > *dev_id) -{
> > -	struct sdhci_s3c *sc = dev_id;
> > -	int status = gpio_get_value(sc->ext_cd_gpio);
> > -	if (sc->pdata->ext_cd_gpio_invert)
> > -		status = !status;
> > -	sdhci_s3c_notify_change(sc->pdev, status);
> > -	return IRQ_HANDLED;
> > -}
> > -
> > -static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
> > -{
> > -	struct s3c_sdhci_platdata *pdata = sc->pdata;
> > -	struct device *dev = &sc->pdev->dev;
> > -
> > -	if (devm_gpio_request(dev, pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) 
{
> > -		sc->ext_cd_gpio = pdata->ext_cd_gpio;
> > -		sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio);
> > -		if (sc->ext_cd_irq &&
> > -		    request_threaded_irq(sc->ext_cd_irq, NULL,
> > -					 sdhci_s3c_gpio_card_detect_thread,
> > -					 IRQF_TRIGGER_RISING |
> > -					 IRQF_TRIGGER_FALLING |
> > -					 IRQF_ONESHOT,
> > -					 dev_name(dev), sc) == 0) {
> > -			int status = gpio_get_value(sc->ext_cd_gpio);
> > -			if (pdata->ext_cd_gpio_invert)
> > -				status = !status;
> > -			sdhci_s3c_notify_change(sc->pdev, status);
> > -		} else {
> > -			dev_warn(dev, "cannot request irq for card detect\n");
> > -			sc->ext_cd_irq = 0;
> > -		}
> > -	} else {
> > -		dev_err(dev, "cannot request gpio for card detect\n");
> > -	}
> > -}
> > -
> > 
> >  #ifdef CONFIG_OF
> >  static int sdhci_s3c_parse_dt(struct device *dev,
> >  
> >  		struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
> > 
> > @@ -699,8 +662,14 @@ static int sdhci_s3c_probe(struct platform_device
> > *pdev)
> > 
> >  	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init)
> >  	
> >  		pdata->ext_cd_init(&sdhci_s3c_notify_change);
> >  	
> >  	if (pdata->cd_type == S3C_SDHCI_CD_GPIO &&
> > 
> > -	    gpio_is_valid(pdata->ext_cd_gpio))
> > -		sdhci_s3c_setup_card_detect_gpio(sc);
> > +	    gpio_is_valid(pdata->ext_cd_gpio)) {
> > +		ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio, 0);
> > +		if (ret) {
> > +			dev_err(dev,
> > +				"failed to request card detect gpio\n");
> > +			goto err_req_cd;
> > +		}
> > +	}
> > 
> >  #ifdef CONFIG_PM_RUNTIME
> >  
> >  	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
> > 
> > @@ -708,6 +677,9 @@ static int sdhci_s3c_probe(struct platform_device
> > *pdev)
> > 
> >  #endif
> >  
> >  	return 0;
> > 
> > + err_req_cd:
> > +	mmc_gpio_free_cd(host->mmc);
> > +
> > 
> >   err_req_regs:
> >  #ifndef CONFIG_PM_RUNTIME
> >  
> >  	clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
> > 
> > @@ -731,8 +703,8 @@ static int sdhci_s3c_remove(struct platform_device
> > *pdev)
> > 
> >  	if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata-
>ext_cd_cleanup)
> >  	
> >  		pdata->ext_cd_cleanup(&sdhci_s3c_notify_change);
> > 
> > -	if (sc->ext_cd_irq)
> > -		free_irq(sc->ext_cd_irq, sc);
> > +	if (pdata->ext_cd_gpio)
> > +		mmc_gpio_free_cd(host->mmc);
> > 
> >  #ifdef CONFIG_PM_RUNTIME
> >  
> >  	if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)


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

end of thread, other threads:[~2013-11-18 20:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05 11:48 [PATCH v2] mmc: sdhci-s3c: Use mmc_gpio_request_cd fuction Beomho Seo
2013-11-18  5:15 ` Jaehoon Chung
2013-11-18 20:03   ` Heiko Stübner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.