linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Qing Zhang <zhangqing@loongson.cn>
Cc: Rob Herring <robh+dt@kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	linux-spi@vger.kernel.org, Huacai Chen <chenhc@lemote.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	devicetree@vger.kernel.org, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org, gaojuxin@loongson.cn,
	yangtiezhu@loongson.cn
Subject: Re: [PATCH v2 1/4] spi: LS7A: Add Loongson LS7A SPI controller driver support
Date: Tue, 8 Dec 2020 13:56:44 +0000	[thread overview]
Message-ID: <20201208135644.GC6686@sirena.org.uk> (raw)
In-Reply-To: <1607413467-17698-1-git-send-email-zhangqing@loongson.cn>

[-- Attachment #1: Type: text/plain, Size: 2508 bytes --]

On Tue, Dec 08, 2020 at 03:44:24PM +0800, Qing Zhang wrote:

> v2:
> - keep Kconfig and Makefile sorted
> - make the entire comment a C++ one so things look more intentional

You say this but...

> +++ b/drivers/spi/spi-ls7a.c
> @@ -0,0 +1,324 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Loongson LS7A SPI Controller driver
> + *
> + * Copyright (C) 2020 Loongson Technology Corporation Limited
> + */

...this is still a mix of C and C++ comments?

> +static int set_cs(struct ls7a_spi *ls7a_spi, struct spi_device  *spi, int val)
> +{
> +	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;
> +}

Why not just expose this to the core and let it handle things?  

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) {
> +		hz = t->speed_hz;
> +		if (!hz)
> +			hz = spi->max_speed_hz;
> +	} else
> +		hz = spi->max_speed_hz;

If one branch of the conditional has braces please use them on both to
improve legibility.

> +static int  ls7a_spi_transfer_one_message(struct spi_master *master,
> +                                         struct spi_message *m)

I don't understand why the driver is implementing transfer_one_message()
- 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);
> +		if (r < 0) {
> +			status = r;
> +			goto error;
> +			}

The indentation here isn't following the kernel coding style.

> +	master = spi_alloc_master(&pdev->dev, sizeof(struct ls7a_spi));
> +	if (!master)
> +		return -ENOMEM;

Why not use devm_ here?

> +	ret = devm_spi_register_master(dev, master);
> +	if (ret)
> +		goto err_free_master;

The driver uses devm_spi_register_master() here but...

> +static void ls7a_spi_pci_remove(struct pci_dev *pdev)
> +{
> +	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);

...releases the PCI regions in the remove() function before the SPI
controller is freed so the controller could still be active.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2020-12-08 13:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08  7:44 [PATCH v2 1/4] spi: LS7A: Add Loongson LS7A SPI controller driver support Qing Zhang
2020-12-08  7:44 ` [PATCH v2 2/4] spi: Add devicetree bindings documentation for Loongson SPI Qing Zhang
2020-12-08  7:49   ` Jiaxun Yang
2020-12-08  8:40   ` Sergei Shtylyov
2020-12-08 10:47     ` zhangqing
2020-12-08 13:58       ` Mark Brown
2020-12-09  1:21         ` zhangqing
2020-12-08 14:48       ` Sergei Shtylyov
2020-12-09  1:16         ` zhangqing
2020-12-08  7:44 ` [PATCH v2 3/4] MIPS: Loongson64: DTS: Add SPI support to LS7A Qing Zhang
2020-12-08  8:15   ` Jiaxun Yang
2020-12-08  7:44 ` [PATCH v2 4/4] MIPS: Loongson: Enable Loongson LS7A SPI in loongson3_defconfig Qing Zhang
2020-12-08 12:26 ` [PATCH v2 1/4] spi: LS7A: Add Loongson LS7A SPI controller driver support kernel test robot
2020-12-08 13:56 ` Mark Brown [this message]
2020-12-09  7:24   ` zhangqing
2020-12-09 11:59     ` Mark Brown
2020-12-08 21:36 ` kernel test robot

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=20201208135644.GC6686@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=chenhc@lemote.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gaojuxin@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhangqing@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).