summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-cd.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2009-02-28 11:25:05 +0000
committermav <mav@FreeBSD.org>2009-02-28 11:25:05 +0000
commitb342cbbd7afd2f2831b83817093c7f75c25d4b4d (patch)
treef3410869622522be80b33c90bcbde706aecd00e0 /sys/dev/ata/atapi-cd.c
parent24ca141ec70a3d76fd6bf5cff5521ec69c1d6d55 (diff)
downloadFreeBSD-src-b342cbbd7afd2f2831b83817093c7f75c25d4b4d.zip
FreeBSD-src-b342cbbd7afd2f2831b83817093c7f75c25d4b4d.tar.gz
Rework device probing by moving ata_getparam() call from ata_identify() to
drivers' probe routines. It allows not to sleep and so not drop Giant inside ata_identify() critical section and so avoid crash if it reentered on request timeout. Reentering of probe call checked inside of it. Give device own knowledge about it's type (ata/atapi/atapicam). It is not a good idea to ask channel status for device type inside ata_getparam(). Add softc memory deallocation on device destruction.
Diffstat (limited to 'sys/dev/ata/atapi-cd.c')
-rw-r--r--sys/dev/ata/atapi-cd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index 7fd80c4..ba0c7c8 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -108,6 +108,18 @@ acd_probe(device_t dev)
{
struct ata_device *atadev = device_get_softc(dev);
+ if (atadev->type != ATA_T_ATAPI)
+ return (ENXIO);
+
+ if (!(atadev->flags & ATA_D_PROBED)) {
+ atadev->flags |= ATA_D_PROBED;
+ if (ata_getparam(atadev, 1) == 0)
+ atadev->flags |= ATA_D_VALID;
+ }
+
+ if (!(atadev->flags & ATA_D_VALID))
+ return (ENXIO);
+
if ((atadev->param.config & ATA_PROTO_ATAPI) &&
(atadev->param.config & ATA_ATAPI_TYPE_MASK) == ATA_ATAPI_TYPE_CDROM)
return 0;
OpenPOWER on IntegriCloud