Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6856434rwr; Tue, 25 Apr 2023 05:02:58 -0700 (PDT) X-Google-Smtp-Source: AKy350ZU0iQbYvkTPlVw1GumTMvRfBYC1c8U+x2crcE7ELRaiOLESMsleXfBuI9udR5aQoo4PquA X-Received: by 2002:a05:6a00:1a86:b0:63d:315f:560f with SMTP id e6-20020a056a001a8600b0063d315f560fmr20709361pfv.13.1682424178455; Tue, 25 Apr 2023 05:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682424178; cv=none; d=google.com; s=arc-20160816; b=ZLHvqKDi0yVVRKpAnrVcdU49vsAV6w/t7xuSc7NVHDnI1wiqk122ulVMQQf3zBqhNc MyptoYfAtLTEt+HQVC0i2cwrVKB8uumiu3VZ8lID3pAkNYeluTtfVNclU+p8+DjVSJun gUKglHB0SEmzkzO9eCV84gmlMiap5HXCKwR/S6+kZwkuStpi3yMBHrPwN/Z+trWXfoPq xgwj5xxIYU/STJQM6HZ2Z/ZCOHjSQJf5CFoJb8aJ+lNpMAmvgiM2OJW3Aig3X89Q/GmA /OcoxJFvAh5sDc/lkmgrYdrUM/3MQDDEHeCQcjBp3BMtYwhniuq0DoJoEfbbug8gwyhB xh0A== 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=WhgvyZf4PUh+HmrqM1Eb5netODiCMB/+LSe2XskQNYE=; b=iqMfZEXsKW/PI+MDzJyIZrN0RrdsG0MHq/ooSGCGttlA6NJXmewRQbDoySkKEB0WhI 2VhmlFMLa6YlEg2Ylje1cKXzzgH+NQ4VtDCBazgPa6yU76e5RB9NgsOHnRQW1qhjP0Vk d+HtZSImoTv4F39TFsTIdtxtLylI1hrf7E2CepzV7eKE/R/rt2mK+uDIKbC6zqAQu18f 9otWVdSTZkOgHhUeu2wgvXfN5vaZ+ShfQ76PPBqUg/cvuMJ3Vwt5L9FOswYHCppTFuou np1CqBP7JO81Ja1gOIPzcZqjCjXushFpeVIWy6r92ASGl+5u6dXT7bylxJeq3dTlie9Y k3nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=Qh8k5Gdb; 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=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a056a00005a00b0063b1421d10fsi14096299pfk.222.2023.04.25.05.02.32; Tue, 25 Apr 2023 05:02:58 -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=@lunn.ch header.s=20171124 header.b=Qh8k5Gdb; 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=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233896AbjDYL57 (ORCPT + 99 others); Tue, 25 Apr 2023 07:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233907AbjDYL5q (ORCPT ); Tue, 25 Apr 2023 07:57:46 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C66B11F; Tue, 25 Apr 2023 04:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=WhgvyZf4PUh+HmrqM1Eb5netODiCMB/+LSe2XskQNYE=; b=Qh8k5GdbB3t+G8IacoH7Gl8vRw 8FfSvtw16hG1BTdx0IghtscGleQrUdyNG+n0MX2V1rgKe46aeAGTZXLUqni7Kfg5l+XMsTp5haOUc cn23Vk7O600FRkfGkD4ZnrCAdTtu+VaOWXrkWllhUgCTJshLKP5AU8C+hYRhWP5LpqKc=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1prHIU-00BBLe-DS; Tue, 25 Apr 2023 13:57:26 +0200 Date: Tue, 25 Apr 2023 13:57:26 +0200 From: Andrew Lunn To: Wang Zhang Cc: Peter Korsgaard , hust-os-kernel-patches@googlegroups.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] i2c: ocores: use devm_ managed clks Message-ID: References: <20230422123253.137368-1-silver_code@hust.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230422123253.137368-1-silver_code@hust.edu.cn> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Sat, Apr 22, 2023 at 08:32:53PM +0800, Wang Zhang wrote: > If any wrong occurs in ocores_i2c_of_probe, the i2c->clk needs to be > released. But the function returns directly in line 701 without freeing > the clock. Even though we can fix it by freeing the clock manually if > platform_get_irq_optional fails, it may not be following the best practice. > The original code for this driver contains if (IS_ERR()) checks > throughout, explicitly allowing the driver to continue loading even if > devm_clk_get() fails. > > While it is not entirely clear why the original author implemented this > behavior, there may have been certain circumstances or issues that were not > apparent to us. It's possible that they were trying to work around a bug by > employing an unconventional solution.Using `devm_clk_get_enabled()` rather > than devm_clk_get() can automatically track the usage of clocks and free > them when they are no longer needed or an error occurs. > > fixing it by changing `ocores_i2c_of_probe` to use > `devm_clk_get_optional_enabled()` rather than `devm_clk_get()`, changing > `goto err_clk' to direct return and removing `err_clk`. > > Signed-off-by: Wang Zhang Reviewed-by: Andrew Lunn Andrew