From patchwork Tue Apr 30 08:37:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 13648488 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27E14C10F16 for ; Tue, 30 Apr 2024 08:39:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ffzo0dGC9nNKLFKethlEwRbmEwvX5AE1aANroAGsfxY=; b=D2HHRMse/Rfyfm EV5xEfkdaQC3P6dM3risED/oBWXYbtmkc2tuaJERefeCif3eU1tf0oisJpZZ2wQiz3WGChOPXTUXm nJmX9L9HVF4BeT+0yTQ3nqvrQSi/mWSf1YZRieYZdR3my6BhCbmXpkPGoSNkLH2mWPb1TQC15hoiV OP72HPe90iKKyCiVkvzVP5RkHGF5x9+TmJmSVPSEJycFGQxbxnamSAsBZFDYzu9a7cfiG2Ao7j0Ue IFnQe5TLY5ZxB5GXuv5e7ZrEO6K4b+nQ7iLNAYqDvI2nCgvwWeODG9bZm71/aGyiMe7/9s67E/u7e 7Wte1Urp/zl4TUSU98UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1j1S-00000005dXT-3J8V; Tue, 30 Apr 2024 08:39:34 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1j1A-00000005dJz-26PX for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 08:39:18 +0000 Received: by mail.gandi.net (Postfix) with ESMTPA id 8BF0520009; Tue, 30 Apr 2024 08:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714466355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQCmnd7DbFj5IxQKgje4KI56L2MhsXyiKeIjOIac594=; b=G0pcULHd1GS1Kd5ctB8CoCy+juU+WQe4NOXWHKIOPlA2HcBeyndoLZIcNdhk8IoE+wmxrZ K5JEQNoVQ79/u4K3yo5AC4dhHiAFBXGI8XE7CuuDRbreLi0cRvvzKw139Wlop5I9ZHQoai IjzEl8+uLGxlICtjb7W/hE805uKRG06Yk1eAM5KlzyC2YPCQG+l9jlzJZSluNa1cnct8V9 dGC0g+TmB1NyK10tEF2z7rocBsP1li2NHUmygMEw2gFs4C6YDiQQowZjOnJ6pkHSHZJ6FU 9JIzdYkyNFMMzz/uVxv9lHEYiFqLbfaBYUCr3MkuW7OTUHmPOH4Uz8q8QrIbKg== From: Herve Codina To: Herve Codina , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones , Arnd Bergmann , Horatiu Vultur , UNGLinuxDriver@microchip.com, Andrew Lunn , Heiner Kallweit , Russell King , Saravana Kannan , Bjorn Helgaas , Philipp Zabel , Lars Povlsen , Steen Hegelund , Daniel Machon , Alexandre Belloni Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Allan Nielsen , Steen Hegelund , Luca Ceresoli , Thomas Petazzoni , =?utf-8?b?Q2zDqW1lbnQgTMOp?= =?utf-8?b?Z2Vy?= Subject: [PATCH 04/17] reset: core: add get_device()/put_device on rcdev Date: Tue, 30 Apr 2024 10:37:13 +0200 Message-ID: <20240430083730.134918-5-herve.codina@bootlin.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430083730.134918-1-herve.codina@bootlin.com> References: <20240430083730.134918-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_013916_817340_5947848B X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Clément Léger Since the rcdev structure is allocated by the reset controller drivers themselves, they need to exists as long as there is a consumer. A call to module_get() is already existing but that does not work when using device-tree overlays. In order to guarantee that the underlying reset controller device does not vanish while using it, add a get_device() call when retrieving a reset control from a reset controller device and a put_device() when releasing that control. Signed-off-by: Clément Léger Signed-off-by: Herve Codina --- drivers/reset/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index dba74e857be6..999c3c41cf21 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -812,6 +812,7 @@ __reset_control_get_internal(struct reset_controller_dev *rcdev, kref_init(&rstc->refcnt); rstc->acquired = acquired; rstc->shared = shared; + get_device(rcdev->dev); return rstc; } @@ -826,6 +827,7 @@ static void __reset_control_release(struct kref *kref) module_put(rstc->rcdev->owner); list_del(&rstc->list); + put_device(rstc->rcdev->dev); kfree(rstc); }