summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/pic32_uart.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2022-05-03 08:31:15 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-05-05 22:39:17 +0200
commitbb2cff419d3253aac12e7513be2b0fd7ee11ad78 (patch)
tree8c4ec847841663e2b29340490b1cdfb7e1457010 /drivers/tty/serial/pic32_uart.c
parent08f643e0224222aa089265a72690187898cac3e7 (diff)
downloadlinux-bb2cff419d3253aac12e7513be2b0fd7ee11ad78.tar.gz
linux-bb2cff419d3253aac12e7513be2b0fd7ee11ad78.tar.bz2
linux-bb2cff419d3253aac12e7513be2b0fd7ee11ad78.zip
serial: pic32: simplify clk handling
struct pic32_sport::ref_clk is only set, but not read. That means we can remove it. And when we do so, pic32_enable_clock() and pic32_disable_clock() are simple wrappers around clk_prepare_enable() and clk_disable_unprepare() respectively. So we can remove the former two from the code and replace it by the latter two. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20220503063122.20957-5-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/pic32_uart.c')
-rw-r--r--drivers/tty/serial/pic32_uart.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/drivers/tty/serial/pic32_uart.c b/drivers/tty/serial/pic32_uart.c
index 1e8ff6004e8e..42269e96b3f8 100644
--- a/drivers/tty/serial/pic32_uart.c
+++ b/drivers/tty/serial/pic32_uart.c
@@ -68,7 +68,6 @@ struct pic32_sport {
bool hw_flow_ctrl;
int cts_gpio;
- int ref_clk;
struct clk *clk;
struct device *dev;
@@ -138,23 +137,6 @@ static inline void pic32_wait_deplete_txbuf(struct pic32_sport *sport)
udelay(1);
}
-static inline int pic32_enable_clock(struct pic32_sport *sport)
-{
- int ret = clk_prepare_enable(sport->clk);
-
- if (ret)
- return ret;
-
- sport->ref_clk++;
- return 0;
-}
-
-static inline void pic32_disable_clock(struct pic32_sport *sport)
-{
- sport->ref_clk--;
- clk_disable_unprepare(sport->clk);
-}
-
/* serial core request to check if uart tx buffer is empty */
static unsigned int pic32_uart_tx_empty(struct uart_port *port)
{
@@ -491,7 +473,7 @@ static int pic32_uart_startup(struct uart_port *port)
local_irq_save(flags);
- ret = pic32_enable_clock(sport);
+ ret = clk_prepare_enable(sport->clk);
if (ret) {
local_irq_restore(flags);
goto out_done;
@@ -611,7 +593,7 @@ static void pic32_uart_shutdown(struct uart_port *port)
spin_lock_irqsave(&port->lock, flags);
pic32_uart_dsbl_and_mask(port);
spin_unlock_irqrestore(&port->lock, flags);
- pic32_disable_clock(sport);
+ clk_disable_unprepare(sport->clk);
/* free all 3 interrupts for this UART */
free_irq(sport->irq_fault, port);
@@ -835,7 +817,7 @@ static int pic32_console_setup(struct console *co, char *options)
return -ENODEV;
port = pic32_get_port(sport);
- ret = pic32_enable_clock(sport);
+ ret = clk_prepare_enable(sport->clk);
if (ret)
return ret;
@@ -965,7 +947,7 @@ static int pic32_uart_probe(struct platform_device *pdev)
/* The peripheral clock has been enabled by console_setup,
* so disable it till the port is used.
*/
- pic32_disable_clock(sport);
+ clk_disable_unprepare(sport->clk);
}
#endif
@@ -986,7 +968,7 @@ static int pic32_uart_remove(struct platform_device *pdev)
struct pic32_sport *sport = to_pic32_sport(port);
uart_remove_one_port(&pic32_uart_driver, port);
- pic32_disable_clock(sport);
+ clk_disable_unprepare(sport->clk);
platform_set_drvdata(pdev, NULL);
pic32_sports[sport->idx] = NULL;