Commit 64310863 authored by Ulf Hansson's avatar Ulf Hansson

mmc: of_mmc_spi: Convert to mmc_of_parse_voltage()

Let's drop the open-coding of the parsing of the "voltage-ranges" DT
property and convert to use the common mmc_of_parse_voltage() API instead.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 03cd5c05
...@@ -61,9 +61,6 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) ...@@ -61,9 +61,6 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
struct device *dev = &spi->dev; struct device *dev = &spi->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct of_mmc_spi *oms; struct of_mmc_spi *oms;
const __be32 *voltage_ranges;
int num_ranges;
int i;
if (dev->platform_data || !np) if (dev->platform_data || !np)
return dev->platform_data; return dev->platform_data;
...@@ -72,25 +69,8 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) ...@@ -72,25 +69,8 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
if (!oms) if (!oms)
return NULL; return NULL;
voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); if (mmc_of_parse_voltage(np, &oms->pdata.ocr_mask) <= 0)
num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
if (!voltage_ranges || !num_ranges) {
dev_err(dev, "OF: voltage-ranges unspecified\n");
goto err_ocr; goto err_ocr;
}
for (i = 0; i < num_ranges; i++) {
const int j = i * 2;
u32 mask;
mask = mmc_vddrange_to_ocrmask(be32_to_cpu(voltage_ranges[j]),
be32_to_cpu(voltage_ranges[j + 1]));
if (!mask) {
dev_err(dev, "OF: voltage-range #%d is invalid\n", i);
goto err_ocr;
}
oms->pdata.ocr_mask |= mask;
}
oms->detect_irq = irq_of_parse_and_map(np, 0); oms->detect_irq = irq_of_parse_and_map(np, 0);
if (oms->detect_irq != 0) { if (oms->detect_irq != 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment