From patchwork Thu Aug 22 02:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huan Yang X-Patchwork-Id: 821543 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2085.outbound.protection.outlook.com [40.107.255.85]) (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 15D0F848C; Thu, 22 Aug 2024 02:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724292238; cv=fail; b=qdDzPUEY0zNBx2V3FWpe3vqeZWGC3BHZ3uTcasTBGUL+eiCsP43HWKkxkZWLQJ5G3u2l78IMXhZtBDzoPVENZqe3oRSOMFuocJNBl5NG3eSQ9XK91zmdq1wrBV9vqpIi9rOBq7JzaUedWXCbX4+9wBQALHLQmoTvGwHnawr6QkU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724292238; c=relaxed/simple; bh=IqIsAwZFSTr4EfZaOcg0cnrOryCV99C68eun7+AG6Cs=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=Sh/9Kn4qLVk86BCdYmCinQyJ3XAnkLqTy4HmjM1FVU3upt4HamkwCDqFZgOiFswAt8aqJQLNdNDQMK9sc+fFIS+VnPyOcMdTPhQnmViD3xkgtfTbmKOoxjBVgL3EaTnJMsrdeZzg6+hxTpc5ZXhmyzT9oAuYoNevumugl4TuR9k= 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=JrLK1L6t; arc=fail smtp.client-ip=40.107.255.85 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="JrLK1L6t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=neMTov5f6ZjJ3fJH0+S7c4CLfUawyvprueHxwxzonD8LRx/6Ffgc6LBn3g+G4GUYOtSnt/3+RJfjnyXsf+uWZIYSSrkDlmDjUM/tLzx2JA9xiA90pReZHXXlH7Cl+jBH2vmiEwUrXnDIADYbePg0/8IplguuL84NPP79RykNr/xNDne5gJHm+QX0afQMqAmeanOpwHsIjbcIanpKuRwuqVjTEQPHiJvXxy9EUFPzz+jlHVNj0PZoMP15aaf0WlZJG6Gq2aEw1yxsR0KWAeREV0QZ4ztDPVRn1OvbehocD3HoxKiVLeGzJqs2XibWpEogvlA/QHrYQ4k2gSV4O52akA== 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=mkZ5WSeLdmXgyiBMEch19wpYdBot8KNgdvqL+PeQJdM=; b=WrPM/3TF8cCUJpapepCM/2i4eqA+1j9O7/LIUgyWy9GisQRRqqNkyKIzs08oqv+mHB5WfkrfyxVhi0xE4BjRw5XxSEAkRXXby4N1VbXUshuf5qHdsR/Gbza8tPSkVaKJCKVW2uZcwOn+6pyRvvqhWvEcQXOUEbabMlA/+VOuLzkTouHNkGYHPQpuLlfbpqdP+HxrCh4xH4zmHGhhJoXdRPPY6uds4AFl+Svz0ZzxXUfNfAa1wJ6c9rHnR8jg2PLgChfXv5J4iDEsFfW3RgZPNUz8slh13s+9WTVn9UpKDbH3jrgOSyxafXGKcP6/O9QUBfkThITyt0nkX1K7YATh/g== 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=mkZ5WSeLdmXgyiBMEch19wpYdBot8KNgdvqL+PeQJdM=; b=JrLK1L6tCYjykraFwRcqy5771HZKaSKEgX63eThnkoFDmk2M213djo+rQAGPNrguelveccGyLsAUkSUPN2QJyQAqIGGohODPxDaHuiLJV22A37L5tJUzs9K6ERIodfWOB7oSO8+3/5wqj80nOe7Jq48WocpknImSLF2RkoFhzvTY1uddFemlG9C1lBuBrtCVH8Jz/dnnmpO2RWjkqtnjdzR0/Y4HkRGzpHVsKiiUlFnMGwCGHmlw8CVgpn7/ZlfW3qK2DaR+Z3LEPNUhFfDWQ7YRg0a7pIeC0SLY5vbsjhYx3wXcRiZDBmUbtcHEY/nlcZAIO/Yargfirt3TBDPr4g== 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 KL1PR0601MB5654.apcprd06.prod.outlook.com (2603:1096:820:b3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 02:03:50 +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; Thu, 22 Aug 2024 02:03:49 +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 Subject: [PATCH v3] leds: lp55xx: Use devm_clk_get_enabled() helpers Date: Thu, 22 Aug 2024 10:03:39 +0800 Message-ID: <20240822020339.474715-1-link@vivo.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: SI2PR01CA0054.apcprd01.prod.exchangelabs.com (2603:1096:4:193::22) 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_|KL1PR0601MB5654:EE_ X-MS-Office365-Filtering-Correlation-Id: a4d04e65-bf49-458a-eaa8-08dcc24eaa1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: VHWN/K4NhE7uk3xvGo0nEuDMJm0P+6cHZ7fqDE3JeJDnzfSra3W59Su0kvG33r3QbVb3NPfhUrx5d8Jgv7aOi/+hFt8hePhKXVdEk8tMMK4UI4pkL0hdyQsrilzCpKsmqVqqh+D9kqJGa04fsdnMTlvqvupg7LgKybMy64CfLg1Dlf7izcOnqm6rTikBomkYlxpaTBu4WfaVDFkJlnYbIztkchKQj7ifaX2oRn0lwPyYHNivnuPvX9ECyyTE/L34NEeIT256ezyOZc0oHp0rZV2T7oBa4bFiMfy4mtTrmu3QBjCUud5GguziGz/GBwJIDV0114UUX5UFsD3OiM/DkQ8NKEjW05gPPzbbVqKBHLcIUJdf9WIlo+xuSY1Lk5t/0nu1PFWhG3D3qpsIn+8XTTzPdL8XsOiVxztoofi1Ahxko+gqnFOyhn3ZnJXA2qRHG2n3ZrHlp6Q7Mtugh4JtUckm9zdPqHur4gaW4z1HOWnUOQdi8OIlIMSXjk9t24kcg58qtQW/NIdAcX7tkIoQ/7bwHD814xelwesod+GDjy9ndW1z2uM5EF6b6Kyj29cUMji31VugQDQWiK2atiLuIlcne40yx/qjLtlxZcvERWrbB3NPStxh8sDYsCeGwJBJN5+kQPNSj0EiEQGJoVuV1q+9oRplUOrb8V8H1nC7yd+LQNRb9FY5QXqJwSBzO45zuTnm3iOp8IfZXr+8wq4B2zAFsYuHdfh/Lkiewo9BVVsdd6+P+puPi0nuToKB1tB2bP3pqv6JaXoTSasdq0wPlZhKn/1wdahhrCcwgDvx//kI3SjaDYwh9tMv9UE2y3Lt/y2e3Td/c9MA57XD3fNSxSDVhaM7W0gg29maPek5M2sh/YMK/jaT6rUcDXgj+x/vGfPrqW2Ye81DERMLDkk0CLt94uExnKdWRLQXt+pa7UhBEje/6EKz2tv/0Fj59EODe4eZqrVZFK4uhfNlEyvTCUMTAZDlE2VojXKBOFFHFRo7Ma9VJWEFv62rHs1T7qACpE0zENk7VtEMeypt7EMoZ+teh8wSz5Jf3AH3nbQfMONeY5FMZkkVfEGvp6AHy1RuXEkZ1NJjgfSZEvXEfKe5HEWCJlRB923kgZJZ+++PoCh2lMZmdaF18KyN3QBzGW62G0cct5yjHrsnibmkBStrfrCmOJdO88719soYuvjeKQtPiJB9JFVSEs+bxwhkud9a8f14DBhCXe5wIvp4/t0aggkNfr+tIIi4SCqEmm2c4MmE9NjskStDVwC1mDqCYuWKFgUcozStGa1Gj+tkwF2dKQBp9MZh01lOrixG4FTFZyWyd4Z28fx+1DcGEwzd27imGfl1I7tpGfkCPGjCUpvaY+SbgorWJlgjSmtD8zg58dpI1+zdFGpvKgS+GIYu61jHpNNipx6lQgvyBcdtCRgQ5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PUZPR06MB5676.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 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Bqh02R3rYwCHHTJ1WsB11a2OLgISTkIaD6F2B/Kgxkv+sa7lzZ1sgmQ2FPRrypWt1eZCae4nlQHrCSz7pIkOgVqVS0f0kn20TNKSilQ6dyaFvnsvLzN8OEfD3VpEzzQyzjnGHOTstThoa8fEIBEqCCWNWR7T4Bg3paP7dyYQ7OmCp+AR8ITK/1W0VmP2Bw0i7bRCY306+RNXypiVba7u/QKq/e/vPP7QSLYCGqFC55ZaRXw7e/uR24o/uj/je4Nb1IYXqLzJ9KbOgnNXJ2yUVwo6PPAT1rFCRtA4hWikrnNgxdzrSJt51W04rWQPTSwVG0cxbAf7P+cze/9RWxT9vrrM0EyCP89MYdZxESamqeDNgi2oV/S0owXc5uPoKHeA5UVSDzei6VkGLN1+q1hYWs0VQEiUyNMmFs0nw9Lx7AGkulVYlMwSxDoG5QEIDgyb4waxCPK0om8RaEFzh8tIWNLM661rViStXpcvPpSkI0bR2Ok5NIJwdiMAJOI42j2EWj/KP1kPZaRVBBcZZPjLOY/Vx0cx5+dXWwoht8uG X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4d04e65-bf49-458a-eaa8-08dcc24eaa1f X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 02:03:49.8884 (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: tHV4RwZTq4l0701B3AB6rVaQrd1ZR1Fn2sVwx2dhLaE2Ujy5gXkTyVpaN/vFy8FEPFxPK1un8HQC86YFCeaQtA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB5654 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 --- v2 -> v3: remove unneccessary suggested tag. 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;