From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Canfeng Zhuang <quic_czhuang@quicinc.com>,
Derek Kiernan <derek.kiernan@amd.com>,
Dragan Cvetic <dragan.cvetic@amd.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH 1/2] misc: qualcomm: QRC driver for Robotic SDK MCU
Date: Sun, 3 Mar 2024 20:11:18 +0100 [thread overview]
Message-ID: <0c089229-237a-43c3-a1ba-8900101aa849@linaro.org> (raw)
In-Reply-To: <20240304-qcom_qrc-v1-1-2a709f95fd61@quicinc.com>
On 03/03/2024 17:53, Canfeng Zhuang wrote:
> QRC Driver support functions:
> - Read data from serial device port.
> - Write data to serial device port.
> - Pin control reset robotic controller.
>
> Signed-off-by: Canfeng Zhuang <quic_czhuang@quicinc.com>
> ---
> drivers/misc/Kconfig | 1 +
> drivers/misc/Makefile | 1 +
> drivers/misc/qrc/Kconfig | 16 ++
> drivers/misc/qrc/Makefile | 6 +
> drivers/misc/qrc/qrc_core.c | 336 ++++++++++++++++++++++++++++++++++++++++++
> drivers/misc/qrc/qrc_core.h | 143 ++++++++++++++++++
> drivers/misc/qrc/qrc_uart.c | 345 ++++++++++++++++++++++++++++++++++++++++++++
> 7 files changed, 848 insertions(+)
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 4fb291f0bf7c..a43108af6fde 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -591,4 +591,5 @@ source "drivers/misc/cardreader/Kconfig"
> source "drivers/misc/uacce/Kconfig"
> source "drivers/misc/pvpanic/Kconfig"
> source "drivers/misc/mchp_pci1xxxx/Kconfig"
> +source "drivers/misc/qrc/Kconfig"
> endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index ea6ea5bbbc9c..ab3b2c4d99fa 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -68,3 +68,4 @@ obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o
> obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o
> obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o
> obj-$(CONFIG_NSM) += nsm.o
> +obj-$(CONFIG_QCOM_QRC) += qrc/
> diff --git a/drivers/misc/qrc/Kconfig b/drivers/misc/qrc/Kconfig
> new file mode 100644
> index 000000000000..994985d7c320
> --- /dev/null
> +++ b/drivers/misc/qrc/Kconfig
> @@ -0,0 +1,16 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# QRC device driver configuration
> +#
> +
> +menu "QCOM QRC device driver"
> +
> +config QCOM_QRC
> + tristate "QCOM QRC device driver for Robotic SDK MCU"
> + help
> + This kernel configuration is used to enable robotic controller
> + device driver. Say M here if you want to enable robotic
> + controller device driver.
> + When in doubt, say N.
> +
> +endmenu
> diff --git a/drivers/misc/qrc/Makefile b/drivers/misc/qrc/Makefile
> new file mode 100644
> index 000000000000..da2cf81f3c59
> --- /dev/null
> +++ b/drivers/misc/qrc/Makefile
> @@ -0,0 +1,6 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Makefile for the QRC bus specific drivers.
QRC bus? Nothing anywhere suggested this is a bus.
Limited review because this really looks like some vendor code, not
cleaned for upstream submission.
> +
> +
> +obj-$(CONFIG_QCOM_QRC) += qrc_core.o qrc_uart.o
...
> +
> +static int qrcuart_config(struct qrc_dev *dev)
> +{
> + /*baudrate,wordlength ... config*/
> + return 0;
> +}
> +
> +static struct qrc_device_ops qrcuart_qrc_ops = {
What is this and why do you need it? Don't define your ops without need.
Just call functions directly.
> + .qrcops_open = qrcuart_open,
> + .qrcops_close = qrcuart_close,
> + .qrcops_init = qrcuart_init,
> + .qrcops_uninit = qrcuart_uninit,
> + .qrcops_xmit = qrcuart_xmit,
> + .qrcops_receive = qrcuart_receive,
> + .qrcops_config = qrcuart_config,
> + .qrcops_setup = qrcuart_setup,
> + .qrcops_data_status = qrcuart_data_status,
> + .qrcops_data_clean = qrcuart_data_clean,
> +};
> +
> +static int qrcuart_setup(struct qrc_dev *dev)
> +{
> + dev->qrc_ops = &qrcuart_qrc_ops;
> + return 0;
> +}
> +
> +static int qrc_uart_probe(struct serdev_device *serdev)
> +{
> + struct qrc_dev *qdev;
> + struct qrcuart *qrc;
> + int ret = 0;
> +
> + qrc = kmalloc(sizeof(*qrc), GFP_KERNEL);
> + if (!qrc)
> + return -ENOMEM;
> + qdev = kmalloc(sizeof(*qdev), GFP_KERNEL);
Just use devm*. What is this code? Ancient vendor, 20 year old stuff?
> + if (!qdev) {
> + kfree(qrc);
> + return -ENOMEM;
> + }
> + qdev->dev = &serdev->dev;
> + qrc_set_data(qdev, qrc);
> +
> + qrc->qrc_dev = qdev;
> + qrc->serdev = serdev;
> + spin_lock_init(&qrc->lock);
> + INIT_WORK(&qrc->tx_work, qrcuart_transmit);
> + qrcuart_setup(qdev);
> + ret = qrcuart_init(qdev);
> + if (ret) {
> + dev_err(qdev->dev, "qrcuart: Fail to init qrc structure\n");
> + kfree(qdev);
> + kfree(qrc);
> + return ret;
> + }
> + serdev_device_set_drvdata(serdev, qrc);
> + serdev_device_set_client_ops(serdev, &qrc_serdev_ops);
> +
> + ret = serdev_device_open(serdev);
> + if (ret) {
> + dev_err(qdev->dev, "qrcuart :Unable to open device\n");
Whitespace typos.
> + goto free;
> + }
> + serdev_device_close(serdev);
> + qrc->is_open = false;
> +
> + ret = qrc_register_device(qdev, &serdev->dev);
> +
> + if (ret) {
> + dev_err(qdev->dev, "qrcuart: Unable to register qrc device\n");
> + cancel_work_sync(&qrc->tx_work);
> + goto free;
> + }
> +
> + return 0;
> +
> +free:
free or uninint? Your error handling is messy.
> + qrcuart_uninit(qdev);
> + kfree(qdev);
> + kfree(qrc);
> + return ret;
> +}
> +
> +static void qrc_uart_remove(struct serdev_device *serdev)
> +{
> + struct qrcuart *qrc = serdev_device_get_drvdata(serdev);
> +
> + if (qrc->is_open)
> + serdev_device_close(serdev);
> +
> + qrcuart_uninit(qrc->qrc_dev);
> + cancel_work_sync(&qrc->tx_work);
> + qrc_unregister(qrc->qrc_dev);
> + kfree(qrc->qrc_dev);
> + kfree(qrc);
> + dev_info(&serdev->dev, "qrcuart drv removed\n");
Drop such simple function entry/exit messages. Not needed and not helpful.
> +}
> +
> +static const struct of_device_id qrc_uart_of_match[] = {
> + { .compatible = "qcom,qrc-uart", },
> + {}
> +};
> +
> +MODULE_DEVICE_TABLE(of, qrc_uart_of_match);
> +
> +static struct serdev_device_driver qrc_uart_driver = {
> + .probe = qrc_uart_probe,
> + .remove = qrc_uart_remove,
> + .driver = {
> + .name = QRCUART_DRV_NAME,
> + .of_match_table = of_match_ptr(qrc_uart_of_match),
Drop of_match_ptr. You have warnings here.
> + },
> +};
> +
> +module_serdev_device_driver(qrc_uart_driver);
> +
> +/**********************************************/
Drop
> +
> +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. QRC Uart Driver");
> +MODULE_LICENSE("GPL");
>
Best regards,
Krzysztof
next prev parent reply other threads:[~2024-03-03 19:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-03 16:53 [PATCH 0/2] QCOM QRC device driver Canfeng Zhuang
2024-03-03 16:53 ` [PATCH 1/2] misc: qualcomm: QRC driver for Robotic SDK MCU Canfeng Zhuang
2024-03-03 17:17 ` Greg Kroah-Hartman
2024-03-03 19:11 ` Krzysztof Kozlowski [this message]
2024-03-03 22:55 ` kernel test robot
2024-03-03 23:29 ` kernel test robot
2024-03-04 0:41 ` kernel test robot
2024-03-03 16:53 ` [PATCH 2/2] dt-bindings: misc: merge qcom,qrc Canfeng Zhuang
2024-03-03 19:07 ` Krzysztof Kozlowski
2024-03-04 19:35 ` [PATCH 0/2] QCOM QRC device driver Bjorn Andersson
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=0c089229-237a-43c3-a1ba-8900101aa849@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=andersson@kernel.org \
--cc=arnd@arndb.de \
--cc=conor+dt@kernel.org \
--cc=derek.kiernan@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dragan.cvetic@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_czhuang@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.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;
as well as URLs for NNTP newsgroup(s).