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: 158250 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp470150jaa; Wed, 13 Feb 2019 11:54:56 -0800 (PST) X-Received: by 2002:a2e:9a16:: with SMTP id o22-v6mr1368296lji.112.1550087696437; Wed, 13 Feb 2019 11:54:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550087696; cv=none; d=google.com; s=arc-20160816; b=0atp2YeGx0uaoi3Sfyen1ONqXy4oyHm7+S5aQXqG97rl1ESEbqna9vLUDRdktO2UpD RCngiM+DqKCxohFX5OAezo1XJ7L6DD8PR3gqgKoYic8Gej4k2c0jBJg195OlGflFo96L hauWMu/Q2NVwMh3zNh52gskuC3ACMXD3HZhmZRDT5Jfxz1cVcESVgFPd/uv6aGsxEAcB Mw0tf+wp8ZnaI9J874yDe1sZJZnGjQdaVh23B3VT/p85wAYiU+SYoQadFS6zn9u1Ni8G zk4tvFNUMfan1Mga5GIwr/de/p/81/so1hYWRp2yqRUJj2/PZ9siWDmjTszCQfaR+eVF 6m/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MRqFhz7nKkdjRls5Ll0A5LeUiGAisfOYUztGbW66WvI=; b=s4zIwlIurfoRHOtE6ZEeMwuhT+f72qN2tVwdQEglv7l2lfPUwDqG1ufPS4VHTAf1oy cI3mFO3GxNq1NYCIdorvnkL0/JjgStXGKcyD4/IfcFGg4xkoweMBFn4JwDvRTDfZJ1fs jX3lIBi+VnuYHJI7FWrNUkdwFqnq9Bkidsf7Fs1LNEWogpeGWtIC+uhS5jU3MyhxqegD 0xOWVdAKaRjgm7Y2Zs2kT0iixcMEz5u/ALO5FwJv6KhBhEtKHGe6N9UHHNzsIM8/GrWe ACce1whTVqbWF9bB9/Zdp0DuFYtbMcyvFbcMBhvhd/1mYNJ7aQgIHsbhNgjVgflCGdqK dlsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P9+IJBWv; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n10sor60498lfe.49.2019.02.13.11.54.56 for (Google Transport Security); Wed, 13 Feb 2019 11:54:56 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P9+IJBWv; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=CcUbhKYcMOZgFRr4mEC28X5VsN243yqMjRR+0nyo//dlLesPK/43oIfZqPT5khQVOD IZWziCsEGu0m5oCgTKuYzsFndj7GJcj+fVqQyZUzbkIL6UAFHza3tdhv7Zqn/SM5AwWn xsjZGzoOOqijfeRpYgOI9i8d79VFFtmrXWZF2JuOGaXVZvosK0PUnaXIF6MYHo6ZTrZv yUktjtofK11eWG565XrzXKC8XHlKdJOOPIBftFJ9ITpQla2mRMTiNTrcnSNn5yLnpGSu d/v598zTLATtXx9cS4ko2I9zohzo+FFyKaSfm9RTz30t1IPLAwY50CB98aYbLnKbMjbs hpAA== X-Gm-Message-State: AHQUAuZnLKeEHHh78eK0QHmW2dtz5y2I9ef5HEl/2pd2yZqzsnvADiSX /Iuv1QWLX5gFBhzDZkDcQSFAEjSX7tMVBg== 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) Return-Path: 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> 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(-) -- 2.17.1 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