From patchwork Fri Dec 20 17:35:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13917180 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 DB4AB22FDF7; Fri, 20 Dec 2024 17:35:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716159; cv=none; b=l5+Jv8sh4WPciorr7upyP1qSC3swKo9WHDmmkjtIVZq3xzjjqfaXEt7rpDVkTDalc6fx1nhvIh10LP4TLGDlznsMf0OSTvoSCxn4h7woQmjt8+bS/TqiJs+ZkDFQqK2kV7LTcLN1TBwX1pK82ka5Kf675O0re3vlXk9L8Lb/tHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716159; c=relaxed/simple; bh=GWnOkUmLTZNHE+/bXMWrp1MgkIeYWL2zroB6FZydnXo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Lg/uLxPF6FTgPY2w/kJlfwc++W6DF8MBRCNWXZMut0ZqOt8lhTGXlWaLPjdAblp/2WFZIKjS1yFIKOcQ2yVxixzljwLvelu5N/D0PTsjCJc5rUOfslXU/mwEB84m2M52UeVUd8RPJIQ6m7kUwqqF/HetLpsRc3YBGlwvjOApcXQ= 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=Tn41P38J; arc=none smtp.client-ip=67.231.152.168 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="Tn41P38J" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BK5g3sk016642; Fri, 20 Dec 2024 11:35:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=PODMain02222019; bh=v832DBdzgsH24BAJ 3ESwKsvTWps8z8nWhI0IDLOgsWY=; b=Tn41P38Jp1tNwU659HLtkUvLwK3dcaGT /rBgInzUGErXmrUOUCKm79YNuSCBtwtpSj612uNCCMtz3BpAA9sl6j9d1HMdNpcw 0Zm+QdhVBsh5KuAe03SZ7zGNjTPUR3TECFisJqPwn7amwngwjIiQnGRjdx9Q2mxT Rn6HcHp5RqkxAVZtQpba7FiYmqxjEYhIizgSArBYDBq2IYF2OmaXuCGs2nWWF4a5 IO2d1SwpC90caN5OiobqdM6cZEysV5djWRa/C5+v3e3DShmAUYfRHVNNcZaw+f0E YforVg55haAP0MXiB3bRWM8xJXuMQ4CH5D8teFZ0XYEsAb5fVLoACg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 43h7akg161-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 11:35:17 -0600 (CST) 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.13; Fri, 20 Dec 2024 17:35:16 +0000 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.13 via Frontend Transport; Fri, 20 Dec 2024 17:35:16 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 17BEC820247; Fri, 20 Dec 2024 17:35:16 +0000 (UTC) From: Charles Keepax To: CC: , , , , , , Subject: [PATCH 1/5] ASoC: SDCA: Add missing header includes Date: Fri, 20 Dec 2024 17:35:12 +0000 Message-ID: <20241220173516.907406-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: KrWO0kQ1mFWqaWtkHXCl77LWA_kDjr2s X-Proofpoint-ORIG-GUID: KrWO0kQ1mFWqaWtkHXCl77LWA_kDjr2s X-Proofpoint-Spam-Reason: safe Several of the SDCA files don't include all the headers they use locally. These are included by the point of use through other headers, so it is not currently causing any issues. However, files should directly include things they directly use, so add the missing header includes. Signed-off-by: Charles Keepax --- include/sound/sdca.h | 3 +++ include/sound/sdca_function.h | 2 ++ sound/soc/sdca/sdca_device.c | 2 ++ sound/soc/sdca/sdca_functions.c | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/include/sound/sdca.h b/include/sound/sdca.h index 7e138229e8f3..3eea1dfec16c 100644 --- a/include/sound/sdca.h +++ b/include/sound/sdca.h @@ -9,6 +9,9 @@ #ifndef __SDCA_H__ #define __SDCA_H__ +#include +#include + struct sdw_slave; #define SDCA_MAX_FUNCTION_COUNT 8 diff --git a/include/sound/sdca_function.h b/include/sound/sdca_function.h index a01eec86b9a6..6943df0851a9 100644 --- a/include/sound/sdca_function.h +++ b/include/sound/sdca_function.h @@ -9,6 +9,8 @@ #ifndef __SDCA_FUNCTION_H__ #define __SDCA_FUNCTION_H__ +#include + /* * SDCA Function Types from SDCA specification v1.0a Section 5.1.2 * all Function types not described are reserved diff --git a/sound/soc/sdca/sdca_device.c b/sound/soc/sdca/sdca_device.c index 80d663777eb5..b6399b773986 100644 --- a/sound/soc/sdca/sdca_device.c +++ b/sound/soc/sdca/sdca_device.c @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index 652865329968..1808e5e7dee2 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -7,7 +7,11 @@ */ #include +#include +#include +#include #include +#include #include #include From patchwork Fri Dec 20 17:35:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13917182 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 4E11A21E0BF; Fri, 20 Dec 2024 17:36:38 +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=1734716202; cv=none; b=o939LMKjUb+CYBH5/TPOLWLpfcPhoqOT6ugD7gC5TC8uZmi/84R1+MBN1afTOANqxClZ6Kq3JxeOFnIA5EnLuKPdyMGKSY1osTQ26RelQhJrQBJw+JMriL6ZhGUdQKxTMqNCJC0/Mczenur42lOKDA0Z+xspGSERicpjc5ykUIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716202; c=relaxed/simple; bh=VJC5/gi/01O6HjbiX7CO4zfrxroD0JoLVZCH0v7SBcY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uar5Iz1wewzzOr0RCxv2LCAAaHd1ZgYG7riTq5NrFwfWRzISXAjb0j3EArW3dE8U6BmM64HktzfKkl49U4BRilTbtrygdcVefXBxVudLsn0tPxDG5SJu8ClRvFiU22HhxV52UB+fjVWO8ntTc2s0pBOpTSPewaz2CrC/OKt+H0s= 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=pwkO5Inz; 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="pwkO5Inz" 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 4BK6qF4H002908; Fri, 20 Dec 2024 11:35:18 -0600 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=tiF6vpndR/TYQxOPfKuHWxiALPaqlrZfM7Ed/jIvYAI=; b= pwkO5InzRTH9EpGqTnJm2Z48fRfq//LqkNSAnAP2X07hjRW4L2JxO6ERI6EnA4at o7qn5hWhA5jWFx6CgS1JzotHAGbep21Pj7rpT6gpxO7l+X5ENGg0eIpEUI3atDzr air4vFu9l7cK9AcNLri59M5uJO8rSX4mAtUuTU0Jp5BEg0INYHkcJgP02LJJTwy4 dwbf1REiWtWwW9CAbpM2k4D7mrDHJwcuMbxElKqEv5IC/y3+HN94K/5K9x6dqoIL 8snxMKaZQRHEK9Dx9vMbSoKZWO8dX9Exo1wOkvn3AT+9GWmWgH+xwV6nXprf8V5K Nph2LVIekKF7wY5WQBNduw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 43h8a286sg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 11:35:18 -0600 (CST) 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.13; Fri, 20 Dec 2024 17:35:16 +0000 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.13 via Frontend Transport; Fri, 20 Dec 2024 17:35:16 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 1C55282024A; Fri, 20 Dec 2024 17:35:16 +0000 (UTC) From: Charles Keepax To: CC: , , , , , , Subject: [PATCH 2/5] ASoC: SDCA: Clean up error messages Date: Fri, 20 Dec 2024 17:35:13 +0000 Message-ID: <20241220173516.907406-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220173516.907406-1-ckeepax@opensource.cirrus.com> References: <20241220173516.907406-1-ckeepax@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-ORIG-GUID: sSdzd9c4gDqB1UWQlaxYYqkGVvfiVduI X-Proofpoint-GUID: sSdzd9c4gDqB1UWQlaxYYqkGVvfiVduI X-Proofpoint-Spam-Reason: safe All the error messages in the SDCA code manually print the function in the output, update these to use dev_fmt instead. Whilst making the changes tweak a couple of the error messages to make them a little shorter. Signed-off-by: Charles Keepax --- sound/soc/sdca/sdca_functions.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index 1808e5e7dee2..46aa874bb0aa 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -6,6 +6,8 @@ * https://www.mipi.org/mipi-sdca-v1-0-download */ +#define dev_fmt(fmt) "%s: " fmt, __func__ + #include #include #include @@ -49,8 +51,8 @@ static int patch_sdca_function_type(struct device *dev, function_type_patch = SDCA_FUNCTION_TYPE_HID; break; default: - dev_warn(dev, "%s: SDCA version %#x unsupported function type %d, skipped\n", - __func__, interface_revision, *function_type); + dev_warn(dev, "SDCA version %#x invalid function type %d\n", + interface_revision, *function_type); return -EINVAL; } @@ -77,17 +79,14 @@ static int patch_sdca_function_type(struct device *dev, case SDCA_FUNCTION_TYPE_SPEAKER_MIC: case SDCA_FUNCTION_TYPE_RJ: case SDCA_FUNCTION_TYPE_IMP_DEF: - dev_warn(dev, "%s: found unsupported SDCA function type %d, skipped\n", - __func__, *function_type); + dev_warn(dev, "unsupported SDCA function type %d\n", *function_type); return -EINVAL; default: - dev_err(dev, "%s: found invalid SDCA function type %d, skipped\n", - __func__, *function_type); + dev_err(dev, "invalid SDCA function type %d\n", *function_type); return -EINVAL; } - dev_info(dev, "%s: found SDCA function %s (type %d)\n", - __func__, *function_name, *function_type); + dev_info(dev, "SDCA function %s (type %d)\n", *function_name, *function_type); return 0; } @@ -105,7 +104,7 @@ static int find_sdca_function(struct acpi_device *adev, void *data) int ret; if (sdca_data->num_functions >= SDCA_MAX_FUNCTION_COUNT) { - dev_err(dev, "%s: maximum number of functions exceeded\n", __func__); + dev_err(dev, "maximum number of functions exceeded\n"); return -EINVAL; } @@ -119,7 +118,7 @@ static int find_sdca_function(struct acpi_device *adev, void *data) return ret; if (!addr) { - dev_err(dev, "%s: no addr\n", __func__); + dev_err(dev, "no addr\n"); return -ENODEV; } @@ -144,8 +143,7 @@ static int find_sdca_function(struct acpi_device *adev, void *data) fwnode_handle_put(control5); if (ret < 0) { - dev_err(dev, "%s: the function type can only be determined from ACPI information\n", - __func__); + dev_err(dev, "function type only supported as DisCo constant\n"); return ret; } From patchwork Fri Dec 20 17:35:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13917178 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 B5C512153EF; Fri, 20 Dec 2024 17:35:41 +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=1734716143; cv=none; b=XJ0h8B9HlR1dhk+204/12JC1K0UCDL+Fbvs/M+AVBE+3VkhD5EsfMPOiiOAyqLTG6gzxeTX1Zg5xB/cuHT4F4r6QDEgO7fXsrdFpgzZxkVJF7ClQrXlN+gvIZf602QZ4ZfYHRns1uzIWZvK9YIJU9jiyrhRqucmIlluYnONhb6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716143; c=relaxed/simple; bh=BzqGWroKZjDmhu6P1Hhdsz2LRc18bdKfJrUO20cbr/w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rhAq1AbKx6w/ZlU81TrYLnoWwN7J42vwRrZhhYb+KNjy38X1DdUcflfi/nLq2zRp+h5I73jB2Rw58FvvnD6XUk51FjRla78+BjmDz5YcgaSKT/On36eb+Zk+0Bevvn/Bv3Q8sr4OkbqRD8sI4LpwgVkd6hm967a+Ta6/xpT4jo4= 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=GmQKQdV8; 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="GmQKQdV8" 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 4BK6qF4I002908; Fri, 20 Dec 2024 11:35:19 -0600 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=NKacIoYOjG/4X0rXHByPFb4MP/Q4BaorAIurYMYf09s=; b= GmQKQdV8b9gGckV2Itd0DEwlBx54TYTWbjuj1N1MBcWv3nyzpIk4LXQaC66pEwsr M5RIxYjnqEun5VHSpHXxJMBNahHoCHAkkd7ulWNhw2euN+Tk77MhmAUchVcgLSmj mD28Dz8ieuMF58jcZWYJI1DZ9YhNnw0knJg6PkzqhrkN69+1uNSUpQjSCPh2mZrf zYwbv8hsxRvE3PBLlamjvRfbrSFpGiKM7oJBRfLcMDZH6HphuG5JJYdto0OPmCDN YDpxlnF75J7AwkAOc/eAFc5h7y/huwmsLp42Pl8SZQJlvDiBdroITb30zP9LcxH+ cYLRCIaJWj05TY2NWhnOnA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 43h8a286sg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 11:35:19 -0600 (CST) 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.13; Fri, 20 Dec 2024 17:35:16 +0000 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.13 via Frontend Transport; Fri, 20 Dec 2024 17:35:16 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 2A77382024B; Fri, 20 Dec 2024 17:35:16 +0000 (UTC) From: Charles Keepax To: CC: , , , , , , Subject: [PATCH 3/5] ASoC: SDCA: Add bounds check for function address Date: Fri, 20 Dec 2024 17:35:14 +0000 Message-ID: <20241220173516.907406-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220173516.907406-1-ckeepax@opensource.cirrus.com> References: <20241220173516.907406-1-ckeepax@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-ORIG-GUID: Fje3O2f7KKPAeI3Am_anEfY3xalqviKA X-Proofpoint-GUID: Fje3O2f7KKPAeI3Am_anEfY3xalqviKA X-Proofpoint-Spam-Reason: safe SDCA only supports 3-bits for the function address, but the ACPI value is 64-bits. Update the code that parses this to do a bounds check and error out on invalid addresses. Currently, an invalid address would truncate to the bottom 3-bits when used and thus use a likely incorrect address. With the bounds check, it is also now safe to shrink the size of the adr member of sdca_function_desc to a u8 and rearrange the struct members to pack better with the new size of adr. Signed-off-by: Charles Keepax --- include/sound/sdca.h | 4 ++-- sound/soc/sdca/sdca_functions.c | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/sound/sdca.h b/include/sound/sdca.h index 3eea1dfec16c..973252d0adac 100644 --- a/include/sound/sdca.h +++ b/include/sound/sdca.h @@ -23,9 +23,9 @@ struct sdw_slave; * @name: human-readable string */ struct sdca_function_desc { - u64 adr; - u32 type; const char *name; + u32 type; + u8 adr; }; /** diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index 46aa874bb0aa..a69fdb9c8b15 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -108,17 +108,12 @@ static int find_sdca_function(struct acpi_device *adev, void *data) return -EINVAL; } - /* - * The number of functions cannot exceed 8, we could use - * acpi_get_local_address() but the value is stored as u64 so - * we might as well avoid casts and intermediate levels - */ ret = acpi_get_local_u64_address(adev->handle, &addr); if (ret < 0) return ret; - if (!addr) { - dev_err(dev, "no addr\n"); + if (!addr || addr > 0x7) { + dev_err(dev, "invalid addr: 0x%llx\n", addr); return -ENODEV; } From patchwork Fri Dec 20 17:35:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13917181 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 72AE521A453; Fri, 20 Dec 2024 17:36:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716199; cv=none; b=LzlLS1+hjpZWU9DW1LzPhKGjiKiiwV6l2XJmfg3R2F/d0w12G9Flszhw+gQ0IysvqjXdw0xg8aCKHUnq7bgITZVPZb4sxHc0UKbDv0Kk8mab9XKuaLSg5Ju9+UhG/RLF0PpMVSfG9du5V3dpedIV/IQWzm3Jr0bpfXl0CIsmipA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716199; c=relaxed/simple; bh=xtF+36SMfxfhe9JRceUbBeqEiyy8uqvUjADdoamyHYU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JrjUKXP3O+ul35OrQjdu2KTnsaeMZVhEbxtzGE3GQLs9psmEIvI7/A3RzhekR7kTbZXayEh2KWKoUmBEbGzDo593JuVcPqTCdb9ow+QCFdyzoBYVC3uyEpJ/UbdCowub3KfQQLpBnmmpybh06uwIyV7JCXem+9Z65Hj3xBQXSCg= 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=OFm7f3Oa; arc=none smtp.client-ip=67.231.152.168 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="OFm7f3Oa" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BK5g3sn016642; Fri, 20 Dec 2024 11:35:19 -0600 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=9syz/MhKemx45uOst2LQPmQseehXbKQ2TdZ4lAM/OTU=; b= OFm7f3Oa5djA0tLgSUsLgvxwZdwZSJkmPWNk8D6lfuTk9fadVJKlIyHmddvvuwi/ RTUhZji86j23zayVqn8BdwGJw5+PyfUamwOMdIL604MXMEhnz9C2FphtIcw0iH8S NvT946OtV6tszrRBm4oT46+1b2Yjjd2n8+sxkRpVGln1urBuFztw4NUOjqsPWwl2 38WS5ETKJikcM9kJCPQ7dY9hArxqKXJktvFOStNLJn0DAH0FOmSZ05ZhOTZE6d6f xq6ghgvfAQ+iCgqCP+19pUC4Jz6EK/bSTjEDNSf9epc1NF9Q3MDxHk1GPUrbkD3z +69C8dQ3Ht5pPiGWRwYTGQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 43h7akg161-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 11:35:18 -0600 (CST) 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.13; Fri, 20 Dec 2024 17:35:16 +0000 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.13 via Frontend Transport; Fri, 20 Dec 2024 17:35:16 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 2E50D82024D; Fri, 20 Dec 2024 17:35:16 +0000 (UTC) From: Charles Keepax To: CC: , , , , , , Subject: [PATCH 4/5] ASoC: SDCA: Add missing function type names Date: Fri, 20 Dec 2024 17:35:15 +0000 Message-ID: <20241220173516.907406-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220173516.907406-1-ckeepax@opensource.cirrus.com> References: <20241220173516.907406-1-ckeepax@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: qnHhMtV70jSfyfR1s5dV58qag6DNhVZo X-Proofpoint-ORIG-GUID: qnHhMtV70jSfyfR1s5dV58qag6DNhVZo X-Proofpoint-Spam-Reason: safe It is not helpful to error out on some SDCA function types, we might as well report the correct name and let the driver core simply not bind a driver to those functions for which the code lacks support. Also given no functions currently have support, it seems odd to select some as unsupported. Signed-off-by: Charles Keepax --- include/sound/sdca_function.h | 1 + sound/soc/sdca/sdca_functions.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/sound/sdca_function.h b/include/sound/sdca_function.h index 6943df0851a9..89e42db6d591 100644 --- a/include/sound/sdca_function.h +++ b/include/sound/sdca_function.h @@ -42,6 +42,7 @@ enum sdca_function_type { #define SDCA_FUNCTION_TYPE_RJ_NAME "RJ" #define SDCA_FUNCTION_TYPE_SIMPLE_NAME "SimpleJack" #define SDCA_FUNCTION_TYPE_HID_NAME "HID" +#define SDCA_FUNCTION_TYPE_IMP_DEF_NAME "ImplementationDefined" enum sdca_entity0_controls { SDCA_CONTROL_ENTITY_0_COMMIT_GROUP_MASK = 0x01, diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index a69fdb9c8b15..400763e056fa 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -75,12 +75,20 @@ static int patch_sdca_function_type(struct device *dev, *function_name = SDCA_FUNCTION_TYPE_HID_NAME; break; case SDCA_FUNCTION_TYPE_SIMPLE_AMP: + *function_name = SDCA_FUNCTION_TYPE_SIMPLE_AMP_NAME; + break; case SDCA_FUNCTION_TYPE_SIMPLE_MIC: + *function_name = SDCA_FUNCTION_TYPE_SIMPLE_MIC_NAME; + break; case SDCA_FUNCTION_TYPE_SPEAKER_MIC: + *function_name = SDCA_FUNCTION_TYPE_SPEAKER_MIC_NAME; + break; case SDCA_FUNCTION_TYPE_RJ: + *function_name = SDCA_FUNCTION_TYPE_RJ_NAME; + break; case SDCA_FUNCTION_TYPE_IMP_DEF: - dev_warn(dev, "unsupported SDCA function type %d\n", *function_type); - return -EINVAL; + *function_name = SDCA_FUNCTION_TYPE_IMP_DEF_NAME; + break; default: dev_err(dev, "invalid SDCA function type %d\n", *function_type); return -EINVAL; From patchwork Fri Dec 20 17:35:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13917179 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 1839621E0BB; Fri, 20 Dec 2024 17:35:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716154; cv=none; b=EfxYKK6fgNohOIu+IF4X2WVn9m3GJ0Mz9QDlcVXCieoeGDz9Sa4X2+9YgjggIx1A34lrulgisTKge0/AgVyZ9E3lWO8WZ9LyGQdTjOYc4lUDaK7RlC29MlHCW+/T272lz2PowQHV6cdmfBXa7jeXXXVRtaUMmsFXfmAWYml6qX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734716154; c=relaxed/simple; bh=8B2On/spqRTBsgBnrR+xF32xPjSUbrrPetqba3MM4EA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BrMlQUWrFToZ6ZFkBVvagXVP7JYaJdsdb8e3sIqH/jGDDGhDi7yvsSHQ5M8WDeZieFfbv8ZQN9CdXHjIRKdTv/0bedq0MAtosMh+LZVzmFSz/1edUBJB7jqDmlh7CPMfEk8p+bMqcv9bv8GUR4wRN8TV7YSs6Vd7/lu+y3BpMYU= 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=qVNdcZlY; arc=none smtp.client-ip=67.231.152.168 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="qVNdcZlY" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BK5g3sm016642; Fri, 20 Dec 2024 11:35:18 -0600 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=CwwYTZj8rOTUzy0cIfvNx/NVEkCVr7rfFAwrv2tL7HE=; b= qVNdcZlYYqvs5JqrlpLJ55Xu/N1CiKFe+gRJ3lQe4oCZdRdOPJ7gtH3kIc4Ym+il ep61Kp4x2y0U5EXsjO4XMDZAs6OgMl4NQsUqxMCXZffKrHEfZdJasyVA+uI7faL4 1WpgkGNyKIEMPchoD6KLrbH/F7Xo7o/RZ9/qCFfYAtl+SdfKm05Y74qkKfMFVmzz 4ZJVRja0mnii8RpsZI08wHEbowbFzOXPYUWXHSU8rOO2INVCeIo2VMAXCELOC+wc rNZ9p1Hxi5Kcn4/zhRGKY0ysN7vR6U1/xIlBmGtQiZpZz5Fw11xyu89jmsjUvHYy cRIlCnkYnaLx0YKSdLFZZA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 43h7akg161-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Dec 2024 11:35:18 -0600 (CST) 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.13; Fri, 20 Dec 2024 17:35:16 +0000 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.13 via Frontend Transport; Fri, 20 Dec 2024 17:35:16 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 31E61820257; Fri, 20 Dec 2024 17:35:16 +0000 (UTC) From: Charles Keepax To: CC: , , , , , , Subject: [PATCH 5/5] ASoC: SDCA: Split function type patching and function naming Date: Fri, 20 Dec 2024 17:35:16 +0000 Message-ID: <20241220173516.907406-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241220173516.907406-1-ckeepax@opensource.cirrus.com> References: <20241220173516.907406-1-ckeepax@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: od2GcPTflMkxY1cTGzvBV_XD96PxkB94 X-Proofpoint-ORIG-GUID: od2GcPTflMkxY1cTGzvBV_XD96PxkB94 X-Proofpoint-Spam-Reason: safe Currently, patch_sdca_function_type() both patches the function type for older SDCA revisions, and reports the name of the function. In general it is cleaner to have a single function only do a single task, so split these operations into two separate functions. Signed-off-by: Charles Keepax --- sound/soc/sdca/sdca_functions.c | 117 +++++++++++++++----------------- 1 file changed, 53 insertions(+), 64 deletions(-) diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c index 400763e056fa..38071bc838b9 100644 --- a/sound/soc/sdca/sdca_functions.c +++ b/sound/soc/sdca/sdca_functions.c @@ -17,86 +17,64 @@ #include #include -static int patch_sdca_function_type(struct device *dev, - u32 interface_revision, - u32 *function_type, - const char **function_name) +static int patch_sdca_function_type(u32 interface_revision, u32 *function_type) { - unsigned long function_type_patch = 0; - /* * Unfortunately early SDCA specifications used different indices for Functions, * for backwards compatibility we have to reorder the values found */ - if (interface_revision >= 0x0801) - goto skip_early_draft_order; - - switch (*function_type) { - case 1: - function_type_patch = SDCA_FUNCTION_TYPE_SMART_AMP; - break; - case 2: - function_type_patch = SDCA_FUNCTION_TYPE_SMART_MIC; - break; - case 3: - function_type_patch = SDCA_FUNCTION_TYPE_SPEAKER_MIC; - break; - case 4: - function_type_patch = SDCA_FUNCTION_TYPE_UAJ; - break; - case 5: - function_type_patch = SDCA_FUNCTION_TYPE_RJ; - break; - case 6: - function_type_patch = SDCA_FUNCTION_TYPE_HID; - break; - default: - dev_warn(dev, "SDCA version %#x invalid function type %d\n", - interface_revision, *function_type); - return -EINVAL; + if (interface_revision < 0x0801) { + switch (*function_type) { + case 1: + *function_type = SDCA_FUNCTION_TYPE_SMART_AMP; + break; + case 2: + *function_type = SDCA_FUNCTION_TYPE_SMART_MIC; + break; + case 3: + *function_type = SDCA_FUNCTION_TYPE_SPEAKER_MIC; + break; + case 4: + *function_type = SDCA_FUNCTION_TYPE_UAJ; + break; + case 5: + *function_type = SDCA_FUNCTION_TYPE_RJ; + break; + case 6: + *function_type = SDCA_FUNCTION_TYPE_HID; + break; + default: + return -EINVAL; + } } -skip_early_draft_order: - if (function_type_patch) - *function_type = function_type_patch; + return 0; +} - /* now double-check the values */ - switch (*function_type) { +static const char *get_sdca_function_name(u32 function_type) +{ + switch (function_type) { case SDCA_FUNCTION_TYPE_SMART_AMP: - *function_name = SDCA_FUNCTION_TYPE_SMART_AMP_NAME; - break; + return SDCA_FUNCTION_TYPE_SMART_AMP_NAME; case SDCA_FUNCTION_TYPE_SMART_MIC: - *function_name = SDCA_FUNCTION_TYPE_SMART_MIC_NAME; - break; + return SDCA_FUNCTION_TYPE_SMART_MIC_NAME; case SDCA_FUNCTION_TYPE_UAJ: - *function_name = SDCA_FUNCTION_TYPE_UAJ_NAME; - break; + return SDCA_FUNCTION_TYPE_UAJ_NAME; case SDCA_FUNCTION_TYPE_HID: - *function_name = SDCA_FUNCTION_TYPE_HID_NAME; - break; + return SDCA_FUNCTION_TYPE_HID_NAME; case SDCA_FUNCTION_TYPE_SIMPLE_AMP: - *function_name = SDCA_FUNCTION_TYPE_SIMPLE_AMP_NAME; - break; + return SDCA_FUNCTION_TYPE_SIMPLE_AMP_NAME; case SDCA_FUNCTION_TYPE_SIMPLE_MIC: - *function_name = SDCA_FUNCTION_TYPE_SIMPLE_MIC_NAME; - break; + return SDCA_FUNCTION_TYPE_SIMPLE_MIC_NAME; case SDCA_FUNCTION_TYPE_SPEAKER_MIC: - *function_name = SDCA_FUNCTION_TYPE_SPEAKER_MIC_NAME; - break; + return SDCA_FUNCTION_TYPE_SPEAKER_MIC_NAME; case SDCA_FUNCTION_TYPE_RJ: - *function_name = SDCA_FUNCTION_TYPE_RJ_NAME; - break; + return SDCA_FUNCTION_TYPE_RJ_NAME; case SDCA_FUNCTION_TYPE_IMP_DEF: - *function_name = SDCA_FUNCTION_TYPE_IMP_DEF_NAME; - break; + return SDCA_FUNCTION_TYPE_IMP_DEF_NAME; default: - dev_err(dev, "invalid SDCA function type %d\n", *function_type); - return -EINVAL; + return NULL; } - - dev_info(dev, "SDCA function %s (type %d)\n", *function_name, *function_type); - - return 0; } static int find_sdca_function(struct acpi_device *adev, void *data) @@ -150,10 +128,21 @@ static int find_sdca_function(struct acpi_device *adev, void *data) return ret; } - ret = patch_sdca_function_type(dev, sdca_data->interface_revision, - &function_type, &function_name); - if (ret < 0) + ret = patch_sdca_function_type(sdca_data->interface_revision, &function_type); + if (ret < 0) { + dev_err(dev, "SDCA version %#x invalid function type %d\n", + sdca_data->interface_revision, function_type); return ret; + } + + function_name = get_sdca_function_name(function_type); + if (!function_name) { + dev_err(dev, "invalid SDCA function type %d\n", function_type); + return -EINVAL; + } + + dev_info(dev, "SDCA function %s (type %d) at 0x%llx\n", + function_name, function_type, addr); /* store results */ func_index = sdca_data->num_functions;