Module Name: src
Committed By: riastradh
Date: Sun Mar 13 12:49:37 UTC 2022
Modified Files:
src/sys/dev/usb: auvitek.c auvitek_audio.c auvitek_dtv.c auvitek_i2c.c
auvitek_video.c auvitekvar.h
Log Message:
auvitek(4): Fix i2c detach if attach failed.
While here, use config_detach_children.
Reported-by: [email protected]
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/usb/auvitek.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/usb/auvitek_audio.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/usb/auvitek_dtv.c \
src/sys/dev/usb/auvitekvar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/auvitek_i2c.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/auvitek_video.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/usb/auvitek.c
diff -u src/sys/dev/usb/auvitek.c:1.12 src/sys/dev/usb/auvitek.c:1.13
--- src/sys/dev/usb/auvitek.c:1.12 Sat Mar 14 02:35:33 2020
+++ src/sys/dev/usb/auvitek.c Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek.c,v 1.12 2020/03/14 02:35:33 christos Exp $ */
+/* $NetBSD: auvitek.c,v 1.13 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.12 2020/03/14 02:35:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.13 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -260,9 +260,21 @@ static int
auvitek_detach(device_t self, int flags)
{
struct auvitek_softc *sc = device_private(self);
+ int error;
sc->sc_dying = 1;
+ error = config_detach_children(self, flags);
+ if (error) {
+ /*
+ * XXX Should ask autoconf to block open with
+ * .d_cfdriver until we're done, instead of setting
+ * this and then rolling it back.
+ */
+ sc->sc_dying = 0;
+ return error;
+ }
+
pmf_device_deregister(self);
auvitek_dtv_detach(sc, flags);
Index: src/sys/dev/usb/auvitek_audio.c
diff -u src/sys/dev/usb/auvitek_audio.c:1.5 src/sys/dev/usb/auvitek_audio.c:1.6
--- src/sys/dev/usb/auvitek_audio.c:1.5 Sat Aug 7 16:19:16 2021
+++ src/sys/dev/usb/auvitek_audio.c Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_audio.c,v 1.5 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_audio.c,v 1.6 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_audio.c,v 1.5 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_audio.c,v 1.6 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -112,10 +112,6 @@ auvitek_audio_attach(struct auvitek_soft
int
auvitek_audio_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_audiodev != NULL) {
- config_detach(sc->sc_audiodev, flags);
- sc->sc_audiodev = NULL;
- }
return 0;
}
Index: src/sys/dev/usb/auvitek_dtv.c
diff -u src/sys/dev/usb/auvitek_dtv.c:1.9 src/sys/dev/usb/auvitek_dtv.c:1.10
--- src/sys/dev/usb/auvitek_dtv.c:1.9 Sat Aug 7 16:19:16 2021
+++ src/sys/dev/usb/auvitek_dtv.c Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.9 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.10 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.9 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.10 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,10 +98,6 @@ auvitek_dtv_attach(struct auvitek_softc
int
auvitek_dtv_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_dtvdev != NULL) {
- config_detach(sc->sc_dtvdev, flags);
- sc->sc_dtvdev = NULL;
- }
return 0;
}
Index: src/sys/dev/usb/auvitekvar.h
diff -u src/sys/dev/usb/auvitekvar.h:1.9 src/sys/dev/usb/auvitekvar.h:1.10
--- src/sys/dev/usb/auvitekvar.h:1.9 Sat Apr 23 10:15:31 2016
+++ src/sys/dev/usb/auvitekvar.h Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitekvar.h,v 1.9 2016/04/23 10:15:31 skrll Exp $ */
+/* $NetBSD: auvitekvar.h,v 1.10 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -102,6 +102,7 @@ struct auvitek_softc {
device_t sc_videodev, sc_dtvdev, sc_audiodev, sc_i2cdev;
struct i2c_controller sc_i2c;
kmutex_t sc_i2c_lock;
+ bool sc_i2c_attached;
struct usbd_device *sc_udev;
int sc_uport;
Index: src/sys/dev/usb/auvitek_i2c.c
diff -u src/sys/dev/usb/auvitek_i2c.c:1.7 src/sys/dev/usb/auvitek_i2c.c:1.8
--- src/sys/dev/usb/auvitek_i2c.c:1.7 Sat Aug 7 16:19:16 2021
+++ src/sys/dev/usb/auvitek_i2c.c Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_i2c.c,v 1.7 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: auvitek_i2c.c,v 1.8 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_i2c.c,v 1.7 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_i2c.c,v 1.8 2022/03/13 12:49:36 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -71,22 +71,26 @@ static bool auvitek_i2c_wait_wrdone(stru
int
auvitek_i2c_attach(struct auvitek_softc *sc)
{
+
iic_tag_init(&sc->sc_i2c);
sc->sc_i2c.ic_cookie = sc;
sc->sc_i2c.ic_exec = auvitek_i2c_exec;
auvitek_i2c_rescan(sc, NULL, NULL);
+ sc->sc_i2c_attached = true;
+
return 0;
}
int
auvitek_i2c_detach(struct auvitek_softc *sc, int flags)
{
- iic_tag_fini(&sc->sc_i2c);
- if (sc->sc_i2cdev)
- config_detach(sc->sc_i2cdev, flags);
+ if (!sc->sc_i2c_attached)
+ return 0;
+
+ iic_tag_fini(&sc->sc_i2c);
return 0;
}
Index: src/sys/dev/usb/auvitek_video.c
diff -u src/sys/dev/usb/auvitek_video.c:1.10 src/sys/dev/usb/auvitek_video.c:1.11
--- src/sys/dev/usb/auvitek_video.c:1.10 Thu Mar 3 06:23:25 2022
+++ src/sys/dev/usb/auvitek_video.c Sun Mar 13 12:49:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_video.c,v 1.10 2022/03/03 06:23:25 riastradh Exp $ */
+/* $NetBSD: auvitek_video.c,v 1.11 2022/03/13 12:49:36 riastradh Exp $ */
/*-
* Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.10 2022/03/03 06:23:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.11 2022/03/13 12:49:36 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -140,10 +140,6 @@ auvitek_video_attach(struct auvitek_soft
int
auvitek_video_detach(struct auvitek_softc *sc, int flags)
{
- if (sc->sc_videodev != NULL) {
- config_detach(sc->sc_videodev, flags);
- sc->sc_videodev = NULL;
- }
return 0;
}