linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Simon Baatz <gmbnomis@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org,
	Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
	Chris Ball <cjb@laptop.org>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Subject: Re: [PATCH V3 01/10] mmc: return mmc_of_parse() errors to caller
Date: Tue, 21 May 2013 09:00:09 +0200	[thread overview]
Message-ID: <CAPDyKFoE-_Kpn_FBmrePEGF84jwSADC+=6ibBmA_ePVg7B4z9Q@mail.gmail.com> (raw)
In-Reply-To: <1369090911-1479-2-git-send-email-gmbnomis@gmail.com>

On 21 May 2013 01:01, Simon Baatz <gmbnomis@gmail.com> wrote:
> In addition to just logging errors encountered during DT parsing or
> allocating GPIO slots for CD/WP, mmc_of_parse() now returns with an error.
>
> In particular, this is needed if the GPIO allocation may return
> EPROBE_DEFER.
>
> Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
> ---
>
> changes in V3:
> - Handle EPROBE_DEFER case
>
>  drivers/mmc/core/host.c  |   30 +++++++++++++++++++++++++-----
>  include/linux/mmc/host.h |    2 +-
>  2 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 2a3593d..89f5849 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -306,7 +306,7 @@ static inline void mmc_host_clk_sysfs_init(struct mmc_host *host)
>   * parse the properties and set respective generic mmc-host flags and
>   * parameters.
>   */
> -void mmc_of_parse(struct mmc_host *host)
> +int mmc_of_parse(struct mmc_host *host)
>  {
>         struct device_node *np;
>         u32 bus_width;
> @@ -315,7 +315,7 @@ void mmc_of_parse(struct mmc_host *host)
>         int len, ret, gpio;
>
>         if (!host->parent || !host->parent->of_node)
> -               return;
> +               return 0;
>
>         np = host->parent->of_node;
>
> @@ -338,6 +338,7 @@ void mmc_of_parse(struct mmc_host *host)
>         default:
>                 dev_err(host->parent,
>                         "Invalid \"bus-width\" value %ud!\n", bus_width);
> +               return -EINVAL;
>         }
>
>         /* f_max is obtained from the optional "max-frequency" property */
> @@ -367,18 +368,22 @@ void mmc_of_parse(struct mmc_host *host)
>                         host->caps |= MMC_CAP_NEEDS_POLL;
>
>                 gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &flags);
> +               if (gpio == -EPROBE_DEFER)
> +                       return gpio;
>                 if (gpio_is_valid(gpio)) {
>                         if (!(flags & OF_GPIO_ACTIVE_LOW))
>                                 gpio_inv_cd = true;
>
>                         ret = mmc_gpio_request_cd(host, gpio);
> -                       if (ret < 0)
> +                       if (ret < 0) {
>                                 dev_err(host->parent,
>                                         "Failed to request CD GPIO #%d: %d!\n",
>                                         gpio, ret);
> -                       else
> +                               return ret;
> +                       } else {
>                                 dev_info(host->parent, "Got CD GPIO #%d.\n",
>                                          gpio);
> +                       }
>                 }
>
>                 if (explicit_inv_cd ^ gpio_inv_cd)
> @@ -389,14 +394,23 @@ void mmc_of_parse(struct mmc_host *host)
>         explicit_inv_wp = of_property_read_bool(np, "wp-inverted");
>
>         gpio = of_get_named_gpio_flags(np, "wp-gpios", 0, &flags);
> +       if (gpio == -EPROBE_DEFER) {
> +               ret = -EPROBE_DEFER;
> +               goto out;
> +       }
>         if (gpio_is_valid(gpio)) {
>                 if (!(flags & OF_GPIO_ACTIVE_LOW))
>                         gpio_inv_wp = true;
>
>                 ret = mmc_gpio_request_ro(host, gpio);
> -               if (ret < 0)
> +               if (ret < 0) {
>                         dev_err(host->parent,
>                                 "Failed to request WP GPIO: %d!\n", ret);
> +                       goto out;
> +               } else {
> +                               dev_info(host->parent, "Got WP GPIO #%d.\n",
> +                                        gpio);
> +               }
>         }
>         if (explicit_inv_wp ^ gpio_inv_wp)
>                 host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
> @@ -413,6 +427,12 @@ void mmc_of_parse(struct mmc_host *host)
>                 host->pm_caps |= MMC_PM_KEEP_POWER;
>         if (of_find_property(np, "enable-sdio-wakeup", &len))
>                 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
> +
> +       return 0;
> +
> +out:
> +       mmc_gpio_free_cd(host);
> +       return ret;
>  }
>
>  EXPORT_SYMBOL(mmc_of_parse);
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index e326ae2..c8c4fbc 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -369,7 +369,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *);
>  int mmc_add_host(struct mmc_host *);
>  void mmc_remove_host(struct mmc_host *);
>  void mmc_free_host(struct mmc_host *);
> -void mmc_of_parse(struct mmc_host *host);
> +int mmc_of_parse(struct mmc_host *host);
>
>  static inline void *mmc_priv(struct mmc_host *host)
>  {
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

  reply	other threads:[~2013-05-21  7:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 23:01 [PATCH V3 00/10] mmc_of_parse() adaptations, DT support for Sheevaplugs Simon Baatz
2013-05-20 23:01 ` [PATCH V3 01/10] mmc: return mmc_of_parse() errors to caller Simon Baatz
2013-05-21  7:00   ` Ulf Hansson [this message]
2013-05-20 23:01 ` [PATCH V3 02/10] mmc: sh_mmcif: handle mmc_of_parse() errors during probe Simon Baatz
2013-05-20 23:01 ` [PATCH V3 03/10] mmc: tmio-mmc: " Simon Baatz
2013-05-20 23:01 ` [PATCH V3 04/10] mmc: mxcmmc: " Simon Baatz
2013-05-20 23:01 ` [PATCH V3 05/10] mmc: sdhci-pxav3: " Simon Baatz
2013-05-20 23:01 ` [PATCH V3 06/10] mmc: tegra: " Simon Baatz
2013-05-20 23:01 ` [PATCH V3 07/10] ARM: mvebu: Use standard MMC binding for all users of mvsdio Simon Baatz
2013-05-20 23:01 ` [PATCH V3 08/10] mmc: mvsdio: use standard MMC device-tree binding parser mmc_of_parse() Simon Baatz
2013-05-20 23:01 ` [PATCH V3 09/10] ARM: Kirkwood: Add dts files for Sheevaplug and eSATA Sheevaplug Simon Baatz
2013-05-21  5:11   ` Andrew Lunn
2013-05-20 23:01 ` [PATCH V3 10/10] ARM: Kirkwood: add DT support for Sheevaplug and Sheevaplug eSATA Simon Baatz
2013-05-21  5:13   ` Andrew Lunn
2013-05-21 13:14 ` [PATCH V3 00/10] mmc_of_parse() adaptations, DT support for Sheevaplugs Jason Cooper
2013-05-22 19:25   ` Simon Baatz
     [not found]     ` <20130522192501.GC25367-2BA9cf72eNkOIzVOb1FTxg@public.gmane.org>
2013-05-23 11:23       ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPDyKFoE-_Kpn_FBmrePEGF84jwSADC+=6ibBmA_ePVg7B4z9Q@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=andrew@lunn.ch \
    --cc=cjb@laptop.org \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=gmbnomis@gmail.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).