Fri, May 12, 2023 at 01:28:37PM +0100, Charles Keepax kirjoitti: > From: Lucas Tanure <tanureal@xxxxxxxxxxxxxxxxxxxxx> > > 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