Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Mar 2004 21:29:21 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        Anthony Wood <adwood@earthlink.net>
Subject:   USB bug fix for DETACH message.
Message-ID:  <200403190529.i2J5TLXs083918@apollo.backplane.com>

next in thread | raw e-mail | index | archive | help
    A DragonFly user noticed that usbd does not seem to get DETACH events
    for UMASS devices. 

    I tracked this down (in the FreeBSD-5 codebase for your convenience)
    to line 1382 of usb_subr.c:

	    /*usbd_add_dev_event(USB_EVENT_DEVICE_DETACH, dev);*/

    This line was apparently commented out by wpaul in rev 1.22, in
    January 2000.

    NetBSD has this line uncommented... that is, activated, and they
    recently committed a bug fix (1.110 I believe in the NetBSD source
    tree) that solves the problem I'm sure wpaul encountered that caused
    him to comment the line out.  The bug fix is trivial.  Just above this
    code, around line 1378, you simply need to NULL out dev->subdevs[i]
    after detaching it:

                                printf(" port %d", up->portno);
                        printf(" (addr %d) disconnected\n", dev->address);
                        config_detach(dev->subdevs[i], DETACH_FORCE);
			dev->subdevs[i] = NULL;	     <<<<<<<<<<<<<<<<<< ADDME

    If you want DETACH events to work, uncomment the add_dev_event and
    make the bug fix above and DETACH events will work again.  If you are
    going to do this, please do this in both FreeBSD-5.x and FreeBSD-4.x.

    You may also wish to commit NetBSD's 1.111 of sub_subr.c, which reorders
    an address assignment to work around certain non-compliant USB devices
    and allow them to work.  The NetBSD repository can be accessed via 
    CVS using the server string ':pserver:anoncvs@anoncvs.netbsd.org:/cvsroot'
    (don't accidently overwrite your FBsd tree, though! :-)).

						-Matt



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403190529.i2J5TLXs083918>