From patchwork Sat Jul 8 06:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 117395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3746301vqx; Fri, 7 Jul 2023 23:54:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCruHxmPv24dKh5PyE8NYpAzARQSbRTrh1eP/mMip/aEYqS/sSctaqUhF7YOsIiXC3yois X-Received: by 2002:a05:6808:1493:b0:3a3:f45b:aa3d with SMTP id e19-20020a056808149300b003a3f45baa3dmr3007483oiw.39.1688799253828; Fri, 07 Jul 2023 23:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688799253; cv=none; d=google.com; s=arc-20160816; b=G7IzTaqIHmxcnx+S/Kyg0rtv72d/sQS4+tJ0FYRyvSOP2hh9HcMYU2qKTrn0Nn5T82 kznelLRuA/SRJlRUFMhT1lZG3OcEGElPBc78IuLLlTGewnNChuyne7yM30e5mnbF5EZf BqCiJ0xWKmEsHwYjd75I+L8arx/WBYrUvvfvvxgwVGblZZtRJklZ1865CExyKkBsyAcJ ZeBTq1ZAkoBY3cK1Bk2S5LsU5rQbBOZUXSMCllcOV0VlVNiHCzZIRSexl6Wn94e/Rhv6 +VfH3oEIvbTO/HbthtahdxpQRZcPqk/7493J1HL+2GF557bOYAHIUQU2ZoMm9wTTnWBf 5G/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3Y7Axqsz6Qm1534LmlCmTjhnVQQHJy6kg1MSVPN3Gt0=; fh=+fl0RbWbWNYTBcjJ1z65pCMyBnCxTZIu5a2bYsk3Z50=; b=cj0firpixDQEfGBseud2ltkMZxTbFbv4kOJT7LPOkL/BjRxBvK4Y2TQAjsiCqkvImN tK+3x05TyvF+kB0L94qjXn7UxLpQP8h4Z1i8bz+zBjBItLflvnuffDAUeNugsl0f3dwk XrjSTrd3jIy7rFoW402FVYMevjwGX9Ti5d2fapCWVcTVvIuekLuKlRjIDI+kEyLXf+UJ RMbauHEwjWXJ5wGxUJSbFQvzRClJ63DTvKdB64dSqMJ3wso1k/89h/Zh7Fq6ii3lZzi7 DBve8LOUN/76IIWu+q6HuqW2iodL6qWU4c/J48WWvFTGuRNhehnnSXTFwtxYN7sM6QDf O8rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=SmvEgK+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w191-20020a6382c8000000b00542aa78ebdasi5196421pgd.838.2023.07.07.23.54.01; Fri, 07 Jul 2023 23:54:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=SmvEgK+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbjGHGF6 (ORCPT + 99 others); Sat, 8 Jul 2023 02:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbjGHGF4 (ORCPT ); Sat, 8 Jul 2023 02:05:56 -0400 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC111183 for ; Fri, 7 Jul 2023 23:05:55 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id I14oqFw01JGUmI14oqAyUU; Sat, 08 Jul 2023 08:05:53 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1688796353; bh=3Y7Axqsz6Qm1534LmlCmTjhnVQQHJy6kg1MSVPN3Gt0=; h=From:To:Cc:Subject:Date; b=SmvEgK+EfvyIN44j7N+plKiYs52wGa/xK2upe/vDIpQXl1KiHLHSCLtCmKzNzznOV JjwZezf4U/QdH2PBUWeHoN5fagBWQoH9Htx1FlHUPLlAOaq3KFaSks9XUEhKk8ltXm Aq588PLl587hszhfw5iWkBuHXii106k2busbmNT5lMcOGl0cxuqm6L545ABCqOtouo RQMjn1WC6Bsa9iJccZ3H71tWI2Fh3MwY8E6X/dqsUEGqrHJyLjY2IJuyL+b1rJu718 d8dr0Qb51usE5Ueo9jDRXUMjbCqVJOln6Js8LOzirpFEreqf3m0S3LAHo/QoC9Lw1V 9iMInGwQtD9PQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 08 Jul 2023 08:05:53 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dri-devel@lists.freedesktop.org Subject: [PATCH v3] drm/bridge: tc358767: Use devm_clk_get_enabled() helper Date: Sat, 8 Jul 2023 08:05:35 +0200 Message-Id: <208a15ce4e01973daf039ad7bc0f9241f650b3af.1672415956.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770834366182526727?= X-GMAIL-MSGID: =?utf-8?q?1770834366182526727?= The devm_clk_get_enabled() helper: - calls devm_clk_get() - calls clk_prepare_enable() and registers what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the need of a dedicated function used with devm_add_action_or_reset(). Signed-off-by: Christophe JAILLET Reviewed-by: Andrzej Hajda --- Change in v3: - Rebase with latest -next Change in v2: - Convert to dev_err_probe() [Andrzej Hajda] - Update the error message [Andrzej Hajda] - Add R-b tag [Andrzej Hajda] https://lore.kernel.org/all/208546ce4e01973da1eb9ad7bc0f9241f650b3af.1672415956.git.christophe.jaillet@wanadoo.fr/ v1: https://lore.kernel.org/all/4f855984ea895e1488169e77935fa6e044912ac2.1672414073.git.christophe.jaillet@wanadoo.fr/ --- drivers/gpu/drm/bridge/tc358767.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 2a58eb271f70..99f3d5ca7257 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -2215,13 +2215,6 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc) return -EINVAL; } -static void tc_clk_disable(void *data) -{ - struct clk *refclk = data; - - clk_disable_unprepare(refclk); -} - static int tc_probe(struct i2c_client *client) { struct device *dev = &client->dev; @@ -2238,20 +2231,10 @@ static int tc_probe(struct i2c_client *client, const struct i2c_device_id *id) if (ret) return ret; - tc->refclk = devm_clk_get(dev, "ref"); - if (IS_ERR(tc->refclk)) { - ret = PTR_ERR(tc->refclk); - dev_err(dev, "Failed to get refclk: %d\n", ret); - return ret; - } - - ret = clk_prepare_enable(tc->refclk); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, tc_clk_disable, tc->refclk); - if (ret) - return ret; + tc->refclk = devm_clk_get_enabled(dev, "ref"); + if (IS_ERR(tc->refclk)) + return dev_err_probe(dev, PTR_ERR(tc->refclk), + "Failed to get and enable the ref clk\n"); /* tRSTW = 100 cycles , at 13 MHz that is ~7.69 us */ usleep_range(10, 15);