Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej-i2c-spi-conf2]: src/sys/dev/spi Record the attached child device...



details:   https://anonhg.NetBSD.org/src/rev/3e4ed7c93b55
branches:  thorpej-i2c-spi-conf2
changeset: 1024889:3e4ed7c93b55
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Sep 10 15:43:03 2021 +0000

description:
Record the attached child device_t in the spi_handle.

diffstat:

 sys/dev/spi/spi.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (49 lines):

diff -r d907d854d670 -r 3e4ed7c93b55 sys/dev/spi/spi.c
--- a/sys/dev/spi/spi.c Tue Aug 24 03:27:39 2021 +0000
+++ b/sys/dev/spi/spi.c Fri Sep 10 15:43:03 2021 +0000
@@ -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 @@
        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 @@
                }
        }
 
+       mutex_enter(&sc->sc_slave_state_lock);
        if (newdev == NULL) {
                /*
                 * Clear our claim on this chip select (yes, just
@@ -218,10 +220,12 @@
                 * 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



Home | Main Index | Thread Index | Old Index