From patchwork Thu Aug 1 15:58:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 816126 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41B601B3F09 for ; Thu, 1 Aug 2024 15:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722527945; cv=none; b=j4oWceJpQCVNzXVqt3DDqdov2Mzr0yqfNZTSimyXZ1spzy1B9yoChxbWkglDgyo93go0VyH6RSqgGho5sha9SY9dKrE+YChmvB5JkYedPvv+I5CWLOiXWcGm5zZ5sOP6zk38/0qHFbaqnLM1fNxW8yOV+MGp8r30V5qZpo+LThg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722527945; c=relaxed/simple; bh=Y8NzZ+2cCsBdUZUcYmx75X5l8PF6dYCbeZPYmVZ3FCw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IG7pZKNsj2bkxV3kqtlCemCN/7EcaXk+C/IcMLL3QnCug9D8w/GzWGjt3IDlkR94RcMBuvVjZNUBUp98dLz0cZN0Q4A3otGWt0psxw9i/YgTE63HoCrbIU1jkjkW2ayBSs1dD3CdzP8/KpSRmvFdEnCmb9Z+Qy3lqMwGn5EBg/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=lGNXsfes; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="lGNXsfes" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2f15790b472so9154711fa.0 for ; Thu, 01 Aug 2024 08:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1722527941; x=1723132741; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xHstomqT0M/TXt45tukB029xYZE9aj0TxyTgGXluxnA=; b=lGNXsfes2Rk1yj37UdOM54z5bGweW10WyYVqws2XLvt7TQIRsm0bm94Jc9HK1ijO5X YP769e+bVOpQKJSZMfguyuegez99uueyGsj7/ghmct8u/OZolAMqrYK2/84DbViZeNH1 UVFesrne/ePa/uOx9yJKfZXktoWbGNVqyQ0tHQjtPD/caEk4e9p1aBVjS12+bqYSaZVM ALVvQpGmMoDH931VO5qnHYodPqDdDs5+L78hTlhSvqQy3wPgCkOxAFAV0gxsl/idXo74 p6KD65C8swZGo4AnpCwFtrdLgVJm3Mirjvg9/jFlowk2Hi0AkEfwlSrMm18heqaMf6ry nniw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722527941; x=1723132741; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xHstomqT0M/TXt45tukB029xYZE9aj0TxyTgGXluxnA=; b=Nn72b6dE2q9EKw47aiVgmvImieg8i308xACypliXV0yeFFrIV+FYk5BNYjcHyhDqgt FVG1fjqGNjdzXeZnxrI5H7hncr7bsxw8zSJDzD53fBW7P66IPAZ/MJS7wJfio1sikI9p j47mulGV0OKlqnajnxEUO+hIcgw8eSbjhwH2UsUhUkzHyUVkszSEJ2zcfzA8EUOwNsP0 dw2Nis7JDJtH/6EuDKD7Bt6rI4ZRH+5+EAMTa9mRJIH0qSTO4rPcpcVaK2AAS+IKz807 ioUoLE+u+nB8G3UDpWGYRrHwT3umXJL4gKKyInUEkMI62vN4FoF78OYDfzjZZNd4vf3z +/LA== X-Forwarded-Encrypted: i=1; AJvYcCU7QDCs+3NEwd6uZs1XAqPMKDwh54NHnmr1xKcW84u34fSOWrJ5xCx3JRxr7+0RfcjrkOveBPQH2DL/vJFa2BWebiuuSG8Q6Ju5Ez34D+b3 X-Gm-Message-State: AOJu0YyaqMZsp38X+6atUPHn5nFj2k1VuE0hmaGX82tsmZNOipWZPAac gy4wnj4d07QjYeS9wbmE0pu6hXrPxF5w73tTyn3mRpE5J1/eonRKjWM6cVkv5gE= X-Google-Smtp-Source: AGHT+IGHsHKzDK+INUytauc7w93lMmXusnl27xUxv3I2sd6nW4vMVIbrfIHDRMeA89WgfhaKfNhTNw== X-Received: by 2002:a05:651c:c6:b0:2ef:1f10:e277 with SMTP id 38308e7fff4ca-2f15ab0bfe0mr4776971fa.34.1722527941161; Thu, 01 Aug 2024 08:59:01 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:9895:bf13:f4de:f316]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e6e7d615sm1393875e9.29.2024.08.01.08.59.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:59:00 -0700 (PDT) From: Bartosz Golaszewski Date: Thu, 01 Aug 2024 17:58:49 +0200 Subject: [PATCH RFC 1/2] clk: provide devm_clk_get_optional_enabled_with_rate() Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240801-clk-new-helper-v1-1-81e9338b7b17@linaro.org> References: <20240801-clk-new-helper-v1-0-81e9338b7b17@linaro.org> In-Reply-To: <20240801-clk-new-helper-v1-0-81e9338b7b17@linaro.org> To: Michael Turquette , Stephen Boyd , Russell King , Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3013; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=ZL/W72WhtKWlXQ3YfSXI2WBmEaie9uQcs/Yqqq5I764=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmq7DDIT7m5tdjMs5UvtI1BL78YM4BsLZCNjr8n OTRxHZN/U6JAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZquwwwAKCRARpy6gFHHX chUbEACegEoh/MQrCD3UG4dxKZMJk9n9v8hm/iPG3wDDf9N4ZPMyqrq5cM/Afy/BM0TrAYy9qud EjPkNrtuOHZBetaJt4aq4z1gfIf/gkvS1cy8U9edb0pJa8IydfVIgo2c/JOloPNzxrAm4Z5nT8g jSBnNdN0t+bhx4QNNc0uzbPo+TPlAO9wKpjWFkrOr/h1vPzwDe8hw5mWABvl/1GlGXJJJz2ebpU vETZc5dayYIU8WdEwKIP0yA2rwqFsiXbese7LMlkuaS9b3icjMdwMHv9ziKTJC9Fp9+aTASYbAe QI/uMCa+upQwT4TYxmnd6JZus/whd8ocr0XIHlY7pHD3Kb/jlNEXAMKpLo01HgT85jWXS1xuOaC JEnbH+I1nTGpRpnqIO4gfN0Z/5HmJ3WrzCz2QEvOahtC2d5QL7ZFYvjZIgZOfs/1/tx1uC1UoG8 9Fp5VDpvLjA/RvSzng4/8xZOzIgxRVEt0Ohu88H9hqb1gmP2p2GUbobSx+3K3NdFm1a4p08yqwH QV+OkFxoUKTlrkgUwN3wRbD13TAHvUDW9ca0wJojJ1Jih5Iq3QYZmORiwHz0LrmjroB7nB5NUSF 7l4OVnGc1UmOHEH6WUA7iEbcTe95PizvnzrhlRpplw5c+5W+cK+DMdr1gO9dhGkKFU2LNyuR36k bR0Dwfk0B83ix8Q== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski There are clock users in the kernel that can't use devm_clk_get_optional_enabled() as they need to set rate after getting the clock and before enabling it. Provide a managed helper that wraps these operations in the correct order. Signed-off-by: Bartosz Golaszewski --- drivers/clk/clk-devres.c | 28 ++++++++++++++++++++++++++++ include/linux/clk.h | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 90e6078fb6e1..34e800525e21 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -99,6 +99,34 @@ struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id) } EXPORT_SYMBOL_GPL(devm_clk_get_optional_enabled); +struct clk *devm_clk_get_optional_enabled_with_rate(struct device *dev, + const char *id, + unsigned long rate) +{ + struct clk *clk; + int ret; + + clk = __devm_clk_get(dev, id, clk_get_optional, NULL, + clk_disable_unprepare); + if (IS_ERR(clk)) + return ERR_CAST(clk); + + ret = clk_set_rate(clk, rate); + if (ret) + goto out_put_clk; + + ret = clk_prepare_enable(clk); + if (ret) + goto out_put_clk; + + return clk; + +out_put_clk: + devm_clk_put(dev, clk); + return ERR_PTR(ret); +} +EXPORT_SYMBOL(devm_clk_get_optional_enabled_with_rate); + struct clk_bulk_devres { struct clk_bulk_data *clks; int num_clks; diff --git a/include/linux/clk.h b/include/linux/clk.h index 0fa56d672532..c8d237e9b8d4 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -640,6 +640,32 @@ struct clk *devm_clk_get_optional_prepared(struct device *dev, const char *id); */ struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id); +/** + * devm_clk_get_optional_enabled_with_rate - devm_clk_get_optional() + + * clk_set_rate() + + * clk_prepare_enable() + * @dev: device for clock "consumer" + * @id: clock consumer ID + * @rate: new clock rate + * + * Context: May sleep. + * + * Return: a struct clk corresponding to the clock producer, or + * valid IS_ERR() condition containing errno. The implementation + * uses @dev and @id to determine the clock consumer, and thereby + * the clock producer. If no such clk is found, it returns NULL + * which serves as a dummy clk. That's the only difference compared + * to devm_clk_get_enabled(). + * + * The returned clk (if valid) is prepared and enabled and rate was set. + * + * The clock will automatically be disabled, unprepared and freed + * when the device is unbound from the bus. + */ +struct clk *devm_clk_get_optional_enabled_with_rate(struct device *dev, + const char *id, + unsigned long rate); + /** * devm_get_clk_from_child - lookup and obtain a managed reference to a * clock producer from child node. From patchwork Thu Aug 1 15:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 816537 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E9621B3F2C for ; Thu, 1 Aug 2024 15:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722527946; cv=none; b=gPcnjBRfEQMviQluOvJyj095MKiyiC2UnXB2bvwaJ4fd3g09d8duwDUubr8z6MDNvM0YzxcAZlQtt2HABbOGLLKkjeFlH95PI6ab6+P8Q+K1Ev/WJfawjEqFdsbofZijJSt94VbuNAoUcjDzgTqrHg9ST2apHY6Jd63KPzWiFhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722527946; c=relaxed/simple; bh=Omcj2xWQwt6NtgOQkDGWvmMiPdAy1FRwJRfuq8HYeCg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KnxCu6u+PaHMvD9r3r8i+9quEjEB+FQ2ht7+L2jcHN4FLKwHPAdC9qEeKuhOASCjO8zONCKenkrgqJ/dhvWJe0QJe0WY1GccKhNX3NLRAfww7MZTz653U7Q6GyxvF7Edh/c9PJcxaEncluGPHVDTxHqKbP+9RtwF9bUfyp8nPW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=qOVvoYSj; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="qOVvoYSj" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-428101fa30aso47369695e9.3 for ; Thu, 01 Aug 2024 08:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1722527943; x=1723132743; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=m5i/CoqWPo0A33bWnp2WK+u0zZkl20goXzr8vooyPLw=; b=qOVvoYSjDY+qN0ew3Vh1ST5RHysrvq14/pXzEceygec6tohb5ojFI/HVWzAph3tv0k cXsy8khrctnna4QydcBzg8DLNgXzqwGXh8oAqnHsr8TNheSEhuSnE64MiTzEQ4ADS43l q/loIJA9x2zWxHJpiTUdanmo3vGPpsulRtglvMLTQvT99ArqhFZJGK/qV9M42RXLn6Ga zm6lhDFp0A0LH2A+cUpV9d0O5o25BzuOva35zajI5um2do1xj48ZFaIoe1v6JtmPfleP GTaGdeY/k2eD/O3PnYwZp+8DwBuwoMNZoWukvncNoXEWo+xUJsxVhNOkcH6/dhZ3zEW8 Fzfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722527943; x=1723132743; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5i/CoqWPo0A33bWnp2WK+u0zZkl20goXzr8vooyPLw=; b=aBBv1UpSSk6bZtBShDAlOm4RrCWpqzsrGg17bKGlg3MT05hWY693eG4MzVqplG0ciO pAZRVEKvOony4O0htij9i5pX3gTL97QvFQdtEhR/Do+BPFtViorxze22J5HIWpp5dD1N EOvgg1NiliKXar9l8o5Q68PQ6vDjs4nt7ui07ilKZV4q2bNBhLLckCro+KWEv+dKVa2U RMsmwXdpozRo06viwD6cBHR9CIeEB1FvSiJhLV8USU5kTuajm4sTfyuWumJDc/bEBT62 /60ii39m+dcbFK36x1v3w2qrX/Ko83g4/lKJhCi8UHmf4CwQ2/4awqsS6NqcnaN+0iE1 4GJA== X-Forwarded-Encrypted: i=1; AJvYcCUt1T7FdtvvpYDJfWQoWmiZQOUAHR3/LyMHQNVKvO+IQs/cUhhzhaYE9/+k2nKyjH8D3CJmimNh/1jHfb3L8j90vmIZ2aipLJ1+GPEsurZW X-Gm-Message-State: AOJu0YwCbbPZS2r4MPUtQh7v7T2k78xdsbkhNSR6E+NcBaSIi/HtUqiI FyIvUOXycAdJmlj7aAs99f0WApx3oj9HLVvRaQpph26GVjQBc47mN4+QlLk3kFU= X-Google-Smtp-Source: AGHT+IFIRyYV8wMpFEMoJ9mEI29GrIsoNHi74Ep547kloryWVfmLguZuTbUrIBagLig+4xgxpoADpw== X-Received: by 2002:a05:600c:458b:b0:428:1dac:1890 with SMTP id 5b1f17b1804b1-428e6b9388fmr2368255e9.32.1722527942515; Thu, 01 Aug 2024 08:59:02 -0700 (PDT) Received: from [127.0.1.1] ([2a01:cb1d:dc:7e00:9895:bf13:f4de:f316]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e6e7d615sm1393875e9.29.2024.08.01.08.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 08:59:01 -0700 (PDT) From: Bartosz Golaszewski Date: Thu, 01 Aug 2024 17:58:50 +0200 Subject: [PATCH RFC 2/2] Bluetooth: hci_qca: use devm_clk_get_optional_enabled_with_rate() Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240801-clk-new-helper-v1-2-81e9338b7b17@linaro.org> References: <20240801-clk-new-helper-v1-0-81e9338b7b17@linaro.org> In-Reply-To: <20240801-clk-new-helper-v1-0-81e9338b7b17@linaro.org> To: Michael Turquette , Stephen Boyd , Russell King , Marcel Holtmann , Luiz Augusto von Dentz Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1648; i=bartosz.golaszewski@linaro.org; h=from:subject:message-id; bh=P/Xbs1jF3li1v+zlwL+edbl5plqFHRk4jCw7biA6/os=; b=owEBbQKS/ZANAwAKARGnLqAUcddyAcsmYgBmq7DDH3C6eXuOAHHcbUdtceaK1dhjfbYwCeF7r 5U3Y6TxXHSJAjMEAAEKAB0WIQQWnetsC8PEYBPSx58Rpy6gFHHXcgUCZquwwwAKCRARpy6gFHHX ci4iD/4qInYT/hTR/ISAtD63aPZ6kdsTJ0DRSJT1AaffUMNUj26XEXUOhPxWGgPFeNMD/ySusmV 1cbkeJIPVaGTfRstR7tP8dGrlTeL5sspUUYv8NWqXKzH0qq54SZO7ZCqKTEbenqdGqxo1gdadcK +TOeLfkzGsEzhO1n9USOt9X2php2JnrO/rMgKEdJuNpbeP6fGof+mhKkgw9CjW/Rvm4s95DlZn3 22sOnAv8qdnX/uwZRudiR8/h0GSLSinxVBrsoSKjMQgC2epKVtGv+0QrNDab3nHUNVgUaCs/MqS BE0bAvaJrJwIgSDyYrmbCnxj89A2IwfV1IdRbUmO1VfwOFzeyPBLIBOjpcibJtkWZI4wtXdf/oB HL7h497eRfDbcsynrcK8JpqLaZ9+1dHkbq8dLVd4xI9/MM/xFgCPT4eCfrYMiolWYVJS9Ycrwst d7hMiSK1pszU4ho2GcwjZfI/0kSHFtGa8qEtND3EvF/2ipjeFv1hTk8sRpEU+O7WW97U7z1LgeA 92WqlNz8JuODFgDdxTpaBN1QapJKVJiPukJXWRoUV3U1ILqIF2+V7VlnVxc6x8N3LY3EoW1BH7l TvWsQi4cG7fm9TQu7mJZobBcAvYfg15CZsFyTFBzOMoN7KGUZeIw91L6N5inFg1LPK03SaoKUb1 zp3wa/Fo1LdxacQ== X-Developer-Key: i=bartosz.golaszewski@linaro.org; a=openpgp; fpr=169DEB6C0BC3C46013D2C79F11A72EA01471D772 From: Bartosz Golaszewski Use the new devm_clk_get_optional_enabled_with_rate() clock helper to shrink the code a bit. Signed-off-by: Bartosz Golaszewski --- drivers/bluetooth/hci_qca.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index ca6466676902..0670f527909c 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -2297,13 +2297,6 @@ static int qca_init_regulators(struct qca_power *qca, return 0; } -static void qca_clk_disable_unprepare(void *data) -{ - struct clk *clk = data; - - clk_disable_unprepare(clk); -} - static int qca_serdev_probe(struct serdev_device *serdev) { struct qca_serdev *qcadev; @@ -2433,25 +2426,12 @@ static int qca_serdev_probe(struct serdev_device *serdev) if (!qcadev->bt_en) power_ctrl_enabled = false; - qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); + qcadev->susclk = devm_clk_get_optional_enabled_with_rate( + &serdev->dev, NULL, SUSCLK_RATE_32KHZ); if (IS_ERR(qcadev->susclk)) { dev_warn(&serdev->dev, "failed to acquire clk\n"); return PTR_ERR(qcadev->susclk); } - err = clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ); - if (err) - return err; - - err = clk_prepare_enable(qcadev->susclk); - if (err) - return err; - - err = devm_add_action_or_reset(&serdev->dev, - qca_clk_disable_unprepare, - qcadev->susclk); - if (err) - return err; - } err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto);