Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6808239ybi; Wed, 5 Jun 2019 06:45:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfAfxHqMvBFvSXqRUnkGl15hRWz5tuT8RwzJr2V3MVhAqv/xtfG+HEqR8ISJkcQydutJ42 X-Received: by 2002:aa7:8d50:: with SMTP id s16mr45547687pfe.96.1559742329191; Wed, 05 Jun 2019 06:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559742329; cv=none; d=google.com; s=arc-20160816; b=K8x97cChE9ZKrp1hG1F5P55H/AZIjykwpQ00Xe/Vc8XtqakJoDGWU7y70yR7+z59z+ lRHmdvlwFg3cV+QRAvLCAcaJnUzb4jCrGBnMazjvwD6AB/FSN6OFlB7JCxjPxzQaSVNz ZpJAZCGFH+caQQnNrPI66NYclJV4CiXol753I4CIb1bfgq15rwI6gD+teeqiJQ5liuZk GuSbVMM/q44BlYl24ATcTkhU8p3cXHYkkI8RzNukzGMsoUA8Qqc/jSvpfiSzhbWGHkUS CPdZEvuzcz7M80c4KRJIZtgjQW3iRIhaHF2Cl3eUnI4EYU1cSxvQ/dUyNN5TEzkDWSZ9 EEpw== 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; bh=WGF+dtQkdxhslX49MStjF8+q2jtmzshvYio0rKnPEDk=; b=wYzAb3KmGeAo74xziLzdCL+JkBSrhvSMheIHIEvetV9vMXiDU/fF04E/VB3LK7kRH2 IpVfp0MYuDur6aQHmHyPYKOlI1rTjOhDjahsPHzcqdwssdxSxiDw7gcLhFmxWHRAJX6P ejPBPRkrZIToU8LlE5YnHpB70mYRj5Wqqtn/6Akd51fJvEM75lu1j68UFzjy6z24ZvyV 58ji4q2+1lfrXBCtDtTgCbpSArYk7HoKRDa8DjY7caGVP3glpFk9oOBVbzPSjbl5TVEi INKmUogwGo9uBr680JRvcZO8A2cM8p+fke3CwmSZ4qaU0K3tJwAYVwNVAZ8xcvBrDE6O ftLw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m23si25596545pgj.296.2019.06.05.06.45.11; Wed, 05 Jun 2019 06:45:29 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728299AbfFENnZ (ORCPT + 99 others); Wed, 5 Jun 2019 09:43:25 -0400 Received: from mga14.intel.com ([192.55.52.115]:51941 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbfFENmZ (ORCPT ); Wed, 5 Jun 2019 09:42:25 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 06:42:25 -0700 X-ExtLoop1: 1 Received: from xxx.igk.intel.com ([10.237.93.170]) by orsmga004.jf.intel.com with ESMTP; 05 Jun 2019 06:42:22 -0700 From: =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= To: alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown , Pierre-Louis Bossart , Jie Yang , Cezary Rojewski , linux-kernel@vger.kernel.org, =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= Subject: [PATCH 03/14] ALSA: hdac: Fix codec name after machine driver is unloaded and reloaded Date: Wed, 5 Jun 2019 15:45:45 +0200 Message-Id: <20190605134556.10322-4-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605134556.10322-1-amadeuszx.slawinski@linux.intel.com> References: <20190605134556.10322-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amadeusz Sławiński This resets internal index used for enumarating codecs. This will only work on assumption that platform has one codec. Anyway if there is more, it won't work with current machine drivers, because we can't guarantee order in which they are enumerated. This workarounds the fact that most intel machine drivers have the following defined: .codec_name = "ehdaudio0D2", However when we unload and reload machine driver idx gets incremented, so .codec_name would've needed to be set to ehdaudio1D2 on first reload and so on. Signed-off-by: Amadeusz Sławiński --- sound/hda/ext/hdac_ext_bus.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index f33ba58b753c..c84d69c2eba4 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c @@ -77,6 +77,8 @@ static const struct hdac_io_ops hdac_ext_default_io = { .dma_free_pages = hdac_ext_dma_free_pages, }; +static int idx; + /** * snd_hdac_ext_bus_init - initialize a HD-audio extended bus * @ebus: the pointer to extended bus object @@ -93,7 +95,6 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, const struct hdac_ext_bus_ops *ext_ops) { int ret; - static int idx; /* check if io ops are provided, if not load the defaults */ if (io_ops == NULL) @@ -118,6 +119,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_init); void snd_hdac_ext_bus_exit(struct hdac_bus *bus) { snd_hdac_bus_exit(bus); + /* FIXME: this is workaround + * reset index used for bus->idx, because machine drivers expect + * the codec name to be ehdaudio0D2, where 0 is bus->idx + * we only perform reset if there is one used device, if there is more + * all bets are off + */ + if (idx == 1) + idx = 0; WARN_ON(!list_empty(&bus->hlink_list)); } EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_exit); -- 2.17.1