Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1271607pxb; Fri, 13 Nov 2020 08:25:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsvwVuZDj3gbMJx/qWFmXn2u96e9vxB+g7iODFDYOqwG9TFwPUD3pB4kgvhoAWIonNLXYV X-Received: by 2002:a17:906:c288:: with SMTP id r8mr2610339ejz.35.1605284740746; Fri, 13 Nov 2020 08:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605284740; cv=none; d=google.com; s=arc-20160816; b=PV/nRCd6n43QL3lPDcivci8mKnsLipTirYeo1yMhaWVVQ+wpm4sFwbyhp+//6vuxPh kWcNMYx2ycHiV+m704gEZHrjobqzotweX0LOQHhgQW2eF8Rs6onAxT9dpowP94Zf4AWe Cb7tCvvtuftJFjgGGzC5F93pSkzc4ee67rWxKpxW2LBa2uABWVterIcDaiO0DcdotxGF zqE5QbZGiBAcL11+9uRrEzQYBI83U9MGDwGnJvjQ891VA0EKtRAAfaUBsuUIqsruGm+i VeqBvgLty0MSyJQEmCwMh2tmk5uPZzpLs+jatd6cfFGDxY4m6T7TPFJXfaZ5xDbTkk2t 8w+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=uc5xppqCXKbZxeYs3EaX074vr3mvvBRnrzgh/OM/N24=; b=QVl6Ugyi9m7gvCo1+/Vsmqic1w0brpkgpTIkGz0z+X8ToXOSafvR7kNYK2IJgMOj+F TDPB17xLyPfr4sI905JkfPNSDVwgSugNUskx3PQ5jcOsLGUxCJCPROZdMZ7py0WzNY57 LkTZQZZFhdgMfo2BMynHQ0KxSoZHfFmQ4WvvpBG6gw4VEmlb7/OvSL1vG7ZXMAud5uVD nng+9WrF0ef8EpoGrIxW7TaOCkJ+TqOVJyTmu3EwQU/RO38c8jLbpToUr5reITB0e4Jd ujzbGOHH/ltDxI6EQUsNELEGYHmsGNNs7s0OknOoudMbEHcNZU4udfV2v0vjLc3fPhO/ U+Lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o5si6258841ejm.525.2020.11.13.08.25.17; Fri, 13 Nov 2020 08:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbgKMQW6 (ORCPT + 99 others); Fri, 13 Nov 2020 11:22:58 -0500 Received: from mga18.intel.com ([134.134.136.126]:46001 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgKMQVp (ORCPT ); Fri, 13 Nov 2020 11:21:45 -0500 IronPort-SDR: E5OxmvtJPvM5w/amJabfqQ+tdHAFLKbZF4YAyNTrUV/x7RBSHXEXjCf43qim2LZNzkuQ6ZOLF9 eF9eddKbqu2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9804"; a="158272289" X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="158272289" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 08:21:43 -0800 IronPort-SDR: 7xWpfFSdKcgBl+qASGrpV/jCI1GuerUtF4R1/bUaWfMnTEFf6MVWKNGgjrtD+VEKkp3KMVLRPK IJogL9NnnLbw== X-IronPort-AV: E=Sophos;i="5.77,475,1596524400"; d="scan'208";a="366767235" Received: from dmert-dev.jf.intel.com ([10.166.241.5]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 08:21:42 -0800 From: Dave Ertman To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, broonie@kernel.org, linux-rdma@vger.kernel.org, jgg@nvidia.com, dledford@redhat.com, netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org, gregkh@linuxfoundation.org, ranjani.sridharan@linux.intel.com, pierre-louis.bossart@linux.intel.com, fred.oh@linux.intel.com, parav@mellanox.com, shiraz.saleem@intel.com, dan.j.williams@intel.com, kiran.patil@intel.com, linux-kernel@vger.kernel.org, leonro@nvidia.com Subject: [PATCH v4 04/10] ASoC: SOF: ops: Add ops for client registration Date: Fri, 13 Nov 2020 08:18:53 -0800 Message-Id: <20201113161859.1775473-5-david.m.ertman@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201113161859.1775473-1-david.m.ertman@intel.com> References: <20201113161859.1775473-1-david.m.ertman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ranjani Sridharan Add new ops for registering/unregistering clients based on DSP capabilities and/or DT information. Reviewed-by: Pierre-Louis Bossart Signed-off-by: Ranjani Sridharan Signed-off-by: Dave Ertman --- sound/soc/sof/core.c | 10 ++++++++++ sound/soc/sof/ops.h | 14 ++++++++++++++ sound/soc/sof/sof-priv.h | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 72a97219395f..ddb9a12d5aac 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -246,8 +246,17 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) if (plat_data->sof_probe_complete) plat_data->sof_probe_complete(sdev->dev); + /* If registering certain clients fails, unregister the previously registered clients. */ + ret = snd_sof_register_clients(sdev); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to register clients %d\n", ret); + goto client_reg_err; + } + return 0; +client_reg_err: + snd_sof_unregister_clients(sdev); fw_trace_err: snd_sof_free_trace(sdev); fw_run_err: @@ -356,6 +365,7 @@ int snd_sof_device_remove(struct device *dev) dev_warn(dev, "error: %d failed to prepare DSP for device removal", ret); + snd_sof_unregister_clients(sdev); snd_sof_fw_unload(sdev); snd_sof_ipc_free(sdev); snd_sof_free_debug(sdev); diff --git a/sound/soc/sof/ops.h b/sound/soc/sof/ops.h index b21632f5511a..00370f8bcd75 100644 --- a/sound/soc/sof/ops.h +++ b/sound/soc/sof/ops.h @@ -470,6 +470,20 @@ snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, sof_ops(sdev)->set_mach_params(mach, dev); } +static inline int snd_sof_register_clients(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev) && sof_ops(sdev)->register_clients) + return sof_ops(sdev)->register_clients(sdev); + + return 0; +} + +static inline void snd_sof_unregister_clients(struct snd_sof_dev *sdev) +{ + if (sof_ops(sdev) && sof_ops(sdev)->unregister_clients) + sof_ops(sdev)->unregister_clients(sdev); +} + static inline const struct snd_sof_dsp_ops *sof_get_ops(const struct sof_dev_desc *d, const struct sof_ops_table mach_ops[], int asize) diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index dceac73b858f..cca239c09d0e 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -252,6 +252,10 @@ struct snd_sof_dsp_ops { void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, struct device *dev); /* optional */ + /* client ops */ + int (*register_clients)(struct snd_sof_dev *sdev); /* optional */ + void (*unregister_clients)(struct snd_sof_dev *sdev); /* optional */ + /* DAI ops */ struct snd_soc_dai_driver *drv; int num_drv; -- 2.26.2