Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1944633rwd; Tue, 13 Jun 2023 17:16:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GyA12sRVYGC8RcqbKLdDPfi4fD9Dy31phFcyBuooMGall7s000cB4fJoFN3L8B8CtsUIm X-Received: by 2002:a17:907:86a3:b0:974:5403:ebb with SMTP id qa35-20020a17090786a300b0097454030ebbmr13053545ejc.54.1686701808798; Tue, 13 Jun 2023 17:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686701808; cv=none; d=google.com; s=arc-20160816; b=hGF66AV5TgydAMCWm0Yd1/BDhhYdvtntmBHYbxVwqWUgxd5wfA0+J/oiRRuwxsRj4o ms2uzjF41fQmIGHKCUGAu8Xm42NvvmBIzN9+nB784Mvl6YWuhK9ZcpBlwMUiZ4i6P0V0 bXiXqRSlD5TttU6JsrPU5G2XWeml22tclQgp1RNc8t6WL6y7pWGqk/xaxrpcVJxFQiNf 9vg/sHLkpdPRz6ytWmhE1KOXbvXh2ELzQpMpfN9/OvTjAbGWQn1HKFis+tciqPuwCL2u G1Z/k7VKAQgT81e8dDYwVCoK9WGR/GDwoLHZTekJhNu42M6YLCC9w/Loo3jUTD3Jkf4B j5Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=87KszZcGDdgxJOrVY2dyKR8Dd6EgT33epZpObVqylo8=; b=sO44Mt4ocVJwwkgV9xbbqxQzHkoktP5mFIOfrfX+hXmG27r4oaW8Cs4Pstdx5zPABA yZZkuyOjDEcIE8tzjErZT2Mh7Rqx1K2lvdxDt6tytOVnVB4bg7Pgiwv7myZqX4QTTgPK WQlxwi8e4wBEy8XsebBrwtQA+O4iI3xPCK87s9/rrqMOSfarjJMn8NY1E86orvVndjr2 Q/U9B9eZLvBQEhBdMPRzea+vISzbTsLRyIiT7r9qW3D+ghHEYipzlFighPiUOA9H+57x RBo43MdpSB7M586BTJs+PK9QJCtDeuKfJiqfmqh0sq2i8bNI08akbNN7CnnlKuvA3ubc V8vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FGxRYHdN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l17-20020a1709066b9100b0098237f8a78dsi1741801ejr.942.2023.06.13.17.16.22; Tue, 13 Jun 2023 17:16:48 -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=@kernel.org header.s=k20201202 header.b=FGxRYHdN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbjFMXzO (ORCPT + 99 others); Tue, 13 Jun 2023 19:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241494AbjFMXy7 (ORCPT ); Tue, 13 Jun 2023 19:54:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1229A7; Tue, 13 Jun 2023 16:54:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 65C0D63B11; Tue, 13 Jun 2023 23:54:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96005C433C8; Tue, 13 Jun 2023 23:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686700497; bh=A2KnQtXsxVJpgrtKvXpTSH8wQ4W6n9q6OJkUWV7Pgdg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FGxRYHdNSZOL8/eFuftct2nIlt1h5MiG6mu/9geKiEAgROtVlyppg+WF2rKGjlfp6 4kJmR4FEE70TabwBFG2t8D39v5B1hRMlWb/MZsfBymjODHxvpZfEPwVDPZ0z7QTab8 Uew17FZbZt4UJsd0Oc4WmXsfGjoKidyMdvn4NUhaH9EZMqjqxbaTbtX5MiCQ0tPZJE eluad5miyEMjSMEmW0s+s+aVKz1uxoeAkceQvlMmTuLymwHCAz/w3401jmCmyLKH0B Ii6vVhThYNhP7Vi/GwgQdvwtV+jBNh+MYGpcVymIeRMXM4i5rdmuetQ7dYlxj/rk8s tOx4j0jT4Q4Ew== Date: Wed, 14 Jun 2023 01:54:53 +0200 From: Andi Shyti To: Wang Zhang Cc: Peter Korsgaard , Andrew Lunn , Wolfram Sang , Andreas Larsson , hust-os-kernel-patches@googlegroups.com, Peter Korsgaard , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] i2c: ocores: use devm_ managed clks Message-ID: <20230613235453.msezptxa5pwpizoi@intel.intel> References: <20230526070534.76112-1-silver_code@hust.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230526070534.76112-1-silver_code@hust.edu.cn> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Wang, > - i2c->clk = devm_clk_get(&pdev->dev, NULL); > - > - if (!IS_ERR(i2c->clk)) { > - int ret = clk_prepare_enable(i2c->clk); > - > - if (ret) { > - dev_err(&pdev->dev, > - "clk_prepare_enable failed: %d\n", ret); > - return ret; > - } > - i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000; > - if (clock_frequency_present) > - i2c->bus_clock_khz = clock_frequency / 1000; > - } > - > + i2c->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); > + if (IS_ERR(i2c->clk)) > + return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk), > + "devm_clk_get_optional_enabled failed\n"); > + > + i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000; if devm_clk_get_optional_enabled() returns NULL, clk_get_rate() returns '0' and op_clk_khz would be '0'... > + if (clock_frequency_present) > + i2c->bus_clock_khz = clock_frequency / 1000; > if (i2c->ip_clock_khz == 0) { ... and we fall inside this 'if', as expected. Looks correct! Reviewed-by: Andi Shyti Thanks, Andi