From patchwork Wed Aug 21 01:37:25 2024
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Huan Yang
X-Patchwork-Id: 821152
Received: from APC01-TYZ-obe.outbound.protection.outlook.com
(mail-tyzapc01on2048.outbound.protection.outlook.com [40.107.117.48])
(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 15AF1A55;
Wed, 21 Aug 2024 01:37:59 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=fail smtp.client-ip=40.107.117.48
ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1724204282; cv=fail;
b=qvdil9Mu0hQVPM0zlLns/xO6dGbvXIO4vPT/9vyD1kpESNAfrIGGbKWET2DAlYDMAxmA/zMrLNsa/j4aODv1S9SDGwb6GzMG4efEEztHiGE1N6o7uVJyWjb83ppe6e6tt93ViqxQY1Y98qsgM7UIIcf2HdQLyS8hlVpXDF1df6Y=
ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1724204282; c=relaxed/simple;
bh=pwyeDVWfre8netSfb7Y4POqrEwnvq8VLnA0r0bxccMc=;
h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version;
b=FvAmTveSNg9vJoZWIbs0/MWvWvPrOPJIPaNpMrPY6oT9SlK8nZ7SlTS2E8jiTGwD+UN+l00SnGMkXcU20mYxQwtH4zhulqHA4DDnm6NNNuE0krYowwBW2KPPvh0kw9wmlr/XM/Z9fRHlam2nc+EGNFdAbH1Gt7xGuL1TddGengs=
ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass (p=quarantine dis=none) header.from=vivo.com;
spf=pass smtp.mailfrom=vivo.com;
dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com
header.b=lYhC2nBi; arc=fail smtp.client-ip=40.107.117.48
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=quarantine dis=none) header.from=vivo.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=vivo.com
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com
header.b="lYhC2nBi"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=Rf4tuMbCu+CNPINKeKX6N+wQasUeIqfbVu8TnbX+nX4EAE+oj9q+Epj/S+2pqgW3f3FFYrXqQZx9wykIOXmrCOeGduOO5M7Ei2vGDl08JCheuOeqCIbmSsrIrZQz4B1aAtz/iNDfpnbo/I4gjZLt03tGOL+4SlKVu0pRTHnbkSA7Qj62XwSo2FWmK/Xv7dGsATtJfvIg0BD8AByoaKFT8/0uShw4Y7J5YJQYi9t3s3j9XsmCkX8rYprvSoI/DiBzT1fL3FKNubq3wgBharen8yo1ymm8FM8OgWlocXT0bogrkJlpHJUStVU0dgydpp7YQ5dn7F3M+TfVsGqM47jmQw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=0rZoqMTEJVcGAE6+o77bF20cMv7hadusnatBkNKLOO8=;
b=BYRN0crO3BAXO1AyH1E9bUO7Do9fIplM515fwJR5xOgiqJDOdRWXc9L0ZAG5147w5UMjqDmr9SOu7G7GVMw7I8Ntfo0yNxIZ99FCz+tag0olz084ZHD4Tm21wcYo7BDE5tCMKZVvCsvyOW703iI8QJ+XoQs0MuQL/slEHLBi6gfHcUlIilykGlZaKM8KlQHqdNfdgTYbR1o1uVUTdH95lalu0TZTF+RGRLfn68YwhzomdoHq+PAanohca1Dh2I2RErxKnsFXiWmPbw8bBU4WMt7dJEXQais+BEyAq3BSjd9VdIELwi5PaWrzRpJ1j1Tf0h0BY0HaJcYDdoxN2luxlw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com;
dkim=pass header.d=vivo.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=0rZoqMTEJVcGAE6+o77bF20cMv7hadusnatBkNKLOO8=;
b=lYhC2nBiL6ot238CWP3LXyxZPMfAn88lXE/lT5i0P4U5VTLhLf8h4oxeJLOMboAH5WRVo7t/hyjcevI3WDyZur4VAXl0II/Ps+tr8246Oh6RjFAcDxmZXcBKNq9MOuwwbgPJCHR2D+taCE+BV5iJ1hUwdJPHqzf5rbZXtn+gUr0ugPGi6S9qZU+re4bDTrhMfZmTEvyrxMBrRmuv1yOGyDdCBZByycabnCV6ZQLt0DIIJEjkxBVK5Uf9D285leAm6TXBojlpXk+WvwmyX/XEPlF3Ngy0bGyeet31JR3jngWAJtmdxvVVOQrYyogbIq8Ct+sVR3Qu30qWs/Zj2uowxA==
Authentication-Results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=vivo.com;
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10)
by KL1PR06MB7035.apcprd06.prod.outlook.com (2603:1096:820:11b::14)
with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.25; Wed, 21 Aug
2024 01:37:53 +0000
Received: from PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f]) by PUZPR06MB5676.apcprd06.prod.outlook.com
([fe80::a00b:f422:ac44:636f%5]) with mapi id 15.20.7875.019; Wed, 21 Aug 2024
01:37:53 +0000
From: Huan Yang
To: Pavel Machek , Lee Jones ,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com, Huan Yang ,
Christophe JAILLET
Subject: [PATCH v2] leds: lp55xx: Use devm_clk_get_enabled() helpers
Date: Wed, 21 Aug 2024 09:37:25 +0800
Message-ID: <20240821013725.785956-1-link@vivo.com>
X-Mailer: git-send-email 2.45.2
X-ClientProxiedBy: SG2PR02CA0039.apcprd02.prod.outlook.com
(2603:1096:3:18::27) To PUZPR06MB5676.apcprd06.prod.outlook.com
(2603:1096:301:f8::10)
Precedence: bulk
X-Mailing-List: linux-leds@vger.kernel.org
List-Id:
List-Subscribe:
List-Unsubscribe:
MIME-Version: 1.0
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|KL1PR06MB7035:EE_
X-MS-Office365-Filtering-Correlation-Id: 8214e9f3-fc22-4c00-b12a-08dcc181dff7
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0;
ARA:13230040|366016|52116014|376014|1800799024|38350700014;
X-Microsoft-Antispam-Message-Info: SKCDgZx33n+Gh5+9yNnatNWHJUTDCqBzKs4ieezEB/HUoj007T3U2kVpiiLY+eb/z7A+n6tI17kTjUB/iXJsVBOpirbtKxh7UKekAouQB3Echc+K+2dJHFreQ9oU9PgYWRPjFQpqbtl4gWHzKqduGHbSuk2kkWcmruBZH23N5auqIN2R8yst5hNRgurMrvredyspviNd7s2W8HNF2fd5Muh7eU87YmnZg3QM5I4UsKGRAa+cCaZYKZBacSe6n7dDHq3H/AMXSGU9/nu0QT5u8jN7chejYJJsvGhjezU8gMIXN3VtGbY4nn6OsMKSLZD3CSDuCJn6uyKuMIFoALiEa48WZwv2KST8S1X+BCxU6UdTTmh2uKXv9/yrPtT+bUIFbrMgVCHbXlwWb5ZVsdChnwvV0f+TRTchqKqTWTwqg0imTRyRmsG6IvwZ7KXoPjTGj/DBWwyuk562joNTegT0rEsvXanwlSH1dnWqDr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)(52116014)(376014)(1800799024)(38350700014); DIR:OUT;
SFP:1101;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: BCdmW4hxSdSQGAQ6lTpn0dlbCX5h5sxS2lPm9ocEU6H35sCH4WKVCXFk/x3NWKKNNS0r72kQJklQy0PDa/GtnCHdozpF0LbKUWprO2csRJpIu+DD4vjQvstyqBlKxR8/Pqz7E0IMf0irV9cRqzvDlUiOBeSiaV3MKugpRBurJu1pqVdIX4LIYO9IMmifA9jP+W3F23fC+xfoty7ewNIIWmz+vU1AxgaenAm3DF2nrh8JBW7xw7UYpE50tPySnbyBP+8Q0rq9SuyhyTby7I4WNNWDaxkTJZhaNY50EgADB7EJA6ce5PN7BstEQ7eX+gQmZvy4O1MR059ZxJ1n9uqi8lcNIstmTWO9cc5nhdsm6+cHd/uVHi0FBB2VapiThdKnu19PVsglH7V5djcuTBo9zVNwNmC3aP5jMhxmYoRnKZ8f54kJmFNK/yEOpyyvP+yVWk3QvxnjLqZbMdOGn4z3+1QI/j2woCwtA1vT4NHgYNxwKp8D9WOz9hESAN7IcWIAIrSr82zM+yKB1QKGdC57HdbubKy69RdCndSjsLok2g+yB4WUb3SVbt5aR06wcvp7BaBb5WZdy7GNHwimlO2briSzFXdOokXV1CqGj4aRR16wF+DV0k862UldZzYsPWEizAxOqV2sYze2xQXtkwC6ikA8cp7JwvrH0RyW/Z5eus2huhB5bcy+NDcGGYtkAHkc+TSTlHKHmTMmxlV5F2q/AdVnmavBNUEXfmOwSd8ATbqZLGgIum01eFB9CB0bI/FfIEDgv7sI+v3iTZbd9SNDP2ny79cdXa5IIp3pIBDXWWrqfeaN2/DhsrYMa4kqt6h98reEbXdz/OW+zwbfg3Mz/5EhFzBJ6l++krZCk9B6h+7Tx9lYY1DRXMVrbV6LOeEy+BSbZ50YTSlp+j0w3yww7iXvKvOg7TulJYjlL17pFdgJz5E0hprex9INaj1dY96YMaoUr2ew/oxxESM7BsySOA7i87VFtgFgJCHy2v1Vrv0pmUKiRlCr42rhsQy4vCv4W4mfFpj/OhJke0lzGVVMflNgKz8sGiYxmI00BgZUfJNntZN+6byIHurUNQQ12U8stIkE+2ql32GjkKuLOtZs3/diY5uXSEi1v+zNP3GG3uz/drXIlkkq2v06hKv1KbR4JIiAYqA9fLkCqTy9BNAeTel7UzzVPF8jQ+NA2proWEc7O3wV7RQGWDIk8DoJe8jacfwT7TNeLuhJs6W/phoBcmJlTh2Re0ctFjXnEFp2awWnfS2U7rI2JN/lJ2Tn87w9ap8WjRg+Gcivfcq6DfuXzWUUYITXpJfy4NLQH9MICxGv93bChs7D1QeuTUaCiYkaifGXkZTGw6tJcCu4khqVgao+AKXEilI7xzOCCj3ez25w5n5gogo1i1dL+azrQkG8ZxwcNa9vkdPZsBlnysfVduF8MineieNnnFi4FiYbzVXHKXmP2/s4yEqWaT7RX1GKmG/iAL5uzqrWZbvcRyVnQhDEQkb9bPdKWjBF+McXBfQ0mnPlYh6gO0IZ4PZK/EKUHDxMhroJXxj4txzrcDDqkbBB95JqhvDxQL7wz7BEzBo67SLx9EkovB4BP1C0Px7I
X-OriginatorOrg: vivo.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 8214e9f3-fc22-4c00-b12a-08dcc181dff7
X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 01:37:53.3813 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: pgU8/JO9ZPmtZCpuS5c9XV4vRF66Y7mDI3OGCCPVZkH/XiTSgA1/i2/W6j+bcGUwZg1g6ASJsS/xnr/5I/LoUg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB7035
lp55xx lp55xx_is_extclk_used get, enable clk and
deinit_device disable and unprepare it.
This can use a simplifies helper to cover. And no need to save clk
pointer, this can save a little memory.
Signed-off-by: Huan Yang
Suggested-by: Christophe JAILLET
---
v1 -> v2: remove clk pointer from lp55xx_chip
drivers/leds/leds-lp55xx-common.c | 15 ++-------------
drivers/leds/leds-lp55xx-common.h | 1 -
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index 29e7142dca72..1bbe170a217b 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -965,24 +965,16 @@ EXPORT_SYMBOL_GPL(lp55xx_update_bits);
bool lp55xx_is_extclk_used(struct lp55xx_chip *chip)
{
struct clk *clk;
- int err;
- clk = devm_clk_get(&chip->cl->dev, "32k_clk");
+ clk = devm_clk_get_enabled(&chip->cl->dev, "32k_clk");
if (IS_ERR(clk))
goto use_internal_clk;
- err = clk_prepare_enable(clk);
- if (err)
+ if (clk_get_rate(clk) != LP55XX_CLK_32K)
goto use_internal_clk;
- if (clk_get_rate(clk) != LP55XX_CLK_32K) {
- clk_disable_unprepare(clk);
- goto use_internal_clk;
- }
-
dev_info(&chip->cl->dev, "%dHz external clock used\n", LP55XX_CLK_32K);
- chip->clk = clk;
return true;
use_internal_clk:
@@ -995,9 +987,6 @@ static void lp55xx_deinit_device(struct lp55xx_chip *chip)
{
struct lp55xx_platform_data *pdata = chip->pdata;
- if (chip->clk)
- clk_disable_unprepare(chip->clk);
-
if (pdata->enable_gpiod)
gpiod_set_value(pdata->enable_gpiod, 0);
}
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h
index 1bb7c559662c..8fd64ec40919 100644
--- a/drivers/leds/leds-lp55xx-common.h
+++ b/drivers/leds/leds-lp55xx-common.h
@@ -193,7 +193,6 @@ struct lp55xx_engine {
*/
struct lp55xx_chip {
struct i2c_client *cl;
- struct clk *clk;
struct lp55xx_platform_data *pdata;
struct mutex lock; /* lock for user-space interface */
int num_leds;