OSDN Git Service

mmc: simplify mmc_cd_gpio_request() by removing two parameters
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Thu, 9 Feb 2012 21:57:07 +0000 (22:57 +0100)
committerChris Ball <cjb@laptop.org>
Tue, 27 Mar 2012 16:20:14 +0000 (12:20 -0400)
Calculate the IRQ number, using gpio_to_irq() and use fixed flags: trigger
on both edges. This makes two out of four arguments of the
mmc_cd_gpio_request() function redundant.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/core/cd-gpio.c
include/linux/mmc/cd-gpio.h

index 082202a..29de31e 100644 (file)
@@ -28,13 +28,17 @@ static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
-int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
-                       unsigned int irq, unsigned long flags)
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio)
 {
        size_t len = strlen(dev_name(host->parent)) + 4;
-       struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
+       struct mmc_cd_gpio *cd;
+       int irq = gpio_to_irq(gpio);
        int ret;
 
+       if (irq < 0)
+               return irq;
+
+       cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL);
        if (!cd)
                return -ENOMEM;
 
@@ -45,7 +49,8 @@ int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio,
                goto egpioreq;
 
        ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt,
-                                  flags, cd->label, host);
+                                  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+                                  cd->label, host);
        if (ret < 0)
                goto eirqreq;
 
index a8e4697..cefaba0 100644 (file)
@@ -12,8 +12,7 @@
 #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);
+int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio);
 void mmc_cd_gpio_free(struct mmc_host *host);
 
 #endif