Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp518305pxu; Fri, 23 Oct 2020 06:59:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfKbfW8Q1y0ijK/DkGIezzmnEDtPGv5q1Bc3DdFxRdE+tFO/pKP3nyv4wLVlgAkum1r9Zh X-Received: by 2002:a17:906:2e0e:: with SMTP id n14mr2026115eji.120.1603461590681; Fri, 23 Oct 2020 06:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603461590; cv=none; d=google.com; s=arc-20160816; b=y73iI5NXKDk3t+vAVi9NZqcTxsuuQJIU0TdkNcjJ7PczPRgPus+SE+xgmY3qjesvR2 TVOtvY4KgVXvZuQtkS/K5+2wfS+GD3w0PZl5HETBkjep2HcdiVPU5zSSAw0yjv0Y+cHq DRPYT5aNPOWcC3QDsKZmA2MkWbiNCnd3wa5Hj9Lij03IBj03FDfnd/KIbN79d/zuMd1A i9MvOvmhnEbLU5Lt/U9Q52IOb85jc30SLm3mP7GPZ93GjmEeCG+DNMA/cpbsqUjmACWr WYYis6k+XxgH1FaYI0+sUx+bBtn0myneWaIJjoTcqepUmOr3pJIa362p765PY4aI9Tzv F4hQ== 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=oO2HXUTENyVeFnDN3hchFfILd25Bg9wAzsFcQodbNrrkjCxp0GRInkJ71OtHJ4/HlT RBR8AQJQMR5u884iyc4+83+BcJhTkK3y5r4tD1pCxSx/iKdmaahNlpw+ciwzW7gB8x9K 0FqJevw6LbUsmHjkKimTLCxbR93Q6Xy4LLz362bhsn8ELzPueYj9T9GU6R+86rGSE4Hr +V3Gmxqie2QLQGfL085k7ykkfeHZiH4OVa2QjUR9Zb2W2izLgM4MEso25293nZBlDoKW mexkOSz0kwmEgKca7BugRXadjB13w1H4hfZizyveMtMid/7iMgJ2L6wfstW7tSS7obDS 4rHA== 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 bl4si1010264ejb.642.2020.10.23.06.59.28; Fri, 23 Oct 2020 06:59:50 -0700 (PDT) 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 S373902AbgJWAfe (ORCPT + 99 others); Thu, 22 Oct 2020 20:35:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:43018 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S373852AbgJWAf0 (ORCPT ); Thu, 22 Oct 2020 20:35:26 -0400 IronPort-SDR: G8BObdC6OAvMiB0YodMFt+DdpEpUJQXAUsIEWUZVFXC2y9n5fob44APavaiZ/n5Vg/XUt0yxTY Od4GAK6Y1tiw== X-IronPort-AV: E=McAfee;i="6000,8403,9782"; a="164118643" X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="164118643" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 17:35:25 -0700 IronPort-SDR: OTeiAXI1PaLWopJs+ay0MQ1U8VXU8WDVreh8x0jGpz4jL73ZAIqFBKK8Hvljt6XKW5esYGZEPv y13NwTARxp8Q== X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="302505801" Received: from dmert-dev.jf.intel.com ([10.166.241.5]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2020 17:35:24 -0700 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 v3 04/10] ASoC: SOF: ops: Add ops for client registration Date: Thu, 22 Oct 2020 17:33:32 -0700 Message-Id: <20201023003338.1285642-5-david.m.ertman@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201023003338.1285642-1-david.m.ertman@intel.com> References: <20201023003338.1285642-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