From patchwork Tue Jul 12 14:08:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 9225379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2E6360871 for ; Tue, 12 Jul 2016 14:09:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E072787D for ; Tue, 12 Jul 2016 14:09:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9A3F27C39; Tue, 12 Jul 2016 14:09:55 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 00E7C27BFF for ; Tue, 12 Jul 2016 14:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbcGLOJ3 (ORCPT ); Tue, 12 Jul 2016 10:09:29 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:12735 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754393AbcGLOJ2 (ORCPT ); Tue, 12 Jul 2016 10:09:28 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OA7004V5GNOGFB0@mailout4.w1.samsung.com>; Tue, 12 Jul 2016 15:09:24 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-64-5784fa148e58 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id AF.9A.05254.41AF4875; Tue, 12 Jul 2016 15:09:24 +0100 (BST) Received: from AMDC2174.DIGITAL.local ([106.120.53.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OA7002OZGNJTT50@eusync3.samsung.com>; Tue, 12 Jul 2016 15:09:24 +0100 (BST) From: Krzysztof Kozlowski To: Ulf Hansson , Jaehoon Chung , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 1/2] mmc: core: Add helper for mapping IOS voltage to string Date: Tue, 12 Jul 2016 16:08:21 +0200 Message-id: <1468332502-28016-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDJMWRmVeSWpSXmKPExsVy+t/xq7oiv1rCDf7v0rfYOGM9q8WNX22s Fq9fGFpc3jWHzeLI/35Gi+Nrwx3YPO5c28Pm0bdlFaPH501yAcxRXDYpqTmZZalF+nYJXBnP l79hLvguULHk7GnmBsbZfF2MnBwSAiYSJ2c9Z4OwxSQu3FsPZHNxCAksZZSYc/sHE4TTyCTR 2HuPEaSKTcBYYvPyJWBVIgK9jBKdE3eCJZgFMiU6985lB7GFBXwklny/ATaWRUBV4sWT40wg Nq+Au8T/Xd8YIdbJSZw8Npl1AiP3AkaGVYyiqaXJBcVJ6bmGesWJucWleel6yfm5mxghYfBl B+PiY1aHGAU4GJV4eB+cbg4XYk0sK67MPcQowcGsJMKb8a0lXIg3JbGyKrUoP76oNCe1+BCj NAeLkjjv3F3vQ4QE0hNLUrNTUwtSi2CyTBycUg2MuaqLNBxe6h6T6moL4lrFfFd14q66aww+ cuzupXfUzi80P2dcsWmLRtnfuecMzsna94tK3eARfSo5j3vDb+eXNw6wPDrYr5vt/EbRRzU6 euLvlZ91K64WOUlef1LqYvO9PnWLy3vmr+oKZWkvzb9vqJjLliiupzE5Z3KPy8niD2UXWhfP +LJZiaU4I9FQi7moOBEAleGlz/8BAAA= 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 Add a helper for producing a user-friendly string with chosen signaling voltage. Signed-off-by: Krzysztof Kozlowski --- drivers/mmc/core/debugfs.c | 15 +-------------- drivers/mmc/core/host.c | 13 +++++++++++++ include/linux/mmc/host.h | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c8451ce557ae..1b669cafea12 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -157,20 +157,7 @@ static int mmc_ios_show(struct seq_file *s, void *data) } seq_printf(s, "timing spec:\t%u (%s)\n", ios->timing, str); - switch (ios->signal_voltage) { - case MMC_SIGNAL_VOLTAGE_330: - str = "3.30 V"; - break; - case MMC_SIGNAL_VOLTAGE_180: - str = "1.80 V"; - break; - case MMC_SIGNAL_VOLTAGE_120: - str = "1.20 V"; - break; - default: - str = "invalid"; - break; - } + str = mmc_voltage_to_str(ios); seq_printf(s, "signal voltage:\t%u (%s)\n", ios->signal_voltage, str); switch (ios->drv_type) { diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index d7e86f9b3dab..6708bea84a0d 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -469,3 +469,16 @@ void mmc_free_host(struct mmc_host *host) } EXPORT_SYMBOL(mmc_free_host); + +const char *mmc_voltage_to_str(struct mmc_ios *ios) +{ + static const char * const voltages[] = { + [MMC_SIGNAL_VOLTAGE_330] = "3.30 V", + [MMC_SIGNAL_VOLTAGE_180] = "1.80 V", + [MMC_SIGNAL_VOLTAGE_120] = "1.20 V", + }; + + if (ios->signal_voltage <= MMC_SIGNAL_VOLTAGE_120) + return voltages[ios->signal_voltage]; + return "invalid"; +} diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index aa4bfbf129e4..e1e87d3432d8 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -544,4 +544,6 @@ static inline void mmc_retune_recheck(struct mmc_host *host) void mmc_retune_pause(struct mmc_host *host); void mmc_retune_unpause(struct mmc_host *host); +const char *mmc_voltage_to_str(struct mmc_ios *ios); + #endif /* LINUX_MMC_HOST_H */