Misc little cleanups.

This commit is contained in:
Søren Schmidt 2002-03-26 09:31:22 +00:00
parent 6898f8c48e
commit d42c4a3ba6
5 changed files with 27 additions and 33 deletions

View File

@ -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));

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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