]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/mmc/core/core.c
mmc: Add SDIO function devicetree subnode parsing
[karo-tx-linux.git] / drivers / mmc / core / core.c
index 9584bffa8b227ed01ea7286542eb269d4b59a5b8..d3bfbdfab05212810cf8f3059bb5c948d428f866 100644 (file)
@@ -1232,6 +1232,34 @@ EXPORT_SYMBOL(mmc_of_parse_voltage);
 
 #endif /* CONFIG_OF */
 
+static int mmc_of_get_func_num(struct device_node *node)
+{
+       u32 reg;
+       int ret;
+
+       ret = of_property_read_u32(node, "reg", &reg);
+       if (ret < 0)
+               return ret;
+
+       return reg;
+}
+
+struct device_node *mmc_of_find_child_device(struct mmc_host *host,
+               unsigned func_num)
+{
+       struct device_node *node;
+
+       if (!host->parent || !host->parent->of_node)
+               return NULL;
+
+       for_each_child_of_node(host->parent->of_node, node) {
+               if (mmc_of_get_func_num(node) == func_num)
+                       return node;
+       }
+
+       return NULL;
+}
+
 #ifdef CONFIG_REGULATOR
 
 /**