Move common parts of attaching an ata_channel to a new ata_channel_attach()

function.
This commit is contained in:
thorpej 2004-08-20 22:17:06 +00:00
parent 3234a02f48
commit 56e2a255b5
3 changed files with 30 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata.c,v 1.51 2004/08/20 22:02:40 thorpej Exp $ */ /* $NetBSD: ata.c,v 1.52 2004/08/20 22:17:06 thorpej Exp $ */
/* /*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.51 2004/08/20 22:02:40 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.52 2004/08/20 22:17:06 thorpej Exp $");
#ifndef ATADEBUG #ifndef ATADEBUG
#define ATADEBUG #define ATADEBUG
@ -143,6 +143,27 @@ ataprint(void *aux, const char *pnp)
return (UNCONF); return (UNCONF);
} }
/*
* ata_channel_attach:
*
* Common parts of attaching an atabus to an ATA controller channel.
*/
void
ata_channel_attach(struct ata_channel *chp)
{
if (chp->ch_flags & ATACH_DISABLED)
return;
callout_init(&chp->ch_callout);
TAILQ_INIT(&chp->ch_queue->queue_xfer);
chp->ch_queue->queue_freeze = 0;
chp->ch_queue->active_xfer = NULL;
chp->atabus = config_found(&chp->ch_atac->atac_dev, chp, atabusprint);
}
static void static void
atabusconfig(struct atabus_softc *atabus_sc) atabusconfig(struct atabus_softc *atabus_sc)
{ {

View File

@ -1,4 +1,4 @@
/* $NetBSD: atavar.h,v 1.62 2004/08/20 20:52:31 thorpej Exp $ */ /* $NetBSD: atavar.h,v 1.63 2004/08/20 22:17:06 thorpej Exp $ */
/* /*
* Copyright (c) 1998, 2001 Manuel Bouyer. * Copyright (c) 1998, 2001 Manuel Bouyer.
@ -406,6 +406,7 @@ struct atac_softc {
}; };
#ifdef _KERNEL #ifdef _KERNEL
void ata_channel_attach(struct ata_channel *);
int atabusprint(void *aux, const char *); int atabusprint(void *aux, const char *);
int ataprint(void *aux, const char *); int ataprint(void *aux, const char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.209 2004/08/20 22:02:40 thorpej Exp $ */ /* $NetBSD: wdc.c,v 1.210 2004/08/20 22:17:06 thorpej Exp $ */
/* /*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved. * Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@ -70,7 +70,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.209 2004/08/20 22:02:40 thorpej Exp $"); __KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.210 2004/08/20 22:17:06 thorpej Exp $");
#ifndef ATADEBUG #ifndef ATADEBUG
#define ATADEBUG #define ATADEBUG
@ -645,9 +645,6 @@ wdcattach(struct ata_channel *chp)
struct atac_softc *atac = chp->ch_atac; struct atac_softc *atac = chp->ch_atac;
struct wdc_softc *wdc = CHAN_TO_WDC(chp); struct wdc_softc *wdc = CHAN_TO_WDC(chp);
if (chp->ch_flags & ATACH_DISABLED)
return;
/* /*
* Start out assuming 2 drives. This may change as we probe * Start out assuming 2 drives. This may change as we probe
* drives. * drives.
@ -655,13 +652,12 @@ wdcattach(struct ata_channel *chp)
chp->ch_ndrive = 2; chp->ch_ndrive = 2;
/* default data transfer methods */ /* default data transfer methods */
if (!wdc->datain_pio) if (wdc->datain_pio == NULL)
wdc->datain_pio = wdc_datain_pio; wdc->datain_pio = wdc_datain_pio;
if (!wdc->dataout_pio) if (wdc->dataout_pio == NULL)
wdc->dataout_pio = wdc_dataout_pio; wdc->dataout_pio = wdc_dataout_pio;
/* initialise global data */ /* initialise global data */
callout_init(&chp->ch_callout);
if (atac->atac_bustype_ata == NULL) if (atac->atac_bustype_ata == NULL)
atac->atac_bustype_ata = &wdc_ata_bustype; atac->atac_bustype_ata = &wdc_ata_bustype;
if (atac->atac_probe == NULL) if (atac->atac_probe == NULL)
@ -671,11 +667,7 @@ wdcattach(struct ata_channel *chp)
atac->atac_atapibus_attach = wdc_atapibus_attach; atac->atac_atapibus_attach = wdc_atapibus_attach;
#endif #endif
TAILQ_INIT(&chp->ch_queue->queue_xfer); ata_channel_attach(chp);
chp->ch_queue->queue_freeze = 0;
chp->ch_queue->active_xfer = NULL;
chp->atabus = config_found(&atac->atac_dev, chp, atabusprint);
} }
int int