From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Praveen Talari <quic_ptalari@quicinc.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, devicetree@vger.kernel.org
Cc: psodagud@quicinc.com, djaggi@quicinc.com,
quic_msavaliy@quicinc.com, quic_vtanuku@quicinc.com,
quic_arandive@quicinc.com, quic_mnaresh@quicinc.com,
quic_shazhuss@quicinc.com
Subject: Re: [PATCH v5 4/8] serial: qcom-geni: move resource initialization to separate function
Date: Tue, 3 Jun 2025 15:24:39 +0100 [thread overview]
Message-ID: <0157bafe-fe94-4d57-a3ea-3501b35cc940@linaro.org> (raw)
In-Reply-To: <20250506180232.1299-5-quic_ptalari@quicinc.com>
On 06/05/2025 19:02, Praveen Talari wrote:
> Enhances code readability and future modifications within the new API.
>
> Move the code that handles the actual initialization of resources
> like clock and ICC paths to a separate function, making the
> probe function cleaner.
>
> Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
> ---
> v3 -> v4
> - added version log after ---
>
> v1 -> v2
> - updated subject description.
> - added a new line after function end
> ---
> drivers/tty/serial/qcom_geni_serial.c | 66 ++++++++++++++++-----------
> 1 file changed, 40 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 0293b6210aa6..6ad759146f71 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1588,6 +1588,43 @@ static struct uart_driver qcom_geni_uart_driver = {
> .nr = GENI_UART_PORTS,
> };
>
> +static int geni_serial_resource_init(struct qcom_geni_serial_port *port)
> +{
> + int ret;
> +
> + port->se.clk = devm_clk_get(port->se.dev, "se");
> + if (IS_ERR(port->se.clk)) {
> + ret = PTR_ERR(port->se.clk);
> + dev_err(port->se.dev, "Err getting SE Core clk %d\n", ret);
> + return ret;
> + }
> +
> + ret = geni_icc_get(&port->se, NULL);
> + if (ret)
> + return ret;
> +
> + port->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW;
> + port->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;
> +
> + /* Set BW for register access */
> + ret = geni_icc_set_bw(&port->se);
> + if (ret)
> + return ret;
> +
> + ret = devm_pm_opp_set_clkname(port->se.dev, "se");
> + if (ret)
> + return ret;
> +
> + /* OPP table is optional */
> + ret = devm_pm_opp_of_add_table(port->se.dev);
> + if (ret && ret != -ENODEV) {
> + dev_err(port->se.dev, "invalid OPP table in device tree\n");
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static void qcom_geni_serial_pm(struct uart_port *uport,
> unsigned int new_state, unsigned int old_state)
> {
> @@ -1690,12 +1727,10 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
> port->dev_data = data;
> port->se.dev = &pdev->dev;
> port->se.wrapper = dev_get_drvdata(pdev->dev.parent);
> - port->se.clk = devm_clk_get(&pdev->dev, "se");
> - if (IS_ERR(port->se.clk)) {
> - ret = PTR_ERR(port->se.clk);
> - dev_err(&pdev->dev, "Err getting SE Core clk %d\n", ret);
> +
> + ret = geni_serial_resource_init(port);
> + if (ret)
> return ret;
> - }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!res)
> @@ -1713,17 +1748,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
> return -ENOMEM;
> }
>
> - ret = geni_icc_get(&port->se, NULL);
> - if (ret)
> - return ret;
> - port->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW;
> - port->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW;
> -
> - /* Set BW for register access */
> - ret = geni_icc_set_bw(&port->se);
> - if (ret)
> - return ret;
> -
> port->name = devm_kasprintf(uport->dev, GFP_KERNEL,
> "qcom_geni_serial_%s%d",
> uart_console(uport) ? "console" : "uart", uport->line);
> @@ -1745,16 +1769,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
> if (of_property_read_bool(pdev->dev.of_node, "cts-rts-swap"))
> port->cts_rts_swap = true;
>
> - ret = devm_pm_opp_set_clkname(&pdev->dev, "se");
> - if (ret)
> - return ret;
> - /* OPP table is optional */
> - ret = devm_pm_opp_of_add_table(&pdev->dev);
> - if (ret && ret != -ENODEV) {
> - dev_err(&pdev->dev, "invalid OPP table in device tree\n");
> - return ret;
> - }
> -
> port->private_data.drv = drv;
> uport->private_data = &port->private_data;
> platform_set_drvdata(pdev, port);
> --
> 2.17.1
>
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
next prev parent reply other threads:[~2025-06-03 14:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 18:02 [PATCH v5 0/8] Enable QUPs and Serial on SA8255p Qualcomm platforms Praveen Talari
2025-05-06 18:02 ` [PATCH v5 1/8] dt-bindings: serial: describe SA8255p Praveen Talari
2025-05-06 18:23 ` Krzysztof Kozlowski
2025-05-08 5:45 ` Praveen Talari
2025-05-09 4:32 ` Praveen Talari
2025-05-16 6:36 ` Praveen Talari
2025-05-28 5:10 ` Praveen Talari
2025-05-06 18:02 ` [PATCH v5 2/8] dt-bindings: qcom: geni-se: " Praveen Talari
2025-05-06 18:25 ` Krzysztof Kozlowski
2025-05-06 18:02 ` [PATCH v5 3/8] soc: qcom: geni-se: Enable QUPs on SA8255p Qualcomm platforms Praveen Talari
2025-06-03 14:21 ` Bryan O'Donoghue
2025-06-04 7:28 ` Praveen Talari
2025-06-04 8:23 ` Bryan O'Donoghue
2025-05-06 18:02 ` [PATCH v5 4/8] serial: qcom-geni: move resource initialization to separate function Praveen Talari
2025-06-03 14:24 ` Bryan O'Donoghue [this message]
2025-05-06 18:02 ` [PATCH v5 5/8] serial: qcom-geni: move resource control logic to separate functions Praveen Talari
2025-06-03 14:28 ` Bryan O'Donoghue
2025-06-03 14:29 ` Bryan O'Donoghue
2025-06-03 14:46 ` Bryan O'Donoghue
2025-06-04 14:09 ` Praveen Talari
2025-06-04 16:10 ` Praveen Talari
2025-05-06 18:02 ` [PATCH v5 6/8] serial: qcom-geni: move clock-rate logic to separate function Praveen Talari
2025-06-03 14:41 ` Bryan O'Donoghue
2025-06-04 17:11 ` Praveen Talari
2025-06-04 23:49 ` Bryan O'Donoghue
2025-06-05 3:34 ` Praveen Talari
2025-05-06 18:02 ` [PATCH v5 7/8] serial: qcom-geni: Enable PM runtime for serial driver Praveen Talari
2025-06-03 14:42 ` Bryan O'Donoghue
2025-05-06 18:02 ` [PATCH v5 8/8] serial: qcom-geni: Enable Serial on SA8255p Qualcomm platforms Praveen Talari
2025-06-03 14:47 ` Bryan O'Donoghue
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=0157bafe-fe94-4d57-a3ea-3501b35cc940@linaro.org \
--to=bryan.odonoghue@linaro.org \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djaggi@quicinc.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=psodagud@quicinc.com \
--cc=quic_arandive@quicinc.com \
--cc=quic_mnaresh@quicinc.com \
--cc=quic_msavaliy@quicinc.com \
--cc=quic_ptalari@quicinc.com \
--cc=quic_shazhuss@quicinc.com \
--cc=quic_vtanuku@quicinc.com \
--cc=robh@kernel.org \
/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