linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	Mark Brown <broonie@kernel.org>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	linux-spi@vger.kernel.org, patches@opensource.cirrus.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 3/4] spi: cs42l43: Make handling missing spk-id GPIOs explicit
Date: Mon, 6 Jan 2025 11:32:12 +0000	[thread overview]
Message-ID: <Z3u/PNryXkda7GyO@opensource.cirrus.com> (raw)
In-Reply-To: <20250104205437.184782-3-krzysztof.kozlowski@linaro.org>

On Sat, Jan 04, 2025 at 09:54:36PM +0100, Krzysztof Kozlowski wrote:
> gpiod_get_array_optional() for spk-id GPIOs can return NULL, if they are
> missing, so do not pass the value to PTR_ERR but instead explicitly
> treat NULL as acceptable condition.  The old code was correct, but
> misleading because PTR_ERR usually is used on errors.
> 
> Reported by Smatch:
>   drivers/spi/spi-cs42l43.c:241 cs42l43_get_speaker_id_gpios() warn: passing zero to 'PTR_ERR'
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
>  drivers/spi/spi-cs42l43.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c
> index ceefc253c549..90180662c4c2 100644
> --- a/drivers/spi/spi-cs42l43.c
> +++ b/drivers/spi/spi-cs42l43.c
> @@ -237,7 +237,9 @@ static int cs42l43_get_speaker_id_gpios(struct cs42l43_spi *priv, int *result)
>  	int i, ret;
>  
>  	descs = gpiod_get_array_optional(priv->dev, "spk-id", GPIOD_IN);
> -	if (IS_ERR_OR_NULL(descs))
> +	if (!descs)
> +		return 0;
> +	else if (IS_ERR_OR_NULL(descs))

Should switch to using just IS_ERR() if adding an explicit case
for the NULL. Otherwise looks good to me.

Thanks,
Charles


  reply	other threads:[~2025-01-06 11:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-04 20:54 [PATCH 1/4] spi: atmel-quadspi: Fix struct atmel_qspi_pcal kerneldoc Krzysztof Kozlowski
2025-01-04 20:54 ` [PATCH 2/4] spi: atmel-quadspi: Fix printed error code during DMA setup Krzysztof Kozlowski
2025-01-04 20:54 ` [PATCH 3/4] spi: cs42l43: Make handling missing spk-id GPIOs explicit Krzysztof Kozlowski
2025-01-06 11:32   ` Charles Keepax [this message]
2025-01-06 12:02     ` Krzysztof Kozlowski
2025-01-04 20:54 ` [PATCH 4/4] spi: cadence-quadspi: Assume device could match via platform Krzysztof Kozlowski
2025-01-06 12:35 ` [PATCH 1/4] spi: atmel-quadspi: Fix struct atmel_qspi_pcal kerneldoc Mark Brown

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=Z3u/PNryXkda7GyO@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=david.rhodes@cirrus.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.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 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).