From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Yinbo Zhu <zhuyinbo@loongson.cn>, Mark Brown <broonie@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Jianmin Lv <lvjianmin@loongson.cn>,
wanghongliang@loongson.cn, Liu Peibao <liupeibao@loongson.cn>,
loongson-kernel@lists.loongnix.cn
Subject: Re: [PATCH v6 2/2] spi: loongson: add bus driver for the loongson spi controller
Date: Sun, 2 Apr 2023 12:04:00 +0200 [thread overview]
Message-ID: <9fcb66fa-aadc-8660-bd4a-452c4811ced9@linaro.org> (raw)
In-Reply-To: <20230401095652.17364-3-zhuyinbo@loongson.cn>
On 01/04/2023 11:56, Yinbo Zhu wrote:
> This bus driver supports the Loongson spi hardware controller in the
> Loongson platforms and supports to use DTS and PCI framework to
> register spi device resources.
>
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
...
> +
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/interrupt.h>
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/spi/spi.h>
> +#include <linux/clk.h>
> +#include <linux/io.h>
> +
> +#include "spi-loongson.h"
> +
> +static inline void loongson_spi_write_reg(struct loongson_spi *spi, unsigned char reg,
> + unsigned char data)
> +{
> + writeb(data, spi->base + reg);
This wrapper does not simplify anything.
> +}
> +
> +static inline char loongson_spi_read_reg(struct loongson_spi *spi, unsigned char reg)
> +{
> + return readb(spi->base + reg);
Neither this one.
> +}
> +
> +static void loongson_spi_set_cs(struct spi_device *spi, bool val)
> +{
> + int cs;
> + struct loongson_spi *loongson_spi = spi_master_get_devdata(spi->master);
> +
(...)
> +
> +static int __init loongson_spi_pci_init(void)
> +{
> + int ret;
> +
> + ret = pci_register_driver(&loongson_spi_pci_driver);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static void __exit loongson_spi_pci_exit(void)
> +{
> + pci_unregister_driver(&loongson_spi_pci_driver);
> +}
> +
> +module_init(loongson_spi_pci_init);
> +module_exit(loongson_spi_pci_exit);
module_xxx_driver?
> +
> +MODULE_DESCRIPTION("Loongson spi pci driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/spi/spi-loongson-plat.c b/drivers/spi/spi-loongson-plat.c
> new file mode 100644
> index 000000000000..8f4aa70168f3
> --- /dev/null
> +++ b/drivers/spi/spi-loongson-plat.c
> @@ -0,0 +1,66 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +// Platform driver for Loongson SPI Support
> +// Copyright (C) 2023 Loongson Technology Corporation Limited
> +
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +
> +#include "spi-loongson.h"
> +
> +static int loongson_spi_platform_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct resource *res;
> + int ret;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (res == NULL) {
> + dev_err(dev, "cannot get io resource memory\n");
> + return -ENOENT;
> + }
> +
> + ret = loongson_spi_init_master(dev, res);
> + if (ret)
> + dev_err(dev, "failed to initialize master\n");
> +
> + return ret;
> +}
> +
> +static const struct of_device_id loongson_spi_id_table[] = {
> + { .compatible = "loongson,ls2k-spi", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, loongson_spi_id_table);
> +
> +static struct platform_driver loongson_spi_plat_driver = {
> + .probe = loongson_spi_platform_probe,
> + .driver = {
> + .name = "loongson-spi",
> + .owner = THIS_MODULE,
Really? We get rid of it years ago. I bet you did not run coccicheck,
smatch, sparse...
> + .bus = &platform_bus_type,
> + .pm = &loongson_spi_dev_pm_ops,
> + .of_match_table = loongson_spi_id_table,
> + },
> +};
> +
> +static int __init loongson_spi_plat_init(void)
> +{
> + int ret;
> +
> + ret = platform_driver_register(&loongson_spi_plat_driver);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static void __exit loongson_spi_plat_exit(void)
> +{
> + platform_driver_unregister(&loongson_spi_plat_driver);
> +}
> +
> +module_init(loongson_spi_plat_init);
> +module_exit(loongson_spi_plat_exit);
module_platform_driver.
> +
> +MODULE_DESCRIPTION("Loongson spi platform driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/spi/spi-loongson.h b/drivers/spi/spi-loongson.h
> new file mode 100644
> index 000000000000..44818340188d
> --- /dev/null
> +++ b/drivers/spi/spi-loongson.h
> @@ -0,0 +1,41 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/* Header File for Loongson SPI Driver. */
> +/* Copyright (C) 2023 Loongson Technology Corporation Limited */
> +
> +#ifndef __LINUX_SPI_LOONGSON_H
> +#define __LINUX_SPI_LOONGSON_H
> +
> +#define LOONGSON_SPI_SPCR_REG 0x00
There is just one space after #define.
Best regards,
Krzysztof
next prev parent reply other threads:[~2023-04-02 10:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 9:56 [PATCH v6 0/2] spi: loongson: add bus driver for the loongson spi Yinbo Zhu
2023-04-01 9:56 ` [PATCH v6 1/2] dt-bindings: spi: add " Yinbo Zhu
2023-04-02 9:58 ` Krzysztof Kozlowski
2023-04-03 7:37 ` zhuyinbo
2023-04-01 9:56 ` [PATCH v6 2/2] spi: loongson: add bus driver for the loongson spi controller Yinbo Zhu
2023-04-02 10:04 ` Krzysztof Kozlowski [this message]
2023-04-02 15:41 ` Mark Brown
2023-04-03 9:35 ` zhuyinbo
2023-04-02 11:44 ` Christophe JAILLET
2023-04-03 7:44 ` zhuyinbo
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=9fcb66fa-aadc-8660-bd4a-452c4811ced9@linaro.org \
--to=krzysztof.kozlowski@linaro.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=liupeibao@loongson.cn \
--cc=loongson-kernel@lists.loongnix.cn \
--cc=lvjianmin@loongson.cn \
--cc=robh+dt@kernel.org \
--cc=wanghongliang@loongson.cn \
--cc=zhuyinbo@loongson.cn \
/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).