Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2679098rdb; Mon, 4 Dec 2023 04:47:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKD9UZKg69hb39nIwkH15pEK26ps9yeO3WzBwRmz0/cFXVk2SgFFv4PXcT7oy0tWcQjKx3 X-Received: by 2002:a17:902:ab8f:b0:1d0:6ffd:ae1a with SMTP id f15-20020a170902ab8f00b001d06ffdae1amr1143310plr.129.1701694076969; Mon, 04 Dec 2023 04:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701694076; cv=none; d=google.com; s=arc-20160816; b=QaVSAYPD0KOSEYdBE+QaWXuLs73bzi8du1dPR+QjM3iv9Q/Az6uk3e+EudwBckpuMs VArm+8xNFDSsE0zP3cf42+TtDQ/RxmVfOf79VHEY7XMOtUB6iGt2cabfzgocIID5UrHx 0PLq2eGIL8fqptHo++FZzXeoURW3+2WNoisIyT/mWY2NysIe9NwpE5z7lIrJVbxeWLIo tudbSNrapnn7dfsHwQRZNvSuSAzVX2ydOktIu1bYywXK680elWnBf31w/jwbFi4+Zsbd Q/dkzUb7r2Lq57ot/Wtnq3oE/uWpl+eRwpJjRN0RdCHYYTvtRaFqzLjFPxURPh+X1OEe XqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+ziVbN5ZTP69p6FxRTQ/DrNWjlcr9menHHHhzgnVhU0=; fh=tKMKhgl5y3qWFLA4WbTOKHpRmq3iK42KyhZj04F1xWA=; b=xTA+IORkw2YuH37S9/zcOq8HUzZMDzJam02sD6Bw6xSzazfSoBq+f78BpBf9gFRnU/ OCjeNFN5KNJbw939E1hMyDcRb0qiNY7SE2x/kjSmjueKY6Hb2EwUkJ+UbIBvoIBKfi6V 60Tdb2LqsSkFO94ahKbiE7ustlCi29oFBuzEnxvFuxx1IdtaZV8CNUYpHVeWJTcwegMM xnRiQ6RL0YaY6lGYewGDgh+gbkNCTa5ZPkElmcWO9bOvcdu3tkAzCKLvgzkNDoZKHKfX 2tGsPwW5+ang9iTw5HY3YzBwLYpgcg/fYXac/sIhhVus3AWck7P/VrLJVs3DMHdUHZI4 HsfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oaxeCEda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z7-20020a170902834700b001d0b78ea7a2si518907pln.516.2023.12.04.04.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:47:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oaxeCEda; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7D9DE805000D; Mon, 4 Dec 2023 04:47:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343916AbjLDMri (ORCPT + 99 others); Mon, 4 Dec 2023 07:47:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbjLDMrh (ORCPT ); Mon, 4 Dec 2023 07:47:37 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86AA7A9 for ; Mon, 4 Dec 2023 04:47:43 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-54ca43031d1so1245447a12.0 for ; Mon, 04 Dec 2023 04:47:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701694062; x=1702298862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+ziVbN5ZTP69p6FxRTQ/DrNWjlcr9menHHHhzgnVhU0=; b=oaxeCEdai59i2UFpX60wj06AWKEDDInfc+sS6P/buF+nKMxpHtCcGsOvMzr3t1DVUi mx/PEgtgzSoMLJ+jeVRDBWCtDE9+tDmstiWpi2EfTb9j4miy5OSmpBx6X2AWbjKqNpWG ZbM8OODMkuvE5yNutRRs9NvBm8q9OKyrcVDVDeOGYfxyT5y1UIjFPz4ZNackzTc7qXW8 adS4yOJMxN8BcmpoaPlrdEDnMWN+aVy2QZdTDccTFWI+PSGXm5mehX3NqXrNLn/QJxZ2 lwUsAZcuZ7W4YjdVuIkaA7/BtDoO6sOFa0VrjKuDZRauepryWj86Hqn/BailDq+8A154 0Avw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701694062; x=1702298862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ziVbN5ZTP69p6FxRTQ/DrNWjlcr9menHHHhzgnVhU0=; b=hPuDDLRpn4hsvQu4EsKLidgOXo+qIR01m4BGA/jWvBIrJqvnpWFJ4uNCmbjbvUPRy+ rh+ZhbYn81GevZtQkk9A8S1Oc7nfJJf4kfMTVNgfL0CYGvN4r1HFX+/Uj3unvbN5Hl/t OUdZ5Uu9/wAAKkyQnXh8FwCD3CG2uoJnf4mbyz4Wd1CP8vMdeWDeYLJNa4/EHFyFXv6V CrWaxvknNpAyTGLNKuBerb/BaGyZ8zacIpm3Tvg7KtBlVKAuwVzDjoO6/as0sH7Gj5tR q9Hqc42aucO78wo9NN3swteSuGW34YHBZrft3IaMabo22CC7HfwkYpUpI8hTFc/X4ooU 3xJg== X-Gm-Message-State: AOJu0Yy0lRbzbS8iWC1KGMX6JtRCGghICeRHdxnDWSEDvf38VH4SZt+Z 4VDhxJoNubBHKNvJ/u1MoTCOkw== X-Received: by 2002:a50:d59a:0:b0:54c:4837:903c with SMTP id v26-20020a50d59a000000b0054c4837903cmr3836618edi.52.1701694062023; Mon, 04 Dec 2023 04:47:42 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id dc15-20020a056402310f00b0054ced65bd26sm457017edb.41.2023.12.04.04.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 04:47:41 -0800 (PST) From: srinivas.kandagatla@linaro.org To: broonie@kernel.org, alsa-devel@alsa-project.org Cc: perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, johan+linaro@kernel.org, Srinivas Kandagatla Subject: [PATCH 1/2] ASoC: ops: add correct range check for limiting volume Date: Mon, 4 Dec 2023 12:47:35 +0000 Message-Id: <20231204124736.132185-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204124736.132185-1-srinivas.kandagatla@linaro.org> References: <20231204124736.132185-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 04:47:54 -0800 (PST) From: Srinivas Kandagatla Volume can have ranges that start with negative values, ex: -84dB to +40dB. Apply correct range check in snd_soc_limit_volume before setting the platform_max. Without this patch, for example setting a 0dB limit on a volume range of -84dB to +40dB would fail. Signed-off-by: Srinivas Kandagatla --- sound/soc/soc-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 55b009d3c681..2d25748ca706 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -661,7 +661,7 @@ int snd_soc_limit_volume(struct snd_soc_card *card, kctl = snd_soc_card_get_kcontrol(card, name); if (kctl) { struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; - if (max <= mc->max) { + if (max <= mc->max - mc->min) { mc->platform_max = max; ret = 0; } -- 2.25.1