Module Name: src Committed By: thorpej Date: Fri Sep 10 15:43:03 UTC 2021
Modified Files: src/sys/dev/spi [thorpej-i2c-spi-conf2]: spi.c Log Message: Record the attached child device_t in the spi_handle. To generate a diff of this commit: cvs rdiff -u -r1.19.2.1 -r1.19.2.2 src/sys/dev/spi/spi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/spi/spi.c diff -u src/sys/dev/spi/spi.c:1.19.2.1 src/sys/dev/spi/spi.c:1.19.2.2 --- src/sys/dev/spi/spi.c:1.19.2.1 Mon Aug 9 00:30:09 2021 +++ src/sys/dev/spi/spi.c Fri Sep 10 15:43:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: spi.c,v 1.19.2.1 2021/08/09 00:30:09 thorpej Exp $ */ +/* $NetBSD: spi.c,v 1.19.2.2 2021/09/10 15:43:03 thorpej Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.19.2.1 2021/08/09 00:30:09 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.19.2.2 2021/09/10 15:43:03 thorpej Exp $"); #include "locators.h" @@ -108,6 +108,7 @@ struct spi_handle { int sh_flags; /* ^^ slave_state_lock ^^ */ #define SPIH_ATTACHED __BIT(0) #define SPIH_DIRECT __BIT(1) + device_t sh_dev; /* ^^ slave_state_lock ^^ */ }; #define SPI_MAXDATA 4096 @@ -211,6 +212,7 @@ spi_attach_child(struct spi_softc *sc, s } } + mutex_enter(&sc->sc_slave_state_lock); if (newdev == NULL) { /* * Clear our claim on this chip select (yes, just @@ -218,10 +220,12 @@ spi_attach_child(struct spi_softc *sc, s * of chip selects for which there is a device tree * node). */ - mutex_enter(&sc->sc_slave_state_lock); CLR(sh->sh_flags, SPIH_ATTACHED); - mutex_exit(&sc->sc_slave_state_lock); + } else { + /* Record the child for posterity. */ + sh->sh_dev = newdev; } + mutex_exit(&sc->sc_slave_state_lock); } static int