Date: Thu, 20 Jan 2022 10:35:10 GMT From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 139afdb1721f - stable/13 - simple_mfd: switch to controllable locking for syscon provider. Message-ID: <202201201035.20KAZAft031706@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mmel: URL: https://cgit.FreeBSD.org/src/commit/?id=139afdb1721fbb31d39e7cb8992dcc5369a17d5f commit 139afdb1721fbb31d39e7cb8992dcc5369a17d5f Author: Michal Meloun <mmel@FreeBSD.org> AuthorDate: 2021-03-04 14:09:32 +0000 Commit: Michal Meloun <mmel@FreeBSD.org> CommitDate: 2022-01-20 10:34:28 +0000 simple_mfd: switch to controllable locking for syscon provider. MFC after 3 weeks (cherry picked from commit f97f57b51855cecb9b497a90dfed06dac2c21111) --- sys/dev/fdt/simple_mfd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/sys/dev/fdt/simple_mfd.c b/sys/dev/fdt/simple_mfd.c index 752740cf705e..aedada3079e8 100644 --- a/sys/dev/fdt/simple_mfd.c +++ b/sys/dev/fdt/simple_mfd.c @@ -73,9 +73,9 @@ static int simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, #define SYSCON_ASSERT_UNLOCKED(_sc) mtx_assert(&(_sc)->mtx, MA_NOTOWNED); static syscon_method_t simple_mfd_syscon_methods[] = { - SYSCONMETHOD(syscon_read_4, simple_mfd_syscon_read_4), - SYSCONMETHOD(syscon_write_4, simple_mfd_syscon_write_4), - SYSCONMETHOD(syscon_modify_4, simple_mfd_syscon_modify_4), + SYSCONMETHOD(syscon_unlocked_read_4, simple_mfd_syscon_read_4), + SYSCONMETHOD(syscon_unlocked_write_4, simple_mfd_syscon_write_4), + SYSCONMETHOD(syscon_unlocked_modify_4, simple_mfd_syscon_modify_4), SYSCONMETHOD_END }; @@ -89,10 +89,8 @@ simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset) uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc);; val = bus_read_4(sc->mem_res, offset); - SYSCON_UNLOCK(sc); return (val); } @@ -103,10 +101,8 @@ simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset, struct simple_mfd_softc *sc; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc); bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } @@ -118,15 +114,14 @@ simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset, uint32_t val; sc = device_get_softc(syscon->pdev); - - SYSCON_LOCK(sc); + SYSCON_ASSERT_LOCKED(sc); val = bus_read_4(sc->mem_res, offset); val &= ~clear_bits; val |= set_bits; bus_write_4(sc->mem_res, offset, val); - SYSCON_UNLOCK(sc); return (0); } + static int simple_mfd_syscon_get_handle(device_t dev, struct syscon **syscon) { @@ -139,6 +134,24 @@ simple_mfd_syscon_get_handle(device_t dev, struct syscon **syscon) return (0); } +static void +simple_mfd_syscon_lock(device_t dev) +{ + struct simple_mfd_softc *sc; + + sc = device_get_softc(dev); + SYSCON_LOCK(sc); +} + +static void +simple_mfd_syscon_unlock(device_t dev) +{ + struct simple_mfd_softc *sc; + + sc = device_get_softc(dev); + SYSCON_UNLOCK(sc); +} + static int simple_mfd_probe(device_t dev) { @@ -293,6 +306,9 @@ simple_mfd_add_device(device_t dev, phandle_t node, u_int order, static device_method_t simple_mfd_methods[] = { /* syscon interface */ DEVMETHOD(syscon_get_handle, simple_mfd_syscon_get_handle), + DEVMETHOD(syscon_device_lock, simple_mfd_syscon_lock), + DEVMETHOD(syscon_device_unlock, simple_mfd_syscon_unlock), + /* Device interface */ DEVMETHOD(device_probe, simple_mfd_probe), DEVMETHOD(device_attach, simple_mfd_attach),
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201201035.20KAZAft031706>