From patchwork Mon Jun 3 10:35:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683589 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C00B783CBE; Mon, 3 Jun 2024 10:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410949; cv=none; b=tZzJubcve9wBz22GdTBrB7pSfcycrFiW8rRkypmlNp3thCAEsivH2RkvagObacwS8R1P6yCPb9Mx9udAXvl1Zd/X67W7WNLP777PTzgSC4y5vLCqiDr3KGaK28geMtRTYtIhajYOlDZBq4QpmD2ATMIIJSujG7xvDysI1MfVI4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410949; c=relaxed/simple; bh=e+bL2RoRUJlaWlprGpWktgCZQsKmm2hk0ARDnnJF7nM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KCvJ54VgNePK5VEuTIT7pW4eUpTvNv43sA6EXbgI/wL3OSMygR8eKzlyx7Tj75w05FubqlA0Rmm5Db7BZTBbDdbft1Zu92d/CxEWCMzAMOMMyOe1iSluiTMrXCilqCx37uJOlLym+J0g5FHyj/SE8t4izh+l52Gds5bMzYv9tlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=mqp/8NIM; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="mqp/8NIM" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pZ018316; Mon, 3 Jun 2024 05:35:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=qUsSAY8N7AKSenNGLa8xZV3wN1+8yO51gSj1XEWRIaQ=; b= mqp/8NIMfMXUEB1p+3SScrbswFbIZikggZm7YjPUVXzfqdG1lxLMebI278cgzOhu GnWmYeFaTPCf1oTTT/Ycnmy9YVgmwp0Ni75ymInN3d1CrK3y13YiWJBlR2KVYCNJ eaZD3QQ2MGsajIfGw4JmWYPtFkKwXwO8y17TDMlHLFSSxm9frp+1u17rG15bIe7a zDEv0C2ss+nkzJcVXzV82+YQxLtFQdPY7i+StcxtFK5NDOhe0ymX7ZqUSCzAmtpv cHnAr6tIDaOe9uXY0R0onTdNy/6MDgfL5eL+k4K15KvsnV2gfyjUFOg1+PHbH/ro CsfRupQ6MtqGsy/zigLu+Q== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:29 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:26 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:26 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 4FF3F82024A; Mon, 3 Jun 2024 10:35:26 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 1/7] ALSA: hda: cs35l56: Component should be unbound before deconstruction Date: Mon, 3 Jun 2024 11:35:18 +0100 Message-ID: <20240603103524.32442-2-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: TTkyztoDiUDSkeFZwReoU0LNOof7MjL_ X-Proofpoint-ORIG-GUID: TTkyztoDiUDSkeFZwReoU0LNOof7MjL_ X-Proofpoint-Spam-Reason: safe The interface associated with the hda_component should be deactivated before the driver is deconstructed during removal. Signed-off-by: Simon Trimmer --- sound/pci/hda/cs35l56_hda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index 0923e2589f5f..e134ede6c5aa 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -1077,12 +1077,12 @@ void cs35l56_hda_remove(struct device *dev) { struct cs35l56_hda *cs35l56 = dev_get_drvdata(dev); + component_del(cs35l56->base.dev, &cs35l56_hda_comp_ops); + pm_runtime_dont_use_autosuspend(cs35l56->base.dev); pm_runtime_get_sync(cs35l56->base.dev); pm_runtime_disable(cs35l56->base.dev); - component_del(cs35l56->base.dev, &cs35l56_hda_comp_ops); - cs_dsp_remove(&cs35l56->cs_dsp); kfree(cs35l56->system_name); From patchwork Mon Jun 3 10:35:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683591 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C007C83CBB; Mon, 3 Jun 2024 10:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; cv=none; b=q7NqDXlJ2bnxGnMD07DZOcGuYKg2GO7nAqBMnQrEKD0ohrxnYVzhMMVlWoytGhvW/13IBSGRPq73pHs/o4Ia8rkN5Mzkd8OqadhVw/Rr2cYOxWgdI7R2M/PU/YUilxD3XSMMw20zD3FZVMKYCi1XtNYD5UXvjmT07fBaupfgd60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; c=relaxed/simple; bh=fY7MkT5JoP238inIzvp80l8R/QuTlnYxL8jXzTxaxIk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nWXbAnpjO+Bdn9sWMtDyjbzV2HzebfpmIlh+F+FwXiSBEHKloh+eL1AwxHXkwfsYFOqKIy6SGVNfKT9gkmXwmm5vRO71j2dAs/dN0BpHS30NPdQCd9AoIt5IQxonC9Gw5GLsz1KTM3N1GlUFmSuFF9MUZYdNGoMZOAwi1ZYBqn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=esInwkes; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="esInwkes" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pa018316; Mon, 3 Jun 2024 05:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=/31H52Kx5dI0pIOnMzUjAMQTByFunlPMmeUhLGzbe3M=; b= esInwkesGZxuY9WQXAW7bal3RcRess6/NZTC8VqIo0F+OvOWc5Phky2+XofLecqs eos08IUjLrBlnCcXaYRIbSp3ut4ZSClomMxz0wLpH/gmDIi4xbNJZh8loNuKbyea gT9FDk4716U7GOwJDp2P+ynzdMOWXmfUMG8HNuNE8r5fh63bvqSU9J7pXgGODZor zETJ8vEcHd5apv0lGm23g/q2+afrZHBJz0IRL7I8DbbGpMYN/HyvuaRT7IZHtIDu jZXx7MyY1e1Kpq/4urjd/8ut/gO2Q0/DeraQl3BEmQwMRpbkKYA73+WxSfWe9ord FTRJ1lN49oS5Z17euLj6Vw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:29 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:27 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:27 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id C6AB0820249; Mon, 3 Jun 2024 10:35:26 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 2/7] ALSA: hda: cs35l41: Component should be unbound before deconstruction Date: Mon, 3 Jun 2024 11:35:19 +0100 Message-ID: <20240603103524.32442-3-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: arj-FzRXEhriQRbaUqWCkdnBZsMDL4Dg X-Proofpoint-ORIG-GUID: arj-FzRXEhriQRbaUqWCkdnBZsMDL4Dg X-Proofpoint-Spam-Reason: safe The interface associated with the hda_component should be deactivated before the driver is deconstructed during removal. Signed-off-by: Simon Trimmer --- sound/pci/hda/cs35l41_hda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index d54d4d60b03e..031703f010be 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -2019,6 +2019,8 @@ void cs35l41_hda_remove(struct device *dev) { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); + component_del(cs35l41->dev, &cs35l41_hda_comp_ops); + pm_runtime_get_sync(cs35l41->dev); pm_runtime_dont_use_autosuspend(cs35l41->dev); pm_runtime_disable(cs35l41->dev); @@ -2026,8 +2028,6 @@ void cs35l41_hda_remove(struct device *dev) if (cs35l41->halo_initialized) cs35l41_remove_dsp(cs35l41); - component_del(cs35l41->dev, &cs35l41_hda_comp_ops); - acpi_dev_put(cs35l41->dacpi); pm_runtime_put_noidle(cs35l41->dev); From patchwork Mon Jun 3 10:35:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683595 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C003C82C6B; Mon, 3 Jun 2024 10:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; cv=none; b=kT+HML8bC+x6+uuz4eYNcdOMnYeLhbeft67KAE2bNodoCsTkP5eZCdzz6AowSImibky1oNbWvtJ+4yfG6AKzbfdZH9RfZk1rpRTaJbF5udWblUUuXU9n6LwoR5deM0WPeBTGriYpOhRp1G18L3a3RHgGdxj5PDWchhbJMlGwEWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; c=relaxed/simple; bh=L7mPsWE59fLvt2m/9tRf4t9eVGbAAWQn7bYALXOm/6w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N+fNQWxU4aYu0NTDgF9siaXS2r7Hx1tS5PoLfJkf5z4lBi5ktdLM+cSq88i2iX0h+YibzwwMoDe7CZ6AA6/umxu/BCRzo+3smFtKOsYM551DZJdUSSGFKblYhKw5A83MfjUnRg4dOOHMi5QWFolGsfdrXak3HPmEQE0AMS13zhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=FfxWepnR; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="FfxWepnR" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pb018316; Mon, 3 Jun 2024 05:35:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=VxH3GmQdzZ7kvCvsSqTihyPEgS2wEiWRURtVFqWL3f8=; b= FfxWepnRYN8xgX7v/vrigGIb+xuDHa+B4dTc1PX45i5IJ3AZ3GSSlF8wfjTRsSWD Bbcbxj7kZcSMmRgauqwsK/dtWllGuuEL83GxHppWISvVRfYAI8+3J8flbOUAGsKh Tqtk4mQIIKfxnqfvHYI2sDP8YqNpuqsSPn8aPXDOowfIKAaAKsoZPjgdZ8DN6XKt PQdB26YD+rljvuttOeJJ8PPaR8A3eZVK08mkQ5Ir9Tjkj6KZ2i8bxc8DXdDaro59 ViYouuarIPoDyvatN1YkHdxc+tThYFVSKM7mzRfnIb2ZVRh+invHNqf+D4z8RsYu GtaM3SYRz4pvmGhHs5CLTg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:30 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:27 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:27 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 496AF82024A; Mon, 3 Jun 2024 10:35:27 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 3/7] ALSA: hda/tas2781: Component should be unbound before deconstruction Date: Mon, 3 Jun 2024 11:35:20 +0100 Message-ID: <20240603103524.32442-4-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 2_eWtm-DasY4CugLiLYehl-6UxDlDY-J X-Proofpoint-ORIG-GUID: 2_eWtm-DasY4CugLiLYehl-6UxDlDY-J X-Proofpoint-Spam-Reason: safe The interface associated with the hda_component should be deactivated before the driver is deconstructed during removal. Signed-off-by: Simon Trimmer --- sound/pci/hda/tas2781_hda_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c index 75f7674c66ee..fdee6592c502 100644 --- a/sound/pci/hda/tas2781_hda_i2c.c +++ b/sound/pci/hda/tas2781_hda_i2c.c @@ -777,11 +777,11 @@ static void tas2781_hda_remove(struct device *dev) { struct tas2781_hda *tas_hda = dev_get_drvdata(dev); + component_del(tas_hda->dev, &tas2781_hda_comp_ops); + pm_runtime_get_sync(tas_hda->dev); pm_runtime_disable(tas_hda->dev); - component_del(tas_hda->dev, &tas2781_hda_comp_ops); - pm_runtime_put_noidle(tas_hda->dev); tasdevice_remove(tas_hda->priv); From patchwork Mon Jun 3 10:35:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683594 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 711D483CD8; Mon, 3 Jun 2024 10:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; cv=none; b=F1dWGA0t3qbg/Dg+iCyAPk/cu5UwGrU5NuTDll+BPw699UqTay3V6XMIVuSHT48U12wncXH0/jTSoSqc98FvBNqjiu2DiRWrV8DW2zDSu2MndQAzHEi4x2gHdWhKEpsLKOZnYeiewQ1SpXC8nnKbbGXlMtNaTr8Y7Y4Q9GUSDlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; c=relaxed/simple; bh=ZN7JwByll9BeZnFXmTydnqXa5Q3/av5bEwRk/ElOTp0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hI/mHL413OV1heo0mVtdtStD51zHrq5bo44vkiyuCT/gwKbgCR0oIv0Z+BPvTfHDSuoOiAB3lqtrWZaS0Hi0s4aeHA+KauWWFEOUsF7kLxQ2X6o8RILgMLxLKJh4jGagB1XMwm4dokkAJGu1K3WTq4RZoBOb00NvDBgsUM008Tg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=OAl5+PRT; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="OAl5+PRT" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pc018316; Mon, 3 Jun 2024 05:35:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=NKAx1VzbuIIdTzH4s8KWr9UrBGJ869ceaCjydPzJV7s=; b= OAl5+PRTIeB7joi3D56zy4/44QMoiCdxW4ZMHN+THIQZ0fCBVbBa6nZOudybJ4U3 fStacEnWFyVSuMYkIc8NqOIyMevDgfZ/byZcv4ZdlL2umowQq6S4lAoSl2OrXmQR iAkkZOIjl6ZRT0C565OwYGUxWGFdpcKN5sEql8/GDHiEpHgTS3wzck4Cr+UO2msi 7xyiK9odZV+SOv+JwkDcfjILdk40egvo4O+l6UDq1CoA8dT3o6FfiMkoS6vY3EKf 95kqDJ6jCzrx96j5JXataFHxm9CGYGv11PSs41A2Bjci1WtVL4uOZMTwyJ3/5Bze 8bxKdDgXx4cDB3kRTTRTgA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:31 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:28 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:28 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id BA5FB820249; Mon, 3 Jun 2024 10:35:27 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 4/7] ALSA: hda: hda_component: Introduce component parent structure Date: Mon, 3 Jun 2024 11:35:21 +0100 Message-ID: <20240603103524.32442-5-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 84uuc4BZpRdbuaKyiCGpw75eczEqQfLv X-Proofpoint-ORIG-GUID: 84uuc4BZpRdbuaKyiCGpw75eczEqQfLv X-Proofpoint-Spam-Reason: safe In preparation for moving duplicated members from the hda_component structure introduce a parent structure that wraps the array of components. This also allows us to confine the knowledge of the maximum number of entries to the hda_component files and eliminate passing that redundant information around and making direct accesses to the array. Signed-off-by: Simon Trimmer --- sound/pci/hda/hda_component.c | 65 +++++++++++++++++++---------------- sound/pci/hda/hda_component.h | 42 ++++++++++++++-------- sound/pci/hda/patch_realtek.c | 17 +++++---- 3 files changed, 71 insertions(+), 53 deletions(-) diff --git a/sound/pci/hda/hda_component.c b/sound/pci/hda/hda_component.c index d02589014a3f..b05a0b87d32a 100644 --- a/sound/pci/hda/hda_component.c +++ b/sound/pci/hda/hda_component.c @@ -15,35 +15,39 @@ #include "hda_local.h" #ifdef CONFIG_ACPI -void hda_component_acpi_device_notify(struct hda_component *comps, int num_comps, +void hda_component_acpi_device_notify(struct hda_component_parent *parent, acpi_handle handle, u32 event, void *data) { + struct hda_component *comp; int i; - for (i = 0; i < num_comps; i++) { - if (comps[i].dev && comps[i].acpi_notify) - comps[i].acpi_notify(acpi_device_handle(comps[i].adev), event, - comps[i].dev); + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { + comp = hda_component_from_index(parent, i); + if (comp->dev && comp->acpi_notify) + comp->acpi_notify(acpi_device_handle(comp->adev), event, comp->dev); } } EXPORT_SYMBOL_NS_GPL(hda_component_acpi_device_notify, SND_HDA_SCODEC_COMPONENT); int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, int num_comps, + struct hda_component_parent *parent, acpi_notify_handler handler, void *data) { bool support_notifications = false; struct acpi_device *adev; + struct hda_component *comp; int ret; int i; - adev = comps[0].adev; + adev = parent->comps[0].adev; if (!acpi_device_handle(adev)) return 0; - for (i = 0; i < num_comps; i++) + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { + comp = hda_component_from_index(parent, i); support_notifications = support_notifications || - comps[i].acpi_notifications_supported; + comp->acpi_notifications_supported; + } if (support_notifications) { ret = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, @@ -61,13 +65,13 @@ int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind_acpi_notifications, SND_HDA_SCODEC_COMPONENT); void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, + struct hda_component_parent *parent, acpi_notify_handler handler) { struct acpi_device *adev; int ret; - adev = comps[0].adev; + adev = parent->comps[0].adev; if (!acpi_device_handle(adev)) return; @@ -78,21 +82,25 @@ void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, EXPORT_SYMBOL_NS_GPL(hda_component_manager_unbind_acpi_notifications, SND_HDA_SCODEC_COMPONENT); #endif /* ifdef CONFIG_ACPI */ -void hda_component_manager_playback_hook(struct hda_component *comps, int num_comps, int action) +void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action) { + struct hda_component *comp; int i; - for (i = 0; i < num_comps; i++) { - if (comps[i].dev && comps[i].pre_playback_hook) - comps[i].pre_playback_hook(comps[i].dev, action); + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { + comp = hda_component_from_index(parent, i); + if (comp->dev && comp->pre_playback_hook) + comp->pre_playback_hook(comp->dev, action); } - for (i = 0; i < num_comps; i++) { - if (comps[i].dev && comps[i].playback_hook) - comps[i].playback_hook(comps[i].dev, action); + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { + comp = hda_component_from_index(parent, i); + if (comp->dev && comp->playback_hook) + comp->playback_hook(comp->dev, action); } - for (i = 0; i < num_comps; i++) { - if (comps[i].dev && comps[i].post_playback_hook) - comps[i].post_playback_hook(comps[i].dev, action); + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { + comp = hda_component_from_index(parent, i); + if (comp->dev && comp->post_playback_hook) + comp->post_playback_hook(comp->dev, action); } } EXPORT_SYMBOL_NS_GPL(hda_component_manager_playback_hook, SND_HDA_SCODEC_COMPONENT); @@ -124,22 +132,21 @@ static int hda_comp_match_dev_name(struct device *dev, void *data) } int hda_component_manager_bind(struct hda_codec *cdc, - struct hda_component *comps, int count) + struct hda_component_parent *parent) { int i; - /* Init shared data */ - for (i = 0; i < count; ++i) { - memset(&comps[i], 0, sizeof(comps[i])); - comps[i].codec = cdc; - } + /* Init shared and component specific data */ + memset(parent, 0, sizeof(*parent)); + for (i = 0; i < ARRAY_SIZE(parent->comps); i++) + parent->comps[i].codec = cdc; - return component_bind_all(hda_codec_dev(cdc), comps); + return component_bind_all(hda_codec_dev(cdc), &parent->comps); } EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, SND_HDA_SCODEC_COMPONENT); int hda_component_manager_init(struct hda_codec *cdc, - struct hda_component *comps, int count, + struct hda_component_parent *parent, int count, const char *bus, const char *hid, const char *match_str, const struct component_master_ops *ops) diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h index c70b3de68ab2..a016f1b942a2 100644 --- a/sound/pci/hda/hda_component.h +++ b/sound/pci/hda/hda_component.h @@ -28,18 +28,21 @@ struct hda_component { void (*post_playback_hook)(struct device *dev, int action); }; +struct hda_component_parent { + struct hda_component comps[HDA_MAX_COMPONENTS]; +}; + #ifdef CONFIG_ACPI -void hda_component_acpi_device_notify(struct hda_component *comps, int num_comps, +void hda_component_acpi_device_notify(struct hda_component_parent *parent, acpi_handle handle, u32 event, void *data); int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, int num_comps, + struct hda_component_parent *parent, acpi_notify_handler handler, void *data); void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, + struct hda_component_parent *parent, acpi_notify_handler handler); #else -static inline void hda_component_acpi_device_notify(struct hda_component *comps, - int num_comps, +static inline void hda_component_acpi_device_notify(struct hda_component_parent *parent, acpi_handle handle, u32 event, void *data) @@ -47,8 +50,7 @@ static inline void hda_component_acpi_device_notify(struct hda_component *comps, } static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, - int num_comps, + struct hda_component_parent *parent, acpi_notify_handler handler, void *data) @@ -57,17 +59,16 @@ static inline int hda_component_manager_bind_acpi_notifications(struct hda_codec } static inline void hda_component_manager_unbind_acpi_notifications(struct hda_codec *cdc, - struct hda_component *comps, + struct hda_component_parent *parent, acpi_notify_handler handler) { } #endif /* ifdef CONFIG_ACPI */ -void hda_component_manager_playback_hook(struct hda_component *comps, int num_comps, - int action); +void hda_component_manager_playback_hook(struct hda_component_parent *parent, int action); int hda_component_manager_init(struct hda_codec *cdc, - struct hda_component *comps, int count, + struct hda_component_parent *parent, int count, const char *bus, const char *hid, const char *match_str, const struct component_master_ops *ops); @@ -75,13 +76,24 @@ int hda_component_manager_init(struct hda_codec *cdc, void hda_component_manager_free(struct hda_codec *cdc, const struct component_master_ops *ops); -int hda_component_manager_bind(struct hda_codec *cdc, - struct hda_component *comps, int count); +int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent); + +static inline struct hda_component *hda_component_from_index(struct hda_component_parent *parent, + int index) +{ + if (!parent) + return NULL; + + if (index < 0 || index >= ARRAY_SIZE(parent->comps)) + return NULL; + + return &parent->comps[index]; +} static inline void hda_component_manager_unbind(struct hda_codec *cdc, - struct hda_component *comps) + struct hda_component_parent *parent) { - component_unbind_all(hda_codec_dev(cdc), comps); + component_unbind_all(hda_codec_dev(cdc), &parent->comps); } #endif /* ifndef __HDA_COMPONENT_H__ */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index aa76d1c88589..ab9d13e7dcaa 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -131,7 +131,7 @@ struct alc_spec { u8 alc_mute_keycode_map[1]; /* component binding */ - struct hda_component comps[HDA_MAX_COMPONENTS]; + struct hda_component_parent comps; }; /* @@ -6789,8 +6789,7 @@ static void comp_acpi_device_notify(acpi_handle handle, u32 event, void *data) codec_info(cdc, "ACPI Notification %d\n", event); - hda_component_acpi_device_notify(spec->comps, ARRAY_SIZE(spec->comps), - handle, event, data); + hda_component_acpi_device_notify(&spec->comps, handle, event, data); } static int comp_bind(struct device *dev) @@ -6799,12 +6798,12 @@ static int comp_bind(struct device *dev) struct alc_spec *spec = cdc->spec; int ret; - ret = hda_component_manager_bind(cdc, spec->comps, ARRAY_SIZE(spec->comps)); + ret = hda_component_manager_bind(cdc, &spec->comps); if (ret) return ret; return hda_component_manager_bind_acpi_notifications(cdc, - spec->comps, ARRAY_SIZE(spec->comps), + &spec->comps, comp_acpi_device_notify, cdc); } @@ -6813,8 +6812,8 @@ static void comp_unbind(struct device *dev) struct hda_codec *cdc = dev_to_hda_codec(dev); struct alc_spec *spec = cdc->spec; - hda_component_manager_unbind_acpi_notifications(cdc, spec->comps, comp_acpi_device_notify); - hda_component_manager_unbind(cdc, spec->comps); + hda_component_manager_unbind_acpi_notifications(cdc, &spec->comps, comp_acpi_device_notify); + hda_component_manager_unbind(cdc, &spec->comps); } static const struct component_master_ops comp_master_ops = { @@ -6827,7 +6826,7 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_ { struct alc_spec *spec = cdc->spec; - hda_component_manager_playback_hook(spec->comps, ARRAY_SIZE(spec->comps), action); + hda_component_manager_playback_hook(&spec->comps, action); } static void comp_generic_fixup(struct hda_codec *cdc, int action, const char *bus, @@ -6838,7 +6837,7 @@ static void comp_generic_fixup(struct hda_codec *cdc, int action, const char *bu switch (action) { case HDA_FIXUP_ACT_PRE_PROBE: - ret = hda_component_manager_init(cdc, spec->comps, count, bus, hid, + ret = hda_component_manager_init(cdc, &spec->comps, count, bus, hid, match_str, &comp_master_ops); if (ret) return; From patchwork Mon Jun 3 10:35:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683592 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7710783CDC; Mon, 3 Jun 2024 10:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; cv=none; b=dJYk5vdh4TsnK5/aNTOPZADmgJ0XsMOrd8X85NPsSJCEQFG5ntgAsBoH6ZtPR1WopGTfSuW3CFUk8pczfmhfDLNTAHDm5vFyXJ0BqrmbJ9pNrvkg8kcDg05DJHsZA/ZFj/BPbAwC2CY2pzVpxwy+pdES1K0V0c7b7b99EkShxzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; c=relaxed/simple; bh=G3NCTk78YScSotueMh9r3AP12WRhWC+sTfZw7LyDrO8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mPUVLNEpiere6SB1+lVWtPqDi+hiMREVGKuAu5ZBEvkvy0F8olki6brGanNejryCCZoSSeqZr/DuoaQsdArQywwEeqiofDgJGcViD4l5C4w6fseIf7XcMu/3shFaVdcdw5WZiHiiaFIaoHeVb1zZtRQA9auWh5Giebihkr1Vvq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=qPAR/cBg; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="qPAR/cBg" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pd018316; Mon, 3 Jun 2024 05:35:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=0gEQ3Xd0Lvw1yagtwuNTUFfPRHlkN9PlF1qv2sDs7lE=; b= qPAR/cBguR8bSLatlAuzdyhqNFriGtvNpAkLnwMME/RC7V4vnELt+TDP9ZU7nau7 s7WWxcoRCOkhSLM0diArRkRGVJtigwpy9W4M3MRnj7wi9Rnw4/qtzsS/eCgkOel3 JX+jv6/6P3hvb6n2m1HBY2IR1WrLYcYP4sYpGspMHeC7rVWIu7KlXZviYlgBhdmO yJvtd5dus3196Bq9ew9f8UgFPn6SaEfIlXswnPuVICzGOESodD9Agnydc0FauUDl 2TM/LNaa9ShnqlAXYOBiUIGJiu9sOoT+o1TY7Ii6A9vhItzcwruGTztESi8kdmUw rTckWwU1PpMPwQHZlEYUQw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:32 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:28 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:28 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 2430382024A; Mon, 3 Jun 2024 10:35:28 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 5/7] ALSA: hda: hda_component: Change codecs to use component parent structure Date: Mon, 3 Jun 2024 11:35:22 +0100 Message-ID: <20240603103524.32442-6-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: _-yxIXqbCR1OV2RHOyZgZTYa6tXuP1Za X-Proofpoint-ORIG-GUID: _-yxIXqbCR1OV2RHOyZgZTYa6tXuP1Za X-Proofpoint-Spam-Reason: safe Change the hda_component binding APIs to pass the hds_component_parent as the parameter so the array of components can be abstracted. Signed-off-by: Simon Trimmer --- sound/pci/hda/cs35l41_hda.c | 42 +++++++++++++++++++-------------- sound/pci/hda/cs35l56_hda.c | 25 +++++++++++--------- sound/pci/hda/hda_component.c | 2 +- sound/pci/hda/hda_component.h | 2 +- sound/pci/hda/tas2781_hda_i2c.c | 33 +++++++++++++------------- 5 files changed, 57 insertions(+), 47 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index 031703f010be..ceba4f2c85f1 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1419,27 +1419,28 @@ static void cs35l41_acpi_device_notify(acpi_handle handle, u32 event, struct dev static int cs35l41_hda_bind(struct device *dev, struct device *master, void *master_data) { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); - struct hda_component *comps = master_data; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; unsigned int sleep_flags; int ret = 0; - if (!comps || cs35l41->index < 0 || cs35l41->index >= HDA_MAX_COMPONENTS) + comp = hda_component_from_index(parent, cs35l41->index); + if (!comp) return -EINVAL; - comps = &comps[cs35l41->index]; - if (comps->dev) + if (comp->dev) return -EBUSY; pm_runtime_get_sync(dev); mutex_lock(&cs35l41->fw_mutex); - comps->dev = dev; + comp->dev = dev; if (!cs35l41->acpi_subsystem_id) cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", - comps->codec->core.subsystem_id); - cs35l41->codec = comps->codec; - strscpy(comps->name, dev_name(dev), sizeof(comps->name)); + comp->codec->core.subsystem_id); + cs35l41->codec = comp->codec; + strscpy(comp->name, dev_name(dev), sizeof(comp->name)); cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT; @@ -1454,13 +1455,13 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas ret = cs35l41_create_controls(cs35l41); - comps->playback_hook = cs35l41_hda_playback_hook; - comps->pre_playback_hook = cs35l41_hda_pre_playback_hook; - comps->post_playback_hook = cs35l41_hda_post_playback_hook; - comps->acpi_notify = cs35l41_acpi_device_notify; - comps->adev = cs35l41->dacpi; + comp->playback_hook = cs35l41_hda_playback_hook; + comp->pre_playback_hook = cs35l41_hda_pre_playback_hook; + comp->post_playback_hook = cs35l41_hda_post_playback_hook; + comp->acpi_notify = cs35l41_acpi_device_notify; + comp->adev = cs35l41->dacpi; - comps->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comps->adev), + comp->acpi_notifications_supported = cs35l41_dsm_supported(acpi_device_handle(comp->adev), CS35L41_DSM_GET_MUTE); cs35l41->mute_override = cs35l41_get_acpi_mute_state(cs35l41, @@ -1469,7 +1470,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas mutex_unlock(&cs35l41->fw_mutex); sleep_flags = lock_system_sleep(); - if (!device_link_add(&comps->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) + if (!device_link_add(&comp->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) dev_warn(dev, "Unable to create device link\n"); unlock_system_sleep(sleep_flags); @@ -1489,14 +1490,19 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas static void cs35l41_hda_unbind(struct device *dev, struct device *master, void *master_data) { struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); - struct hda_component *comps = master_data; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; unsigned int sleep_flags; - if (comps[cs35l41->index].dev == dev) { - memset(&comps[cs35l41->index], 0, sizeof(*comps)); + comp = hda_component_from_index(parent, cs35l41->index); + if (!comp) + return; + + if (comp->dev == dev) { sleep_flags = lock_system_sleep(); device_link_remove(&cs35l41->codec->core.dev, cs35l41->dev); unlock_system_sleep(sleep_flags); + memset(comp, 0, sizeof(*comp)); } } diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index e134ede6c5aa..df4498c77171 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -685,20 +685,21 @@ static int cs35l56_hda_fw_load(struct cs35l56_hda *cs35l56) static int cs35l56_hda_bind(struct device *dev, struct device *master, void *master_data) { struct cs35l56_hda *cs35l56 = dev_get_drvdata(dev); - struct hda_component *comps = master_data; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; int ret; - if (!comps || cs35l56->index < 0 || cs35l56->index >= HDA_MAX_COMPONENTS) + comp = hda_component_from_index(parent, cs35l56->index); + if (!comp) return -EINVAL; - comps = &comps[cs35l56->index]; - if (comps->dev) + if (comp->dev) return -EBUSY; - comps->dev = dev; - cs35l56->codec = comps->codec; - strscpy(comps->name, dev_name(dev), sizeof(comps->name)); - comps->playback_hook = cs35l56_hda_playback_hook; + comp->dev = dev; + cs35l56->codec = comp->codec; + strscpy(comp->name, dev_name(dev), sizeof(comp->name)); + comp->playback_hook = cs35l56_hda_playback_hook; ret = cs35l56_hda_fw_load(cs35l56); if (ret) @@ -720,7 +721,8 @@ static int cs35l56_hda_bind(struct device *dev, struct device *master, void *mas static void cs35l56_hda_unbind(struct device *dev, struct device *master, void *master_data) { struct cs35l56_hda *cs35l56 = dev_get_drvdata(dev); - struct hda_component *comps = master_data; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; cs35l56_hda_remove_controls(cs35l56); @@ -732,8 +734,9 @@ static void cs35l56_hda_unbind(struct device *dev, struct device *master, void * if (cs35l56->base.fw_patched) cs_dsp_power_down(&cs35l56->cs_dsp); - if (comps[cs35l56->index].dev == dev) - memset(&comps[cs35l56->index], 0, sizeof(*comps)); + comp = hda_component_from_index(parent, cs35l56->index); + if (comp && (comp->dev == dev)) + memset(comp, 0, sizeof(*comp)); cs35l56->codec = NULL; diff --git a/sound/pci/hda/hda_component.c b/sound/pci/hda/hda_component.c index b05a0b87d32a..8c11c8b37799 100644 --- a/sound/pci/hda/hda_component.c +++ b/sound/pci/hda/hda_component.c @@ -141,7 +141,7 @@ int hda_component_manager_bind(struct hda_codec *cdc, for (i = 0; i < ARRAY_SIZE(parent->comps); i++) parent->comps[i].codec = cdc; - return component_bind_all(hda_codec_dev(cdc), &parent->comps); + return component_bind_all(hda_codec_dev(cdc), parent); } EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, SND_HDA_SCODEC_COMPONENT); diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h index a016f1b942a2..e547e1f1e674 100644 --- a/sound/pci/hda/hda_component.h +++ b/sound/pci/hda/hda_component.h @@ -93,7 +93,7 @@ static inline struct hda_component *hda_component_from_index(struct hda_componen static inline void hda_component_manager_unbind(struct hda_codec *cdc, struct hda_component_parent *parent) { - component_unbind_all(hda_codec_dev(cdc), &parent->comps); + component_unbind_all(hda_codec_dev(cdc), parent); } #endif /* ifndef __HDA_COMPONENT_H__ */ diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c index fdee6592c502..c6c1e8e81972 100644 --- a/sound/pci/hda/tas2781_hda_i2c.c +++ b/sound/pci/hda/tas2781_hda_i2c.c @@ -706,20 +706,20 @@ static int tas2781_hda_bind(struct device *dev, struct device *master, void *master_data) { struct tas2781_hda *tas_hda = dev_get_drvdata(dev); - struct hda_component *comps = master_data; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; struct hda_codec *codec; unsigned int subid; int ret; - if (!comps || tas_hda->priv->index < 0 || - tas_hda->priv->index >= HDA_MAX_COMPONENTS) + comp = hda_component_from_index(parent, tas_hda->priv->index); + if (!comp) return -EINVAL; - comps = &comps[tas_hda->priv->index]; - if (comps->dev) + if (comp->dev) return -EBUSY; - codec = comps->codec; + codec = comp->codec; subid = codec->core.subsystem_id >> 16; switch (subid) { @@ -733,13 +733,13 @@ static int tas2781_hda_bind(struct device *dev, struct device *master, pm_runtime_get_sync(dev); - comps->dev = dev; + comp->dev = dev; - strscpy(comps->name, dev_name(dev), sizeof(comps->name)); + strscpy(comp->name, dev_name(dev), sizeof(comp->name)); ret = tascodec_init(tas_hda->priv, codec, THIS_MODULE, tasdev_fw_ready); if (!ret) - comps->playback_hook = tas2781_hda_playback_hook; + comp->playback_hook = tas2781_hda_playback_hook; pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); @@ -751,13 +751,14 @@ static void tas2781_hda_unbind(struct device *dev, struct device *master, void *master_data) { struct tas2781_hda *tas_hda = dev_get_drvdata(dev); - struct hda_component *comps = master_data; - comps = &comps[tas_hda->priv->index]; - - if (comps->dev == dev) { - comps->dev = NULL; - memset(comps->name, 0, sizeof(comps->name)); - comps->playback_hook = NULL; + struct hda_component_parent *parent = master_data; + struct hda_component *comp; + + comp = hda_component_from_index(parent, tas_hda->priv->index); + if (comp && (comp->dev == dev)) { + comp->dev = NULL; + memset(comp->name, 0, sizeof(comp->name)); + comp->playback_hook = NULL; } tas2781_hda_remove_controls(tas_hda); From patchwork Mon Jun 3 10:35:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683593 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73AAE83CD9; Mon, 3 Jun 2024 10:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; cv=none; b=DEcYVI9g3tFfD3GbcETzsZenpwSnG/8zswtcVQzdEDY0M9a/OrOpMGbvcxsr/1UUlT0WNMrm8PbiwDLJApp86aYKawXQ/4GMb2QDEuwANNALW90qX8AjXDGqvrhdrxmfdNL389eo0urUFlTxfRNheltieJ3VQqHcfLxAbK8q3kw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410951; c=relaxed/simple; bh=oUtizzgKM4/3Y9KkrNWL/XebKvCrh4DHO7Gq6YBmIoQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NDjfZPOiENuc4CpCEcQYX/OPQbWNIkGK5VkWB3GdQ3V4hDhuGFxPtMzTTxFOFsqjkfVNYST4Fe+WmjjTroNA54GuEeZQpzHDAKDao/0IbYkUlitYOZrDr+jEjiVnwJlrNPQPe8WbQmSRkwwedsQqNigYebcVzLIeZ58mIyl37jA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=KoaRP/Ar; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="KoaRP/Ar" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535l7pe018316; Mon, 3 Jun 2024 05:35:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=HzZ9klruY/Ztssobbt7j7Ac2UZsl8E8kYKbpCSTaTdA=; b= KoaRP/Arn34eI38X4XNrs23UxtjOxXaXqHhTstt979gLF5BYDetUofnr9UBgBJU0 4qZW5XwFDaMOAi40QnaFDZgH5bzT4GJl+GguM3p/IZlToVGmIS9WujDoBpv8NqZz 42Cd0G/yP7bqNJoM2pMspW4jfRPyQXI+YZy3NJVF15M0wJJzjCa6RGWha4BBNhgb vXzXjyfC6+LN+dc/JOtXQazvO5p27qH6zSapadA5ienWao8Z70tLrRe6i1ZAYByf H+HPwgwnc1PEn6DO2yUxxXIkcnAztQ6bzK/T3dXO4caW+OAWInbfJzznNGjVgK5v 2kubmP9aKnE7+APngHNCGQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbq-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:33 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 3 Jun 2024 11:35:28 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:28 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 8205E820249; Mon, 3 Jun 2024 10:35:28 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 6/7] ALSA: hda: hda_component: Move codec field into the parent Date: Mon, 3 Jun 2024 11:35:23 +0100 Message-ID: <20240603103524.32442-7-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: znmTngXIww7_pS2_kFgRvYih2P0oyzUO X-Proofpoint-ORIG-GUID: znmTngXIww7_pS2_kFgRvYih2P0oyzUO X-Proofpoint-Spam-Reason: safe There is one codec shared across all of the bound HDA components and a copy is usually stashed in the amp driver so it doesn't need to be in every hda_component. Signed-off-by: Simon Trimmer --- sound/pci/hda/cs35l41_hda.c | 7 ++++--- sound/pci/hda/cs35l56_hda.c | 2 +- sound/pci/hda/hda_component.c | 5 +---- sound/pci/hda/hda_component.h | 2 +- sound/pci/hda/tas2781_hda_i2c.c | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/pci/hda/cs35l41_hda.c b/sound/pci/hda/cs35l41_hda.c index ceba4f2c85f1..ee9f83b737de 100644 --- a/sound/pci/hda/cs35l41_hda.c +++ b/sound/pci/hda/cs35l41_hda.c @@ -1436,10 +1436,11 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas mutex_lock(&cs35l41->fw_mutex); comp->dev = dev; + cs35l41->codec = parent->codec; if (!cs35l41->acpi_subsystem_id) cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", - comp->codec->core.subsystem_id); - cs35l41->codec = comp->codec; + cs35l41->codec->core.subsystem_id); + strscpy(comp->name, dev_name(dev), sizeof(comp->name)); cs35l41->firmware_type = HDA_CS_DSP_FW_SPK_PROT; @@ -1470,7 +1471,7 @@ static int cs35l41_hda_bind(struct device *dev, struct device *master, void *mas mutex_unlock(&cs35l41->fw_mutex); sleep_flags = lock_system_sleep(); - if (!device_link_add(&comp->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) + if (!device_link_add(&cs35l41->codec->core.dev, cs35l41->dev, DL_FLAG_STATELESS)) dev_warn(dev, "Unable to create device link\n"); unlock_system_sleep(sleep_flags); diff --git a/sound/pci/hda/cs35l56_hda.c b/sound/pci/hda/cs35l56_hda.c index df4498c77171..cc4aa90db1d1 100644 --- a/sound/pci/hda/cs35l56_hda.c +++ b/sound/pci/hda/cs35l56_hda.c @@ -697,7 +697,7 @@ static int cs35l56_hda_bind(struct device *dev, struct device *master, void *mas return -EBUSY; comp->dev = dev; - cs35l56->codec = comp->codec; + cs35l56->codec = parent->codec; strscpy(comp->name, dev_name(dev), sizeof(comp->name)); comp->playback_hook = cs35l56_hda_playback_hook; diff --git a/sound/pci/hda/hda_component.c b/sound/pci/hda/hda_component.c index 8c11c8b37799..1a9950b76866 100644 --- a/sound/pci/hda/hda_component.c +++ b/sound/pci/hda/hda_component.c @@ -134,12 +134,9 @@ static int hda_comp_match_dev_name(struct device *dev, void *data) int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent) { - int i; - /* Init shared and component specific data */ memset(parent, 0, sizeof(*parent)); - for (i = 0; i < ARRAY_SIZE(parent->comps); i++) - parent->comps[i].codec = cdc; + parent->codec = cdc; return component_bind_all(hda_codec_dev(cdc), parent); } diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h index e547e1f1e674..dd4dabeae9ee 100644 --- a/sound/pci/hda/hda_component.h +++ b/sound/pci/hda/hda_component.h @@ -19,7 +19,6 @@ struct hda_component { struct device *dev; char name[HDA_MAX_NAME_SIZE]; - struct hda_codec *codec; struct acpi_device *adev; bool acpi_notifications_supported; void (*acpi_notify)(acpi_handle handle, u32 event, struct device *dev); @@ -29,6 +28,7 @@ struct hda_component { }; struct hda_component_parent { + struct hda_codec *codec; struct hda_component comps[HDA_MAX_COMPONENTS]; }; diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c index c6c1e8e81972..d7af4fd10714 100644 --- a/sound/pci/hda/tas2781_hda_i2c.c +++ b/sound/pci/hda/tas2781_hda_i2c.c @@ -719,7 +719,7 @@ static int tas2781_hda_bind(struct device *dev, struct device *master, if (comp->dev) return -EBUSY; - codec = comp->codec; + codec = parent->codec; subid = codec->core.subsystem_id >> 16; switch (subid) { From patchwork Mon Jun 3 10:35:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Trimmer X-Patchwork-Id: 13683590 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 752B683CDA; Mon, 3 Jun 2024 10:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; cv=none; b=sXdxQWF8OUK1JECXegCdkP5gq+spQT/UExJ1NuimsdU4C2vAx7ZI549aeMJ8USDb85+DEDRtHeDXgHMSZy9TNaufvPyP7kqP2LsZ5ZxxgKpWxqMjvA5jcqdL30jJ3taLPuCYjYisJGRIldkYKjqw0COinZhmUsNuOKcrDlLTPxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717410950; c=relaxed/simple; bh=tyHcTilPJBf1ZtldFADW7DKJj5yP1ToJmKxXcIXtfGI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pyp7Of7odbOASUFgoMl50PnHXzAHKzaSyh+Ny8hkMKGlLzAWSfkzxn3oeo/U6IbXqdTCMSU6RB0eSu3+tymSzbaAaggl9mB1waMQPx3DQrdcdzNfGjEG4TSHl4+zfA1M9uhrl2IrWH5ivlu6n4pVs4j8Ra0CWV6FgvufmuaaTtQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=HqjbIreP; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="HqjbIreP" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4535SpqV028069; Mon, 3 Jun 2024 05:35:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=+0kLEE8LRxxWUa9qJB+cByKX7sWs5TP2HYGpu4CAWoU=; b= HqjbIrePigF45RLHqnlnRFfAo4N1yaSqaJNKtfIrC+6fR0NaFXnOoUac00Q3M2Zd NGAp7gWv6cTAwN80EwoPyW+kOqKEsEakKtclvVBP63MgBwG0CwoNYkeh4WZgIiQE OVpZ7++CJyQG+phhQHVm0bR8RHkkqEg9+ijQTvtmDefiDJ5pXo2csp8ArYGuEGkL BCIQgf1xN8hVkVLQJluGcgSGazAcCmepMl2LlVRLegqGvsPV+X8n/jzmv1wg/Yo+ 8CWFUNGQG/au7xVh+557ntOOBP5Mhcr6Iz1TZuH1aqYhYwCmwGyEhxuSXDxYXhIF Yuihb1i0Rb3MziqxL439cg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3yg11xscbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Jun 2024 05:35:31 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) 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.1544.9; Mon, 3 Jun 2024 11:35:29 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Mon, 3 Jun 2024 11:35:29 +0100 Received: from EDIN6ZZ2FY3.ad.cirrus.com (EDIN6ZZ2FY3.ad.cirrus.com [198.61.64.166]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id DBD1982024A; Mon, 3 Jun 2024 10:35:28 +0000 (UTC) From: Simon Trimmer To: CC: , , , , , , , , , Simon Trimmer Subject: [PATCH 7/7] ALSA: hda: hda_component: Protect shared data with a mutex Date: Mon, 3 Jun 2024 11:35:24 +0100 Message-ID: <20240603103524.32442-8-simont@opensource.cirrus.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240603103524.32442-1-simont@opensource.cirrus.com> References: <20240603103524.32442-1-simont@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: 0nwIrSmRf_IfMTA0X0QcMZBbFF3xBT3x X-Proofpoint-ORIG-GUID: 0nwIrSmRf_IfMTA0X0QcMZBbFF3xBT3x X-Proofpoint-Spam-Reason: safe The hda_component contains information shared from the amp drivers to the codec that can be altered (for example as the driver unloads). Guard the update and use of these to prevent use of stale data. Signed-off-by: Simon Trimmer --- sound/pci/hda/hda_component.c | 13 ++++++++++++- sound/pci/hda/hda_component.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_component.c b/sound/pci/hda/hda_component.c index 1a9950b76866..7b19cb38b4e0 100644 --- a/sound/pci/hda/hda_component.c +++ b/sound/pci/hda/hda_component.c @@ -21,11 +21,13 @@ void hda_component_acpi_device_notify(struct hda_component_parent *parent, struct hda_component *comp; int i; + mutex_lock(&parent->mutex); for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { comp = hda_component_from_index(parent, i); if (comp->dev && comp->acpi_notify) comp->acpi_notify(acpi_device_handle(comp->adev), event, comp->dev); } + mutex_unlock(&parent->mutex); } EXPORT_SYMBOL_NS_GPL(hda_component_acpi_device_notify, SND_HDA_SCODEC_COMPONENT); @@ -87,6 +89,7 @@ void hda_component_manager_playback_hook(struct hda_component_parent *parent, in struct hda_component *comp; int i; + mutex_lock(&parent->mutex); for (i = 0; i < ARRAY_SIZE(parent->comps); i++) { comp = hda_component_from_index(parent, i); if (comp->dev && comp->pre_playback_hook) @@ -102,6 +105,7 @@ void hda_component_manager_playback_hook(struct hda_component_parent *parent, in if (comp->dev && comp->post_playback_hook) comp->post_playback_hook(comp->dev, action); } + mutex_unlock(&parent->mutex); } EXPORT_SYMBOL_NS_GPL(hda_component_manager_playback_hook, SND_HDA_SCODEC_COMPONENT); @@ -134,11 +138,18 @@ static int hda_comp_match_dev_name(struct device *dev, void *data) int hda_component_manager_bind(struct hda_codec *cdc, struct hda_component_parent *parent) { + int ret; + /* Init shared and component specific data */ memset(parent, 0, sizeof(*parent)); + mutex_init(&parent->mutex); parent->codec = cdc; - return component_bind_all(hda_codec_dev(cdc), parent); + mutex_lock(&parent->mutex); + ret = component_bind_all(hda_codec_dev(cdc), parent); + mutex_unlock(&parent->mutex); + + return ret; } EXPORT_SYMBOL_NS_GPL(hda_component_manager_bind, SND_HDA_SCODEC_COMPONENT); diff --git a/sound/pci/hda/hda_component.h b/sound/pci/hda/hda_component.h index dd4dabeae9ee..9f786608144c 100644 --- a/sound/pci/hda/hda_component.h +++ b/sound/pci/hda/hda_component.h @@ -11,6 +11,7 @@ #include #include +#include #include #define HDA_MAX_COMPONENTS 4 @@ -28,6 +29,7 @@ struct hda_component { }; struct hda_component_parent { + struct mutex mutex; struct hda_codec *codec; struct hda_component comps[HDA_MAX_COMPONENTS]; }; @@ -93,7 +95,9 @@ static inline struct hda_component *hda_component_from_index(struct hda_componen static inline void hda_component_manager_unbind(struct hda_codec *cdc, struct hda_component_parent *parent) { + mutex_lock(&parent->mutex); component_unbind_all(hda_codec_dev(cdc), parent); + mutex_unlock(&parent->mutex); } #endif /* ifndef __HDA_COMPONENT_H__ */