aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sr.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@steeleye.com>2005-06-12 23:21:29 -0400
committerJames Bottomley <jejb@titanic.(none)>2005-08-28 12:34:07 -0400
commit820732b501a5bbdd3bde1263f391891e21b5ed8c (patch)
treecaf927bfbc9bd83ae0812e02d59456117106c97c /drivers/scsi/sr.c
parentea73a9f23906c374b697cd5b0d64f6dceced63de (diff)
[SCSI] convert sr to scsi_execute_req
This follows almost the identical model to sd, except that there's one ioctl which returns raw sense data, so it had to use scsi_execute() instead. Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r--drivers/scsi/sr.c49
1 files changed, 10 insertions, 39 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 8cbe6e00418..39fc5b0fbc1 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -50,10 +50,10 @@
50#include <scsi/scsi_dbg.h> 50#include <scsi/scsi_dbg.h>
51#include <scsi/scsi_device.h> 51#include <scsi/scsi_device.h>
52#include <scsi/scsi_driver.h> 52#include <scsi/scsi_driver.h>
53#include <scsi/scsi_cmnd.h>
53#include <scsi/scsi_eh.h> 54#include <scsi/scsi_eh.h>
54#include <scsi/scsi_host.h> 55#include <scsi/scsi_host.h>
55#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */ 56#include <scsi/scsi_ioctl.h> /* For the door lock/unlock commands */
56#include <scsi/scsi_request.h>
57 57
58#include "scsi_logging.h" 58#include "scsi_logging.h"
59#include "sr.h" 59#include "sr.h"
@@ -658,39 +658,27 @@ static void get_sectorsize(struct scsi_cd *cd)
658 unsigned char *buffer; 658 unsigned char *buffer;
659 int the_result, retries = 3; 659 int the_result, retries = 3;
660 int sector_size; 660 int sector_size;
661 struct scsi_request *SRpnt = NULL;
662 request_queue_t *queue; 661 request_queue_t *queue;
663 662
664 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 663 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
665 if (!buffer) 664 if (!buffer)
666 goto Enomem; 665 goto Enomem;
667 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
668 if (!SRpnt)
669 goto Enomem;
670 666
671 do { 667 do {
672 cmd[0] = READ_CAPACITY; 668 cmd[0] = READ_CAPACITY;
673 memset((void *) &cmd[1], 0, 9); 669 memset((void *) &cmd[1], 0, 9);
674 /* Mark as really busy */
675 SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
676 SRpnt->sr_cmd_len = 0;
677
678 memset(buffer, 0, 8); 670 memset(buffer, 0, 8);
679 671
680 /* Do the command and wait.. */ 672 /* Do the command and wait.. */
681 SRpnt->sr_data_direction = DMA_FROM_DEVICE; 673 the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
682 scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, 674 buffer, 8, NULL, SR_TIMEOUT,
683 8, SR_TIMEOUT, MAX_RETRIES); 675 MAX_RETRIES);
684 676
685 the_result = SRpnt->sr_result;
686 retries--; 677 retries--;
687 678
688 } while (the_result && retries); 679 } while (the_result && retries);
689 680
690 681
691 scsi_release_request(SRpnt);
692 SRpnt = NULL;
693
694 if (the_result) { 682 if (the_result) {
695 cd->capacity = 0x1fffff; 683 cd->capacity = 0x1fffff;
696 sector_size = 2048; /* A guess, just in case */ 684 sector_size = 2048; /* A guess, just in case */
@@ -750,8 +738,6 @@ Enomem:
750 cd->capacity = 0x1fffff; 738 cd->capacity = 0x1fffff;
751 sector_size = 2048; /* A guess, just in case */ 739 sector_size = 2048; /* A guess, just in case */
752 cd->needs_sector_size = 1; 740 cd->needs_sector_size = 1;
753 if (SRpnt)
754 scsi_release_request(SRpnt);
755 goto out; 741 goto out;
756} 742}
757 743
@@ -759,8 +745,8 @@ static void get_capabilities(struct scsi_cd *cd)
759{ 745{
760 unsigned char *buffer; 746 unsigned char *buffer;
761 struct scsi_mode_data data; 747 struct scsi_mode_data data;
762 struct scsi_request *SRpnt;
763 unsigned char cmd[MAX_COMMAND_SIZE]; 748 unsigned char cmd[MAX_COMMAND_SIZE];
749 struct scsi_sense_hdr sshdr;
764 unsigned int the_result; 750 unsigned int the_result;
765 int retries, rc, n; 751 int retries, rc, n;
766 752
@@ -776,19 +762,11 @@ static void get_capabilities(struct scsi_cd *cd)
776 "" 762 ""
777 }; 763 };
778 764
779 /* allocate a request for the TEST_UNIT_READY */
780 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
781 if (!SRpnt) {
782 printk(KERN_WARNING "(get_capabilities:) Request allocation "
783 "failure.\n");
784 return;
785 }
786 765
787 /* allocate transfer buffer */ 766 /* allocate transfer buffer */
788 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 767 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
789 if (!buffer) { 768 if (!buffer) {
790 printk(KERN_ERR "sr: out of memory.\n"); 769 printk(KERN_ERR "sr: out of memory.\n");
791 scsi_release_request(SRpnt);
792 return; 770 return;
793 } 771 }
794 772
@@ -800,20 +778,15 @@ static void get_capabilities(struct scsi_cd *cd)
800 memset((void *)cmd, 0, MAX_COMMAND_SIZE); 778 memset((void *)cmd, 0, MAX_COMMAND_SIZE);
801 cmd[0] = TEST_UNIT_READY; 779 cmd[0] = TEST_UNIT_READY;
802 780
803 SRpnt->sr_cmd_len = 0; 781 the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
804 SRpnt->sr_sense_buffer[0] = 0; 782 0, &sshdr, SR_TIMEOUT,
805 SRpnt->sr_sense_buffer[2] = 0; 783 MAX_RETRIES);
806 SRpnt->sr_data_direction = DMA_NONE;
807
808 scsi_wait_req (SRpnt, (void *) cmd, buffer,
809 0, SR_TIMEOUT, MAX_RETRIES);
810 784
811 the_result = SRpnt->sr_result;
812 retries++; 785 retries++;
813 } while (retries < 5 && 786 } while (retries < 5 &&
814 (!scsi_status_is_good(the_result) || 787 (!scsi_status_is_good(the_result) ||
815 ((driver_byte(the_result) & DRIVER_SENSE) && 788 (scsi_sense_valid(&sshdr) &&
816 SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION))); 789 sshdr.sense_key == UNIT_ATTENTION)));
817 790
818 /* ask for mode page 0x2a */ 791 /* ask for mode page 0x2a */
819 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, 792 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
@@ -825,7 +798,6 @@ static void get_capabilities(struct scsi_cd *cd)
825 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | 798 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
826 CDC_DVD | CDC_DVD_RAM | 799 CDC_DVD | CDC_DVD_RAM |
827 CDC_SELECT_DISC | CDC_SELECT_SPEED); 800 CDC_SELECT_DISC | CDC_SELECT_SPEED);
828 scsi_release_request(SRpnt);
829 kfree(buffer); 801 kfree(buffer);
830 printk("%s: scsi-1 drive\n", cd->cdi.name); 802 printk("%s: scsi-1 drive\n", cd->cdi.name);
831 return; 803 return;
@@ -885,7 +857,6 @@ static void get_capabilities(struct scsi_cd *cd)
885 cd->device->writeable = 1; 857 cd->device->writeable = 1;
886 } 858 }
887 859
888 scsi_release_request(SRpnt);
889 kfree(buffer); 860 kfree(buffer);
890} 861}
891 862