From patchwork Fri Apr 14 15:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Binding X-Patchwork-Id: 83489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp467228vqo; Fri, 14 Apr 2023 08:29:49 -0700 (PDT) X-Google-Smtp-Source: AKy350YkjvhMdZ7cVzlWuy7rZw3bohzQ0VmzWvfdCzrUKGOK8Rd2WnpjZDyL3DJ7dobVoSK8ynUG X-Received: by 2002:a17:90a:7785:b0:246:818c:d8e4 with SMTP id v5-20020a17090a778500b00246818cd8e4mr5713657pjk.11.1681486189465; Fri, 14 Apr 2023 08:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681486189; cv=none; d=google.com; s=arc-20160816; b=RT01AYpn68cT0ki8VwazPe6EG9IjJt/l0nscWfKWp82SYJNNl+SN2y80sMV0NmmvUd P0ci+KVXI//1kh11eVNc0ePKqICkpG9xnadiH9dh5GBZIMF2eanx1hmlOF5ovMydSC29 EtqSyqPdAu8sAvNML1hOqhYoEzrs9uFgMGny9QeRO8HfYFVmixZM1OfiVmyhnQ9qft1i qB5ut/lznBvyD6F2RV6CJsKb7P/ru+zIaiWpBlWLtR4WBtaY2fogozxMwH1wdrayPmFu N75Y/fhf7FPkAL/bqNddMNbv4udhickEvhwQtoy+pxwNs3lYMsx/gwvN16Ogcx22FVkC SKsA== 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=I3l9dEf9Pxrt0iwsB+1r4Bv1ieTEMmtO3O+2uHhuyLc=; b=XztR7kRv/CeSZWJWXhE6eLacxX3LO93DZdgJuTmnoYxFmZ+pTVnidnxB2vPppduD8+ DzPDjTwwhSRM2wMtYSl285grGyOC6PBOWCF3WzK2sJ8dw0WNt2rIRmk4kuOCxMpCrqvp +SvMqD6O/Bj3h4U2VqASOnlLwPJ3ex+WpZY8iDQGvcEOn0wWIHe01QDOjY3/OLrrKpgc Quag93TuXUeCNAtE9p2hTcfN71kvboR4UOsD7bO5z4TC4/IrpJF9PQWw0GgzQCsP4sJA EN96yi1F7XYSmqJQGzc3LuY8D6CNoEgfJY/NOAXmb73GnLFdPHYPh0tf3hqhny0eBMZ2 mK5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=H7Lglqao; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 2-20020a630d42000000b004fb7e7ef77dsi4889346pgn.693.2023.04.14.08.29.36; Fri, 14 Apr 2023 08:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=H7Lglqao; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbjDNP1W (ORCPT + 99 others); Fri, 14 Apr 2023 11:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231274AbjDNP1K (ORCPT ); Fri, 14 Apr 2023 11:27:10 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE95FF0D for ; Fri, 14 Apr 2023 08:26:34 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33EDVEGo030487; Fri, 14 Apr 2023 10:26:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=I3l9dEf9Pxrt0iwsB+1r4Bv1ieTEMmtO3O+2uHhuyLc=; b=H7LglqaoEwfzYkPgtASdJxtxvolzG99MPScVDQjlRdAQ/DIwrHLNwiBfOMLt06Ac8ZVF g/w5FMFls8dIZD6N0QYUtVgwXDAGVV1mkZXQ02BhThiUvHXeczPloFrTAmMEFWp8pQ7p ovuA9EApLPzTKianpN0jZ9GT0GbtnWsJg946R0A8AqR7/Liyg06MFq2i/nsk6DVAP1GT hyHU5uAFSDlg0tvXpRp2xnpxwmoc4DLopQxlFve5HNLXEI9dGdYfszbomdYw0pfVB6rl 9J90AdDUGuCJJExfGtayzfnCymxMSZAjtUqWLZP6npzi7WEK9x0MdX9OdYzFEfygUUXl PA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3pu5p3skxn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 14 Apr 2023 10:26:02 -0500 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 14 Apr 2023 10:25:59 -0500 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 14 Apr 2023 10:25:59 -0500 Received: from sbinding-cirrus-dsktp2.ad.cirrus.com (unknown [198.90.238.135]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 5782211C6; Fri, 14 Apr 2023 15:25:59 +0000 (UTC) From: Stefan Binding To: Mark Brown , Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v1 1/4] ALSA: hda: cs35l41: Clean up Firmware Load Controls Date: Fri, 14 Apr 2023 16:25:49 +0100 Message-ID: <20230414152552.574502-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230414152552.574502-1-sbinding@opensource.cirrus.com> References: <20230414152552.574502-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: zUZitPZy_kxOGxncML1uE6UtVdccA4Kb X-Proofpoint-GUID: zUZitPZy_kxOGxncML1uE6UtVdccA4Kb X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763166062473984347?= X-GMAIL-MSGID: =?utf-8?q?1763166062473984347?= Ensure Firmware Load control and Firmware Type control returns 1 when the value changes. Remove fw_mutex from firmware load control put, since it is unnecessary, and prevents any possibility of mutex inversion. Signed-off-by: Stefan Binding --- sound/pci/hda/cs35l41_hda.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index b5210abb5141f..d100189e15b83 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -835,34 +835,26 @@ static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); - unsigned int ret = 0; - - mutex_lock(&cs35l41->fw_mutex); if (cs35l41->request_fw_load == ucontrol->value.integer.value[0]) - goto err; + return 0; if (cs35l41->fw_request_ongoing) { dev_dbg(cs35l41->dev, "Existing request not complete\n"); - ret = -EBUSY; - goto err; + return -EBUSY; } /* Check if playback is ongoing when initial request is made */ if (cs35l41->playback_started) { dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); - ret = -EBUSY; - goto err; + return -EBUSY; } cs35l41->fw_request_ongoing = true; cs35l41->request_fw_load = ucontrol->value.integer.value[0]; schedule_work(&cs35l41->fw_load_work); -err: - mutex_unlock(&cs35l41->fw_mutex); - - return ret; + return 1; } static int cs35l41_fw_type_ctl_get(struct snd_kcontrol *kcontrol, @@ -881,8 +873,12 @@ static int cs35l41_fw_type_ctl_put(struct snd_kcontrol *kcontrol, struct cs35l41_hda *cs35l41 = snd_kcontrol_chip(kcontrol); if (ucontrol->value.enumerated.item[0] < HDA_CS_DSP_NUM_FW) { - cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; - return 0; + if (cs35l41->firmware_type != ucontrol->value.enumerated.item[0]) { + cs35l41->firmware_type = ucontrol->value.enumerated.item[0]; + return 1; + } else { + return 0; + } } return -EINVAL;