diff options
author | sos <sos@FreeBSD.org> | 2002-03-26 09:31:22 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2002-03-26 09:31:22 +0000 |
commit | cf912d2e7adf28df9b489a4fdac3f010cfdd7372 (patch) | |
tree | 1dddd30ce30d7962181ee37dc4ea3687faae43b1 /sys/dev/ata | |
parent | 5713462d5adb7131b4da0be427ff395fe49a0c81 (diff) | |
download | FreeBSD-src-cf912d2e7adf28df9b489a4fdac3f010cfdd7372.zip FreeBSD-src-cf912d2e7adf28df9b489a4fdac3f010cfdd7372.tar.gz |
Misc little cleanups.
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata-all.c | 18 | ||||
-rw-r--r-- | sys/dev/ata/atapi-all.c | 22 | ||||
-rw-r--r-- | sys/dev/ata/atapi-cd.c | 8 | ||||
-rw-r--r-- | sys/dev/ata/atapi-fd.c | 6 | ||||
-rw-r--r-- | sys/dev/ata/atapi-tape.c | 6 |
5 files changed, 27 insertions, 33 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 6b25699..ef47133 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -418,31 +418,27 @@ ata_getparam(struct ata_device *atadev, u_int8_t command) struct ata_params *ata_parm; int retry = 0; + if (!(ata_parm = malloc(sizeof(struct ata_params), M_ATA, M_NOWAIT))) { + ata_prtdev(atadev, "malloc for identify data failed\n"); + return -1; + } + /* apparently some devices needs this repeated */ do { if (ata_command(atadev, command, 0, 0, 0, ATA_WAIT_INTR)) { ata_prtdev(atadev, "%s identify failed\n", command == ATA_C_ATAPI_IDENTIFY ? "ATAPI" : "ATA"); + free(ata_parm, M_ATA); return -1; } if (retry++ > 4) { ata_prtdev(atadev, "%s identify retries exceeded\n", command == ATA_C_ATAPI_IDENTIFY ? "ATAPI" : "ATA"); + free(ata_parm, M_ATA); return -1; } } while (ata_wait(atadev, ((command == ATA_C_ATAPI_IDENTIFY) ? ATA_S_DRQ : (ATA_S_READY|ATA_S_DSC|ATA_S_DRQ)))); - - ata_parm = malloc(sizeof(struct ata_params), M_ATA, M_NOWAIT); - if (!ata_parm) { - int i; - - for (i = 0; i < sizeof(struct ata_params)/sizeof(int16_t); i++) - ATA_INW(atadev->channel->r_io, ATA_DATA); - ata_prtdev(atadev, "malloc for identify data failed\n"); - return -1; - } - ATA_INSW(atadev->channel->r_io, ATA_DATA, (int16_t *)ata_parm, sizeof(struct ata_params)/sizeof(int16_t)); diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index 033c242..5a2e790 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -95,29 +95,27 @@ atapi_attach(struct ata_device *atadev) #ifdef DEV_ATAPICD case ATAPI_TYPE_CDROM: if (acdattach(atadev)) - goto notfound; + return; break; #endif #ifdef DEV_ATAPIFD case ATAPI_TYPE_DIRECT: if (afdattach(atadev)) - goto notfound; - break; + return; + break; #endif #ifdef DEV_ATAPIST case ATAPI_TYPE_TAPE: if (astattach(atadev)) - goto notfound; - break; + return; + break; #endif -notfound: - default: - ata_prtdev(atadev, "<%.40s/%.8s> %s device - NO DRIVER!\n", - atadev->param->model, atadev->param->revision, - atapi_type(atadev->param->type)); - free(atadev->result, M_ATAPI); - atadev->driver = NULL; } + ata_prtdev(atadev, "<%.40s/%.8s> %s device - NO DRIVER!\n", + atadev->param->model, atadev->param->revision, + atapi_type(atadev->param->type)); + free(atadev->result, M_ATAPI); + atadev->driver = NULL; } void diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index f96267c..359e26b 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -113,7 +113,7 @@ acdattach(struct ata_device *atadev) if ((cdp = acd_init_lun(atadev, NULL)) == NULL) { ata_prtdev(atadev, "acd: out of memory\n"); - return -1; + return 0; } ata_set_name(atadev, "acd", cdp->lun); @@ -129,7 +129,7 @@ acdattach(struct ata_device *atadev) if (chp == NULL) { ata_prtdev(atadev, "out of memory\n"); free(cdp, M_ACD); - return -1; + return 0; } if (!atapi_queue_cmd(cdp->device, ccb, (caddr_t)chp, sizeof(struct changer), @@ -145,7 +145,7 @@ acdattach(struct ata_device *atadev) ata_prtdev(atadev, "out of memory\n"); free(chp, M_ACD); free(cdp, M_ACD); - return -1; + return 0; } for (count = 0; count < chp->slots; count++) { if (count > 0) { @@ -181,7 +181,7 @@ acdattach(struct ata_device *atadev) } acd_describe(cdp); atadev->driver = cdp; - return 0; + return 1; } void diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index 0ebac0e..5a20ae5 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -87,7 +87,7 @@ afdattach(struct ata_device *atadev) fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO); if (!fdp) { ata_prtdev(atadev, "out of memory\n"); - return -1; + return 0; } fdp->device = atadev; @@ -97,7 +97,7 @@ afdattach(struct ata_device *atadev) if (afd_sense(fdp)) { free(fdp, M_AFD); - return -1; + return 0; } if (!strncmp(atadev->param->model, "IOMEGA ZIP", 10)) @@ -114,7 +114,7 @@ afdattach(struct ata_device *atadev) afd_describe(fdp); atadev->flags |= ATA_D_MEDIA_CHANGED; atadev->driver = fdp; - return 0; + return 1; } void diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 494404a..764a9ef 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -95,7 +95,7 @@ astattach(struct ata_device *atadev) stp = malloc(sizeof(struct ast_softc), M_AST, M_NOWAIT | M_ZERO); if (!stp) { ata_prtdev(atadev, "out of memory\n"); - return -1; + return 0; } stp->device = atadev; @@ -105,7 +105,7 @@ astattach(struct ata_device *atadev) if (ast_sense(stp)) { free(stp, M_AST); - return -1; + return 0; } if (!strcmp(atadev->param->model, "OnStream DI-30")) { @@ -141,7 +141,7 @@ astattach(struct ata_device *atadev) stp->device->flags |= ATA_D_MEDIA_CHANGED; ast_describe(stp); atadev->driver = stp; - return 0; + return 1; } void |