From e6d61c5bc9c9158e4de3d4e03517ff471ddf22eb Mon Sep 17 00:00:00 2001 From: thorpej Date: Thu, 12 Aug 2004 22:39:40 +0000 Subject: [PATCH] Move wdc_addref() and wdc_delref() to ata.c and rename them to ata_*. --- sys/dev/ata/ata.c | 42 ++++++++++++++++++++++++++++++++----- sys/dev/ata/ata_wdc.c | 8 +++---- sys/dev/ata/atavar.h | 4 +++- sys/dev/ic/wdc.c | 38 +++------------------------------ sys/dev/ic/wdcvar.h | 5 +---- sys/dev/pcmcia/wdc_pcmcia.c | 6 +++--- sys/dev/scsipi/atapi_wdc.c | 6 +++--- 7 files changed, 54 insertions(+), 55 deletions(-) diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index 230791775570..ffe5a265144f 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -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 -__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; diff --git a/sys/dev/ata/ata_wdc.c b/sys/dev/ata/ata_wdc.c index 71ea6622c094..e479ad526362 100644 --- a/sys/dev/ata/ata_wdc.c +++ b/sys/dev/ata/ata_wdc.c @@ -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 -__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); } diff --git a/sys/dev/ata/atavar.h b/sys/dev/ata/atavar.h index 9978030e019a..371360297d02 100644 --- a/sys/dev/ata/atavar.h +++ b/sys/dev/ata/atavar.h @@ -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 *); diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c index 3232e0673d64..fc4ea1c8406d 100644 --- a/sys/dev/ic/wdc.c +++ b/sys/dev/ic/wdc.c @@ -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 -__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; diff --git a/sys/dev/ic/wdcvar.h b/sys/dev/ic/wdcvar.h index b327fc111bc4..ea3b966d612d 100644 --- a/sys/dev/ic/wdcvar.h +++ b/sys/dev/ic/wdcvar.h @@ -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. diff --git a/sys/dev/pcmcia/wdc_pcmcia.c b/sys/dev/pcmcia/wdc_pcmcia.c index f6666863014c..b856de36a592 100644 --- a/sys/dev/pcmcia/wdc_pcmcia.c +++ b/sys/dev/pcmcia/wdc_pcmcia.c @@ -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 -__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 #include @@ -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; diff --git a/sys/dev/scsipi/atapi_wdc.c b/sys/dev/scsipi/atapi_wdc.c index 8f3085d6224a..090109f636e8 100644 --- a/sys/dev/scsipi/atapi_wdc.c +++ b/sys/dev/scsipi/atapi_wdc.c @@ -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 -__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