FreeBSD/sys/dev/twe/twe_freebsd.c
/********************************************************************************
 * Given a detected drive, attach it to the bio interface.
 *
 * This is called from twe_add_unit.
 */
Given a detected drive, attach it to the bio interface.
This is called from twe_add_unit.
Given a detected drive attach it to the bio interface . This is called from twe_add_unit .
int
twe_attach_drive(struct twe_softc *sc, struct twe_drive *dr)
{
    char	buf[80];
    int		error;
    mtx_lock(&Giant);
    dr->td_disk =  device_add_child(sc->twe_dev, NULL, -1);
    if (dr->td_disk == NULL) {
	mtx_unlock(&Giant);
	twe_printf(sc, "Cannot add unit\n");
	return (EIO);
    }
    device_set_ivars(dr->td_disk, dr);
    sprintf(buf, "Unit %d, %s, %s",
	    dr->td_twe_unit,
	    twe_describe_code(twe_table_unittype, dr->td_type),
	    twe_describe_code(twe_table_unitstate, dr->td_state & TWE_PARAM_UNITSTATUS_MASK));
    device_set_desc_copy(dr->td_disk, buf);
    error = device_probe_and_attach(dr->td_disk);
    mtx_unlock(&Giant);
    if (error != 0) {
	twe_printf(sc, "Cannot attach unit to controller. error = %d\n", error);
	return (EIO);
    }
    return (0);
}
int twe_attach_drive ( struct twe_softc * sc , struct twe_drive * dr ) { char buf [ 80 ] ; int error ; mtx_lock ( & Giant ) ; dr -> td_disk = device_add_child ( sc -> twe_dev , NULL , -1 ) ; if ( dr -> td_disk == NULL ) { mtx_unlock ( & Giant ) ; twe_printf ( sc , " \n " ) ; return ( EIO ) ; } device_set_ivars ( dr -> td_disk , dr ) ; sprintf ( buf , " " , dr -> td_twe_unit , twe_describe_code ( twe_table_unittype , dr -> td_type ) , twe_describe_code ( twe_table_unitstate , dr -> td_state & TWE_PARAM_UNITSTATUS_MASK ) ) ; device_set_desc_copy ( dr -> td_disk , buf ) ; error = device_probe_and_attach ( dr -> td_disk ) ; mtx_unlock ( & Giant ) ; if ( error != 0 ) { twe_printf ( sc , " \n " , error ) ; return ( EIO ) ; } return ( 0 ) ; }
Given a detected drive, attach it to the bio interface.
Given a detected drive attach it to the bio interface .
/* 
     * XXX It would make sense to test the online/initialising bits, but they seem to be
     * always set...
     */