All of lore.kernel.org
 help / color / mirror / Atom feed
From: andy.shevchenko@gmail.com
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: broonie@kernel.org, lee@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	linus.walleij@linaro.org, vkoul@kernel.org, lgirdwood@gmail.com,
	yung-chuan.liao@linux.intel.com, sanyog.r.kale@intel.com,
	pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
	devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 5/6] spi: cs42l43: Add SPI controller support
Date: Thu, 18 Jan 2024 19:06:13 +0200	[thread overview]
Message-ID: <ZalahZkCrBm-BXwz@surfacebook.localdomain> (raw)
In-Reply-To: <20230804104602.395892-6-ckeepax@opensource.cirrus.com>

Fri, Aug 04, 2023 at 11:46:01AM +0100, Charles Keepax kirjoitti:
> From: Lucas Tanure <tanureal@opensource.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.

...

> +		while (buf < block) {
> +			const u8 *word = min(buf + sizeof(u32), block);
> +			int pad = (buf + sizeof(u32)) - word;
> +
> +			while (buf < word) {
> +				val >>= BITS_PER_BYTE;
> +				val |= FIELD_PREP(GENMASK(31, 24), *buf);
> +
> +				buf++;
> +			}

Is this a reinvented way of get_unaligned_*() APIs?

> +			val >>= pad * BITS_PER_BYTE;
> +
> +			regmap_write(regmap, CS42L43_TX_DATA, val);
> +		}

...

> +			while (buf < word) {
> +				*buf = FIELD_GET(GENMASK(7, 0), val);
> +
> +				val >>= BITS_PER_BYTE;
> +				buf++;
> +			}

put_unaligned_*() ?

...

> +	/* select another internal CS, which doesn't exist, so CS 0 is not used */
> +	if (spi_get_csgpiod(spi, 0))
> +		spi_config1 |= 1 << CS42L43_SPI_SS_SEL_SHIFT;

BIT() ?

> +	if (spi->mode & SPI_CPOL)
> +		spi_config1 |= CS42L43_SPI_CPOL_MASK;
> +	if (spi->mode & SPI_CPHA)
> +		spi_config1 |= CS42L43_SPI_CPHA_MASK;
> +	if (spi->mode & SPI_3WIRE)
> +		spi_config1 |= CS42L43_SPI_THREE_WIRE_MASK;

...

> +	if (is_of_node(fwnode))
> +		fwnode = fwnode_get_named_child_node(fwnode, "spi");

You can actually drop these is_of_node() tests and use another variable. In
ACPI there can't be child node in small letters.

But main problem here (and in another driver where the similar is used) that
you bumped reference count for fwnode. I haven't seen where you drop it back.
Have you tested rmmod/modprobe in a loop?

...

> +	devm_pm_runtime_enable(priv->dev);

No error check? Why?

...

> +	ret = devm_spi_register_controller(priv->dev, priv->ctlr);
> +	if (ret) {
> +		pm_runtime_disable(priv->dev);

Ah! Are you sure you properly simulated faults when testing this code?

> +		dev_err(priv->dev, "Failed to register SPI controller: %d\n", ret);
> +	}
> +
> +	return ret;

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2024-01-18 17:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-04 10:45 [PATCH v7 0/6] Add cs42l43 PC focused SoundWire CODEC Charles Keepax
2023-08-04 10:45 ` [PATCH v7 1/6] soundwire: bus: Allow SoundWire peripherals to register IRQ handlers Charles Keepax
2024-01-18 16:16   ` andy.shevchenko
2023-08-04 10:45 ` [PATCH v7 2/6] dt-bindings: mfd: cirrus,cs42l43: Add initial DT binding Charles Keepax
2023-08-04 10:45 ` [PATCH v7 3/6] mfd: cs42l43: Add support for cs42l43 core driver Charles Keepax
2023-08-29 14:06   ` Guenter Roeck
2023-08-29 16:22     ` Charles Keepax
2023-08-31 13:54     ` Guenter Roeck
2024-01-18 16:42   ` andy.shevchenko
2024-01-19 11:32     ` Charles Keepax
2024-01-19 16:01       ` Andy Shevchenko
2023-08-04 10:46 ` [PATCH v7 4/6] pinctrl: cs42l43: Add support for the cs42l43 Charles Keepax
2024-01-18 16:56   ` andy.shevchenko
2023-08-04 10:46 ` [PATCH v7 5/6] spi: cs42l43: Add SPI controller support Charles Keepax
2024-01-18 17:06   ` andy.shevchenko [this message]
2024-01-19 11:49     ` Charles Keepax
2024-01-19 16:09       ` Andy Shevchenko
2024-01-31 15:41       ` Charles Keepax
2024-01-31 20:17         ` Andy Shevchenko
2023-08-04 10:46 ` [PATCH v7 6/6] ASoC: cs42l43: Add support for the cs42l43 Charles Keepax
2024-01-18 17:41   ` andy.shevchenko
2024-01-18 18:11     ` Mark Brown
2024-01-18 20:46       ` Andy Shevchenko
2024-01-18 22:07         ` Mark Brown
2024-01-19 16:13           ` Andy Shevchenko
2024-01-19 16:59     ` Charles Keepax
2024-01-19 17:24       ` Andy Shevchenko
2023-08-17 11:09 ` (subset) [PATCH v7 0/6] Add cs42l43 PC focused SoundWire CODEC Lee Jones
2023-08-17 11:26   ` Lee Jones
2023-08-18 15:40 ` [GIT PULL] Immutable branch between MFD, Pinctrl and soundwire due for the v6.6 merge window Lee Jones
2023-08-18 22:39 ` (subset) [PATCH v7 0/6] Add cs42l43 PC focused SoundWire CODEC Mark Brown
2023-08-22 16:33 ` Mark Brown
2024-01-18 16:58 ` andy.shevchenko

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=ZalahZkCrBm-BXwz@surfacebook.localdomain \
    --to=andy.shevchenko@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=sanyog.r.kale@intel.com \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.