Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec0a7517 authored by Simon Baatz's avatar Simon Baatz Committed by Chris Ball
Browse files

mmc: return mmc_of_parse() errors to caller



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: default avatarSimon Baatz <gmbnomis@gmail.com>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent fca9661c
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -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,19 +368,23 @@ 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)
			host->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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)
{