Re: [PATCH 1/2] misc: qualcomm: QRC driver for Robotic SDK MCU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> ---
>  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





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux