]> www.infradead.org Git - users/willy/xarray.git/commitdiff
reset: core: add get_device()/put_device on rcdev
authorClément Léger <clement.leger@bootlin.com>
Thu, 8 Aug 2024 15:46:56 +0000 (17:46 +0200)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 2 Sep 2024 10:02:41 +0000 (12:02 +0200)
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 <clement.leger@bootlin.com>
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240808154658.247873-8-herve.codina@bootlin.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/reset/core.c

index c9074810306cd513409893b797612bc6e63eeada..4d509d41456ad83ae97fee280bf74d97c3539a7d 100644 (file)
@@ -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);
 }