From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E47EFEEB582 for ; Thu, 12 Sep 2024 09:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jZQpf6I66yvqfbpd8Qesa4kf9KenMUMosdFRAJU57Y4=; b=IBA2ErvRd7cwlcgJ3QbIBrLxLK mwBsr+akAg6nDzR9eSEhRQqbcEz76TC8PjfmKvlSov8S9KJSNTZbd4KFG2bQDjnxoWAI+4fhC5RQN ovkycoOk56np79RyCPC3hhPD3lP7dybZlml5B9roffdtCD+gUhEHD+e0JP0Wbw5aGfzn/yKjzerNE IAbeRC8ghQ507w9aOusG4qIJ5MVTA5/9/HniihNTy97T+Ga146vLSVEE9sXRh3pFSJfG0jzZu7xdF 14KeND6GZ24jR5YTguO0EL0fUNM9Sp3/+58wqb3468KIiZMnBzPTkZiR1TaoSF+d2RtIuN0mr5RSe BbsRqDMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sogYr-0000000CcAO-1BQL; Thu, 12 Sep 2024 09:56:25 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sogXg-0000000CbmQ-25nR for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 09:55:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1726134912; x=1757670912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ak0oM6R+aQCqIdmgcyfTd+zaQr3ycIgnJT5Jwb25V3E=; b=hIR4Wu+4wpOsKeaY4JUOOFkbpHlh+Fe5+LmdJylbZQfc2ZU7Cc4c2sYz 66IkRtWDMax9OzztRswm0AZCbLrbqF/n9EcxJZOx/PrEq6HdhzbX4zN0r gOho/X/HNRextlCLGbLxP+dwowWXlXltFqDGxTGGnO9zAK3viaISMY7Tk jTJ5prhUPop6ei5YT0Xc4T+KjG3k0l1ZVG2npsoOm/nlxYamClksHrlRP nOCVcXVjpAV0+bP9CxZ5BmEx4qMPdXfSerbfuD3o08gcNXKJNg/wp6PLf wNWYALp4JuLi2GA5TkN7+N1i34CafxQTXWDVO7NUox9MeCrpQWTHynqnk A==; X-CSE-ConnectionGUID: T/B5t8f4R/WLMPbvf6HuCg== X-CSE-MsgGUID: PI/UPcP3QuiZ0PEyxZoDhw== X-IronPort-AV: E=Sophos;i="6.10,222,1719903600"; d="scan'208";a="34843216" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 12 Sep 2024 02:55:09 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 12 Sep 2024 02:54:44 -0700 Received: from ROB-ULT-M76677.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 12 Sep 2024 02:54:41 -0700 From: Andrei Simion To: Subject: Re: [PATCH 3/3] ASoC: atmel: mchp-pdmc: Retain Non-Runtime Controls Date: Thu, 12 Sep 2024 12:53:38 +0300 Message-ID: <20240912095337.41507-1-andrei.simion@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240912_025512_564741_A9BC1DC9 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, lgirdwood@gmail.com, broonie@kernel.org, tiwai@suse.com, andrei.simion@microchip.com, codrin.ciubotariu@microchip.com, perex@perex.cz, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >> struct mchp_pdmc { >> struct mic_map channel_mic_map[MCHP_PDMC_MAX_CHANNELS]; >> + spinlock_t busy_lock; /* lock protecting busy */ >> struct device *dev; >> struct snd_dmaengine_dai_dma_data addr; >> struct regmap *regmap; >> @@ -124,6 +126,7 @@ struct mchp_pdmc { >> int mic_no; >> int sinc_order; >> bool audio_filter_en; >> + u8 busy:1; > Can the spinlock and busy flag be replaced by an atomic variable? I will use atomic_t variable with atomic_set and atomic_read. I will do a test and send V2. >> }; >> >> static const char *const mchp_pdmc_sinc_filter_order_text[] = { >> @@ -167,10 +170,19 @@ static int mchp_pdmc_sinc_order_put(struct snd_kcontrol *kcontrol, >> return -EINVAL; >> >> val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; >> - if (val == dd->sinc_order) >> + >> + spin_lock(&dd->busy_lock); >> + if (dd->busy) { >> + spin_unlock((&dd->busy_lock)); > You can remove () around (&dd->busy_lock). Valid for the rest of occurrences. OK. Got it! >> + return -EBUSY; >> + } >> + if (val == dd->sinc_order) { >> + spin_unlock((&dd->busy_lock)); >> return 0; >> + } >> >> dd->sinc_order = val; >> + spin_unlock((&dd->busy_lock)); >> >> return 1; >> }