From patchwork Wed Feb 21 15:25:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565680 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 B32E080050 for ; Wed, 21 Feb 2024 15:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529028; cv=none; b=DXthV3fA9JRdpHzDVXFCK0g4Qb9AfiF3ERwrosA/w4l20DMN/sxdQVk8ewPeyECnymhiv9Y6AaJQRo5pcqbtaI3RLJYVTWnAK/e9uc5m1yl9MceL07fvQP6FeIQV7LYphiAMqgGAFFELsub2nzvaF+H1OASusU12oreRSwyPmPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529028; c=relaxed/simple; bh=BXL7zP4AWoU74NVuXh75FzHEXhJzzz7hn04HPQZ5I4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=djLApjHRbRbawIZ1nSWwFlRedlNUDRKoFUun2apuE+w1MxVTDFaBA01kTESb4VQuxr2smZc0T3WScMQHecNgoyJmTLGo99BOA0kE6/lW1sqk8jASp0gL0x5sQXEcPw3jlcCfRBgdT/66KS899S8Dli2TmdjJhyAtvqrLQFltXp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Mrt/L8U8; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Mrt/L8U8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529026; x=1740065026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BXL7zP4AWoU74NVuXh75FzHEXhJzzz7hn04HPQZ5I4o=; b=Mrt/L8U8USOSJSLUoSm/KpyPM7jAcaRGdrTtyAk7vV1HHSoSWH0vwQNM //hs+hx658lrEpg22CagAaHA/p7I+xgh7DCxrz2he5ZDtlV5bwPcWuR7q h9aXvOPhWv52BHjSiiVdbbrpMmoyz6vDuZCBXCq2QbCudZD/u08CSp1uz slSwa49V4tqTz0PwIZttAytnP14Ci2yaqB5ePwRth/np0ustz0qL8a9GQ 5lezCvG2Qysngkvc4wjEJaKgbVrQT7hdMQQ4tCaPln5q0oeq3Byum3Ztp qqbj+O0Nxxo8cmVpL9PC8Nx2TZBQzG/8+xfLjj9QzEE/0LFXqtlOWR7z7 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104776" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104776" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374243" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:44 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 1/6] ASoC: codecs: da7213: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:11 +0100 Message-Id: <20240221152516.852353-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/da7213.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 0e5c527687a2..369c62078780 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -2101,18 +2101,14 @@ static int da7213_probe(struct snd_soc_component *component) pm_runtime_put_sync(component->dev); /* Check if MCLK provided */ - da7213->mclk = devm_clk_get(component->dev, "mclk"); - if (IS_ERR(da7213->mclk)) { - if (PTR_ERR(da7213->mclk) != -ENOENT) - return PTR_ERR(da7213->mclk); - else - da7213->mclk = NULL; - } else { + da7213->mclk = devm_clk_get_optional(component->dev, "mclk"); + if (IS_ERR(da7213->mclk)) + return PTR_ERR(da7213->mclk); + if (da7213->mclk) /* Do automatic PLL handling assuming fixed clock until * set_pll() has been called. This makes the codec usable * with the simple-audio-card driver. */ da7213->fixed_clk_auto_pll = true; - } /* Default infinite tone gen, start/stop by Kcontrol */ snd_soc_component_write(component, DA7213_TONE_GEN_CYCLES, DA7213_BEEP_CYCLES_MASK); From patchwork Wed Feb 21 15:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565681 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 6C48280606 for ; Wed, 21 Feb 2024 15:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529031; cv=none; b=jeXOpCXQZdgqyITH13Qp+HWrcSYoTCz9Wk6Nb+Kfg5bPhUS16fe1Ki7taHHZRQ+dyUkxU6m8L09ZNRLzuVBLUxaLPbSQ+2ca2TyAAMqCdnSFaIKB7qMkRapubjl7ss1jZiQ334qJASWGDcmMvpAVA43wcWvhlrK8PyfiNmdzguU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529031; c=relaxed/simple; bh=C4eam5B1/ua7yw+Vatsep/Lrr+vtYohYNHxWd27npZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=N9XvG3EClwnxPzxf/6dhhSd9aijVSyetryxXoFsD3HCmn6nJy6DOdF2IknLx8mZWaTvvPWhe8igIDKPSWmtMRHXKFapXyJB1DrdMwC7YhhX4axCUc9fypuyvsduCQWK5EDtgesPz8iRXdHWxJZPuSLmS6Zy1rJj4+rmReS2LseA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=dzQBAJb9; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dzQBAJb9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529029; x=1740065029; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C4eam5B1/ua7yw+Vatsep/Lrr+vtYohYNHxWd27npZw=; b=dzQBAJb9JdEZnSeqXMuPYALxS9/e6PQwPFhImHTTSjfEquKeST1vBtQ2 pJTy6doY5w9SBj3SU58evvXCEtVO8xB1WllEeBAII5sjxehWWS7sLDHMN Tn+AHAZRHMCVAFjouLLounN2Xm4uWPRrK274WrqAGPRT+VArB3xQuiZS8 0zd0fSVZ9ax2MZkxYafwNhhYrA+CaDFgyOLxDYxyHyJRIzbtaa01QE8uk IjlENei62Qc8AhO39lmHwgNkT+mPPDaHEn8bAzPy3Emm17O0pPJA/GOtP HVplV2ZIZBoum2uW8tWZodaS+heDFVJ6IEkbHAA3NfAXTf8q/rgLiolTL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104788" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104788" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374253" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:46 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 2/6] ASoC: codecs: nau8825: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:12 +0100 Message-Id: <20240221152516.852353-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/nau8825.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 5cb0de648bd3..cd30ad649bae 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -2836,16 +2836,12 @@ static int nau8825_read_device_properties(struct device *dev, if (nau8825->adc_delay < 125 || nau8825->adc_delay > 500) dev_warn(dev, "Please set the suitable delay time!\n"); - nau8825->mclk = devm_clk_get(dev, "mclk"); - if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) { - return -EPROBE_DEFER; - } else if (PTR_ERR(nau8825->mclk) == -ENOENT) { + nau8825->mclk = devm_clk_get_optional(dev, "mclk"); + if (IS_ERR(nau8825->mclk)) + return PTR_ERR(nau8825->mclk); + if (!nau8825->mclk) /* The MCLK is managed externally or not used at all */ - nau8825->mclk = NULL; dev_info(dev, "No 'mclk' clock found, assume MCLK is managed externally"); - } else if (IS_ERR(nau8825->mclk)) { - return -EINVAL; - } return 0; } From patchwork Wed Feb 21 15:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565682 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 900738005D for ; Wed, 21 Feb 2024 15:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529034; cv=none; b=VDZLRilmRVTrtbD5LoehhYu1z47Y4BrhuL873oua5QT4+hJJoIbFhcY48o8LE0yS4WUeavC0EhahLRcS18ZI9pJYOXzQF1XBKu0hlIunX0u3rmr72xcCo3DV3QqVOlkqO882GLxbhnFzV+F/0JmifPZziOLmSCx3bARKZJbUkgM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529034; c=relaxed/simple; bh=8gAZLk1t2SE3VLe9M+fDd8kW9V6hhS05RvORX1PQ8q8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=miOOJ0XJbk3iia/Fd3SqKqxkcYaQ5nj9F//R1M9KwnFvIenattPnHznCBwiX4yrnHWS+VgcTkyoBto1GrTWQTqB4IvNC4EHPE563lRODHKtgk9nTQeqAOOd2EObZiXJSnd1dLvcVk1dTrpdTgWBUu9eNmInpT+xB+6rYx2OgTCU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=g5ooRKuj; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="g5ooRKuj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529032; x=1740065032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8gAZLk1t2SE3VLe9M+fDd8kW9V6hhS05RvORX1PQ8q8=; b=g5ooRKujhc9zny2CFWgQFtG0G+Hj/Qnlx3nVH+NL30S/ykSNvVabRSis CzhpRViMWLDIHNnx7zNtPXvEoyX9F7XzByU2uX9pY3ni0vxFDp4MeDvLb nHkkZK5AwWsWCeylPUFGtuDucsJWrnecNuSSbUB5msyuvVH2w0xdmjf1d Z/lIXAUaLdneWuCTOPEjHCAFu76ybp+KCdyQddOoa98i/WyHsiOOExy0G 2+Jn0oXc4yjlVglrvkzJPsX9fZES08JA4M8inlj79kOvyK0fRzXg6NBuo AFUxcbF7PRJZhshgkA75kXAA8RSghkByDoPaRXaRaJL7r3w+UdxCSd46g A==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104800" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104800" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374265" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:48 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 3/6] ASoC: codecs: rt5514: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:13 +0100 Message-Id: <20240221152516.852353-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/rt5514.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 43fc7814fdde..a8cdc3d6994d 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -1054,9 +1054,6 @@ static int rt5514_set_bias_level(struct snd_soc_component *component, switch (level) { case SND_SOC_BIAS_PREPARE: - if (IS_ERR(rt5514->mclk)) - break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5514->mclk); } else { @@ -1097,9 +1094,9 @@ static int rt5514_probe(struct snd_soc_component *component) struct platform_device *pdev = container_of(component->dev, struct platform_device, dev); - rt5514->mclk = devm_clk_get(component->dev, "mclk"); - if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + rt5514->mclk = devm_clk_get_optional(component->dev, "mclk"); + if (IS_ERR(rt5514->mclk)) + return PTR_ERR(rt5514->mclk); if (rt5514->pdata.dsp_calib_clk_name) { rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev, From patchwork Wed Feb 21 15:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565683 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 4AF3B80609 for ; Wed, 21 Feb 2024 15:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529035; cv=none; b=qYMd72a6EnE8V5mept9rziwMbS3swli2aJgO/K38oAZiFFZoe2lq0aH3LyV8KTslYEaaepnHuWDefTV+1kLtvyN2YtyJojm/DSez2bqes4Bsv1SsBAb4e3d4MEQsV0BCtQGsCo1ENJXerSYIJtcMF+FyxT4RB4DF3Mgz6xELeCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529035; c=relaxed/simple; bh=Qtg3t5Qo59zUGmKkh1SsQQK/Vt6TCkwJIxrRq/xMrnI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tyf7Lkp2uDHsiRpVWvp8TsDr7JIjLSm9o6cfQKdJHz5j3yyt1WbrAFm6yYf3u0emyW+DYzqdHcGjGL1CJlZfxphj+x+b2TAwSMl5P9meKXSH731R6bdF1yq9cfVX4hYJBuiglHdKf4i8wgBxQRm/QbVIK05SZ6QP7NsLUsU4v/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IvomuOK+; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IvomuOK+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529034; x=1740065034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qtg3t5Qo59zUGmKkh1SsQQK/Vt6TCkwJIxrRq/xMrnI=; b=IvomuOK+tkKLgGHOLnqU+2I3rDYVIT5GSbUuSxNz2pUeAdhKfkplJjTN HKbIvEL+dzxfAVtnJGcUHshJnI268rbZ1I2bDnfzYIL0LS1rMwDzCh5IE xqHhIyyYdllVryH9Lr4AUA6bDaexq4piPqj/+5ewm9mppLB9v7hWWdKiG 0uw6Ovx3JKq3ulMhHNsEqlDStWdGTHuPOoZYzY7X7EAIZCsv47rERjH5c IoB+XmiqFr8vw2F6gg8zWEt5yS+Qx671FKoCybXUXpu8uWt4UeMyQd2lu 5bs6EzTjPdmXgTu9Vx7tEPIKiRqYz5P39QJ2J8YXhI+WZvXAn4OwkR1CN A==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104811" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104811" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374278" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:51 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 4/6] ASoC: codecs: rt5616: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:14 +0100 Message-Id: <20240221152516.852353-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/rt5616.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index c13108b51eaf..e7aa60e73961 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -1174,9 +1174,6 @@ static int rt5616_set_bias_level(struct snd_soc_component *component, * away from ON. Disable the clock in that case, otherwise * enable it. */ - if (IS_ERR(rt5616->mclk)) - break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5616->mclk); } else { @@ -1225,9 +1222,9 @@ static int rt5616_probe(struct snd_soc_component *component) struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); /* Check if MCLK provided */ - rt5616->mclk = devm_clk_get(component->dev, "mclk"); - if (PTR_ERR(rt5616->mclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + rt5616->mclk = devm_clk_get_optional(component->dev, "mclk"); + if (IS_ERR(rt5616->mclk)) + return PTR_ERR(rt5616->mclk); rt5616->component = component; From patchwork Wed Feb 21 15:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565684 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 2C58180609 for ; Wed, 21 Feb 2024 15:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529037; cv=none; b=LFfmDEj8BLswmZdsDX08gkIBWmpin2+E08tbs+m32m8Z9747fAvcHGmYTvRACELTJAPBG+0DwmUej7LY/AWbg6g5bPbdz+KaZ59JSwPIX+nf19c3QYPfKtds9cWBoI4QM/ECKd0do546Gd7g480XdcS0RBiuecBOw1VhkMe/wq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529037; c=relaxed/simple; bh=v2OUrfB05ibruSdwef5/iHstmtFCVpEQra9U5EyAw3w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=k+8hom9+RzynnOrKDNnkLIgeo8furgVVCyuWz9yPIXD36LXio0DnX7uk7IY6XrG0k5cAhrwrE0GShwXjcKmpTc6ra1V+V3PKg42bFRBG+MAv7vPm3TqLgu36Bv7qt0dwsZPMJNNOxHgoX12H4tKWqhuB0o5ASsMpRCUcDxpL3z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=efnBtRZo; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="efnBtRZo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529036; x=1740065036; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v2OUrfB05ibruSdwef5/iHstmtFCVpEQra9U5EyAw3w=; b=efnBtRZoqjRJDWGmEhB5hLfk8HZrKA+O5xLp8c7ihM6wCrMcj0SXHLlx 1w7Ox4NMYZKgt1WuGtkv3rYOXwD3cVAkkkfxtt2fRtHhWD06Uu4dD0d+U oM27UU2wVBEOrL1LLQlAgorKZgzAr7bXD3leOTxKVH/ZY/FSnEQvVyT2D kK+C2vkYpNPEYQAINnd2c4eiM4wAWgELdnFKnMGJhzi7G8yWfZ+HNc9pz q+gKDujml6C0scdVjAKJJ0t5yNYkgb/coZ4dK4L8Xl5kjnPCQd2UR+ryM LEUGGEx1ffeuOCZKAw6G6/BgVig1rMS9fECO2Kziq2qy5/ifHz/7SPGS+ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104824" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104824" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374285" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:53 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 5/6] ASoC: codecs: rt5640: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:15 +0100 Message-Id: <20240221152516.852353-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. rt5640_set_dai_sysclk() is an example of that - clk_set_rate() is not guarded by IS_ERR(). By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/rt5640.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index c60894327296..c579ead0deec 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1949,9 +1949,6 @@ static int rt5640_set_bias_level(struct snd_soc_component *component, * away from ON. Disable the clock in that case, otherwise * enable it. */ - if (IS_ERR(rt5640->mclk)) - break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5640->mclk); } else { @@ -2661,9 +2658,9 @@ static int rt5640_probe(struct snd_soc_component *component) u32 val; /* Check if MCLK provided */ - rt5640->mclk = devm_clk_get(component->dev, "mclk"); - if (PTR_ERR(rt5640->mclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + rt5640->mclk = devm_clk_get_optional(component->dev, "mclk"); + if (IS_ERR(rt5640->mclk)) + return PTR_ERR(rt5640->mclk); rt5640->component = component; From patchwork Wed Feb 21 15:25:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13565685 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 47C9980609 for ; Wed, 21 Feb 2024 15:23:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529039; cv=none; b=YdQjKKdCQBQIUtU5f0TcA3qfqI+3sBisu/8VHZ8nePhGzzLUQQp+H2dta9ZWjrzXq2cWwZs6dgKzJZLqTIlIFsKXfPKbhjzqf93d08IxmRCAaUu7on/ADYTDEfF241WKVuZKmE7FTsek3h85pZpkHC80bIbjwUlrsuh5s4NEQNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708529039; c=relaxed/simple; bh=gzcWGNL38cfVL/MuMfhSxMmLpqdQ1ceJameavm9K4g8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PlXdrRIzIg4IcTB4VAQ/xt7PZ4pMd8G7aN62YchRH0gac6piPAjZyc4LvnqYaclYFyOMeapB6TSgOm2nwgSC+cTGxTPdZA0iUW/oSexzy0AJgoG94M9cyrsyRRGfT8f+NKXuw6rzQjjp8TO5e6X5pbXZpg2zapfMxUivaMID67Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=bKi9YWlC; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bKi9YWlC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708529038; x=1740065038; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gzcWGNL38cfVL/MuMfhSxMmLpqdQ1ceJameavm9K4g8=; b=bKi9YWlCTib0bfVpdW5FYTZUhvpsFaG4pU6UQ9w63o/W7e3nDFETh/lZ HXp0xr6qMG1R00QCld6qLKd0wOezgsOr4I1iJ4bCe5GmDmIseVBjJkX9f ko8a9WfUlQWU4vnTGWa4VgMnoP1zOCx/NEI9Q0hVhjtgKqE+U53fNUvQe NgUjJDCLHckxjQriTHyc4wXGI0s8jWirMM5D2xgah39VjFu2wK8Z4wVd5 T/sGABN2PcRyk7vUz9GmwmUMrwzKP4RjwlXYMVJuB+kQs90gYt18BmECq D7OluIk+dfs+CvkfnJCbCDVsdq6AKwXBrRRTHFuicSKMImakXYtMDtrFc g==; X-IronPort-AV: E=McAfee;i="6600,9927,10991"; a="14104831" X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="14104831" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Feb 2024 07:23:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,175,1705392000"; d="scan'208";a="5374293" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa006.fm.intel.com with ESMTP; 21 Feb 2024 07:23:55 -0800 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 6/6] ASoC: codecs: rt5660: Simplify mclk initialization Date: Wed, 21 Feb 2024 16:25:16 +0100 Message-Id: <20240221152516.852353-7-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240221152516.852353-1-cezary.rojewski@intel.com> References: <20240221152516.852353-1-cezary.rojewski@intel.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most of clk_xxx() functions do check if provided clk-pointer is non-NULL. These do not check if the pointer is an error-pointer. Providing such to a clk_xxx() results in a panic. By utilizing _optional() variant of devm_clk_get() the driver code is both simplified and more robust. There is no need to remember about IS_ERR(clk) checks each time mclk is accessed. Reviewed-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- sound/soc/codecs/rt5660.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c index 0cecfd602415..d5c2f0f2df98 100644 --- a/sound/soc/codecs/rt5660.c +++ b/sound/soc/codecs/rt5660.c @@ -1079,9 +1079,6 @@ static int rt5660_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5660_GEN_CTRL1, RT5660_DIG_GATE_CTRL, RT5660_DIG_GATE_CTRL); - if (IS_ERR(rt5660->mclk)) - break; - if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5660->mclk); } else { @@ -1277,9 +1274,9 @@ static int rt5660_i2c_probe(struct i2c_client *i2c) return -ENOMEM; /* Check if MCLK provided */ - rt5660->mclk = devm_clk_get(&i2c->dev, "mclk"); - if (PTR_ERR(rt5660->mclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; + rt5660->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); + if (IS_ERR(rt5660->mclk)) + return PTR_ERR(rt5660->mclk); i2c_set_clientdata(i2c, rt5660);