spi: sn-f-ospi: Use devm_mutex_init() to simplify code

Switch to devm_mutex_init() to handle mutex destruction automatically.
This simplifies the error paths in probe() and removes the need for an
explicit mutex_destroy() in remove() callback.

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Link: https://patch.msgid.link/20260319-sn-f-v1-2-33a6738d2da8@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
master
Felix Gu 2026-03-19 00:12:35 +08:00 committed by Mark Brown
parent ef3d549e1d
commit a42c9b8b0c
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 5 additions and 20 deletions

View File

@ -642,29 +642,15 @@ static int f_ospi_probe(struct platform_device *pdev)
if (IS_ERR(ospi->clk))
return PTR_ERR(ospi->clk);
mutex_init(&ospi->mlock);
ret = devm_mutex_init(dev, &ospi->mlock);
if (ret)
return ret;
ret = f_ospi_init(ospi);
if (ret)
goto err_destroy_mutex;
return ret;
ret = devm_spi_register_controller(dev, ctlr);
if (ret)
goto err_destroy_mutex;
return 0;
err_destroy_mutex:
mutex_destroy(&ospi->mlock);
return ret;
}
static void f_ospi_remove(struct platform_device *pdev)
{
struct f_ospi *ospi = platform_get_drvdata(pdev);
mutex_destroy(&ospi->mlock);
return devm_spi_register_controller(dev, ctlr);
}
static const struct of_device_id f_ospi_dt_ids[] = {
@ -679,7 +665,6 @@ static struct platform_driver f_ospi_driver = {
.of_match_table = f_ospi_dt_ids,
},
.probe = f_ospi_probe,
.remove = f_ospi_remove,
};
module_platform_driver(f_ospi_driver);