From patchwork Fri Dec 30 16:00:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 37703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2957721wrt; Fri, 30 Dec 2022 08:04:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXuq8MiaLOrcRCrazqbsiwQ/NoAFPoKeA32g8yHJOsjDnhcJVMhZ/TBHbdZMC/QHPzEUMwCf X-Received: by 2002:a05:6a00:338b:b0:581:ce00:f69e with SMTP id cm11-20020a056a00338b00b00581ce00f69emr6541966pfb.10.1672416271835; Fri, 30 Dec 2022 08:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672416271; cv=none; d=google.com; s=arc-20160816; b=LsAJTYTLKFJosl6hANN37tlslwGEtfPT3bG1PlQ3Sjelha8Friedye6ZDQK1yc2X0i rkuF15pFWUmuwy6hw3Xp5HmKQgpFS7ufM+jJ+S4eAmeFyY0+xZvVZJ05BGVceoghE1Qj OfEs6ERvfB89BNqjvStnISWyUTCLwhsFRu7UHVpKHqVpfl8qwJS7AOZYgmjRDQHZZpZA 8Eqecha5JLnvqBwGWKUQeuHua1qj4o9UQvLPqrzIgZjsouh7BxUKsckl/oxIxvovBOgx hL6xF4u4EEmrs9JvfHC4Ohmlj5B/Wow/Z9vgChqbhrc1otWmujlUGfHPj8v27LiScAUJ dhKg== 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; bh=lYrxnM8kTDmYozN1r6za+9E47sfJBL9V3W+BpwENImM=; b=PsqZsk//CBK7wkyu+8r+s8/wzr4/S2x6e9JYiK79vwd92983lQvje7GqpwoCxnQ2UE 9s965bpo5cH+LXDIs4v/r+h5qmEQWSNHphOAH94Jx+v5nX9nWA7dW7d5o6dxSCjX4iqy NYDyfjjjCV3DnLDTtc+zE49H9+PjzUqXJYKGXX/ipp7bcvV9RH1Z9WPjOZ/DhxE00yTU uVGLheaJeCW10I0cLI0pcjtog89tFWhXEsK30sKEY7o95vzMBJamtj8NEz37lbU6nGzO VGsjjEHHg2orr1ZbQL6xXekgC0Li/ljDD98fpIZJ0bF3FB+KrirK0/apnBBtwO/RfmXR Lifg== ARC-Authentication-Results: i=1; mx.google.com; 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 p12-20020a056a000a0c00b00576c9c3c4aasi24053038pfh.5.2022.12.30.08.04.20; Fri, 30 Dec 2022 08:04:31 -0800 (PST) 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; 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 S235350AbiL3QAe (ORCPT + 99 others); Fri, 30 Dec 2022 11:00:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235349AbiL3QAQ (ORCPT ); Fri, 30 Dec 2022 11:00:16 -0500 Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D5D95A4 for ; Fri, 30 Dec 2022 08:00:15 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id BHnmp7f8kLrOWBHnnp1MiM; Fri, 30 Dec 2022 17:00:13 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 30 Dec 2022 17:00:13 +0100 X-ME-IP: 86.243.100.34 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 v2] drm/bridge: tc358767: Use devm_clk_get_enabled() helper Date: Fri, 30 Dec 2022 17:00:09 +0100 Message-Id: <208546ce4e01973da1eb9ad7bc0f9241f650b3af.1672415956.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1753655564206731576?= X-GMAIL-MSGID: =?utf-8?q?1753655564206731576?= 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 v2: - Convert to dev_err_probe() [Andrzej Hajda] - Update the error message [Andrzej Hajda] - Add R-b tag [Andrzej Hajda] 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 @@ -2022,13 +2022,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, const struct i2c_device_id *id) { struct device *dev = &client->dev; @@ -2045,20 +2038,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);