Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752440AbdFZM4P convert rfc822-to-8bit (ORCPT ); Mon, 26 Jun 2017 08:56:15 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:26096 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752006AbdFZMtt (ORCPT ); Mon, 26 Jun 2017 08:49:49 -0400 From: Bich HEMON To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Maxime Coquelin , Alexandre TORGUE , "Jiri Slaby" , "linux-serial@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" CC: Bich HEMON Subject: [PATCH 05/20] serial: stm32: add debugfs Thread-Topic: [PATCH 05/20] serial: stm32: add debugfs Thread-Index: AQHS7nqbFZUp16u/UkChhd+GYWlCWw== Date: Mon, 26 Jun 2017 12:49:10 +0000 Message-ID: <1498481318-1894-6-git-send-email-bich.hemon@st.com> References: <1498481318-1894-1-git-send-email-bich.hemon@st.com> In-Reply-To: <1498481318-1894-1-git-send-email-bich.hemon@st.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.50] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-26_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2968 Lines: 103 From: Bich Hemon Adding debugfs infrastructure and one virtual file allowing to change fifoen value. This value change is taken into account on next port setup or enabling. Signed-off-by: Gerald Baeza --- drivers/tty/serial/stm32-usart.c | 49 ++++++++++++++++++++++++++++++++++++++++ drivers/tty/serial/stm32-usart.h | 3 +++ 2 files changed, 52 insertions(+) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 34e31d1..3ce0f7a 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -34,6 +34,51 @@ #include "stm32-usart.h" +#ifdef CONFIG_DEBUG_FS +#include +#include +#include +#include + +static struct dentry *stm32_debugfs_root; +static atomic_t stm32_debugfs_cnt = ATOMIC_INIT(0); + +static void stm32_serial_debugfs(struct stm32_port *stm32port, + phys_addr_t phys_addr) +{ + struct device *dev = stm32port->port.dev; + + if (!stm32_debugfs_root) + stm32_debugfs_root = debugfs_create_dir("usart-stm32", NULL); + + stm32port->debugfs_dir = debugfs_create_dir(dev_name(dev), + stm32_debugfs_root); + + debugfs_create_bool("fifoen", 0644, + stm32port->debugfs_dir, &stm32port->fifoen); + + atomic_inc(&stm32_debugfs_cnt); +} + +static void stm32_serial_debugfs_rm(struct stm32_port *stm32port) +{ + debugfs_remove_recursive(stm32port->debugfs_dir); + if (atomic_dec_and_test(&stm32_debugfs_cnt)) { + debugfs_remove_recursive(stm32_debugfs_root); + stm32_debugfs_root = NULL; + } +} +#else +static void stm32_serial_debugfs(struct stm32_port *stm32port, + phys_addr_t phys_addr) +{ +} + +static void stm32_serial_debugfs_rm(struct stm32_port *stm32port) +{ +} +#endif + static void stm32_stop_tx(struct uart_port *port); static void stm32_transmit_chars(struct uart_port *port); @@ -672,6 +717,8 @@ static int stm32_init_port(struct stm32_port *stm32port, return PTR_ERR(port->membase); port->mapbase = res->start; + stm32_serial_debugfs(stm32port, res->start); + spin_lock_init(&port->lock); stm32port->clk = devm_clk_get(&pdev->dev, NULL); @@ -914,6 +961,8 @@ static int stm32_serial_remove(struct platform_device *pdev) clk_disable_unprepare(stm32_port->clk); + stm32_serial_debugfs_rm(stm32_port); + return uart_remove_one_port(&stm32_usart_driver, port); } diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index 9429baf..a8999a1 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -216,6 +216,9 @@ struct stm32_port { struct uart_port port; struct clk *clk; struct stm32_usart_info *info; +#ifdef CONFIG_DEBUG_FS + struct dentry *debugfs_dir; +#endif struct dma_chan *rx_ch; /* dma rx channel */ dma_addr_t rx_dma_buf; /* dma rx buffer bus address */ unsigned char *rx_buf; /* dma rx buffer cpu address */ -- 1.9.1