All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: add generic hotplug handler and a GPIO implementation
@ 2011-12-23 23:00 Guennadi Liakhovetski
  2011-12-23 23:00 ` [PATCH 1/2] mmc: add a card hotplug handler context Guennadi Liakhovetski
  2011-12-23 23:00 ` [PATCH 2/2] mmc: add a generic GPIO card-detect helper Guennadi Liakhovetski
  0 siblings, 2 replies; 7+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-23 23:00 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

The following two patches add an ability to implement pluggable card 
hotplug handlers and a simple implementation for GPIO hotplug IRQs.

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* [PATCH 1/2] mmc: add a card hotplug handler context
  2011-12-23 23:00 [PATCH 0/2] mmc: add generic hotplug handler and a GPIO implementation Guennadi Liakhovetski
@ 2011-12-23 23:00 ` Guennadi Liakhovetski
  2011-12-23 23:00 ` [PATCH 2/2] mmc: add a generic GPIO card-detect helper Guennadi Liakhovetski
  1 sibling, 0 replies; 7+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-23 23:00 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

SD/MMC controllers provide different card insertion and removal detection
methods. On some of them the controller itself issues an interrupt, on
others polling is used, on yet others auxiliary means are used for this
purpose, e.g., a GPIO IRQ. Further, on some systems one of those methods
can be chosen at driver probing time and configured in software. E.g., on
some systems the SD/MMC controller card hot-plug detection pin can be
configured either as a respective controller functions, or an IRQ-capable
GPIO. To support such flexible configurations a card hot-plug context
is added by this patch.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 include/linux/mmc/host.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index edf1f45..e43b808 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -168,6 +168,11 @@ struct mmc_async_req {
 	int (*err_check) (struct mmc_card *, struct mmc_async_req *);
 };
 
+struct mmc_hotplug {
+	unsigned int irq;
+	void *handler_priv;
+};
+
 struct mmc_host {
 	struct device		*parent;
 	struct device		class_dev;
@@ -299,6 +304,7 @@ struct mmc_host {
 	int			claim_cnt;	/* "claim" nesting count */
 
 	struct delayed_work	detect;
+	struct mmc_hotplug	hotplug;
 
 	const struct mmc_bus_ops *bus_ops;	/* current bus driver */
 	unsigned int		bus_refs;	/* reference counter */
-- 
1.7.2.5


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

* [PATCH 2/2] mmc: add a generic GPIO card-detect helper
  2011-12-23 23:00 [PATCH 0/2] mmc: add generic hotplug handler and a GPIO implementation Guennadi Liakhovetski
  2011-12-23 23:00 ` [PATCH 1/2] mmc: add a card hotplug handler context Guennadi Liakhovetski
@ 2011-12-23 23:00 ` Guennadi Liakhovetski
  2011-12-25  2:41   ` Chris Ball
  2012-01-04 13:18   ` Guennadi Liakhovetski
  1 sibling, 2 replies; 7+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-23 23:00 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

This patch adds a primitive helper to support card hotplug detection on
platforms, where a GPIO, capable of producing interrupts, is used for
detection of card-insertion and -removal events.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
 drivers/mmc/core/Makefile   |    2 +-
 drivers/mmc/core/cd-gpio.c  |   74 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/cd-gpio.h |   19 +++++++++++
 3 files changed, 94 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/core/cd-gpio.c
 create mode 100644 include/linux/mmc/cd-gpio.h

diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index 6395019..dca4428 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -7,6 +7,6 @@ mmc_core-y			:= core.o bus.o host.o \
 				   mmc.o mmc_ops.o sd.o sd_ops.o \
 				   sdio.o sdio_ops.o sdio_bus.o \
 				   sdio_cis.o sdio_io.o sdio_irq.o \
-				   quirks.o
+				   quirks.o cd-gpio.o
 
 mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
new file mode 100644
index 0000000..4c79f0c
--- /dev/null
+++ b/drivers/mmc/core/cd-gpio.c
@@ -0,0 +1,74 @@
+/*
+ * Generic GPIO card-detect helper
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/mmc/host.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+struct mmc_cd_gpio {
+	unsigned int gpio;
+	char label[0];
+};
+
+static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id)
+{
+	/* Schedule a card detection after a debounce timeout */
+	mmc_detect_change(dev_id, msecs_to_jiffies(100));
+	return IRQ_HANDLED;
+}
+
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags)
+{
+	size_t len = strlen(dev_name(host->parent)) + 4;
+	struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
+	int ret;
+
+	if (!cd)
+		return -ENOMEM;
+
+	sprintf(cd->label, "%s cd", dev_name(host->parent));
+
+	ret = gpio_request_one(gpio, GPIOF_DIR_IN, cd->label);
+	if (ret < 0)
+		goto egpioreq;
+
+	ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt,
+				   flags, cd->label, host);
+	if (ret < 0)
+		goto eirqreq;
+
+	cd->gpio = gpio;
+	host->hotplug.irq = irq;
+	host->hotplug.handler_priv = cd;
+
+	return 0;
+
+eirqreq:
+	gpio_free(gpio);
+egpioreq:
+	kfree(cd);
+	return ret;
+}
+EXPORT_SYMBOL(mmc_cd_gpio_request);
+
+void mmc_cd_gpio_free(struct mmc_host *host)
+{
+	struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
+
+	free_irq(host->hotplug.irq, host);
+	gpio_free(cd->gpio);
+	kfree(cd);
+}
+EXPORT_SYMBOL(mmc_cd_gpio_free);
diff --git a/include/linux/mmc/cd-gpio.h b/include/linux/mmc/cd-gpio.h
new file mode 100644
index 0000000..a8e4697
--- /dev/null
+++ b/include/linux/mmc/cd-gpio.h
@@ -0,0 +1,19 @@
+/*
+ * Generic GPIO card-detect helper header
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MMC_CD_GPIO_H
+#define MMC_CD_GPIO_H
+
+struct mmc_host;
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags);
+void mmc_cd_gpio_free(struct mmc_host *host);
+
+#endif
-- 
1.7.2.5


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

* Re: [PATCH 2/2] mmc: add a generic GPIO card-detect helper
  2011-12-23 23:00 ` [PATCH 2/2] mmc: add a generic GPIO card-detect helper Guennadi Liakhovetski
@ 2011-12-25  2:41   ` Chris Ball
  2011-12-25 20:36     ` [PATCH 2/2 v2] " Guennadi Liakhovetski
  2012-01-04 13:18   ` Guennadi Liakhovetski
  1 sibling, 1 reply; 7+ messages in thread
From: Chris Ball @ 2011-12-25  2:41 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: linux-mmc

Hi,

On Fri, Dec 23 2011, Guennadi Liakhovetski wrote:
> This patch adds a primitive helper to support card hotplug detection on
> platforms, where a GPIO, capable of producing interrupts, is used for
> detection of card-insertion and -removal events.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>  drivers/mmc/core/Makefile   |    2 +-
>  drivers/mmc/core/cd-gpio.c  |   74 +++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mmc/cd-gpio.h |   19 +++++++++++
>  3 files changed, 94 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/mmc/core/cd-gpio.c
>  create mode 100644 include/linux/mmc/cd-gpio.h
>
> diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
> index 6395019..dca4428 100644
> --- a/drivers/mmc/core/Makefile
> +++ b/drivers/mmc/core/Makefile
> @@ -7,6 +7,6 @@ mmc_core-y			:= core.o bus.o host.o \
>  				   mmc.o mmc_ops.o sd.o sd_ops.o \
>  				   sdio.o sdio_ops.o sdio_bus.o \
>  				   sdio_cis.o sdio_io.o sdio_irq.o \
> -				   quirks.o
> +				   quirks.o cd-gpio.o
>  
>  mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
> diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
> new file mode 100644
> index 0000000..4c79f0c
> --- /dev/null
> +++ b/drivers/mmc/core/cd-gpio.c
> @@ -0,0 +1,74 @@
> +/*
> + * Generic GPIO card-detect helper
> + *
> + * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/gpio.h>
> +#include <linux/interrupt.h>
> +#include <linux/jiffies.h>
> +#include <linux/mmc/host.h>
> +#include <linux/module.h>
> +#include <linux/slab.h>
> +
> +struct mmc_cd_gpio {
> +	unsigned int gpio;
> +	char label[0];
> +};
> +
> +static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id)
> +{
> +	/* Schedule a card detection after a debounce timeout */
> +	mmc_detect_change(dev_id, msecs_to_jiffies(100));
> +	return IRQ_HANDLED;
> +}
> +
> +int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
> +			unsigned int irq, unsigned long flags)
> +{
> +	size_t len = strlen(dev_name(host->parent)) + 4;
> +	struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
> +	int ret;
> +
> +	if (!cd)
> +		return -ENOMEM;
> +
> +	sprintf(cd->label, "%s cd", dev_name(host->parent));

Mind using snprintf() instead?  I prefer it for new uses, it leaves
fewer uses of sprintf to audit for correctness.

Thanks,

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* [PATCH 2/2 v2] mmc: add a generic GPIO card-detect helper
  2011-12-25  2:41   ` Chris Ball
@ 2011-12-25 20:36     ` Guennadi Liakhovetski
  2011-12-25 22:46       ` Chris Ball
  0 siblings, 1 reply; 7+ messages in thread
From: Guennadi Liakhovetski @ 2011-12-25 20:36 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc

This patch adds a primitive helper to support card hotplug detection on
platforms, where a GPIO, capable of producing interrupts, is used for
detection of card-insertion and -removal events.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

v2: switch to use snprintf()

Hi Chris

On Sat, 24 Dec 2011, Chris Ball wrote:

> > +int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
> > +			unsigned int irq, unsigned long flags)
> > +{
> > +	size_t len = strlen(dev_name(host->parent)) + 4;
> > +	struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
> > +	int ret;
> > +
> > +	if (!cd)
> > +		return -ENOMEM;
> > +
> > +	sprintf(cd->label, "%s cd", dev_name(host->parent));
> 
> Mind using snprintf() instead?  I prefer it for new uses, it leaves
> fewer uses of sprintf to audit for correctness.

I don't think it's needed here - I allocate exactly the required number of 
bytes, but, as you mention, it should help us, humans, feel more secure 
about it:-)

 drivers/mmc/core/Makefile   |    2 +-
 drivers/mmc/core/cd-gpio.c  |   74 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mmc/cd-gpio.h |   19 +++++++++++
 3 files changed, 94 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mmc/core/cd-gpio.c
 create mode 100644 include/linux/mmc/cd-gpio.h

diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index 6395019..dca4428 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -7,6 +7,6 @@ mmc_core-y			:= core.o bus.o host.o \
 				   mmc.o mmc_ops.o sd.o sd_ops.o \
 				   sdio.o sdio_ops.o sdio_bus.o \
 				   sdio_cis.o sdio_io.o sdio_irq.o \
-				   quirks.o
+				   quirks.o cd-gpio.o
 
 mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
new file mode 100644
index 0000000..4c79f0c
--- /dev/null
+++ b/drivers/mmc/core/cd-gpio.c
@@ -0,0 +1,74 @@
+/*
+ * Generic GPIO card-detect helper
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/mmc/host.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+struct mmc_cd_gpio {
+	unsigned int gpio;
+	char label[0];
+};
+
+static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id)
+{
+	/* Schedule a card detection after a debounce timeout */
+	mmc_detect_change(dev_id, msecs_to_jiffies(100));
+	return IRQ_HANDLED;
+}
+
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags)
+{
+	size_t len = strlen(dev_name(host->parent)) + 4;
+	struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
+	int ret;
+
+	if (!cd)
+		return -ENOMEM;
+
+	snprintf(cd->label, len, "%s cd", dev_name(host->parent));
+
+	ret = gpio_request_one(gpio, GPIOF_DIR_IN, cd->label);
+	if (ret < 0)
+		goto egpioreq;
+
+	ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt,
+				   flags, cd->label, host);
+	if (ret < 0)
+		goto eirqreq;
+
+	cd->gpio = gpio;
+	host->hotplug.irq = irq;
+	host->hotplug.handler_priv = cd;
+
+	return 0;
+
+eirqreq:
+	gpio_free(gpio);
+egpioreq:
+	kfree(cd);
+	return ret;
+}
+EXPORT_SYMBOL(mmc_cd_gpio_request);
+
+void mmc_cd_gpio_free(struct mmc_host *host)
+{
+	struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
+
+	free_irq(host->hotplug.irq, host);
+	gpio_free(cd->gpio);
+	kfree(cd);
+}
+EXPORT_SYMBOL(mmc_cd_gpio_free);
diff --git a/include/linux/mmc/cd-gpio.h b/include/linux/mmc/cd-gpio.h
new file mode 100644
index 0000000..a8e4697
--- /dev/null
+++ b/include/linux/mmc/cd-gpio.h
@@ -0,0 +1,19 @@
+/*
+ * Generic GPIO card-detect helper header
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MMC_CD_GPIO_H
+#define MMC_CD_GPIO_H
+
+struct mmc_host;
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags);
+void mmc_cd_gpio_free(struct mmc_host *host);
+
+#endif
-- 
1.7.2.5


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

* Re: [PATCH 2/2 v2] mmc: add a generic GPIO card-detect helper
  2011-12-25 20:36     ` [PATCH 2/2 v2] " Guennadi Liakhovetski
@ 2011-12-25 22:46       ` Chris Ball
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Ball @ 2011-12-25 22:46 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: linux-mmc

Hi,

On Sun, Dec 25 2011, Guennadi Liakhovetski wrote:
> This patch adds a primitive helper to support card hotplug detection on
> platforms, where a GPIO, capable of producing interrupts, is used for
> detection of card-insertion and -removal events.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> ---
>
> v2: switch to use snprintf()

Thanks, pushed to mmc-next for 3.3.  I agree the change was only
necessarily to make life easier for humans.  :-)

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* [PATCH 2/2 v2] mmc: add a generic GPIO card-detect helper
  2011-12-23 23:00 ` [PATCH 2/2] mmc: add a generic GPIO card-detect helper Guennadi Liakhovetski
  2011-12-25  2:41   ` Chris Ball
@ 2012-01-04 13:18   ` Guennadi Liakhovetski
  1 sibling, 0 replies; 7+ messages in thread
From: Guennadi Liakhovetski @ 2012-01-04 13:18 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

This patch adds a primitive helper to support card hotplug detection on
platforms, where a GPIO, capable of producing interrupts, is used for
detection of card-insertion and -removal events.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---

v2: allow NULL hotplug handler context in mmc_cd_gpio_free()

diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
index 6395019..dca4428 100644
--- a/drivers/mmc/core/Makefile
+++ b/drivers/mmc/core/Makefile
@@ -7,6 +7,6 @@ mmc_core-y			:= core.o bus.o host.o \
 				   mmc.o mmc_ops.o sd.o sd_ops.o \
 				   sdio.o sdio_ops.o sdio_bus.o \
 				   sdio_cis.o sdio_io.o sdio_irq.o \
-				   quirks.o
+				   quirks.o cd-gpio.o
 
 mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
new file mode 100644
index 0000000..8c3e6f0
--- /dev/null
+++ b/drivers/mmc/core/cd-gpio.c
@@ -0,0 +1,77 @@
+/*
+ * Generic GPIO card-detect helper
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/err.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/mmc/host.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+struct mmc_cd_gpio {
+	unsigned int gpio;
+	char label[0];
+};
+
+static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id)
+{
+	/* Schedule a card detection after a debounce timeout */
+	mmc_detect_change(dev_id, msecs_to_jiffies(100));
+	return IRQ_HANDLED;
+}
+
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags)
+{
+	size_t len = strlen(dev_name(host->parent)) + 4;
+	struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
+	int ret;
+
+	if (!cd)
+		return -ENOMEM;
+
+	snprintf(cd->label, len, "%s cd", dev_name(host->parent));
+
+	ret = gpio_request_one(gpio, GPIOF_DIR_IN, cd->label);
+	if (ret < 0)
+		goto egpioreq;
+
+	ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt,
+				   flags, cd->label, host);
+	if (ret < 0)
+		goto eirqreq;
+
+	cd->gpio = gpio;
+	host->hotplug.irq = irq;
+	host->hotplug.handler_priv = cd;
+
+	return 0;
+
+eirqreq:
+	gpio_free(gpio);
+egpioreq:
+	kfree(cd);
+	return ret;
+}
+EXPORT_SYMBOL(mmc_cd_gpio_request);
+
+void mmc_cd_gpio_free(struct mmc_host *host)
+{
+	struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
+
+	if (!cd)
+		return;
+
+	free_irq(host->hotplug.irq, host);
+	gpio_free(cd->gpio);
+	kfree(cd);
+}
+EXPORT_SYMBOL(mmc_cd_gpio_free);
diff --git a/include/linux/mmc/cd-gpio.h b/include/linux/mmc/cd-gpio.h
new file mode 100644
index 0000000..a8e4697
--- /dev/null
+++ b/include/linux/mmc/cd-gpio.h
@@ -0,0 +1,19 @@
+/*
+ * Generic GPIO card-detect helper header
+ *
+ * Copyright (C) 2011, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef MMC_CD_GPIO_H
+#define MMC_CD_GPIO_H
+
+struct mmc_host;
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
+			unsigned int irq, unsigned long flags);
+void mmc_cd_gpio_free(struct mmc_host *host);
+
+#endif
-- 
1.7.2.5


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

end of thread, other threads:[~2012-01-04 13:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-23 23:00 [PATCH 0/2] mmc: add generic hotplug handler and a GPIO implementation Guennadi Liakhovetski
2011-12-23 23:00 ` [PATCH 1/2] mmc: add a card hotplug handler context Guennadi Liakhovetski
2011-12-23 23:00 ` [PATCH 2/2] mmc: add a generic GPIO card-detect helper Guennadi Liakhovetski
2011-12-25  2:41   ` Chris Ball
2011-12-25 20:36     ` [PATCH 2/2 v2] " Guennadi Liakhovetski
2011-12-25 22:46       ` Chris Ball
2012-01-04 13:18   ` Guennadi Liakhovetski

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.