From patchwork Wed Feb 13 19:54:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10810821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FD2214E1 for ; Wed, 13 Feb 2019 19:55:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DBDE2DD45 for ; Wed, 13 Feb 2019 19:55:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 824702DD56; Wed, 13 Feb 2019 19:55:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18EE42DD45 for ; Wed, 13 Feb 2019 19:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403869AbfBMTy7 (ORCPT ); Wed, 13 Feb 2019 14:54:59 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:39093 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403877AbfBMTy6 (ORCPT ); Wed, 13 Feb 2019 14:54:58 -0500 Received: by mail-lf1-f66.google.com with SMTP id m11so2741459lfc.6 for ; Wed, 13 Feb 2019 11:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MRqFhz7nKkdjRls5Ll0A5LeUiGAisfOYUztGbW66WvI=; b=P9+IJBWv5AGiWVDo1cB1Tdh8vWIfJ93mJaEpslrhAWiaqvb890cGtZHuk+wySC3CY/ 7XtT1HKWHlgrmznn5VwjZ+IyV4vXuhjNSwt0k5fAwOaD4ZyOUvB/WdSUQQxRuZoB5E80 weFaO+7gOMZBcLRUKCRbDeScJTlDe27XIEFfxhkvd/ReRyPt3skKhZkKt8zZJH8dTGIF sCIr36yOVY78CKAiKHCJz8N9mJHfSoRWw0jLfS/GWCbVEFTtcKuxTOo5MkA0YEsARPlr 3kn0kQAGNLQvSnzJNhWlBpsfQrdiaVmLbg8C3CBo1ZL8r0TRPQQCl13cSm7PNvF7Es3q hpZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MRqFhz7nKkdjRls5Ll0A5LeUiGAisfOYUztGbW66WvI=; b=Vi7tum/VVAuZqfOVkH8LH3iUTWJ1ZgwodDPG5k5jjX5WV42Xhay+xk7zUsLXzsN0Yz mlD8+50JBnjH4ivGYmnR8gj0kH4wUk6Kh53iMlnCtWXUg4VP0vrQZyZOYS+M0V2FbxxW rd4RDH7WAYXBn1m9tIVIqwQA85ywHSeMgOcW1xSZuwewqwEFiLoIJWX71E1v6HjeExbu 2Gn5lWunDBpdUyYzrkiUNY0ju1VVpTtGu8oJw+QcYkC4u/dVOGrQZjqYbQEXKr6zrA7n sSBYlyBUhl4FhdL8+49vCktcKFNIXftevkpGnQsD+b8LKIAPtLUXwlbHFb/9jYmAKeB7 tcNQ== X-Gm-Message-State: AHQUAuZkh+4TeNjCVMKdG1iaYQ3OxKeXHT2TGuEcvrHpSXGiGROAc5n/ aQlEou9c7ETjZ/142KI7LHbUTHs/IvQ= X-Google-Smtp-Source: AHgI3IaX+6CtEcWQ54lj+m5c5QHYpckxQoZ+36sanl4MT+NXM0HYIktF35gZM68xHhTLm49Pob8p/g== X-Received: by 2002:a19:6e0b:: with SMTP id j11mr1335191lfc.124.1550087695900; Wed, 13 Feb 2019 11:54:55 -0800 (PST) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id g194sm39169lfg.55.2019.02.13.11.54.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 11:54:55 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Adrian Hunter Cc: Ulf Hansson Subject: [PATCH 6/7] mmc: core: Move mmc_of_parse_voltage() to host.c Date: Wed, 13 Feb 2019 20:54:42 +0100 Message-Id: <20190213195443.18935-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213195443.18935-1-ulf.hansson@linaro.org> References: <20190213195443.18935-1-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/mmc/core/core.c | 48 ----------------------------------------- drivers/mmc/core/host.c | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f796a6afb19b..659eb32c0246 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -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; diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 652ea6502336..3a4402a79904 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -348,6 +348,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