Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1355607rwr; Wed, 26 Apr 2023 13:50:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VuKy4i4yqH8y/vPQEDWoAY19Qup2w2ga/RgayL2m7+KUqOyFx37cCX4DQ+2V3NNHfPb38 X-Received: by 2002:a17:90a:7d06:b0:24b:c0a5:3591 with SMTP id g6-20020a17090a7d0600b0024bc0a53591mr10698196pjl.27.1682542230762; Wed, 26 Apr 2023 13:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682542230; cv=none; d=google.com; s=arc-20160816; b=u2oQQyW7K0HXo6ikkyWj4aGocWq6buPkejEtPF72VkxXOIiKqHPuxHAekAIWUymdbU kKojS0xnn9qDWuHM8vzhu7ZBwuXjYZISrO1jJvYOcIi6/jK/gO9X85vpFI3Z8AJjR3kE ZKJ8BFmAyT5lHUkdFGM1fgohRnFYg5jEdZ+xNDGCK+qAYnHOmyHXdLk/RBmDJDDJ4gB2 djUvPNcHIxM2vYGDe4UgeZmUGj5NSk4iDtm5A6K0/YnlvrEzncddr2JieLxW/EVut8cW JvYrWS5ZE0w5UfgkdyVt0yq0yZinJP2wAZcEJgJQN+GOudjyevT4wVQv0c3IZyWCYd+R JtNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xxo+GagR2E5RsONBsNVbiP1yowr7LdpGNwMG4261j9A=; b=mGHwS1CBpJk9Bwr1y3VrYwaNjEUVr3QMjrgX/UJZr/3oPyx07CsM5vqb2ZEyWAQQMX 5GiIbGsoO5BItH+teFwoHrapzHaWkSi7FhoVbHHdSuvC+MdIAmRNnHCar9FIbjdC3wHM w7FNu9lRpq+JfDOqlUlAV3OVZQTNLJYHZsKw1XAzdrDX09johZVSf2/Qbxhnc9S7NT/i 7FX4wlTZzTfjV0Isbej0nEL21+zJ1FRKRTRWQNvuHRtHRj8fKufpSVxCoOAQ9j9jSkjQ ERReXfaKqDR5q7Wb9tQS0RCXklOiQYOLrSqgYXIEARU8jjBlljXX3dyiMp7QuUaG7KOA /7JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=faYBWlmY; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu10-20020a17090b388a00b002470f78a168si21596051pjb.104.2023.04.26.13.49.51; Wed, 26 Apr 2023 13:50:30 -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=@linaro.org header.s=google header.b=faYBWlmY; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235264AbjDZUom (ORCPT + 99 others); Wed, 26 Apr 2023 16:44:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbjDZUol (ORCPT ); Wed, 26 Apr 2023 16:44:41 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDE410DE for ; Wed, 26 Apr 2023 13:44:40 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-54fb4c97d55so59481937b3.0 for ; Wed, 26 Apr 2023 13:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682541879; x=1685133879; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xxo+GagR2E5RsONBsNVbiP1yowr7LdpGNwMG4261j9A=; b=faYBWlmYPyVvv7dCSVdlURDjZBV+jp5BEAL4MPplDhYFuE+X+/yt2ANHT/yKYSmHyY 1bI3KzdDYZ/S+tlVPGuDbzvjDeHxPl8NmJmeGk5oBqZB5OpAU7FxnWmSFvy/24BS/pxF kzev6AMTpWTf/VpiABPkTvJxutYbuCVtPi7xZ+uZkPYRAe7vw3+UxDePsFNdlFm2Hg/3 d4iRmoquc+59g7WqDlvtM8BNVIE7PWw5SBSz4QTorNiTx9ane0rsAi9nN20cJArQRlKh TyqOsCt2/dKAOSK2EPxJlCwA5xZQMIBeIbxyZJ7FjTdPAXmVkFb/fq2On3WYVKPY1qzf zlNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682541879; x=1685133879; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xxo+GagR2E5RsONBsNVbiP1yowr7LdpGNwMG4261j9A=; b=kYcKepM8B3HTmAb0zha1rpXzwYeMDhXQB3GCDyN+lHnmCrB0nuB9HR4FroVHhPmf+m jysGI0SLbVQW3d+C5w75N2ndKc5oUYDU+VMHOTpPj+/v8JMAgTpCT0JEwgzurC4kGGFd Xt4fqlks7h7AwWHBvY+5EWxrArVFMHMPgPnaY85Bf/e7nzz/ea7ZoI+btwcX6liy2X1J KnsDICuUPzy63Ho+0rFn/OaTqxTB9FM32/VJYz+04Yi5vji+0xs13ka27gnqgjU+rzg9 KpS6Z1VbMOXWTmJhjjOZq3cRHM6Lexv+q4BX7J0HKJsULue8jzDwLTkuXS4rNTkAJChE haRw== X-Gm-Message-State: AAQBX9dLIqfxpZGyRd9S5ZVGGPtAFxfPhMhN2Cp76owrYvzUH3vWc4zu O+hJfiqqh0DxTi0Us7qWZLe0pcXSNosufxCowmWXow== X-Received: by 2002:a0d:d908:0:b0:54e:dcf2:705b with SMTP id b8-20020a0dd908000000b0054edcf2705bmr13240850ywe.47.1682541879483; Wed, 26 Apr 2023 13:44:39 -0700 (PDT) MIME-Version: 1.0 References: <20230423053208.2348-1-yejunyan@hust.edu.cn> In-Reply-To: <20230423053208.2348-1-yejunyan@hust.edu.cn> From: Linus Walleij Date: Wed, 26 Apr 2023 22:44:28 +0200 Message-ID: Subject: Re: [PATCH v2] pci: controller: pci-ftpci100: Release the clock resources To: Junyan Ye Cc: christophe.jaillet@wanadoo.fr, Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Wei Yongjun , Andrew Murray , hust-os-kernel-patches@googlegroups.com, Dongliang Mu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Sun, Apr 23, 2023 at 7:34=E2=80=AFAM Junyan Ye wr= ote: > Smatch reported: > 1. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() > warn: 'clk' from clk_prepare_enable() not released on lines: > 442,451,462,478,512,517. > 2. drivers/pci/controller/pci-ftpci100.c:526 faraday_pci_probe() > warn: 'p->bus_clk' from clk_prepare_enable() not released on lines: > 451,462,478,512,517. > > The clock resource is obtained by the devm_clk_get function. The > clk_prepare_enable function then makes the clock resource ready for use, > notifying the system that the clock resource should be run. After that, > the clock resource should be released when it is no longer needed. The > corresponding function is clk_disable_unprepare. However, while doing > some error handling in the faraday_pci_probe function, the > clk_disable_unprepare function is not called to release the clk and > p->bus_clk resources. > > Fix this warning by changing the devm_clk_get function to > devm_clk_get_enabled, which is equivalent to > devm_clk_get() + clk_prepare_enable(). And with the > devm_clk_get_enabled function, the clock will automatically be > disabled, unprepared and freed when the device is unbound from the bus. > > Fixes: b3c433efb8a3 ("PCI: faraday: Fix wrong pointer passed to PTR_ERR()= ") > Fixes: 2eeb02b28579 ("PCI: faraday: Add clock handling") > Fixes: 783a862563f7 ("PCI: faraday: Use pci_parse_request_of_pci_ranges()= ") > Fixes: d3c68e0a7e34 ("PCI: faraday: Add Faraday Technology FTPCI100 PCI H= ost Bridge driver") > Fixes: f1e8bd21e39e ("PCI: faraday: Convert IRQ masking to raw PCI config= accessors") > Signed-off-by: Junyan Ye > Reviewed-by: Dongliang Mu > --- > v1 -> v2: Switch from clk_disable_unprepare() to devm_clk_get_enabled() t= o release the clock. > This issue is found by static analyzer. Neat fix, saves codelines! Reviewed-by: Linus Walleij Yours, Linus Walleij