From patchwork Mon Aug 12 01:39:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Haijun.Zhang" X-Patchwork-Id: 266409 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id BFA462C0208 for ; Mon, 12 Aug 2013 12:34:18 +1000 (EST) Received: from co9outboundpool.messaging.microsoft.com (co9ehsobe002.messaging.microsoft.com [207.46.163.25]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "MSIT Machine Auth CA 2" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D45932C0138 for ; Mon, 12 Aug 2013 12:33:06 +1000 (EST) Received: from mail17-co9-R.bigfish.com (10.236.132.241) by CO9EHSOBE041.bigfish.com (10.236.130.104) with Microsoft SMTP Server id 14.1.225.22; Mon, 12 Aug 2013 02:33:02 +0000 Received: from mail17-co9 (localhost [127.0.0.1]) by mail17-co9-R.bigfish.com (Postfix) with ESMTP id C4E072A00DC; Mon, 12 Aug 2013 02:33:02 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzd2iz1de098h8275bh1de097hz2dh2a8h668h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1155h) Received: from mail17-co9 (localhost.localdomain [127.0.0.1]) by mail17-co9 (MessageSwitch) id 1376274780715622_32433; Mon, 12 Aug 2013 02:33:00 +0000 (UTC) Received: from CO9EHSMHS009.bigfish.com (unknown [10.236.132.247]) by mail17-co9.bigfish.com (Postfix) with ESMTP id A819D300047; Mon, 12 Aug 2013 02:33:00 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS009.bigfish.com (10.236.130.19) with Microsoft SMTP Server (TLS) id 14.16.227.3; Mon, 12 Aug 2013 02:33:00 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.136.1; Mon, 12 Aug 2013 02:32:59 +0000 Received: from rock.am.freescale.net (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r7C2WmJn029746; Sun, 11 Aug 2013 19:32:56 -0700 From: Haijun Zhang To: , Subject: [PATCH V3] mmc:of_spi: Update the code of getting voltage-ranges Date: Mon, 12 Aug 2013 09:39:05 +0800 Message-ID: <1376271546-25085-3-git-send-email-Haijun.Zhang@freescale.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1376271546-25085-1-git-send-email-Haijun.Zhang@freescale.com> References: <1376271546-25085-1-git-send-email-Haijun.Zhang@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Cc: X.Xie@freescale.com, cbouatmailru@gmail.com, scottwood@freescale.com, cjb@laptop.org, Haijun Zhang X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Using function mmc_of_parse_voltage() to get voltage-ranges. Signed-off-by: Haijun Zhang Acked-by: Anton Vorontsov --- changes for V3: - changes the type of ocr_mask and function mmc_of_parse_voltage drivers/mmc/host/of_mmc_spi.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c index d720b5e..fd1928d 100644 --- a/drivers/mmc/host/of_mmc_spi.c +++ b/drivers/mmc/host/of_mmc_spi.c @@ -90,8 +90,7 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) struct device *dev = &spi->dev; struct device_node *np = dev->of_node; struct of_mmc_spi *oms; - const u32 *voltage_ranges; - int num_ranges; + u32 ocr_mask; int i; int ret = -EINVAL; @@ -102,26 +101,10 @@ struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) if (!oms) return NULL; - voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); - num_ranges = num_ranges / sizeof(*voltage_ranges) / 2; - if (!voltage_ranges || !num_ranges) { - dev_err(dev, "OF: voltage-ranges unspecified\n"); + if (mmc_of_parse_voltage(np, &ocr_mask)) 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) { - ret = -EINVAL; - dev_err(dev, "OF: voltage-range #%d is invalid\n", i); - goto err_ocr; - } - oms->pdata.ocr_mask |= mask; - } + oms->pdata.ocr_mask |= ocr_mask; for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { enum of_gpio_flags gpio_flags;