Device layer rollup commit.
[dragonfly.git] / sys / bus / cam / scsi / scsi_cd.c
index da19387..1a073df 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.31.2.16 2003/10/21 22:26:11 thomas Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.10 2003/12/29 06:42:10 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.15 2004/05/19 22:52:38 dillon Exp $
  */
 /*
  * Portions of this driver taken from the original FreeBSD cd driver.
@@ -302,7 +302,7 @@ static struct cdevsw cd_cdevsw = {
        /* maj */       SCSICD_CDEV_MAJOR,
        /* flags */     D_DISK,
        /* port */      NULL,
-       /* autoq */     0,
+       /* clone */     NULL,
 
        /* open */      cdopen,
        /* close */     cdclose,
@@ -333,7 +333,6 @@ static int changer_max_busy_seconds = CHANGER_MAX_BUSY_SECONDS;
  * XXX KDM this CAM node should be moved if we ever get more CAM sysctl
  * variables.
  */
-SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem");
 SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver");
 SYSCTL_NODE(_kern_cam_cd, OID_AUTO, changer, CTLFLAG_RD, 0, "CD Changer");
 SYSCTL_INT(_kern_cam_cd_changer, OID_AUTO, min_busy_seconds, CTLFLAG_RW,
@@ -546,7 +545,7 @@ cdcleanup(struct cam_periph *periph)
        }
        devstat_remove_entry(&softc->device_stats);
        cam_extend_release(cdperiphs, periph->unit_number);
-       if (softc->disk.d_dev) {
+       if (softc->disk.d_rawdev) {
                disk_destroy(&softc->disk);
        }
        free(softc, M_DEVBUF);
@@ -707,15 +706,7 @@ cdregister(struct cam_periph *periph, void *arg)
                return(CAM_REQ_CMP_ERR);
        }
 
-       softc = (struct cd_softc *)malloc(sizeof(*softc),M_DEVBUF,M_NOWAIT);
-
-       if (softc == NULL) {
-               printf("cdregister: Unable to probe new device. "
-                      "Unable to allocate softc\n");                           
-               return(CAM_REQ_CMP_ERR);
-       }
-
-       bzero(softc, sizeof(*softc));
+       softc = malloc(sizeof(*softc), M_DEVBUF, M_INTWAIT | M_ZERO);
        LIST_INIT(&softc->pending_ccbs);
        STAILQ_INIT(&softc->mode_queue);
        softc->state = CD_STATE_PROBE;
@@ -921,23 +912,7 @@ cdregister(struct cam_periph *periph, void *arg)
                 */
                else {
                        nchanger = malloc(sizeof(struct cdchanger),
-                               M_DEVBUF, M_NOWAIT);
-
-                       if (nchanger == NULL) {
-                               softc->flags &= ~CD_FLAG_CHANGER;
-                               printf("cdregister: unable to malloc "
-                                      "changer structure\ncdregister: "
-                                      "changer support disabled\n");
-
-                               /*
-                                * Yes, gotos can be gross but in this case
-                                * I think it's justified..
-                                */
-                               goto cdregisterexit;
-                       }
-
-                       /* zero the structure */
-                       bzero(nchanger, sizeof(struct cdchanger));
+                               M_DEVBUF, M_INTWAIT | M_ZERO);
 
                        if (camq_init(&nchanger->devq, 1) != 0) {
                                softc->flags &= ~CD_FLAG_CHANGER;
@@ -1631,15 +1606,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
        case CD_STATE_PROBE:
        {
 
-               rcap = (struct scsi_read_capacity_data *)malloc(sizeof(*rcap),
-                                                               M_TEMP,
-                                                               M_NOWAIT);
-               if (rcap == NULL) {
-                       xpt_print_path(periph->path);
-                       printf("cdstart: Couldn't malloc read_capacity data\n");
-                       /* cd_free_periph??? */
-                       break;
-               }
+               rcap = malloc(sizeof(*rcap), M_TEMP, M_INTWAIT);
                csio = &start_ccb->csio;
                scsi_read_capacity(csio,
                                   /*retries*/1,
@@ -2889,7 +2856,7 @@ cdcheckmedia(struct cam_periph *periph)
                         * We don't bother checking the return value here,
                         * since we already have an error...
                         */
-                       dsioctl(softc->disk.d_dev, DIOCSYNCSLICEINFO,
+                       dsioctl(softc->disk.d_cdev, DIOCSYNCSLICEINFO,
                                /*data*/(caddr_t)&force, /*flags*/ 0,
                                &softc->disk.d_slice);
                }
@@ -2920,7 +2887,7 @@ cdcheckmedia(struct cam_periph *periph)
 
                        force = 1;
 
-                       error = dsioctl(softc->disk.d_dev, DIOCSYNCSLICEINFO,
+                       error = dsioctl(softc->disk.d_cdev, DIOCSYNCSLICEINFO,
                                        /*data*/(caddr_t)&force, /*flags*/ 0,
                                        &softc->disk.d_slice);
                        if (error != 0) {
@@ -3092,7 +3059,7 @@ cdsize(struct cam_periph *periph, u_int32_t *size)
        ccb = cdgetccb(periph, /* priority */ 1);
 
        rcap_buf = malloc(sizeof(struct scsi_read_capacity_data), 
-                         M_TEMP, M_WAITOK);
+                         M_TEMP, M_INTWAIT | M_ZERO);
 
        scsi_read_capacity(&ccb->csio, 
                           /*retries*/ 1,
@@ -3950,9 +3917,10 @@ cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
        }
 
        if (length != 0) {
-               databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
-       } else
+               databuf = malloc(length, M_DEVBUF, M_INTWAIT | M_ZERO);
+       } else {
                databuf = NULL;
+       }
 
 
        scsi_report_key(&ccb->csio,
@@ -4083,7 +4051,7 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
 
                length = sizeof(*challenge_data);
 
-               challenge_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
+               challenge_data = malloc(length, M_DEVBUF, M_INTWAIT | M_ZERO);
 
                databuf = (u_int8_t *)challenge_data;
 
@@ -4100,7 +4068,7 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
 
                length = sizeof(*key2_data);
 
-               key2_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
+               key2_data = malloc(length, M_DEVBUF, M_INTWAIT | M_ZERO);
 
                databuf = (u_int8_t *)key2_data;
 
@@ -4117,7 +4085,7 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo)
 
                length = sizeof(*rpc_data);
 
-               rpc_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
+               rpc_data = malloc(length, M_DEVBUF, M_INTWAIT | M_ZERO);
 
                databuf = (u_int8_t *)rpc_data;
 
@@ -4259,9 +4227,10 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct)
        }
 
        if (length != 0) {
-               databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
-       } else
+               databuf = malloc(length, M_DEVBUF, M_INTWAIT | M_ZERO);
+       } else {
                databuf = NULL;
+       }
 
        scsi_read_dvd_structure(&ccb->csio,
                                /* retries */ 1,