From d6b23ce1539543a5cc3dfe32ca002797fb016713 Mon Sep 17 00:00:00 2001 From: mav Date: Sat, 21 Feb 2009 16:39:26 +0000 Subject: Teach device drivers' ata_reinit() methods, that there can be more then two devices per channel. --- sys/dev/ata/ata-disk.c | 5 ++--- sys/dev/ata/atapi-cd.c | 8 ++++---- sys/dev/ata/atapi-fd.c | 8 ++++---- sys/dev/ata/atapi-tape.c | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'sys/dev/ata') diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 27d4210..e11f3f9 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -199,10 +199,9 @@ ad_reinit(device_t dev) struct ata_device *atadev = device_get_softc(dev); /* if detach pending, return error */ - if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATA_MASTER)) || - ((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATA_SLAVE))) { + if (!(ch->devices & (ATA_ATA_MASTER << atadev->unit))) return 1; - } + ad_init(dev); return 0; } diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index ba65a6b..7fd80c4 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -159,10 +159,10 @@ acd_reinit(device_t dev) struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ata_device *atadev = device_get_softc(dev); - if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATAPI_MASTER)) || - ((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATAPI_SLAVE))) { - return 1; - } + /* if detach pending, return error */ + if (!(ch->devices & (ATA_ATAPI_MASTER << atadev->unit))) + return 1; + ATA_SETMODE(device_get_parent(dev), dev); return 0; } diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index e9f3021..b8434b3 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -147,11 +147,11 @@ afd_reinit(device_t dev) { struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ata_device *atadev = device_get_softc(dev); - - if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATAPI_MASTER)) || - ((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATAPI_SLAVE))) { + + /* if detach pending, return error */ + if (!(ch->devices & (ATA_ATAPI_MASTER << atadev->unit))) return 1; - } + ATA_SETMODE(device_get_parent(dev), dev); return 0; } diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 734f012..aa44afe 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -191,10 +191,10 @@ ast_reinit(device_t dev) struct ata_channel *ch = device_get_softc(device_get_parent(dev)); struct ata_device *atadev = device_get_softc(dev); - if (((atadev->unit == ATA_MASTER) && !(ch->devices & ATA_ATAPI_MASTER)) || - ((atadev->unit == ATA_SLAVE) && !(ch->devices & ATA_ATAPI_SLAVE))) { + /* if detach pending, return error */ + if (!(ch->devices & (ATA_ATAPI_MASTER << atadev->unit))) return 1; - } + ATA_SETMODE(device_get_parent(dev), dev); return 0; } -- cgit v1.1