aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r--drivers/scsi/sr.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index f63d8c6c2a33..ce63fc8312dc 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"
@@ -642,39 +642,27 @@ static void get_sectorsize(struct scsi_cd *cd)
642 unsigned char *buffer; 642 unsigned char *buffer;
643 int the_result, retries = 3; 643 int the_result, retries = 3;
644 int sector_size; 644 int sector_size;
645 struct scsi_request *SRpnt = NULL;
646 request_queue_t *queue; 645 request_queue_t *queue;
647 646
648 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 647 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
649 if (!buffer) 648 if (!buffer)
650 goto Enomem; 649 goto Enomem;
651 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
652 if (!SRpnt)
653 goto Enomem;
654 650
655 do { 651 do {
656 cmd[0] = READ_CAPACITY; 652 cmd[0] = READ_CAPACITY;
657 memset((void *) &cmd[1], 0, 9); 653 memset((void *) &cmd[1], 0, 9);
658 /* Mark as really busy */
659 SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
660 SRpnt->sr_cmd_len = 0;
661
662 memset(buffer, 0, 8); 654 memset(buffer, 0, 8);
663 655
664 /* Do the command and wait.. */ 656 /* Do the command and wait.. */
665 SRpnt->sr_data_direction = DMA_FROM_DEVICE; 657 the_result = scsi_execute_req(cd->device, cmd, DMA_FROM_DEVICE,
666 scsi_wait_req(SRpnt, (void *) cmd, (void *) buffer, 658 buffer, 8, NULL, SR_TIMEOUT,
667 8, SR_TIMEOUT, MAX_RETRIES); 659 MAX_RETRIES);
668 660
669 the_result = SRpnt->sr_result;
670 retries--; 661 retries--;
671 662
672 } while (the_result && retries); 663 } while (the_result && retries);
673 664
674 665
675 scsi_release_request(SRpnt);
676 SRpnt = NULL;
677
678 if (the_result) { 666 if (the_result) {
679 cd->capacity = 0x1fffff; 667 cd->capacity = 0x1fffff;
680 sector_size = 2048; /* A guess, just in case */ 668 sector_size = 2048; /* A guess, just in case */
@@ -730,8 +718,6 @@ out:
730Enomem: 718Enomem:
731 cd->capacity = 0x1fffff; 719 cd->capacity = 0x1fffff;
732 cd->device->sector_size = 2048; /* A guess, just in case */ 720 cd->device->sector_size = 2048; /* A guess, just in case */
733 if (SRpnt)
734 scsi_release_request(SRpnt);
735 goto out; 721 goto out;
736} 722}
737 723
@@ -739,8 +725,8 @@ static void get_capabilities(struct scsi_cd *cd)
739{ 725{
740 unsigned char *buffer; 726 unsigned char *buffer;
741 struct scsi_mode_data data; 727 struct scsi_mode_data data;
742 struct scsi_request *SRpnt;
743 unsigned char cmd[MAX_COMMAND_SIZE]; 728 unsigned char cmd[MAX_COMMAND_SIZE];
729 struct scsi_sense_hdr sshdr;
744 unsigned int the_result; 730 unsigned int the_result;
745 int retries, rc, n; 731 int retries, rc, n;
746 732
@@ -756,19 +742,11 @@ static void get_capabilities(struct scsi_cd *cd)
756 "" 742 ""
757 }; 743 };
758 744
759 /* allocate a request for the TEST_UNIT_READY */
760 SRpnt = scsi_allocate_request(cd->device, GFP_KERNEL);
761 if (!SRpnt) {
762 printk(KERN_WARNING "(get_capabilities:) Request allocation "
763 "failure.\n");
764 return;
765 }
766 745
767 /* allocate transfer buffer */ 746 /* allocate transfer buffer */
768 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 747 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
769 if (!buffer) { 748 if (!buffer) {
770 printk(KERN_ERR "sr: out of memory.\n"); 749 printk(KERN_ERR "sr: out of memory.\n");
771 scsi_release_request(SRpnt);
772 return; 750 return;
773 } 751 }
774 752
@@ -780,24 +758,19 @@ static void get_capabilities(struct scsi_cd *cd)
780 memset((void *)cmd, 0, MAX_COMMAND_SIZE); 758 memset((void *)cmd, 0, MAX_COMMAND_SIZE);
781 cmd[0] = TEST_UNIT_READY; 759 cmd[0] = TEST_UNIT_READY;
782 760
783 SRpnt->sr_cmd_len = 0; 761 the_result = scsi_execute_req (cd->device, cmd, DMA_NONE, NULL,
784 SRpnt->sr_sense_buffer[0] = 0; 762 0, &sshdr, SR_TIMEOUT,
785 SRpnt->sr_sense_buffer[2] = 0; 763 MAX_RETRIES);
786 SRpnt->sr_data_direction = DMA_NONE;
787
788 scsi_wait_req (SRpnt, (void *) cmd, buffer,
789 0, SR_TIMEOUT, MAX_RETRIES);
790 764
791 the_result = SRpnt->sr_result;
792 retries++; 765 retries++;
793 } while (retries < 5 && 766 } while (retries < 5 &&
794 (!scsi_status_is_good(the_result) || 767 (!scsi_status_is_good(the_result) ||
795 ((driver_byte(the_result) & DRIVER_SENSE) && 768 (scsi_sense_valid(&sshdr) &&
796 SRpnt->sr_sense_buffer[2] == UNIT_ATTENTION))); 769 sshdr.sense_key == UNIT_ATTENTION)));
797 770
798 /* ask for mode page 0x2a */ 771 /* ask for mode page 0x2a */
799 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128, 772 rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
800 SR_TIMEOUT, 3, &data); 773 SR_TIMEOUT, 3, &data, NULL);
801 774
802 if (!scsi_status_is_good(rc)) { 775 if (!scsi_status_is_good(rc)) {
803 /* failed, drive doesn't have capabilities mode page */ 776 /* failed, drive doesn't have capabilities mode page */
@@ -805,7 +778,6 @@ static void get_capabilities(struct scsi_cd *cd)
805 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R | 778 cd->cdi.mask |= (CDC_CD_R | CDC_CD_RW | CDC_DVD_R |
806 CDC_DVD | CDC_DVD_RAM | 779 CDC_DVD | CDC_DVD_RAM |
807 CDC_SELECT_DISC | CDC_SELECT_SPEED); 780 CDC_SELECT_DISC | CDC_SELECT_SPEED);
808 scsi_release_request(SRpnt);
809 kfree(buffer); 781 kfree(buffer);
810 printk("%s: scsi-1 drive\n", cd->cdi.name); 782 printk("%s: scsi-1 drive\n", cd->cdi.name);
811 return; 783 return;
@@ -865,7 +837,6 @@ static void get_capabilities(struct scsi_cd *cd)
865 cd->device->writeable = 1; 837 cd->device->writeable = 1;
866 } 838 }
867 839
868 scsi_release_request(SRpnt);
869 kfree(buffer); 840 kfree(buffer);
870} 841}
871 842