Move wdc_addref() and wdc_delref() to ata.c and rename them to

ata_*.
This commit is contained in:
thorpej 2004-08-12 22:39:40 +00:00
parent 2eaa5c6142
commit e6d61c5bc9
7 changed files with 54 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata.c,v 1.42 2004/08/12 22:33:46 thorpej Exp $ */
/* $NetBSD: ata.c,v 1.43 2004/08/12 22:39:40 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.42 2004/08/12 22:33:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.43 2004/08/12 22:39:40 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -240,7 +240,7 @@ atabus_attach(struct device *parent, struct device *self, void *aux)
aprint_normal("\n");
aprint_naive("\n");
if (wdc_addref(chp))
if (ata_addref(chp))
return;
initq = malloc(sizeof(*initq), M_DEVBUF, M_WAITOK);
@ -563,6 +563,38 @@ ata_kill_pending(struct ata_drive_datas *drvp)
splx(s);
}
int
ata_addref(struct wdc_channel *chp)
{
struct wdc_softc *wdc = chp->ch_wdc;
struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
int s, error = 0;
s = splbio();
if (adapt->adapt_refcnt++ == 0 &&
adapt->adapt_enable != NULL) {
error = (*adapt->adapt_enable)(&wdc->sc_dev, 1);
if (error)
adapt->adapt_refcnt--;
}
splx(s);
return (error);
}
void
ata_delref(struct wdc_channel *chp)
{
struct wdc_softc *wdc = chp->ch_wdc;
struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
int s;
s = splbio();
if (adapt->adapt_refcnt-- == 1 &&
adapt->adapt_enable != NULL)
(void) (*adapt->adapt_enable)(&wdc->sc_dev, 0);
splx(s);
}
void
ata_print_modes(struct wdc_channel *chp)
{
@ -888,7 +920,7 @@ int atabusopen(dev, flag, fmt, p)
if (sc->sc_flags & ATABUSCF_OPEN)
return (EBUSY);
if ((error = wdc_addref(sc->sc_chan)) != 0)
if ((error = ata_addref(sc->sc_chan)) != 0)
return (error);
sc->sc_flags |= ATABUSCF_OPEN;
@ -905,7 +937,7 @@ atabusclose(dev, flag, fmt, p)
{
struct atabus_softc *sc = atabus_cd.cd_devs[minor(dev)];
wdc_delref(sc->sc_chan);
ata_delref(sc->sc_chan);
sc->sc_flags &= ~ATABUSCF_OPEN;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_wdc.c,v 1.66 2004/08/12 22:33:46 thorpej Exp $ */
/* $NetBSD: ata_wdc.c,v 1.67 2004/08/12 22:39:40 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.66 2004/08/12 22:33:46 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.67 2004/08/12 22:39:40 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -772,7 +772,7 @@ wdc_ata_addref(struct ata_drive_datas *drvp)
{
struct wdc_channel *chp = drvp->chnl_softc;
return (wdc_addref(chp));
return (ata_addref(chp));
}
static void
@ -780,5 +780,5 @@ wdc_ata_delref(struct ata_drive_datas *drvp)
{
struct wdc_channel *chp = drvp->chnl_softc;
wdc_delref(chp);
ata_delref(chp);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: atavar.h,v 1.55 2004/08/12 22:33:46 thorpej Exp $ */
/* $NetBSD: atavar.h,v 1.56 2004/08/12 22:39:41 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -315,6 +315,8 @@ void ata_free_xfer(struct wdc_channel *, struct ata_xfer *);
void ata_kill_pending(struct ata_drive_datas *);
int ata_addref(struct wdc_channel *);
void ata_delref(struct wdc_channel *);
void ata_print_modes(struct wdc_channel *);
int ata_downgrade_mode(struct ata_drive_datas *, int);
void ata_probe_caps(struct ata_drive_datas *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.199 2004/08/12 22:33:45 thorpej Exp $ */
/* $NetBSD: wdc.c,v 1.200 2004/08/12 22:39:41 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.199 2004/08/12 22:33:45 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.200 2004/08/12 22:39:41 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -469,7 +469,7 @@ atabusconfig(struct atabus_softc *atabus_sc)
free(atabus_initq, M_DEVBUF);
wakeup(&atabus_initq_head);
wdc_delref(chp);
ata_delref(chp);
config_pending_decr();
}
@ -1852,38 +1852,6 @@ wdcbit_bucket(struct wdc_channel *chp, int size)
(void)bus_space_read_1(chp->cmd_iot, chp->cmd_iohs[wd_data], 0);
}
int
wdc_addref(struct wdc_channel *chp)
{
struct wdc_softc *wdc = chp->ch_wdc;
struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
int s, error = 0;
s = splbio();
if (adapt->adapt_refcnt++ == 0 &&
adapt->adapt_enable != NULL) {
error = (*adapt->adapt_enable)(&wdc->sc_dev, 1);
if (error)
adapt->adapt_refcnt--;
}
splx(s);
return (error);
}
void
wdc_delref(struct wdc_channel *chp)
{
struct wdc_softc *wdc = chp->ch_wdc;
struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
int s;
s = splbio();
if (adapt->adapt_refcnt-- == 1 &&
adapt->adapt_enable != NULL)
(void) (*adapt->adapt_enable)(&wdc->sc_dev, 0);
splx(s);
}
void
wdc_datain_pio(chp, flags, buf, len)
struct wdc_channel *chp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdcvar.h,v 1.70 2004/08/12 22:33:45 thorpej Exp $ */
/* $NetBSD: wdcvar.h,v 1.71 2004/08/12 22:39:41 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@ -221,9 +221,6 @@ void wdc_reset_channel(struct wdc_channel *, int);
int wdc_exec_command(struct ata_drive_datas *, struct ata_command*);
int wdc_addref(struct wdc_channel *);
void wdc_delref(struct wdc_channel *);
/*
* ST506 spec says that if READY or SEEKCMPLT go off, then the read or write
* command is aborted.

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc_pcmcia.c,v 1.88 2004/08/11 20:27:42 mycroft Exp $ */
/* $NetBSD: wdc_pcmcia.c,v 1.89 2004/08/12 22:39:41 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.88 2004/08/11 20:27:42 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: wdc_pcmcia.c,v 1.89 2004/08/12 22:39:41 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -291,7 +291,7 @@ wdc_pcmcia_attach(parent, self, aux)
sc->sc_wdcdev.sc_atapi_adapter._generic.adapt_refcnt = 1;
wdcattach(&sc->wdc_channel);
wdc_delref(&sc->wdc_channel);
ata_delref(&sc->wdc_channel);
sc->sc_state = WDC_PCMCIA_ATTACHED;
return;

View File

@ -1,4 +1,4 @@
/* $NetBSD: atapi_wdc.c,v 1.81 2004/08/12 21:34:52 thorpej Exp $ */
/* $NetBSD: atapi_wdc.c,v 1.82 2004/08/12 22:39:41 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Manuel Bouyer.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.81 2004/08/12 21:34:52 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.82 2004/08/12 22:39:41 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@ -165,7 +165,7 @@ wdc_atapi_kill_pending(struct scsipi_periph *periph)
struct wdc_channel *chp =
wdc->channels[periph->periph_channel->chan_channel];
wdc_kill_pending(&chp->ch_drive[periph->periph_target]);
ata_kill_pending(&chp->ch_drive[periph->periph_target]);
}
static void