Index: sys/dev/pci/esm.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/esm.c,v
retrieving revision 1.66
diff -p -u -r1.66 esm.c
--- sys/dev/pci/esm.c	23 May 2022 13:53:37 -0000	1.66
+++ sys/dev/pci/esm.c	1 Sep 2025 17:11:40 -0000
@@ -1321,18 +1321,14 @@ esm_intr(void *sc)
 	struct esm_softc *ess;
 	uint16_t status;
 	uint16_t pos;
-	int ret;
 
 	ess = sc;
-	ret = 0;
 
-	mutex_spin_enter(&ess->sc_intr_lock);
 	status = bus_space_read_1(ess->st, ess->sh, PORT_HOSTINT_STAT);
-	if (!status) {
-		mutex_spin_exit(&ess->sc_intr_lock);
+	if (!status)
 		return 0;
-	}
 
+	mutex_spin_enter(&ess->sc_intr_lock);
 	/* Acknowledge all. */
 	bus_space_write_2(ess->st, ess->sh, PORT_INT_STAT, 1);
 	bus_space_write_1(ess->st, ess->sh, PORT_HOSTINT_STAT, 0);
@@ -1353,7 +1349,6 @@ esm_intr(void *sc)
 			    + ((delta << 7) & 0x700) - 0x400);
 		}
 		bus_space_write_1(ess->st, ess->sh, PORT_HWVOL_MASTER, 0x88);
-		ret++;
 	}
 #endif	/* XXX - HWVOL */
 
@@ -1377,7 +1372,6 @@ esm_intr(void *sc)
 			}
 
 		}
-		ret++;
 	}
 
 	if (ess->ractive) {
@@ -1405,11 +1399,10 @@ esm_intr(void *sc)
 			}
 
 		}
-		ret++;
 	}
 	mutex_spin_exit(&ess->sc_intr_lock);
 
-	return ret;
+	return 1;
 }
 
 static void
@@ -1556,7 +1549,7 @@ esm_attach(device_t parent, device_t sel
 		return;
 	}
 	intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
-	ess->ih = pci_intr_establish_xname(pc, ih, IPL_AUDIO, esm_intr, self,
+	ess->ih = pci_intr_establish_xname(pc, ih, IPL_AUDIO, esm_intr, ess,
 	    device_xname(self));
 	if (ess->ih == NULL) {
 		aprint_error_dev(ess->sc_dev, "can't establish interrupt");
@@ -1619,7 +1612,7 @@ esm_attach(device_t parent, device_t sel
 	ess->codec_flags |= AC97_HOST_DONT_READ;
 
 	/* initialize AC97 host interface */
-	ess->host_if.arg = self;
+	ess->host_if.arg = ess;
 	ess->host_if.attach = esm_attach_codec;
 	ess->host_if.read = esm_read_codec;
 	ess->host_if.write = esm_write_codec;
@@ -1647,7 +1640,7 @@ esm_attach(device_t parent, device_t sel
 		wc_wrreg(ess, pcmbar,
 		    DMAADDR(&ess->sc_dma) >> WAVCACHE_BASEADDR_SHIFT);
 
-	audio_attach_mi(&esm_hw_if, self, ess->sc_dev);
+	audio_attach_mi(&esm_hw_if, ess, ess->sc_dev);
 
 	if (!pmf_device_register(self, esm_suspend, esm_resume))
 		aprint_error_dev(self, "couldn't establish power handler\n");
