OSDN Git Service

mmc: core: Move mmc_of_parse_voltage() to host.c
authorUlf Hansson <ulf.hansson@linaro.org>
Wed, 13 Feb 2019 17:46:45 +0000 (18:46 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 25 Feb 2019 14:20:58 +0000 (15:20 +0100)
MMC OF parsing functions, which parses various host DT properties, should
stay close to each other. Therefore, let's move mmc_of_parse_voltage()
close to mmc_of_parse() into host.c.

Additionally, there is no reason to build the code only when CONFIG_OF is
set, as there should be stub functions for the OF helpers that is being
used, so let's drop this condition as well.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/core/core.c
drivers/mmc/core/host.c

index f796a6a..659eb32 100644 (file)
@@ -1112,54 +1112,6 @@ u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
        return mask;
 }
 
-#ifdef CONFIG_OF
-
-/**
- * mmc_of_parse_voltage - return mask of supported voltages
- * @np: The device node need to be parsed.
- * @mask: mask of voltages available for MMC/SD/SDIO
- *
- * Parse the "voltage-ranges" DT property, returning zero if it is not
- * found, negative errno if the voltage-range specification is invalid,
- * or one if the voltage-range is specified and successfully parsed.
- */
-int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
-{
-       const u32 *voltage_ranges;
-       int num_ranges, i;
-
-       voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
-       num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
-       if (!voltage_ranges) {
-               pr_debug("%pOF: voltage-ranges unspecified\n", np);
-               return 0;
-       }
-       if (!num_ranges) {
-               pr_err("%pOF: voltage-ranges empty\n", np);
-               return -EINVAL;
-       }
-
-       for (i = 0; i < num_ranges; i++) {
-               const int j = i * 2;
-               u32 ocr_mask;
-
-               ocr_mask = mmc_vddrange_to_ocrmask(
-                               be32_to_cpu(voltage_ranges[j]),
-                               be32_to_cpu(voltage_ranges[j + 1]));
-               if (!ocr_mask) {
-                       pr_err("%pOF: voltage-range #%d is invalid\n",
-                               np, i);
-                       return -EINVAL;
-               }
-               *mask |= ocr_mask;
-       }
-
-       return 1;
-}
-EXPORT_SYMBOL(mmc_of_parse_voltage);
-
-#endif /* CONFIG_OF */
-
 static int mmc_of_get_func_num(struct device_node *node)
 {
        u32 reg;
index 652ea65..3a4402a 100644 (file)
@@ -349,6 +349,50 @@ int mmc_of_parse(struct mmc_host *host)
 EXPORT_SYMBOL(mmc_of_parse);
 
 /**
+ * mmc_of_parse_voltage - return mask of supported voltages
+ * @np: The device node need to be parsed.
+ * @mask: mask of voltages available for MMC/SD/SDIO
+ *
+ * Parse the "voltage-ranges" DT property, returning zero if it is not
+ * found, negative errno if the voltage-range specification is invalid,
+ * or one if the voltage-range is specified and successfully parsed.
+ */
+int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
+{
+       const u32 *voltage_ranges;
+       int num_ranges, i;
+
+       voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
+       num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
+       if (!voltage_ranges) {
+               pr_debug("%pOF: voltage-ranges unspecified\n", np);
+               return 0;
+       }
+       if (!num_ranges) {
+               pr_err("%pOF: voltage-ranges empty\n", np);
+               return -EINVAL;
+       }
+
+       for (i = 0; i < num_ranges; i++) {
+               const int j = i * 2;
+               u32 ocr_mask;
+
+               ocr_mask = mmc_vddrange_to_ocrmask(
+                               be32_to_cpu(voltage_ranges[j]),
+                               be32_to_cpu(voltage_ranges[j + 1]));
+               if (!ocr_mask) {
+                       pr_err("%pOF: voltage-range #%d is invalid\n",
+                               np, i);
+                       return -EINVAL;
+               }
+               *mask |= ocr_mask;
+       }
+
+       return 1;
+}
+EXPORT_SYMBOL(mmc_of_parse_voltage);
+
+/**
  *     mmc_alloc_host - initialise the per-host structure.
  *     @extra: sizeof private data structure
  *     @dev: pointer to host device model structure