svn commit: r188897 - head/sys/dev/ata

Alexander Motin mav at FreeBSD.org
Sat Feb 21 08:39:28 PST 2009


Author: mav
Date: Sat Feb 21 16:39:26 2009
New Revision: 188897
URL: http://svn.freebsd.org/changeset/base/188897

Log:
  Teach device drivers' ata_reinit() methods, that there can be more then two
  devices per channel.

Modified:
  head/sys/dev/ata/ata-disk.c
  head/sys/dev/ata/atapi-cd.c
  head/sys/dev/ata/atapi-fd.c
  head/sys/dev/ata/atapi-tape.c

Modified: head/sys/dev/ata/ata-disk.c
==============================================================================
--- head/sys/dev/ata/ata-disk.c	Sat Feb 21 15:40:03 2009	(r188896)
+++ head/sys/dev/ata/ata-disk.c	Sat Feb 21 16:39:26 2009	(r188897)
@@ -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;
 }

Modified: head/sys/dev/ata/atapi-cd.c
==============================================================================
--- head/sys/dev/ata/atapi-cd.c	Sat Feb 21 15:40:03 2009	(r188896)
+++ head/sys/dev/ata/atapi-cd.c	Sat Feb 21 16:39:26 2009	(r188897)
@@ -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;
 }

Modified: head/sys/dev/ata/atapi-fd.c
==============================================================================
--- head/sys/dev/ata/atapi-fd.c	Sat Feb 21 15:40:03 2009	(r188896)
+++ head/sys/dev/ata/atapi-fd.c	Sat Feb 21 16:39:26 2009	(r188897)
@@ -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;
 }

Modified: head/sys/dev/ata/atapi-tape.c
==============================================================================
--- head/sys/dev/ata/atapi-tape.c	Sat Feb 21 15:40:03 2009	(r188896)
+++ head/sys/dev/ata/atapi-tape.c	Sat Feb 21 16:39:26 2009	(r188897)
@@ -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;
 }


More information about the svn-src-head mailing list