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

Commit cfcc5550 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: allow setting slot index via device tree alias"

parents 4d6092f0 8dceb5dc
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -464,6 +464,20 @@ int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
}
EXPORT_SYMBOL(mmc_of_parse_voltage);

/**
 * mmc_first_nonreserved_index() - get the first index that is not reserved
 */
static int mmc_first_nonreserved_index(void)
{
	int max;

	max = of_alias_get_highest_id("sdhc");
	if (max < 0)
		return 0;

	return max + 1;
}

/**
 *	mmc_alloc_host - initialise the per-host structure.
 *	@extra: sizeof private data structure
@@ -475,6 +489,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
{
	int err;
	struct mmc_host *host;
	int alias_id, min_idx, max_idx;

	host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
	if (!host)
@@ -483,7 +498,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
	/* scanning will be enabled when we're ready */
	host->rescan_disable = 1;

	err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL);
	alias_id = of_alias_get_id(dev->of_node, "sdhc");
	if (alias_id >= 0) {
		min_idx = alias_id;
		max_idx = alias_id + 1;
	} else {
		min_idx = mmc_first_nonreserved_index();
		max_idx = 0;
	}

	err = ida_simple_get(&mmc_host_ida, min_idx, max_idx, GFP_KERNEL);
	if (err < 0) {
		kfree(host);
		return NULL;