From patchwork Sun Jan 12 19:06:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 239512 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Sun, 12 Jan 2020 12:06:12 -0700 Subject: [PATCH 21/33] sandbox: sound: Handle errors better in sound_beep() In-Reply-To: <20200112190624.79077-1-sjg@chromium.org> References: <20200112190624.79077-1-sjg@chromium.org> Message-ID: <20200112120216.21.I1b9a34b646b3a92f9b3c31b01af1ecdb1f6757cd@changeid> At present an error does not stop the sound-output loop. This is incorrect since nothing can be gained by trying to continue. Fix it. Signed-off-by: Simon Glass --- drivers/sound/sound-uclass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/sound/sound-uclass.c b/drivers/sound/sound-uclass.c index c213472d60..bada0c2ba5 100644 --- a/drivers/sound/sound-uclass.c +++ b/drivers/sound/sound-uclass.c @@ -97,11 +97,14 @@ int sound_beep(struct udevice *dev, int msecs, int frequency_hz) sound_create_square_wave(i2s_uc_priv->samplingrate, data, data_size, frequency_hz, i2s_uc_priv->channels); + ret = 0; while (msecs >= 1000) { ret = sound_play(dev, data, data_size); + if (ret) + break; msecs -= 1000; } - if (msecs) { + if (!ret && msecs) { unsigned long size = (data_size * msecs) / (sizeof(int) * 1000);