diff options
| author | jdolecek <jdolecek@NetBSD.org> | 2017-10-20 07:06:05 +0000 |
|---|---|---|
| committer | jdolecek <jdolecek@NetBSD.org> | 2017-10-20 07:06:05 +0000 |
| commit | a1bf30e8664357bafc3ccae2f9fd0a82b80da38d (patch) | |
| tree | bbe67330ed63b1c91a85eaa6f8e1a5164678e218 /sys/dev/ata | |
| parent | ad78d490fdb1c20addcc0d39920b7609a2133ad9 (diff) | |
move ata_queue_alloc(1) and ata_queue_free() calls to ata_channel_init()
and ata_channel_destroy() respectively, to make attachment code simpler,
and to make it easier to spot special queue manipulation like cmdide(4)
on topic of PR kern/52606
Diffstat (limited to 'sys/dev/ata')
| -rw-r--r-- | sys/dev/ata/ata.c | 8 | ||||
| -rw-r--r-- | sys/dev/ata/ata_subr.c | 14 |
2 files changed, 16 insertions, 6 deletions
diff --git a/sys/dev/ata/ata.c b/sys/dev/ata/ata.c index 9315a4692d0..c5443e64980 100644 --- a/sys/dev/ata/ata.c +++ b/sys/dev/ata/ata.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata.c,v 1.139 2017/10/19 20:45:07 jdolecek Exp $ */ +/* $NetBSD: ata.c,v 1.140 2017/10/20 07:06:07 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.139 2017/10/19 20:45:07 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata.c,v 1.140 2017/10/20 07:06:07 jdolecek Exp $"); #include "opt_ata.h" @@ -196,10 +196,10 @@ ata_channel_attach(struct ata_channel *chp) if (chp->ch_flags & ATACH_DISABLED) return; - KASSERT(chp->ch_queue != NULL); - ata_channel_init(chp); + KASSERT(chp->ch_queue != NULL); + chp->atabus = config_found_ia(chp->ch_atac->atac_dev, "ata", chp, atabusprint); } diff --git a/sys/dev/ata/ata_subr.c b/sys/dev/ata/ata_subr.c index 721f41c01e2..a94107dfeb7 100644 --- a/sys/dev/ata/ata_subr.c +++ b/sys/dev/ata/ata_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ata_subr.c,v 1.3 2017/10/19 20:45:07 jdolecek Exp $ */ +/* $NetBSD: ata_subr.c,v 1.4 2017/10/20 07:06:07 jdolecek Exp $ */ /* * Copyright (c) 1998, 2001 Manuel Bouyer. All rights reserved. @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.3 2017/10/19 20:45:07 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ata_subr.c,v 1.4 2017/10/20 07:06:07 jdolecek Exp $"); #include "opt_ata.h" @@ -225,11 +225,21 @@ ata_channel_init(struct ata_channel *chp) { mutex_init(&chp->ch_lock, MUTEX_DEFAULT, IPL_BIO); cv_init(&chp->ch_thr_idle, "atath"); + + /* Optionally setup the queue, too */ + if (chp->ch_queue == NULL) { + chp->ch_queue = ata_queue_alloc(1); + } } void ata_channel_destroy(struct ata_channel *chp) { + if (chp->ch_queue != NULL) { + ata_queue_free(chp->ch_queue); + chp->ch_queue = NULL; + } + mutex_destroy(&chp->ch_lock); cv_destroy(&chp->ch_thr_idle); } |
