From: Richard Genoud <richard.genoud@gmail.com>
To: Claudiu Beznea <claudiu.beznea@microchip.com>,
richard.genoud@gmail.com, gregkh@linuxfoundation.org,
jirislaby@kernel.org, nicolas.ferre@microchip.com,
alexandre.belloni@bootlin.com, patrice.chotard@foss.st.com
Cc: linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] tty: serial: atmel: use devm_clk_get()
Date: Fri, 17 Jun 2022 15:06:24 +0200 [thread overview]
Message-ID: <b08857ab-ce3d-d597-b229-1a61b849118d@gmail.com> (raw)
In-Reply-To: <20220616140024.2081238-3-claudiu.beznea@microchip.com>
Le 16/06/2022 à 16:00, Claudiu Beznea a écrit :
> Use devm_clk_get() for serial clock instead of clk_get()/clk_put().
> With this move the clk_get in driver's probe function.
>
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
> ---
> drivers/tty/serial/atmel_serial.c | 50 ++++++++++---------------------
> 1 file changed, 15 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index c618d7e93058..4cec97fd7241 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2508,24 +2508,7 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
> if (ret)
> return ret;
>
> - /* for console, the clock could already be configured */
> - if (!atmel_port->clk) {
> - atmel_port->clk = clk_get(&mpdev->dev, "usart");
> - if (IS_ERR(atmel_port->clk)) {
> - ret = PTR_ERR(atmel_port->clk);
> - atmel_port->clk = NULL;
> - return ret;
> - }
> - ret = clk_prepare_enable(atmel_port->clk);
> - if (ret) {
> - clk_put(atmel_port->clk);
> - atmel_port->clk = NULL;
> - return ret;
> - }
> - port->uartclk = clk_get_rate(atmel_port->clk);
> - clk_disable_unprepare(atmel_port->clk);
> - /* only enable clock when USART is in use */
> - }
> + port->uartclk = clk_get_rate(atmel_port->clk);
>
> /*
> * Use TXEMPTY for interrupt when rs485 or ISO7816 else TXRDY or
> @@ -2896,14 +2879,23 @@ static int atmel_serial_probe(struct platform_device *pdev)
> atomic_set(&atmel_port->tasklet_shutdown, 0);
> spin_lock_init(&atmel_port->lock_suspended);
>
> + atmel_port->clk = devm_clk_get(&pdev->dev, "usart");
> + if (IS_ERR(atmel_port->clk)) {
> + ret = PTR_ERR(atmel_port->clk);
> + goto err;
> + }
> + ret = clk_prepare_enable(atmel_port->clk);
> + if (ret)
> + goto err;
> +
> ret = atmel_init_port(atmel_port, pdev);
> if (ret)
> - goto err_clear_bit;
> + goto err_clk_disable_unprepare;
>
> atmel_port->gpios = mctrl_gpio_init(&atmel_port->uart, 0);
> if (IS_ERR(atmel_port->gpios)) {
> ret = PTR_ERR(atmel_port->gpios);
> - goto err_clear_bit;
> + goto err_clk_disable_unprepare;
> }
>
> if (!atmel_use_pdc_rx(&atmel_port->uart)) {
> @@ -2912,7 +2904,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
> sizeof(struct atmel_uart_char),
> GFP_KERNEL);
> if (!data)
> - goto err_alloc_ring;
> + goto err_clk_disable_unprepare;
> atmel_port->rx_ring.buf = data;
> }
>
> @@ -2936,12 +2928,6 @@ static int atmel_serial_probe(struct platform_device *pdev)
> device_init_wakeup(&pdev->dev, 1);
> platform_set_drvdata(pdev, atmel_port);
>
> - /*
> - * The peripheral clock has been disabled by atmel_init_port():
> - * enable it before accessing I/O registers
> - */
> - clk_prepare_enable(atmel_port->clk);
> -
> if (rs485_enabled) {
> atmel_uart_writel(&atmel_port->uart, ATMEL_US_MR,
> ATMEL_US_USMODE_NORMAL);
> @@ -2965,12 +2951,8 @@ static int atmel_serial_probe(struct platform_device *pdev)
> err_add_port:
> kfree(atmel_port->rx_ring.buf);
> atmel_port->rx_ring.buf = NULL;
> -err_alloc_ring:
> - if (!uart_console(&atmel_port->uart)) {
> - clk_put(atmel_port->clk);
> - atmel_port->clk = NULL;
> - }
> -err_clear_bit:
> +err_clk_disable_unprepare:
> + clk_disable_unprepare(atmel_port->clk);
> clear_bit(atmel_port->uart.line, atmel_ports_in_use);
> err:
> return ret;
> @@ -3004,8 +2986,6 @@ static int atmel_serial_remove(struct platform_device *pdev)
>
> clear_bit(port->line, atmel_ports_in_use);
>
> - clk_put(atmel_port->clk);
> - atmel_port->clk = NULL;
> pdev->dev.of_node = NULL;
>
> return ret;
Thanks !
next prev parent reply other threads:[~2022-06-17 13:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 14:00 [PATCH v3 0/4] serial: atmel: cleanup code Claudiu Beznea
2022-06-16 14:00 ` [PATCH v3 1/4] tty: serial: atmel: stop using legacy pm ops Claudiu Beznea
2022-06-16 14:00 ` [PATCH v3 2/4] tty: serial: atmel: use devm_clk_get() Claudiu Beznea
2022-06-17 13:06 ` Richard Genoud [this message]
2022-06-16 14:00 ` [PATCH v3 3/4] tty: serial: atmel: remove enable/disable clock due to atmel_console_setup() Claudiu Beznea
2022-06-17 13:06 ` Richard Genoud
2022-06-16 14:00 ` [PATCH v3 4/4] serial: st-asc: remove include of pm_runtime.h Claudiu Beznea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b08857ab-ce3d-d597-b229-1a61b849118d@gmail.com \
--to=richard.genoud@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=patrice.chotard@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®