lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 8 Dec 2020 13:56:44 +0000
From:   Mark Brown <broonie@...nel.org>
To:     Qing Zhang <zhangqing@...ngson.cn>
Cc:     Rob Herring <robh+dt@...nel.org>,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        linux-spi@...r.kernel.org, Huacai Chen <chenhc@...ote.com>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        devicetree@...r.kernel.org, linux-mips@...r.kernel.org,
        linux-kernel@...r.kernel.org, gaojuxin@...ngson.cn,
        yangtiezhu@...ngson.cn
Subject: Re: [PATCH v2 1/4] spi: LS7A: Add Loongson LS7A SPI controller
 driver support

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.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ