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]
Message-ID: <ZF6NbHVD4ay2S83R@surfacebook>
Date:   Fri, 12 May 2023 22:03:08 +0300
From:   andy.shevchenko@...il.com
To:     Charles Keepax <ckeepax@...nsource.cirrus.com>
Cc:     broonie@...nel.org, lee@...nel.org, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
        tglx@...utronix.de, maz@...nel.org, linus.walleij@...aro.org,
        vkoul@...nel.org, lgirdwood@...il.com,
        yung-chuan.liao@...ux.intel.com, sanyog.r.kale@...el.com,
        pierre-louis.bossart@...ux.intel.com, alsa-devel@...a-project.org,
        patches@...nsource.cirrus.com, devicetree@...r.kernel.org,
        linux-gpio@...r.kernel.org, linux-spi@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 09/10] spi: cs42l43: Add SPI controller support

Fri, May 12, 2023 at 01:28:37PM +0100, Charles Keepax kirjoitti:
> From: Lucas Tanure <tanureal@...nsource.cirrus.com>
> 
> The CS42L43 is an audio CODEC with integrated MIPI SoundWire interface
> (Version 1.2.1 compliant), I2C, SPI, and I2S/TDM interfaces designed
> for portable applications. It provides a high dynamic range, stereo
> DAC for headphone output, two integrated Class D amplifiers for
> loudspeakers, and two ADCs for wired headset microphone input or
> stereo line input. PDM inputs are provided for digital microphones.
> 
> The SPI component incorporates a SPI controller interface for
> communication with other peripheral components.

...

> +#define CS42L43_SPI_ROOT_HZ		40000000

HZ_PER_MHZ?

...

> +		const u8 *block = min_t(const u8 *, buf + CS42L43_FIFO_SIZE, end);

Wouldn't min() work?

...

> +		for (; buf < block - (sizeof(u32) - 1); buf += sizeof(u32))
> +			regmap_write(regmap, CS42L43_TX_DATA, *(const u32 *)buf);

This casting might be potentially wrong taking alignment into consideration.
Perhaps you need get_unaligned(). Also here the return value isn't checked,
while in the read it is.

...

> +		const u8 *block = min_t(const u8 *, buf + CS42L43_FIFO_SIZE, end);

min() ?

...

> +		for (; buf < block - (sizeof(u32) - 1); buf += sizeof(u32)) {
> +			ret = regmap_read(regmap, CS42L43_RX_DATA, (u32 *)buf);

put_unaligned() ?

> +			if (ret)
> +				return ret;
> +		}

...

> +static int cs42l43_prepare_transfer_hardware(struct spi_controller *ctlr)
> +{
> +	struct cs42l43_spi *priv = spi_controller_get_devdata(ctlr);
> +	int ret;
> +
> +	ret = regmap_write(priv->regmap, CS42L43_BLOCK_EN2, CS42L43_SPI_MSTR_EN_MASK);
> +	if (ret) {
> +		dev_err(priv->dev, "Failed to enable SPI controller: %d\n", ret);

> +		return ret;
> +	}
> +
> +	return 0;

	return ret; ?

> +}
> +
> +static int cs42l43_unprepare_transfer_hardware(struct spi_controller *ctlr)
> +{
> +	struct cs42l43_spi *priv = spi_controller_get_devdata(ctlr);
> +	int ret;
> +
> +	ret = regmap_write(priv->regmap, CS42L43_BLOCK_EN2, 0);
> +	if (ret) {
> +		dev_err(priv->dev, "Failed to disable SPI controller: %d\n", ret);
> +		return ret;
> +	}
> +
> +	return 0;

Ditto.

> +}

...

> +	if (is_of_node(dev_fwnode(cs42l43->dev))) {
> +		priv->ctlr->dev.fwnode =
> +			fwnode_get_named_child_node(dev_fwnode(cs42l43->dev), "spi");
> +		priv->ctlr->dev.of_node = to_of_node(dev_fwnode(&priv->ctlr->dev));
> +	} else {
> +		priv->ctlr->dev.fwnode = dev_fwnode(priv->dev);
> +	}

Can you use device_set_node() once you have an fwnode that needs to be passed?

...

> +	priv->ctlr->mode_bits = SPI_3WIRE | SPI_CPHA | SPI_CPOL;

SPI_MODE_X_MASK

...

> +static struct platform_driver cs42l43_spi_driver = {
> +	.driver = {
> +		.name	= "cs42l43-spi",
> +	},

> +

Unneeded blank line.

> +	.probe		= cs42l43_spi_probe,
> +	.remove		= cs42l43_spi_remove,
> +};

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ