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: 1221853 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=fTcP8/aO; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47wmX144Frz9s4Y for ; Mon, 13 Jan 2020 06:10:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E7EF281821; Sun, 12 Jan 2020 20:07:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="fTcP8/aO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D2981817E8; Sun, 12 Jan 2020 20:07:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0A944804C1 for ; Sun, 12 Jan 2020 20:07:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id b10so7246951iof.11 for ; Sun, 12 Jan 2020 11:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fYUg8p5hlkO0pbM98HYh4/DeGc1oskvZ1HrFXt/U91g=; b=fTcP8/aOZoDbKa5/GaqBObrRHRBYph8SLbq1nTBhTOLqwk9S/lQTJuR2J4uh+5GRPc Bnn3aieZhX5Ku00jcg7zNgnG626tzaRyeheLAkhFs1qnVbLAivX3kNXUrWH6uCPVNPNk 73Vf7fK0JXE6wXyCBrAGNkLtswAwLjUfDN4Ho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fYUg8p5hlkO0pbM98HYh4/DeGc1oskvZ1HrFXt/U91g=; b=BLtf/Gpe+3oWPJMdl1DIHt4BjzZbaZMmUvcgnZZGYSyORt9zTkLHctBuuSBW0qKmkm RYX4MSNdvpJV9Op4jnJBpEvXsLYYPv1xK7FlifWw4V+bxY63ZCJlN0/3YsjLXmc8P8Fp IUR0y66GUjqFmpsQoTCG2ul+bSD+S9/XpDZzNKqv+SQkah1s64DaMwNZU7QRBsGU1WYY 9AmmeXQ5f4z5MmeuZ/0klfh4y3/3A7rjeP5RiUHlK7D3eHc9ifnFr/KUf/z3uda7dYbT MjmT/VWBrQmVGxkWOfhzE66UaWArYmyomlfQveayNWGnT31Ncl3ST2WFDiZFXaOivhur gz/A== X-Gm-Message-State: APjAAAXlewGyr2wSW/5Xa8EQlXJD+k/mx9cJ9LSNeSupxAtgg33CJYTh 20QReH8agRNCyp1ktg9CYvjx0o6ooU8= X-Google-Smtp-Source: APXvYqwFAw2uYUA3s7JsX4geuwV6sJrNshVfTf7Xv96hh67LhSpQGgVPIINmaxek8JKc9KgXlrfhQw== X-Received: by 2002:a05:6638:21a:: with SMTP id e26mr7689885jaq.53.1578856046852; Sun, 12 Jan 2020 11:07:26 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id r22sm3039219ilb.25.2020.01.12.11.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 11:07:26 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH 21/33] sandbox: sound: Handle errors better in sound_beep() Date: Sun, 12 Jan 2020 12:06:12 -0700 Message-Id: <20200112120216.21.I1b9a34b646b3a92f9b3c31b01af1ecdb1f6757cd@changeid> X-Mailer: git-send-email 2.25.0.rc1.283.g88dfdc4193-goog In-Reply-To: <20200112190624.79077-1-sjg@chromium.org> References: <20200112190624.79077-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean 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);