On Tue, Dec 08, 2020 at 03:44:24PM +0800, Qing Zhang wrote:Replace all with //
v2:You say this but...
- keep Kconfig and Makefile sorted
- make the entire comment a C++ one so things look more intentional
+++ b/drivers/spi/spi-ls7a.c...this is still a mix of C and C++ comments?
@@ -0,0 +1,324 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Loongson LS7A SPI Controller driver
+ *
+ * Copyright (C) 2020 Loongson Technology Corporation Limited
+ */
static void ls7a_spi_set_cs(struct spi_device *spi, bool enable)
+static int set_cs(struct ls7a_spi *ls7a_spi, struct spi_device *spi, int val)Why not just expose this to the core and let it handle things?
+{
+ int cs = ls7a_spi_read_reg(ls7a_spi, SFCS) & ~(0x11 << spi->chip_select);
+
+ if (spi->mode & SPI_CS_HIGH)
+ val = !val;
+ ls7a_spi_write_reg(ls7a_spi, SFCS,
+ (val ? (0x11 << spi->chip_select):(0x1 << spi->chip_select)) | cs);
+
+ return 0;
+}
Please also write normal conditional statements to improve legibility.
There's quite a lot of coding style issues in this with things like
missing spaces
+ if (t) {If one branch of the conditional has braces please use them on both to
+ hz = t->speed_hz;
+ if (!hz)
+ hz = spi->max_speed_hz;
+ } else
+ hz = spi->max_speed_hz;
improve legibility.
+static int ls7a_spi_transfer_one_message(struct spi_master *master,I don't understand why the driver is implementing transfer_one_message()
+ struct spi_message *m)
- it looks like this is just open coding the standard loop that the
framework provides and should just be using transfer_one().
+ r = ls7a_spi_write_read(spi, t);The indentation here isn't following the kernel coding style.
+ if (r < 0) {
+ status = r;
+ goto error;
+ }
+ master = spi_alloc_master(&pdev->dev, sizeof(struct ls7a_spi));Why not use devm_ here?
+ if (!master)
+ return -ENOMEM;
+ ret = devm_spi_register_master(dev, master);The driver uses devm_spi_register_master() here but...
+ if (ret)
+ goto err_free_master;
+static void ls7a_spi_pci_remove(struct pci_dev *pdev)...releases the PCI regions in the remove() function before the SPI
+{
+ struct spi_master *master = pci_get_drvdata(pdev);
+ struct ls7a_spi *spi;
+
+ spi = spi_master_get_devdata(master);
+ if (!spi)
+ return;
+
+ pci_release_regions(pdev);
controller is freed so the controller could still be active.