From patchwork Mon Apr 29 13:29:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163023 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1887709ill; Mon, 29 Apr 2019 06:29:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqynkyXYf5MwuNrKGedDt9ckGvIQ6HaWliVEfFPeRMCSJ9up/m4kgpEBX4dd0eIClDZ3lpqX X-Received: by 2002:a63:a849:: with SMTP id i9mr14072699pgp.205.1556544595613; Mon, 29 Apr 2019 06:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544595; cv=none; d=google.com; s=arc-20160816; b=oWSGIwoyHALUEgGtKlSRGJ+g04gsk31w5Z7KO4IE5Fa4FqU63zA8FriTJJZnbK5Ah7 2eHCPwUhDXvipKLxmCfOfkKfIBloAa++8zYpGQl73w6c1qpwsVgZ/cRQVbvEONZdQUV/ 7c9L9Z7e7HVxbDuMH7eyIoJ8ErvMC1dznJvfKJ+q90dj3VdNl1dWbW0xPgBEbgCJpdCh wKjsoSFD1nCm1gheLTbCPsjemPOHxZlg5qK+SQKRKKwnwnVBPSXoapM15PGJiPM9kKWr q+NPV+2NbHfZwcfbgovj6pVK1zt6p36EUlVPDJplGxn+FCO4/BTS5NZkkdWeTREZwRg0 tR3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u5gkjIo0jKHz5nMirUsgx+T49vpY9J+GcHz2XWc4FKc=; b=MJzZOt6zFnOlfLMvVpw8yUthwSzAZ3I0SKTcstZDr4HMgzFwGrFHNSOGl6PQjbKAx9 500kdDs+l8tm41tvb/gUxVnpmJCTXCy+Pl2LS9oM1t+EtcnM8xFztLZ+9kigGDatmvOg 4Eexl+eruWWKs4aTIxDqo20conPaM9Bpl9AZeXr3FjmrJ8ZAeee0+uMvRQjrxnqu9dcy XhKPUkaw81eLIy+W8wT1N0p1SBQsmDYksg9uu+B08LPbOo032aUvIyGp3tZ/wnnJRNPE BCJ374uyxYzdSwcZ+1byn3XLuSISCiwrCrC0Nvgp/Ub+Qt2gGeeLPgDyYUxMz6PYoz0e jR2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=pFUVGdlR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl5si7420539plb.397.2019.04.29.06.29.55; Mon, 29 Apr 2019 06:29:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=pFUVGdlR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728263AbfD2N3y (ORCPT + 30 others); Mon, 29 Apr 2019 09:29:54 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32851 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfD2N3v (ORCPT ); Mon, 29 Apr 2019 09:29:51 -0400 Received: by mail-wr1-f66.google.com with SMTP id s18so16140521wrp.0 for ; Mon, 29 Apr 2019 06:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u5gkjIo0jKHz5nMirUsgx+T49vpY9J+GcHz2XWc4FKc=; b=pFUVGdlRPrcuUqW2/0hELTzPbKKNEYhqDI3CkoHGbZm5Yq65C2D4IF8ZEXBAdCGtm8 6y06tr2gg4sOArlY8cGKjM3ebjdz0ngMoptkgu46RzVGo5BR9g2+DFM/wOEPtp9o8wT4 Rwoc0G8zd17SAbTmHP7FagKPPu93ZXMX/8yb+MbH4oV242MLkVQFh4kWT4loQuxdmu0x tYoULFW6Gm/RlFujGK8PtsjODesDRrDXCUEXXxbX1fOWnMy/BdnVREtQkCQeYj8X50nr ymiJSVYd7oFu6C++IEeQyMRAe+AFq2Wdm4m2vv7Zk3zP031MG5rTwCecm4QiH1gEyYXu Hx8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u5gkjIo0jKHz5nMirUsgx+T49vpY9J+GcHz2XWc4FKc=; b=M/tC5zWnXfxzrceQwZHC1nzukuJTutaiA5SuJjjpQFkcNArycXWD25ALDQRQ15w4Qk mlQMjIjPRobEveOcZgj4XB3cQXnLIMN/CDPMTKXvR39FQUv4xptWrKOhz7zbF/bQd5i9 QUxEwpkZ2og7GIvfogPYb6muSPAzTuW8VSKSsiRj4p2WuPZfAVWtkOwB+MzWhMoC34eJ ePuVzoNBnpltbuN58jy+EqEq0PhZ9xDJ1GRgMYdlzYxYJbJUZJoeN1gpgZMUUSmURl6I D58Eb9YkP/SVvSKlG6rM77WXlTZO7jGI8upj1Uu7oX/SlaT2gwXZvQJC3I9fdfdXPREe B8fw== X-Gm-Message-State: APjAAAU8JnPhFoFrkTTzejpsrEqZfOkAPkpRIdv8h0Qe+EexY9lyAHHB OAoL9HClZpDPa3JAU/xLgCvpvA== X-Received: by 2002:a5d:4392:: with SMTP id i18mr10153524wrq.239.1556544589439; Mon, 29 Apr 2019 06:29:49 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:48 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 1/6] ASoC: hdmi-codec: remove function name debug traces Date: Mon, 29 Apr 2019 15:29:38 +0200 Message-Id: <20190429132943.16269-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the debug traces only showing the function name on entry. The same can be obtained using ftrace. Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 12 ------------ 1 file changed, 12 deletions(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index e5b6769b9797..9dca24732069 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -416,8 +416,6 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); int ret = 0; - dev_dbg(dai->dev, "%s()\n", __func__); - ret = hdmi_codec_new_stream(substream, dai); if (ret) return ret; @@ -453,8 +451,6 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - dev_dbg(dai->dev, "%s()\n", __func__); - WARN_ON(hcp->current_stream != substream); hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; @@ -531,8 +527,6 @@ static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, struct hdmi_codec_daifmt cf = { 0 }; int ret = 0; - dev_dbg(dai->dev, "%s()\n", __func__); - if (dai->id == DAI_ID_SPDIF) { cf.fmt = HDMI_SPDIF; } else { @@ -602,8 +596,6 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - dev_dbg(dai->dev, "%s()\n", __func__); - if (hcp->hcd.ops->digital_mute) return hcp->hcd.ops->digital_mute(dai->dev->parent, hcp->hcd.data, mute); @@ -661,8 +653,6 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, }; int ret; - dev_dbg(dai->dev, "%s()\n", __func__); - ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, NULL, drv->playback.channels_max, 0, &hcp->chmap_info); @@ -759,8 +749,6 @@ static int hdmi_codec_probe(struct platform_device *pdev) int dai_count, i = 0; int ret; - dev_dbg(dev, "%s()\n", __func__); - if (!hcd) { dev_err(dev, "%s: No plalform data\n", __func__); return -EINVAL; From patchwork Mon Apr 29 13:29:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163028 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1888136ill; Mon, 29 Apr 2019 06:30:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyx9AwRS0sZo+kbQS7XeHdUnuHFt0jytzvMa0jcWCIq2lAzdFu8jBnLtfXQFee+90JTasgD X-Received: by 2002:a17:902:be12:: with SMTP id r18mr44580430pls.11.1556544619244; Mon, 29 Apr 2019 06:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544619; cv=none; d=google.com; s=arc-20160816; b=VV6lE56ZgbQ7QoyecgE2ebW3bdIsmpkn5VURGU8Npueqq+AsA6Ks7OJ8+Iuz+KqQoh 6xChCFBg7BPDravwGP9ge76VAQQTXrmP3BSPp1kOjfAfWrvU5AnktlaSuJIR1Y6Nfvq5 rUOggvlS7fOKQI80j90adpTzcakxlNvFKg2ytiqluwHsCdWAea3QVUbvTu7NNSGMggEc dCPj6c+Y3DAer8ls12eUjY8I8pyTduf6kTMLAKIkrVe7fvDdngYSftBiGcpDNldBUEd1 lQae3j2jkxS7p0P0QYGmy66VhYsqEAz1+Zgn7Xo3ZcPonAobzI/Jurt92Pims966YdOO ZZYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jguxe++uQg1Tg16qsCOT2xdBZ2LoE15AQChE753+pog=; b=yD2H7ak+rIKEdnLaqc6PdIYr6g/u1CeCag8zTLgiZjr4xpeABsL5RBGrza8WJKdHLQ 2qQvG6Jm/gPvP+CTfqtYr6xlZgWnKfA1w+66cOT1ak3RDUBdktHS/7CzWdABXkKIB1e5 WwV0UKxPLHof4ObpX7oqkf24XF4bAWnw3bxwN6rvWoowWxm5AA0dXWYrcIngDqtEWiHs auevDnL6WaCmXBOrt9BGGAglkj19r//7ox4ieVBiADDYgsmxpnab158ZOIINkjStcAyY NzpiNrynXOBXAQDtB56bjBhYopsQRx963AiyOx4p5972nxQHp1+n4pZbALkVRDBwzt/y WPwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=ns9DV7vl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si33973639pgj.576.2019.04.29.06.30.18; Mon, 29 Apr 2019 06:30:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=ns9DV7vl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728319AbfD2NaR (ORCPT + 30 others); Mon, 29 Apr 2019 09:30:17 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55250 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbfD2N3w (ORCPT ); Mon, 29 Apr 2019 09:29:52 -0400 Received: by mail-wm1-f68.google.com with SMTP id b10so759215wmj.4 for ; Mon, 29 Apr 2019 06:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jguxe++uQg1Tg16qsCOT2xdBZ2LoE15AQChE753+pog=; b=ns9DV7vl1GqOrO/l7Pw/dLmy4NgN3/x795IBIKZ+BKXrvNhko8jL+GoCk33SLpy7nF GphkEdLsA1stWrdCKWx20VUWt0I8WUBc+s7fvJgfBs1SeB61JEkA1oxNmTRIluXP87g5 xJtw8WLKxGjC2bFqvsAiFkZtMyKHE4MJdov2el5ZY2sbLNkl/K52f9Xitk383AEiq/Ht ZIIYkFr4XvTxV8WamLucfoPYlelow6AmwOej3EUaHz4AebYx52vKuwUdQyv+BoZTmUjB ndUGecFTHr8UYRamWk0vJP6sQLfC4pLm9TnIcemJ8aIKRqoZU3wZhZaghTXBIXLZc0sk BaSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jguxe++uQg1Tg16qsCOT2xdBZ2LoE15AQChE753+pog=; b=SWUAvLmJ1fwkwKz323uKIPJDnw906flAiERE+rRVeXoiThJ3ykeRkS9eCO67lad+M4 rwRjHQ9hUu24im5Qj7XWmKlTpA1mt4Gp0e55d36c0bLOPCTyLNHsMAgq8ULMnVUygT0b +cfE/AS6PU/qhXQiJ1zZ+VDTPiBgz57Lun/DksDDuSEV7shz+aA5iwyDGIiNIhu/t90f un0VT1RTHaq2bENTyTimq5X1WcVmTg15dHM2QXJz0SMICBy+5Umv+SuLnbwe8ZoLushw 0cIjOmp5aYqI82PMbS+Z6TZ6LkMlRdVWPK/GVUFWdzKHMbmB14xS8DPrSXTNdsPyRTOR 0KQg== X-Gm-Message-State: APjAAAVbduYZ8J6h4kbNQSFmYI6KdytoILkjYO2Vl6kXl/dYlPziGR21 YwTCalJp1VQnsqxCiRxsLELyGQ== X-Received: by 2002:a7b:ce84:: with SMTP id q4mr18135443wmj.41.1556544590406; Mon, 29 Apr 2019 06:29:50 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:49 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 2/6] ASoC: hdmi-codec: unlock the device on startup errors Date: Mon, 29 Apr 2019 15:29:39 +0200 Message-Id: <20190429132943.16269-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the hdmi codec startup fails, it should clear the current_substream pointer to free the device. This is properly done for the audio_startup() callback but for snd_pcm_hw_constraint_eld(). Make sure the pointer cleared if an error is reported. Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 9dca24732069..4bd598253c62 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -437,8 +437,12 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, if (!ret) { ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); - if (ret) + if (ret) { + mutex_lock(&hcp->current_stream_lock); + hcp->current_stream = NULL; + mutex_unlock(&hcp->current_stream_lock); return ret; + } } /* Select chmap supported */ hdmi_codec_eld_chmap(hcp); From patchwork Mon Apr 29 13:29:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163024 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1887734ill; Mon, 29 Apr 2019 06:29:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzujPjW1CWtQ2VvLCmo6Ul/iCDgR9m/66UdtDo1iguKrMWqOdMvI/XS4VOCFdOHuD3F4JYA X-Received: by 2002:a65:6655:: with SMTP id z21mr58321618pgv.33.1556544597737; Mon, 29 Apr 2019 06:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544597; cv=none; d=google.com; s=arc-20160816; b=bSjQWbi30sIdot+LbpO+Jb6FSDQRNLs1mR+KMEi1lhKZfN/M6mKLL3VWjlWhUT3qjy 8+dq5wSPyL7WH7GIJBvABZ4o8uQb5mz+ULBAsKEYrVlkCjbdVXCG7IfxR6vQHIZu53ly CxtZeEOEnA0ZujA57ubMCy87pPnc4nckX7/fVdOk74juvZNIcVvDo/eQjvc61+SCF88e GSxoiYebGQ+gQERYSdVDltk9zYgMYDhPyhcO20oev7vmEfxzReuTAcPb0muZGZeVW0uP +50ogyVEWrhf8LF48yANpvPFw4jL59r8ex9dhUc+FwS/8ucqNJJtuqtFWowVGcQ1AhvL sjtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=whsOXQ8xRakI5AVYAzepVuB15C/D0yrTQsABLkaS6Vw=; b=pfFykhI3WbJjMvDB7WwGGaav25aiKM+zLmgPCdYXxet2YM9eGlqCrE7otD1trIqkXe sU1gVrYu79qHO6XslxwVzM21yDDEr2xqOheZS+8+Ngq05s35gfKJNPhUx++qXEyLBTbz 32H4Yb2vLvS+HUe6Iajt12ZyGNmdrmBav5WAOSumoIV7K1eZYXSKhwhHBkThpBvUTd47 Fo11MBFlKDcp9r1inAUO4sHm5doNVHjiSuicVj1QG440jYvHXTOmSt4maXNSO155YOs4 cd4e+JLrfytDvAzsnagnnZC5fw4F3FC+45c+Xugo7Fd9Y9KFa5yEpTjla0/AVaieqMVe pP/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=J2dTv1NP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cl5si7420539plb.397.2019.04.29.06.29.57; Mon, 29 Apr 2019 06:29:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=J2dTv1NP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728280AbfD2N34 (ORCPT + 30 others); Mon, 29 Apr 2019 09:29:56 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46930 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728246AbfD2N3x (ORCPT ); Mon, 29 Apr 2019 09:29:53 -0400 Received: by mail-wr1-f68.google.com with SMTP id t17so16009283wrw.13 for ; Mon, 29 Apr 2019 06:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=whsOXQ8xRakI5AVYAzepVuB15C/D0yrTQsABLkaS6Vw=; b=J2dTv1NPn4J99TrrljZ2hOdA1bv1ifuVO+cH2SVjLUxRsCwvDn6BHWRe13ydolX9HU f0TgeitA6xsof7AZ1BTeJMhJx9kNVCtreRIIz9tilr7F8ppdQBBxnamrpVfxs+7s0EuC /JVT4wZ1PMsPZY5/LjXMc70KWL4sthpL7sEtgbb7ZuUzPpYMMhz4nifFsD75k0rW8ryA spcy4SlO6AluDcIowl1fcf1VPnzD2N57NI7qTRcgkQAlS9idnCiCIUExwUaYbgeV7gih tm7D8w2q0cvdL0hYkGcQiVK21c5VDYXHMhWi8jpwQFBdbCzSs5At+eD45xDtXv+WytzX tf+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=whsOXQ8xRakI5AVYAzepVuB15C/D0yrTQsABLkaS6Vw=; b=jSjqbXfxdamEX83PCunFV/AEM0aNjTJiZFw9tNFlxZoYANPdVM5AUXplXseiWX2PfG Khb/CI2E3N0tvCOpKiY5/aF19ML4KGl7MzdCBg4HQIMpL1H3gV8wMyVNcG3ExiKNeq37 iEw2gLl9LOj0rPC+/ZFj2bZVhz/rkrTBGOgP0rMpqOJsb3pMWbdBVIMTqyepqg+2UlYd naEaekFcjy2BA3UUUOne3cl9ELRUebqya5Cx1owzBWKk82HLhZ4m6MlEdaJVTDHpyqEE sVvuYJgwsaJVsUmJOp4N0kkksiMEHtSdwYk8Rf+cXDV8R+qQJFe/ZXQJbHOs6O6lxmvj tDLw== X-Gm-Message-State: APjAAAUhPMvHZLSN6ktGJHGmgJm4cSU4WeR6Pu7+rX+mmqF0NQcpS8PG 5JGif+nzW+COs/cTgXdxUD91ZiYMue4= X-Received: by 2002:adf:f845:: with SMTP id d5mr2185657wrq.107.1556544591717; Mon, 29 Apr 2019 06:29:51 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:51 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 3/6] ASoC: hdmi-codec: stream is already locked in hw_params Date: Mon, 29 Apr 2019 15:29:40 +0200 Message-Id: <20190429132943.16269-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org startup() should have run before hw_params() is called, so the current_substream pointer should already be properly set. There is no reason to call hdmi_codec_new_stream() again in the hw_params() callback Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 4bd598253c62..780f2008b271 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -495,10 +495,6 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, return ret; } - ret = hdmi_codec_new_stream(substream, dai); - if (ret) - return ret; - hdmi_audio_infoframe_init(&hp.cea); hp.cea.channels = params_channels(params); hp.cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; From patchwork Mon Apr 29 13:29:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163026 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1887925ill; Mon, 29 Apr 2019 06:30:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSAThrT4GhKQHQU1zE8T5GS1oV2OIfFwZhldmV8qtQ4eN+RftSVYL4H80CGX0JJZbTGdzt X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr61973139plb.190.1556544607722; Mon, 29 Apr 2019 06:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544607; cv=none; d=google.com; s=arc-20160816; b=Y/HtCXFaPtHudn6IJi3yxnwpMmjaTafcRgKPIw4sF7BrWTzFhyOC2Qximv2TsuXTt8 jan/MgIJxl4k6FoNnBOe5/rDDkRUW1hH7CGJavrd6uAmbYfR3EHgR29pS3G2tOshAkn1 8an9ReE5EO+U9p6nZptFKUXrKV4LkopGGB5rXwFnxMzsJirZra68NQcFdv2+XW1cCnT+ KRMf10kvFXyojwJiGe5xm5ZfLgT92xgkbzSVt8/GP7axCdozq4+Mz/0YCesomP9iF/wT 5YOjz/SFfjd9EtBtAqUyJUB90eCwrcA8rwKC3ANTYfM8zPPvHhqtMZsWPaLQaGTMUYoS zKdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Hd6mJetFt+bYMfDoxeUlaN2SLCfgBvFwtxKuQlMcFOY=; b=grKnRPDIaRj6kbVgpt2PXxvrcWJOWhpLp4nNWmj9O1Q7dkFAk/jGo9BWrNnaCfNpcP GyJrp+brDBa34k2QHJ0z5fc5m3tWSNS1yqFCOy0vPi8qgXquF77Hz/+VoEOBkGqE7CGf cDXzrmh01Ti07zZuh9SKrch0ffO7ZFnadsze3m+TnKeP8hQeLRldyJnBv9S5Zm95ajz6 NIIJLFRaBG/kWOzS0xWuDgxtsbDVjjj48Q7E4vRccyWtN53HwTOUwWkku90SjQAoSzJc hW+vBcWgyeRe3RAiSvSOuxTK4B+xvNzqk+a/rpM/IL8N6WafJykI1QKQwwH76RXbHSF+ LFKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=C4SN6Sjb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si31403818pgb.292.2019.04.29.06.30.07; Mon, 29 Apr 2019 06:30:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=C4SN6Sjb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728311AbfD2NaG (ORCPT + 30 others); Mon, 29 Apr 2019 09:30:06 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39488 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728251AbfD2N3z (ORCPT ); Mon, 29 Apr 2019 09:29:55 -0400 Received: by mail-wm1-f68.google.com with SMTP id n25so822992wmk.4 for ; Mon, 29 Apr 2019 06:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hd6mJetFt+bYMfDoxeUlaN2SLCfgBvFwtxKuQlMcFOY=; b=C4SN6SjbEVh9brvwWa9I0k53I0+eUkzThi7Z4tRSiWcMVwsyOZkS2Ri2zTPFrRU1hA EX/Qwh90q+DdtDX5XD3rlaN050hOPFVqbmNEVbyos3JbwA6mzccSmjWIaZPBUpywAIPb +n0lfVLB+RwIP/HVA+qrZJlAooCK1oDs9FWOJ/UH1ymIGBpoFQJcmHKkt34UQ6B/S5M1 qakEvdkdQC1+yhn3HOWd4JlDgMDcPRolzMqRbMQzZhlFoFyM2+m045V8Tze+YtdDT7hQ RH8eFWekONdGWfyo9zvBOhVFQmPyzzQt+1SuV6+7hosSTQVBEy+lVvumrFEhB2BWSJvV AbTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hd6mJetFt+bYMfDoxeUlaN2SLCfgBvFwtxKuQlMcFOY=; b=VbCWlnux6zJcvouWVNaK+NaI5Xq0qAJuRkAsdL3TcGbOBW/sStFNoSPLo8bPYdGoiI NhynOntihwRu0vdPugz7DH+hp4Tz/UAMzZJrcFjW3rG7wdXfrY6xxii/u+NX2yFwK28J oYngPml+y0J1QYC8pxbz4cN62wLE+YjcJfSpcax+pHPFijqF5ZBVEVvDEYV4t9Sgl+SG 2ZPZaxhWdc55a2rAmiH7PxYiSOburHRnipDfDraNZOn9aM9sYt96KJgLOC8WwKX5kby5 3VmzAFs/WY3gJcUiDM33TWst2WQWrwzQOZbu/+JkYn1BXOZmd7YyqS0N+rWAI8ARBPDY NxNw== X-Gm-Message-State: APjAAAV8BjBMcLbDFXoSDfby2sWQPxe1YGhJuwlGcRq0hyE71d7lKRdM PWEnrgnElmv0T9osVGPQsOkY7A== X-Received: by 2002:a1c:3845:: with SMTP id f66mr16599583wma.97.1556544592685; Mon, 29 Apr 2019 06:29:52 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:52 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 4/6] ASoC: hdmi-codec: remove reference to the current substream Date: Mon, 29 Apr 2019 15:29:41 +0200 Message-Id: <20190429132943.16269-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the hdmi-codec is on a codec-to-codec link, the substream pointer it receives is completely made up by snd_soc_dai_link_event(). The pointer will be different between startup() and shutdown(). The hdmi-codec complains when this happens even if it is not really a problem. The current_substream pointer is not used for anything useful apart from getting the exclusive ownership of the device. Remove current_substream pointer and replace the exclusive locking mechanism with a simple variable and some atomic operations. Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 58 ++++++++++------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 780f2008b271..717d0949f8b4 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -280,11 +280,10 @@ struct hdmi_codec_priv { struct hdmi_codec_pdata hcd; struct snd_soc_dai_driver *daidrv; struct hdmi_codec_daifmt daifmt[2]; - struct mutex current_stream_lock; - struct snd_pcm_substream *current_stream; uint8_t eld[MAX_ELD_BYTES]; struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; + unsigned long busy; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -392,42 +391,22 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } -static int hdmi_codec_new_stream(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - int ret = 0; - - mutex_lock(&hcp->current_stream_lock); - if (!hcp->current_stream) { - hcp->current_stream = substream; - } else if (hcp->current_stream != substream) { - dev_err(dai->dev, "Only one simultaneous stream supported!\n"); - ret = -EINVAL; - } - mutex_unlock(&hcp->current_stream_lock); - - return ret; -} - static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); int ret = 0; - ret = hdmi_codec_new_stream(substream, dai); - if (ret) - return ret; + ret = test_and_set_bit(0, &hcp->busy); + if (ret) { + dev_err(dai->dev, "Only one simultaneous stream supported!\n"); + return -EINVAL; + } if (hcp->hcd.ops->audio_startup) { ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data); - if (ret) { - mutex_lock(&hcp->current_stream_lock); - hcp->current_stream = NULL; - mutex_unlock(&hcp->current_stream_lock); - return ret; - } + if (ret) + goto err; } if (hcp->hcd.ops->get_eld) { @@ -437,17 +416,18 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, if (!ret) { ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); - if (ret) { - mutex_lock(&hcp->current_stream_lock); - hcp->current_stream = NULL; - mutex_unlock(&hcp->current_stream_lock); - return ret; - } + if (ret) + goto err; } /* Select chmap supported */ hdmi_codec_eld_chmap(hcp); } return 0; + +err: + /* Release the exclusive lock on error */ + clear_bit(0, &hcp->busy); + return ret; } static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, @@ -455,14 +435,10 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - WARN_ON(hcp->current_stream != substream); - hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); - mutex_lock(&hcp->current_stream_lock); - hcp->current_stream = NULL; - mutex_unlock(&hcp->current_stream_lock); + clear_bit(0, &hcp->busy); } static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, @@ -766,8 +742,6 @@ static int hdmi_codec_probe(struct platform_device *pdev) return -ENOMEM; hcp->hcd = *hcd; - mutex_init(&hcp->current_stream_lock); - hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv), GFP_KERNEL); if (!hcp->daidrv) From patchwork Mon Apr 29 13:29:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163027 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1887966ill; Mon, 29 Apr 2019 06:30:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPZ5y8QuDUIqayGkJstAy8aoB600QXG+3L+H2N4WE9cQ4iodfpf20ZpySxXUTVc1nB4UPj X-Received: by 2002:a17:902:7b8e:: with SMTP id w14mr44761056pll.202.1556544610954; Mon, 29 Apr 2019 06:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544610; cv=none; d=google.com; s=arc-20160816; b=G+xqm9i19m0hNh4KYyD5/5908pY0ent6k/jY6u7bAEvWSTABYb1uKO+9dJsbRVECSW V4RiHJGaZWjGaPeklDqKSciVUVOJchPXcc3rGtdBdAd2ZY8zLMq5l/OScSLkRfet6N7D gLG5Z1OJ3L0Q9VZFUpVfzRsIWm4ff1CNNjb7RtNdHjQYYfgNLqX7O4DooEq9jl9+5q6M 50L9WkZ/xqUn0wdUc7h30+hw0h/bC+EVp98uX1KRSxQqLfljQ5LlczEVmE3vJvWop4JD Qggd0px2qMuzkPzK+7GSU6Xc9La0mutBpTy8wn10cR81Htk9ir5VHpZX1dwrGR5uCxZI scWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c2Ly6nFnbTUuYqirG7Hg6dg1zRcYgFT1GAPuXl6J8C8=; b=TMvbwEGIGjULFBajflxQ+01ov8pwGfHCZOc2QVKFFf8JfWZTV/wBLjvhc43Ex7yK5L GQII42PxoWbk4n8wnkoB8xYcVeKzw8Brc1Vr0be+oyoVDuZxu7h+YjzFcE0exW5z+Bdw HWhROFOeePXAZ/FRCptC1V8Q4B+uNPy+mQ3pbM5pbjMKTkj/HDcYJlosKSH3yX5KSCK+ RfF4kYFkqttjJqRtJYRIISrCkExeAkS0O/BUoSdroDtQy0TTZyqc+6Qi9Nl5lfM1I4fb reTKXUdGoGHCEO9gHjDBGJuJBJQHLs5j55RWIZBH6bYAWAn6FzbUWhnhwIcYzUos50BB 4VGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=meqj0rsJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p14si31403818pgb.292.2019.04.29.06.30.10; Mon, 29 Apr 2019 06:30:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=meqj0rsJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728299AbfD2NaF (ORCPT + 30 others); Mon, 29 Apr 2019 09:30:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51753 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfD2N3z (ORCPT ); Mon, 29 Apr 2019 09:29:55 -0400 Received: by mail-wm1-f66.google.com with SMTP id 4so14104900wmf.1 for ; Mon, 29 Apr 2019 06:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c2Ly6nFnbTUuYqirG7Hg6dg1zRcYgFT1GAPuXl6J8C8=; b=meqj0rsJv5rfBIShZLQunnMvrc8ItTEICy2+kAclCNP4u/MykXbVjfGB2rZlt3+NG8 0kXXs/AjAOB2zWPpqduLNYKK4WD+nT7H86fGbdVPXEA3IBi/rPUQSOWSWFGHXIpJw3gS VpwnuOvEyHRtvq17hw0O0lylYaxZV0eRkY2PknHzpbM8+q2P5biZpCQkFjQWcHzi4zhL CC1/4GTBYQwp/l4GSLsrOss2g/4OaEOEYetdNnJa3KWknO88apc6PrwVP0C816M4Gniz Qm+xY1TJ17Kqn7M9V0EIOYMQrG6u9ijK54KnoLq+iXPVWBf2904tvI2g/pqxJwkDa1eh KYWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c2Ly6nFnbTUuYqirG7Hg6dg1zRcYgFT1GAPuXl6J8C8=; b=fjcSlA2GSEZLQKnr9KUR95NoRbSQEFF1Ab1C/x55PzCRH9n+0UmqG1KvsMkFpAnPAS 35gTsqsDxd8quDZpBKXoo1PaG224SYYLByOrsFEPE14oCcNqqhZqls+Nq1ZcMBdqPixy /CRdASUlpT+pXn/8E9hNxUxukqr0pqUqtBbbj40fq1mYXkDpZyTv1oPl0yKbb4qUg7CG zOBUgbhSdMfpn0/NMhC11VBV+h59fP6N00B/QSHTDbhV5gia+DW9qhx96/NOZteA8w5m FOoECqyBUJYmjtJw586sosgR3RpjMS0APV63ihNhDmS9BHprDId5rWLRgm61RD825FtB Mqvw== X-Gm-Message-State: APjAAAVTeOKJ5JdhpYWIh5UvREDXF7F2TJ9LvBLYtIcfzoNwVIXc2csx Ezyz2GviVV5S6fxH7H3Yrfum7w== X-Received: by 2002:a05:600c:204d:: with SMTP id p13mr2263305wmg.53.1556544593778; Mon, 29 Apr 2019 06:29:53 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:53 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 5/6] ASoC: hdmi-codec: remove reference to the dai drivers in the private data Date: Mon, 29 Apr 2019 15:29:42 +0200 Message-Id: <20190429132943.16269-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Keeping the a pointer to the dai drivers is not necessary. It is not used by the hdmi_codec after the probe. Even if it was used, the 'struct snd_soc_dai_driver' can accessed through the 'struct snd_soc_dai' so keeping the pointer in the private data structure is not useful. Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 717d0949f8b4..bcc2e5c3bf43 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -278,7 +278,6 @@ static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = { struct hdmi_codec_priv { struct hdmi_codec_pdata hcd; - struct snd_soc_dai_driver *daidrv; struct hdmi_codec_daifmt daifmt[2]; uint8_t eld[MAX_ELD_BYTES]; struct snd_pcm_chmap *chmap_info; @@ -720,6 +719,7 @@ static const struct snd_soc_component_driver hdmi_driver = { static int hdmi_codec_probe(struct platform_device *pdev) { struct hdmi_codec_pdata *hcd = pdev->dev.platform_data; + struct snd_soc_dai_driver *daidrv; struct device *dev = &pdev->dev; struct hdmi_codec_priv *hcp; int dai_count, i = 0; @@ -742,25 +742,23 @@ static int hdmi_codec_probe(struct platform_device *pdev) return -ENOMEM; hcp->hcd = *hcd; - hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv), - GFP_KERNEL); - if (!hcp->daidrv) + daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL); + if (!daidrv) return -ENOMEM; if (hcd->i2s) { - hcp->daidrv[i] = hdmi_i2s_dai; - hcp->daidrv[i].playback.channels_max = - hcd->max_i2s_channels; + daidrv[i] = hdmi_i2s_dai; + daidrv[i].playback.channels_max = hcd->max_i2s_channels; i++; } if (hcd->spdif) - hcp->daidrv[i] = hdmi_spdif_dai; + daidrv[i] = hdmi_spdif_dai; dev_set_drvdata(dev, hcp); - ret = devm_snd_soc_register_component(dev, &hdmi_driver, hcp->daidrv, - dai_count); + ret = devm_snd_soc_register_component(dev, &hdmi_driver, daidrv, + dai_count); if (ret) { dev_err(dev, "%s: snd_soc_register_component() failed (%d)\n", __func__, ret); From patchwork Mon Apr 29 13:29:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 163025 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1887815ill; Mon, 29 Apr 2019 06:30:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmoW2X5O00I0Lbi1ZgUYglQ9PbzBM28f6a81475Rg2gPeUOaOIterNiKHVo92RW7VC9E0h X-Received: by 2002:a62:4183:: with SMTP id g3mr6274828pfd.229.1556544602139; Mon, 29 Apr 2019 06:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556544602; cv=none; d=google.com; s=arc-20160816; b=YVyGHQvnswIbozhezK4a8un5jHacrn6F5wrKxBXXi6UrUSRaUm1S0p82aKCjwj/+9I y8Sjd3u9L2BJ2Z0zLg1tsw2sxG0Tz+Xccqe20Ks0mxF6dfp9wi/skt4RSzOT7qbBBpxR JsTsrLitsw/stXpQU7/AFUFFQMMmR+uws4qfl9lWFmngG8PRhkiI1GxKsXmtl8oohlPY 4VoNHQN0qTYYhB9jxTbh3+rYFiZh70X41+CikZY54CvxXiV4LTLYF2cOvlVPwPzlx7jM S/8zEpuurkrRwVclJZrOCz+uPM6Ot6YsM9hOCmYtnUOx8JqGyJsyQH5jnkMjSOAR01q5 hymw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CKsfp1x/LbsxbNcHvbSqLYmsrwzcbB2URURXREr5yxQ=; b=rj3h9KqrMG2fww4rd++3TgBQMQfMY33QKK1pwJLe3MH+9ffNbi52CsQ/Zesqzj9XDs NhpAtE358AN7R/0kkcpc3yi7gK79mKtpCMOl1y+6p5M91uXQGHfcTYZY79SyLCfX5EiB YsjoYeTL8v7bKN5++WSYx13yiyPoFsO88A+Rm/1cbQrvEk4AKBi8NxGQDP9bqWhmdxSB 5QXAQwQMYdahoHRxgjfwVgdknRThp3P13cxqoqI9q3DFi6QvUv6E9U0iRsDbZefHpatJ sGvIlXOe5jsQqHFUsJrDL8l7UrIMseZ2tHe6cH1z5+dkzBhQxf1Z1Tq4nSzaJgDvE5n8 zNiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=a7wNSCFm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si33462485pgo.563.2019.04.29.06.30.01; Mon, 29 Apr 2019 06:30:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=a7wNSCFm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728290AbfD2NaA (ORCPT + 30 others); Mon, 29 Apr 2019 09:30:00 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39494 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728271AbfD2N36 (ORCPT ); Mon, 29 Apr 2019 09:29:58 -0400 Received: by mail-wm1-f66.google.com with SMTP id n25so823236wmk.4 for ; Mon, 29 Apr 2019 06:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CKsfp1x/LbsxbNcHvbSqLYmsrwzcbB2URURXREr5yxQ=; b=a7wNSCFml35ej21GIKLMIp1B8FJJD6WKn+HBxm7MnD0q03OqMi1T+ixkgRHxkJMvcz 8OHqdXfzd4s6QyHxAZm0QonNqasgOMMjc469b3x7+R9UX4EeGwEgb70oOz2gQrmrgNvI qfgIq7RestSYIyCkpVAttt9NVhXdZDwjd/CFL8xwgZCFiNz3nK/HO6WeEnIbLLPbS5zG bYTm32Bv/lwGgZ6buYs3a5Adeo5TZIcLTk1SD7pYAwnexKvh1sBURl7g7d0KL3N8uQij 5UGBAs0yAO5TYECwcHH2x05Ri/RrKY4W/rXX0MrV9w3xEJjYgYTcF/PefvxHz1Xn3xH0 30+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CKsfp1x/LbsxbNcHvbSqLYmsrwzcbB2URURXREr5yxQ=; b=T8vKnzfVSBoeyBcpb1jts2VD6g4+XCb2kg9Al+ZMJFDJLlCKuZBYmet7zomS9xJk5x xj5SWjJV11T18xhWv4iPweJUmHW6vYpj70dDKWV0KppmqNst/DYXvcIj/G0tqo6SnJYt lXyTlj6msSsrkpVZBD+rFcLMYcbNf/sq0u9Kh0/BIQ+vSZeCPvMOg8hZFzZl6orluAo8 JYUDX7kLCWcdkoj4HfiafYRz3DStH3sqDQOCxkbL9gHamD/38qrhJRb+K1d/eW0AUEEm Q5n/lxGlGogk9CSTSMm5tvZq+x98kbBcWjU3PV7iYHKCWC8ki+zPePR8yaHLA6ZZr4g2 PSsw== X-Gm-Message-State: APjAAAVastQqfT6m0buGqZBF5pQeBglz8J6do9XFyMqMEr06m0TOPyKg YAZLg280+dOB5QlQjptuFpVjbg== X-Received: by 2002:a1c:b782:: with SMTP id h124mr2298471wmf.5.1556544594954; Mon, 29 Apr 2019 06:29:54 -0700 (PDT) Received: from boomer.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id s17sm2857593wra.94.2019.04.29.06.29.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 06:29:54 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patchwork-bot+notify@kernel.org Subject: [PATCH 6/6] ASoC: hdmi-codec: remove ops dependency on the dai id Date: Mon, 29 Apr 2019 15:29:43 +0200 Message-Id: <20190429132943.16269-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429132943.16269-1-jbrunet@baylibre.com> References: <20190429132943.16269-1-jbrunet@baylibre.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dependency on the dai_id can be removed by setting different ops for the i2s and spdif dai and storing the dai format information in each dai structure. It simplies the code a bit. Signed-off-by: Jerome Brunet --- sound/soc/codecs/hdmi-codec.c | 173 ++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 71 deletions(-) -- 2.20.1 diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index bcc2e5c3bf43..4b56fc92a80d 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -278,7 +278,6 @@ static const struct hdmi_codec_cea_spk_alloc hdmi_codec_channel_alloc[] = { struct hdmi_codec_priv { struct hdmi_codec_pdata hcd; - struct hdmi_codec_daifmt daifmt[2]; uint8_t eld[MAX_ELD_BYTES]; struct snd_pcm_chmap *chmap_info; unsigned int chmap_idx; @@ -445,6 +444,7 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct hdmi_codec_daifmt *cf = dai->playback_dma_data; struct hdmi_codec_params hp = { .iec = { .status = { 0 }, @@ -492,79 +492,85 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, hp.channels = params_channels(params); return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, - &hcp->daifmt[dai->id], &hp); + cf, &hp); } -static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, - unsigned int fmt) +static int hdmi_codec_i2s_set_fmt(struct snd_soc_dai *dai, + unsigned int fmt) { - struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - struct hdmi_codec_daifmt cf = { 0 }; - int ret = 0; - - if (dai->id == DAI_ID_SPDIF) { - cf.fmt = HDMI_SPDIF; - } else { - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - cf.bit_clk_master = 1; - cf.frame_clk_master = 1; - break; - case SND_SOC_DAIFMT_CBS_CFM: - cf.frame_clk_master = 1; - break; - case SND_SOC_DAIFMT_CBM_CFS: - cf.bit_clk_master = 1; - break; - case SND_SOC_DAIFMT_CBS_CFS: - break; - default: - return -EINVAL; - } + struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + + /* Reset daifmt */ + memset(cf, 0, sizeof(*cf)); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + cf->bit_clk_master = 1; + cf->frame_clk_master = 1; + break; + case SND_SOC_DAIFMT_CBS_CFM: + cf->frame_clk_master = 1; + break; + case SND_SOC_DAIFMT_CBM_CFS: + cf->bit_clk_master = 1; + break; + case SND_SOC_DAIFMT_CBS_CFS: + break; + default: + return -EINVAL; + } - switch (fmt & SND_SOC_DAIFMT_INV_MASK) { - case SND_SOC_DAIFMT_NB_NF: - break; - case SND_SOC_DAIFMT_NB_IF: - cf.frame_clk_inv = 1; - break; - case SND_SOC_DAIFMT_IB_NF: - cf.bit_clk_inv = 1; - break; - case SND_SOC_DAIFMT_IB_IF: - cf.frame_clk_inv = 1; - cf.bit_clk_inv = 1; - break; - } + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + break; + case SND_SOC_DAIFMT_NB_IF: + cf->frame_clk_inv = 1; + break; + case SND_SOC_DAIFMT_IB_NF: + cf->bit_clk_inv = 1; + break; + case SND_SOC_DAIFMT_IB_IF: + cf->frame_clk_inv = 1; + cf->bit_clk_inv = 1; + break; + } - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - cf.fmt = HDMI_I2S; - break; - case SND_SOC_DAIFMT_DSP_A: - cf.fmt = HDMI_DSP_A; - break; - case SND_SOC_DAIFMT_DSP_B: - cf.fmt = HDMI_DSP_B; - break; - case SND_SOC_DAIFMT_RIGHT_J: - cf.fmt = HDMI_RIGHT_J; - break; - case SND_SOC_DAIFMT_LEFT_J: - cf.fmt = HDMI_LEFT_J; - break; - case SND_SOC_DAIFMT_AC97: - cf.fmt = HDMI_AC97; - break; - default: - dev_err(dai->dev, "Invalid DAI interface format\n"); - return -EINVAL; - } + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + cf->fmt = HDMI_I2S; + break; + case SND_SOC_DAIFMT_DSP_A: + cf->fmt = HDMI_DSP_A; + break; + case SND_SOC_DAIFMT_DSP_B: + cf->fmt = HDMI_DSP_B; + break; + case SND_SOC_DAIFMT_RIGHT_J: + cf->fmt = HDMI_RIGHT_J; + break; + case SND_SOC_DAIFMT_LEFT_J: + cf->fmt = HDMI_LEFT_J; + break; + case SND_SOC_DAIFMT_AC97: + cf->fmt = HDMI_AC97; + break; + default: + dev_err(dai->dev, "Invalid DAI interface format\n"); + return -EINVAL; } - hcp->daifmt[dai->id] = cf; + return 0; +} + +static int hdmi_codec_spdif_set_fmt(struct snd_soc_dai *dai, + unsigned int fmt) +{ + struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + + /* No need to reset the format, it is always the same for spdif */ + cf->fmt = HDMI_SPDIF; - return ret; + return 0; } static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) @@ -578,14 +584,21 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) return 0; } -static const struct snd_soc_dai_ops hdmi_dai_ops = { +static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, - .set_fmt = hdmi_codec_set_fmt, + .set_fmt = hdmi_codec_i2s_set_fmt, .digital_mute = hdmi_codec_digital_mute, }; +static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { + .startup = hdmi_codec_startup, + .shutdown = hdmi_codec_shutdown, + .hw_params = hdmi_codec_hw_params, + .set_fmt = hdmi_codec_spdif_set_fmt, + .digital_mute = hdmi_codec_digital_mute, +}; #define HDMI_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ @@ -653,20 +666,37 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, static int hdmi_dai_probe(struct snd_soc_dai *dai) { struct snd_soc_dapm_context *dapm; + struct hdmi_codec_daifmt *daifmt; struct snd_soc_dapm_route route = { .sink = "TX", .source = dai->driver->playback.stream_name, }; + int ret; dapm = snd_soc_component_get_dapm(dai->component); + ret = snd_soc_dapm_add_routes(dapm, &route, 1); + if (ret) + return ret; - return snd_soc_dapm_add_routes(dapm, &route, 1); + daifmt = kzalloc(sizeof(*daifmt), GFP_KERNEL); + if (!daifmt) + return -ENOMEM; + + dai->playback_dma_data = daifmt; + return 0; +} + +static int hdmi_codec_dai_remove(struct snd_soc_dai *dai) +{ + kfree(dai->playback_dma_data); + return 0; } static const struct snd_soc_dai_driver hdmi_i2s_dai = { .name = "i2s-hifi", .id = DAI_ID_I2S, .probe = hdmi_dai_probe, + .remove = hdmi_codec_dai_remove, .playback = { .stream_name = "I2S Playback", .channels_min = 2, @@ -675,7 +705,7 @@ static const struct snd_soc_dai_driver hdmi_i2s_dai = { .formats = I2S_FORMATS, .sig_bits = 24, }, - .ops = &hdmi_dai_ops, + .ops = &hdmi_codec_i2s_dai_ops, .pcm_new = hdmi_codec_pcm_new, }; @@ -683,6 +713,7 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = { .name = "spdif-hifi", .id = DAI_ID_SPDIF, .probe = hdmi_dai_probe, + .remove = hdmi_codec_dai_remove, .playback = { .stream_name = "SPDIF Playback", .channels_min = 2, @@ -690,7 +721,7 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = { .rates = HDMI_RATES, .formats = SPDIF_FORMATS, }, - .ops = &hdmi_dai_ops, + .ops = &hdmi_codec_spdif_dai_ops, .pcm_new = hdmi_codec_pcm_new, };