Skip to content

Commit a42c9b8

Browse files
outman119broonie
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ef3d549 commit a42c9b8

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

drivers/spi/spi-sn-f-ospi.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -642,29 +642,15 @@ static int f_ospi_probe(struct platform_device *pdev)
642642
if (IS_ERR(ospi->clk))
643643
return PTR_ERR(ospi->clk);
644644

645-
mutex_init(&ospi->mlock);
646-
647-
ret = f_ospi_init(ospi);
645+
ret = devm_mutex_init(dev, &ospi->mlock);
648646
if (ret)
649-
goto err_destroy_mutex;
647+
return ret;
650648

651-
ret = devm_spi_register_controller(dev, ctlr);
649+
ret = f_ospi_init(ospi);
652650
if (ret)
653-
goto err_destroy_mutex;
654-
655-
return 0;
656-
657-
err_destroy_mutex:
658-
mutex_destroy(&ospi->mlock);
659-
660-
return ret;
661-
}
662-
663-
static void f_ospi_remove(struct platform_device *pdev)
664-
{
665-
struct f_ospi *ospi = platform_get_drvdata(pdev);
651+
return ret;
666652

667-
mutex_destroy(&ospi->mlock);
653+
return devm_spi_register_controller(dev, ctlr);
668654
}
669655

670656
static const struct of_device_id f_ospi_dt_ids[] = {
@@ -679,7 +665,6 @@ static struct platform_driver f_ospi_driver = {
679665
.of_match_table = f_ospi_dt_ids,
680666
},
681667
.probe = f_ospi_probe,
682-
.remove = f_ospi_remove,
683668
};
684669
module_platform_driver(f_ospi_driver);
685670

0 commit comments

Comments
 (0)