]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/mmc/core/slot-gpio.c
mmc: slot-gpio: Use the parent device while allocating data
[mirror_ubuntu-artful-kernel.git] / drivers / mmc / core / slot-gpio.c
index 69bbf2adb329db5570b0c0b698152110fb2ccee4..f9a0c6e8001ecf10183aad226a885762dcaf873e 100644 (file)
@@ -52,7 +52,7 @@ static int mmc_gpio_alloc(struct mmc_host *host)
                 * before device_add(), i.e., between mmc_alloc_host() and
                 * mmc_add_host()
                 */
-               ctx = devm_kzalloc(&host->class_dev, sizeof(*ctx) + 2 * len,
+               ctx = devm_kzalloc(host->parent, sizeof(*ctx) + 2 * len,
                                   GFP_KERNEL);
                if (ctx) {
                        ctx->ro_label = ctx->cd_label + len;
@@ -103,11 +103,7 @@ EXPORT_SYMBOL(mmc_gpio_get_cd);
  * @gpio: gpio number requested
  *
  * As devm_* managed functions are used in mmc_gpio_request_ro(), client
- * drivers do not need to explicitly call mmc_gpio_free_ro() for freeing up,
- * if the requesting and freeing are only needed at probing and unbinding time
- * for once.  However, if client drivers do something special like runtime
- * switching for write-protection, they are responsible for calling
- * mmc_gpio_request_ro() and mmc_gpio_free_ro() as a pair on their own.
+ * drivers do not need to worry about freeing up memory.
  *
  * Returns zero on success, else an error.
  */
@@ -125,7 +121,7 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio)
 
        ctx = host->slot.handler_priv;
 
-       ret = devm_gpio_request_one(&host->class_dev, gpio, GPIOF_DIR_IN,
+       ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN,
                                    ctx->ro_label);
        if (ret < 0)
                return ret;
@@ -156,7 +152,7 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host)
                irq = -EINVAL;
 
        if (irq >= 0) {
-               ret = devm_request_threaded_irq(&host->class_dev, irq,
+               ret = devm_request_threaded_irq(host->parent, irq,
                        NULL, mmc_gpio_cd_irqt,
                        IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                        ctx->cd_label, host);
@@ -178,11 +174,7 @@ EXPORT_SYMBOL(mmc_gpiod_request_cd_irq);
  * @debounce: debounce time in microseconds
  *
  * As devm_* managed functions are used in mmc_gpio_request_cd(), client
- * drivers do not need to explicitly call mmc_gpio_free_cd() for freeing up,
- * if the requesting and freeing are only needed at probing and unbinding time
- * for once.  However, if client drivers do something special like runtime
- * switching for card-detection, they are responsible for calling
- * mmc_gpio_request_cd() and mmc_gpio_free_cd() as a pair on their own.
+ * drivers do not need to worry about freeing up memory.
  *
  * If GPIO debouncing is desired, set the debounce parameter to a non-zero
  * value. The caller is responsible for ensuring that the GPIO driver associated
@@ -202,7 +194,7 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
 
        ctx = host->slot.handler_priv;
 
-       ret = devm_gpio_request_one(&host->class_dev, gpio, GPIOF_DIR_IN,
+       ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN,
                                    ctx->cd_label);
        if (ret < 0)
                /*
@@ -225,55 +217,6 @@ int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio,
 }
 EXPORT_SYMBOL(mmc_gpio_request_cd);
 
-/**
- * mmc_gpio_free_ro - free the write-protection gpio
- * @host: mmc host
- *
- * It's provided only for cases that client drivers need to manually free
- * up the write-protection gpio requested by mmc_gpio_request_ro().
- */
-void mmc_gpio_free_ro(struct mmc_host *host)
-{
-       struct mmc_gpio *ctx = host->slot.handler_priv;
-       int gpio;
-
-       if (!ctx || !ctx->ro_gpio)
-               return;
-
-       gpio = desc_to_gpio(ctx->ro_gpio);
-       ctx->ro_gpio = NULL;
-
-       devm_gpio_free(&host->class_dev, gpio);
-}
-EXPORT_SYMBOL(mmc_gpio_free_ro);
-
-/**
- * mmc_gpio_free_cd - free the card-detection gpio
- * @host: mmc host
- *
- * It's provided only for cases that client drivers need to manually free
- * up the card-detection gpio requested by mmc_gpio_request_cd().
- */
-void mmc_gpio_free_cd(struct mmc_host *host)
-{
-       struct mmc_gpio *ctx = host->slot.handler_priv;
-       int gpio;
-
-       if (!ctx || !ctx->cd_gpio)
-               return;
-
-       if (host->slot.cd_irq >= 0) {
-               devm_free_irq(&host->class_dev, host->slot.cd_irq, host);
-               host->slot.cd_irq = -EINVAL;
-       }
-
-       gpio = desc_to_gpio(ctx->cd_gpio);
-       ctx->cd_gpio = NULL;
-
-       devm_gpio_free(&host->class_dev, gpio);
-}
-EXPORT_SYMBOL(mmc_gpio_free_cd);
-
 /**
  * mmc_gpiod_request_cd - request a gpio descriptor for card-detection
  * @host: mmc host
@@ -285,8 +228,7 @@ EXPORT_SYMBOL(mmc_gpio_free_cd);
  * to NULL to ignore
  *
  * Use this function in place of mmc_gpio_request_cd() to use the GPIO
- * descriptor API.  Note that it is paired with mmc_gpiod_free_cd() not
- * mmc_gpio_free_cd().  Note also that it must be called prior to mmc_add_host()
+ * descriptor API.  Note that it must be called prior to mmc_add_host()
  * otherwise the caller must also call mmc_gpiod_request_cd_irq().
  *
  * Returns zero on success, else an error.
@@ -339,8 +281,7 @@ EXPORT_SYMBOL(mmc_gpiod_request_cd);
  * set to NULL to ignore
  *
  * Use this function in place of mmc_gpio_request_ro() to use the GPIO
- * descriptor API.  Note that it is paired with mmc_gpiod_free_ro() not
- * mmc_gpio_free_ro().
+ * descriptor API.
  *
  * Returns zero on success, else an error.
  */
@@ -380,28 +321,3 @@ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
        return 0;
 }
 EXPORT_SYMBOL(mmc_gpiod_request_ro);
-
-/**
- * mmc_gpiod_free_cd - free the card-detection gpio descriptor
- * @host: mmc host
- *
- * It's provided only for cases that client drivers need to manually free
- * up the card-detection gpio requested by mmc_gpiod_request_cd().
- */
-void mmc_gpiod_free_cd(struct mmc_host *host)
-{
-       struct mmc_gpio *ctx = host->slot.handler_priv;
-
-       if (!ctx || !ctx->cd_gpio)
-               return;
-
-       if (host->slot.cd_irq >= 0) {
-               devm_free_irq(&host->class_dev, host->slot.cd_irq, host);
-               host->slot.cd_irq = -EINVAL;
-       }
-
-       devm_gpiod_put(host->parent, ctx->cd_gpio);
-
-       ctx->cd_gpio = NULL;
-}
-EXPORT_SYMBOL(mmc_gpiod_free_cd);