diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c
index 492067531b61..b31290addba1 100644
--- a/sys/dev/ata/atapi-all.c
+++ b/sys/dev/ata/atapi-all.c
@@ -128,7 +128,7 @@ notfound:
 	atp = NULL;
     }
     /* store our softc */
-    scp->dev_softc[ATA_DEV(atp->unit)] = atp;
+    scp->dev_softc[ATA_DEV(device)] = atp;
 }
 
 int32_t