From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74B67C38145 for ; Tue, 6 Sep 2022 07:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238241AbiIFHOE (ORCPT ); Tue, 6 Sep 2022 03:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbiIFHOD (ORCPT ); Tue, 6 Sep 2022 03:14:03 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69DF25EDD9; Tue, 6 Sep 2022 00:14:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 45FC2424EB; Tue, 6 Sep 2022 07:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1662448440; bh=0nUWl89mjqQ5K31+h2G4hNBO/2+SnGSjnZ+TdSHB9e8=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=ZoXYswq0HIX0U7DUE3HhgoIat+FrZQJmJZN5Qkuv9B9QlHGflmeOrVJVtI2rh/Pug eB/LcOM6VlZeg89arq1wH9Jb3/7G7D3g7lPaM83BhcnSCeZKVrUHQkK0O2mWWi2NE4 O6hwwHI4IkN3qlS9piY5O+JryIer8/GnZSzsFQdJxeC2zUZP3Mnvlks6wwTjkT40in bFABA/rPAF8Vmhuj2Q/jTtKvAlfcgzmEfbybd86A0bnAzt0r5qFiwRTOfoXwW43fPq hZKq6nU2NRsLcGChvypsO0P6PEkbaijBAbzVSf+3qs1SgLdgkLDb6SM7HhhpmbARiB 9V7gRx8x5B+hA== Message-ID: Date: Tue, 6 Sep 2022 16:13:56 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] PCI: apple: do not leak reset GPIO on unbind/unload/error Content-Language: es-ES To: Dmitry Torokhov , Alyssa Rosenzweig , Marc Zyngier Cc: Lorenzo Pieralisi , Rob Herring , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas , Sven Peter , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Hector Martin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On 06/09/2022 11.15, Dmitry Torokhov wrote: > The driver allocates reset GPIO in apple_pcie_setup_port() but neither > releases the resource, nor uses devm API to have it released > automatically. > > Let's fix this by switching to devm API. While at it let's use generic > devm_fwnode_gpiod_get() instead of OF-specific gpiod_get_from_of_node() > - this will allow us top stop exporting the latter down the road. > > Fixes: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up") > Signed-off-by: Dmitry Torokhov > --- > > This patch has been pulled out of the series > https://lore.kernel.org/all/20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com/ > with updated justification (leak fix vs pure API deprecation). > > drivers/pci/controller/pcie-apple.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c > index a2c3c207a04b..66f37e403a09 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -516,8 +516,8 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie, > u32 stat, idx; > int ret, i; > > - reset = gpiod_get_from_of_node(np, "reset-gpios", 0, > - GPIOD_OUT_LOW, "PERST#"); > + reset = devm_fwnode_gpiod_get(pcie->dev, of_fwnode_handle(np), "reset", > + GPIOD_OUT_LOW, "PERST#"); > if (IS_ERR(reset)) > return PTR_ERR(reset); > Reviewed-by: Hector Martin I actually caught this one a while back, just didn't get around to submitting it yet since it's part of my WIP PCIe power management branch (that I'm getting back to next week or so!) :) https://github.com/AsahiLinux/linux/commit/04f5628fc73ea0369f66c83ba473cb6f8187d2b3 - Hector