aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-09-25 12:42:03 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:52:41 -0400
commit687d2bc4877081a44c41b5b312e012cc69edda53 (patch)
tree8daf04207eb3fb61fe50aa1c051d09e9060e3de6 /drivers/scsi
parent9ec76fbf7d6da3e98070a7059699d0ca019b0c9b (diff)
[SCSI] gdth: Stop abusing ->done for internal commands
The ->done member was being used to mark commands as being internal. I decided to put a magic number in ->underflow instead. I believe this to be safe as no current user of ->underflow has any of the bottom 9 bits set. Signed-off-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/gdth.c19
-rw-r--r--drivers/scsi/gdth_proc.c4
2 files changed, 13 insertions, 10 deletions
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index b20c188cc529..317a2826af05 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -692,6 +692,9 @@ static const struct file_operations gdth_fops = {
692 .release = gdth_close, 692 .release = gdth_close,
693}; 693};
694 694
695#define GDTH_MAGIC 0xc2e7c389 /* I got it from /dev/urandom */
696#define IS_GDTH_INTERNAL_CMD(scp) (scp->underflow == GDTH_MAGIC)
697
695#include "gdth_proc.h" 698#include "gdth_proc.h"
696#include "gdth_proc.c" 699#include "gdth_proc.c"
697 700
@@ -715,7 +718,7 @@ static void gdth_scsi_done(struct scsi_cmnd *scp)
715{ 718{
716 TRACE2(("gdth_scsi_done()\n")); 719 TRACE2(("gdth_scsi_done()\n"));
717 720
718 if (scp->request) 721 if (IS_GDTH_INTERNAL_CMD(scp))
719 complete((struct completion *)scp->request); 722 complete((struct completion *)scp->request);
720} 723}
721 724
@@ -738,7 +741,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
738 scp->cmd_len = 12; 741 scp->cmd_len = 12;
739 memcpy(scp->cmnd, cmnd, 12); 742 memcpy(scp->cmnd, cmnd, 12);
740 scp->SCp.this_residual = IOCTL_PRI; /* priority */ 743 scp->SCp.this_residual = IOCTL_PRI; /* priority */
741 scp->done = gdth_scsi_done; /* some fn. test this */ 744 scp->underflow = GDTH_MAGIC;
742 gdth_queuecommand(scp, gdth_scsi_done); 745 gdth_queuecommand(scp, gdth_scsi_done);
743 wait_for_completion(&wait); 746 wait_for_completion(&wait);
744 747
@@ -2355,7 +2358,7 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
2355 ha = HADATA(gdth_ctr_tab[hanum]); 2358 ha = HADATA(gdth_ctr_tab[hanum]);
2356 spin_lock_irqsave(&ha->smp_lock, flags); 2359 spin_lock_irqsave(&ha->smp_lock, flags);
2357 2360
2358 if (scp->done != gdth_scsi_done) { 2361 if (!IS_GDTH_INTERNAL_CMD(scp)) {
2359 scp->SCp.this_residual = (int)priority; 2362 scp->SCp.this_residual = (int)priority;
2360 b = virt_ctr ? NUMDATA(scp->device->host)->busnum:scp->device->channel; 2363 b = virt_ctr ? NUMDATA(scp->device->host)->busnum:scp->device->channel;
2361 t = scp->device->id; 2364 t = scp->device->id;
@@ -2418,7 +2421,7 @@ static void gdth_next(int hanum)
2418 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) { 2421 for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
2419 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr) 2422 if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
2420 pscp = (Scsi_Cmnd *)pscp->SCp.ptr; 2423 pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
2421 if (nscp->done != gdth_scsi_done) { 2424 if (!IS_GDTH_INTERNAL_CMD(nscp)) {
2422 b = virt_ctr ? 2425 b = virt_ctr ?
2423 NUMDATA(nscp->device->host)->busnum : nscp->device->channel; 2426 NUMDATA(nscp->device->host)->busnum : nscp->device->channel;
2424 t = nscp->device->id; 2427 t = nscp->device->id;
@@ -2444,7 +2447,7 @@ static void gdth_next(int hanum)
2444 firsttime = FALSE; 2447 firsttime = FALSE;
2445 } 2448 }
2446 2449
2447 if (nscp->done != gdth_scsi_done) { 2450 if (!IS_GDTH_INTERNAL_CMD(nscp)) {
2448 if (nscp->SCp.phase == -1) { 2451 if (nscp->SCp.phase == -1) {
2449 nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */ 2452 nscp->SCp.phase = CACHESERVICE; /* default: cache svc. */
2450 if (nscp->cmnd[0] == TEST_UNIT_READY) { 2453 if (nscp->cmnd[0] == TEST_UNIT_READY) {
@@ -2507,7 +2510,7 @@ static void gdth_next(int hanum)
2507 else 2510 else
2508 nscp->scsi_done(nscp); 2511 nscp->scsi_done(nscp);
2509 } 2512 }
2510 } else if (nscp->done == gdth_scsi_done) { 2513 } else if (IS_GDTH_INTERNAL_CMD(nscp)) {
2511 if (!(cmd_index=gdth_special_cmd(hanum,nscp))) 2514 if (!(cmd_index=gdth_special_cmd(hanum,nscp)))
2512 this_cmd = FALSE; 2515 this_cmd = FALSE;
2513 next_cmd = FALSE; 2516 next_cmd = FALSE;
@@ -3848,7 +3851,7 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
3848 scp->sense_buffer[2] = NOT_READY; 3851 scp->sense_buffer[2] = NOT_READY;
3849 scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1); 3852 scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
3850 } 3853 }
3851 if (scp->done != gdth_scsi_done) { 3854 if (!IS_GDTH_INTERNAL_CMD(scp)) {
3852 ha->dvr.size = sizeof(ha->dvr.eu.sync); 3855 ha->dvr.size = sizeof(ha->dvr.eu.sync);
3853 ha->dvr.eu.sync.ionode = hanum; 3856 ha->dvr.eu.sync.ionode = hanum;
3854 ha->dvr.eu.sync.service = service; 3857 ha->dvr.eu.sync.service = service;
@@ -4945,7 +4948,7 @@ static int gdth_queuecommand(Scsi_Cmnd *scp,void (*done)(Scsi_Cmnd *))
4945#endif 4948#endif
4946 4949
4947 priority = DEFAULT_PRI; 4950 priority = DEFAULT_PRI;
4948 if (scp->done == gdth_scsi_done) 4951 if (IS_GDTH_INTERNAL_CMD(scp))
4949 priority = scp->SCp.this_residual; 4952 priority = scp->SCp.this_residual;
4950 else 4953 else
4951 gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6); 4954 gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6);
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 32982eb75c84..1f8d9a53003b 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -805,7 +805,7 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
805 spin_lock_irqsave(&ha->smp_lock, flags); 805 spin_lock_irqsave(&ha->smp_lock, flags);
806 806
807 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 807 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
808 if (scp->done != gdth_scsi_done) { 808 if (!IS_GDTH_INTERNAL_CMD(scp)) {
809 b = virt_ctr ? 809 b = virt_ctr ?
810 NUMDATA(scp->device->host)->busnum : scp->device->channel; 810 NUMDATA(scp->device->host)->busnum : scp->device->channel;
811 t = scp->device->id; 811 t = scp->device->id;
@@ -829,7 +829,7 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
829 spin_lock_irqsave(&ha->smp_lock, flags); 829 spin_lock_irqsave(&ha->smp_lock, flags);
830 830
831 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { 831 for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
832 if (scp->done != gdth_scsi_done) { 832 if (!IS_GDTH_INTERNAL_CMD(scp)) {
833 b = virt_ctr ? 833 b = virt_ctr ?
834 NUMDATA(scp->device->host)->busnum : scp->device->channel; 834 NUMDATA(scp->device->host)->busnum : scp->device->channel;
835 t = scp->device->id; 835 t = scp->device->id;