X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fscsi%2Fsr.c;h=f9c1192dc15eca635b7d866486956aa5edecc925;hb=2cc432eed0491df66e14b578139bba2c75fb3f9a;hp=d68cea753bb2222629db977d5ebf37614dc9c093;hpb=333c47c847c90aaefde8b593054d9344106333b5;p=linux-2.6-omap-h63xx.git diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index d68cea753bb..f9c1192dc15 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,10 @@ #include "sr.h" +MODULE_DESCRIPTION("SCSI cdrom (sr) driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR); + #define SR_DISKS 256 #define MAX_RETRIES 3 @@ -90,7 +95,7 @@ static DEFINE_SPINLOCK(sr_index_lock); /* This semaphore is used to mediate the 0->1 reference get in the * face of object destruction (i.e. we can't allow a get on an * object after last put) */ -static DECLARE_MUTEX(sr_ref_sem); +static DEFINE_MUTEX(sr_ref_mutex); static int sr_open(struct cdrom_device_info *, int); static void sr_release(struct cdrom_device_info *); @@ -133,7 +138,7 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk) { struct scsi_cd *cd = NULL; - down(&sr_ref_sem); + mutex_lock(&sr_ref_mutex); if (disk->private_data == NULL) goto out; cd = scsi_cd(disk); @@ -146,18 +151,18 @@ static inline struct scsi_cd *scsi_cd_get(struct gendisk *disk) kref_put(&cd->kref, sr_kref_release); cd = NULL; out: - up(&sr_ref_sem); + mutex_unlock(&sr_ref_mutex); return cd; } -static inline void scsi_cd_put(struct scsi_cd *cd) +static void scsi_cd_put(struct scsi_cd *cd) { struct scsi_device *sdev = cd->device; - down(&sr_ref_sem); + mutex_lock(&sr_ref_mutex); kref_put(&cd->kref, sr_kref_release); scsi_device_put(sdev); - up(&sr_ref_sem); + mutex_unlock(&sr_ref_mutex); } /* @@ -237,8 +242,6 @@ static void rw_intr(struct scsi_cmnd * SCpnt) case ILLEGAL_REQUEST: if (!(SCpnt->sense_buffer[0] & 0x90)) break; - if (!blk_fs_request(SCpnt->request)) - break; error_sector = (SCpnt->sense_buffer[3] << 24) | (SCpnt->sense_buffer[4] << 16) | (SCpnt->sense_buffer[5] << 8) | @@ -316,37 +319,6 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) return 0; } - /* - * these are already setup, just copy cdb basically - */ - if (SCpnt->request->flags & REQ_BLOCK_PC) { - struct request *rq = SCpnt->request; - - if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd)) - return 0; - - memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd)); - SCpnt->cmd_len = rq->cmd_len; - if (!rq->data_len) - SCpnt->sc_data_direction = DMA_NONE; - else if (rq_data_dir(rq) == WRITE) - SCpnt->sc_data_direction = DMA_TO_DEVICE; - else - SCpnt->sc_data_direction = DMA_FROM_DEVICE; - - this_count = rq->data_len; - if (rq->timeout) - timeout = rq->timeout; - - SCpnt->transfersize = rq->data_len; - goto queue; - } - - if (!(SCpnt->request->flags & REQ_CMD)) { - blk_dump_rq_flags(SCpnt->request, "sr unsup command"); - return 0; - } - /* * we do lazy blocksize switching (when reading XA sectors, * see CDROMREADMODE2 ioctl) @@ -435,8 +407,6 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) */ SCpnt->transfersize = cd->device->sector_size; SCpnt->underflow = this_count << 9; - -queue: SCpnt->allowed = MAX_RETRIES; SCpnt->timeout_per_command = timeout; @@ -559,10 +529,9 @@ static int sr_probe(struct device *dev) goto fail; error = -ENOMEM; - cd = kmalloc(sizeof(*cd), GFP_KERNEL); + cd = kzalloc(sizeof(*cd), GFP_KERNEL); if (!cd) goto fail; - memset(cd, 0, sizeof(*cd)); kref_init(&cd->kref); @@ -608,8 +577,6 @@ static int sr_probe(struct device *dev) get_capabilities(cd); sr_vendor_init(cd); - snprintf(disk->devfs_name, sizeof(disk->devfs_name), - "%s/cd", sdev->devfs_name); disk->driverfs_dev = &sdev->sdev_gendev; set_capacity(disk, cd->capacity); disk->private_data = &cd->driver; @@ -730,7 +697,7 @@ static void get_capabilities(struct scsi_cd *cd) unsigned int the_result; int retries, rc, n; - static char *loadmech[] = + static const char *loadmech[] = { "caddy", "tray", @@ -776,8 +743,9 @@ static void get_capabilities(struct scsi_cd *cd) /* failed, drive doesn't have capabilities mode page */ cd->cdi.speed = 1; cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | - CDC_DVD | CDC_DVD_RAM | - CDC_SELECT_DISC | CDC_SELECT_SPEED); + CDC_DVD | CDC_DVD_RAM | + CDC_SELECT_DISC | CDC_SELECT_SPEED | + CDC_MRW | CDC_MRW_W | CDC_RAM); kfree(buffer); printk("%s: scsi-1 drive\n", cd->cdi.name); return; @@ -859,7 +827,7 @@ static int sr_packet(struct cdrom_device_info *cdi, * sr_kref_release - Called to free the scsi_cd structure * @kref: pointer to embedded kref * - * sr_ref_sem must be held entering this routine. Because it is + * sr_ref_mutex must be held entering this routine. Because it is * called on last put, you should always use the scsi_cd_get() * scsi_cd_put() helpers which manipulate the semaphore directly * and never do a direct kref_put(). @@ -888,9 +856,9 @@ static int sr_remove(struct device *dev) del_gendisk(cd->disk); - down(&sr_ref_sem); + mutex_lock(&sr_ref_mutex); kref_put(&cd->kref, sr_kref_release); - up(&sr_ref_sem); + mutex_unlock(&sr_ref_mutex); return 0; }