linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / block / DAC960.c
index 1c5e5c2..babd29e 100644 (file)
@@ -17,8 +17,8 @@
 */
 
 
-#define DAC960_DriverVersion                   "2.5.48"
-#define DAC960_DriverDate                      "14 May 2006"
+#define DAC960_DriverVersion                   "2.5.47"
+#define DAC960_DriverDate                      "14 November 2002"
 
 
 #include <linux/module.h>
@@ -41,7 +41,6 @@
 #include <linux/timer.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <linux/jiffies.h>
 #include <linux/random.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -229,7 +228,8 @@ static void *slice_dma_loaf(struct dma_loaf *loaf, size_t len,
        void *cpu_end = loaf->cpu_free + len;
        void *cpu_addr = loaf->cpu_free;
 
-       BUG_ON(cpu_end > loaf->cpu_base + loaf->length);
+       if (cpu_end > loaf->cpu_base + loaf->length)
+               BUG();
        *dma_handle = loaf->dma_free;
        loaf->cpu_free = cpu_end;
        loaf->dma_free += len;
@@ -312,10 +312,11 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
                CommandsRemaining = CommandAllocationGroupSize;
          CommandGroupByteCount =
                CommandsRemaining * CommandAllocationLength;
-         AllocationPointer = kzalloc(CommandGroupByteCount, GFP_ATOMIC);
+         AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC);
          if (AllocationPointer == NULL)
                return DAC960_Failure(Controller,
                                        "AUXILIARY STRUCTURE CREATION");
+         memset(AllocationPointer, 0, CommandGroupByteCount);
         }
       Command = (DAC960_Command_T *) AllocationPointer;
       AllocationPointer += CommandAllocationLength;
@@ -770,7 +771,7 @@ static void DAC960_P_QueueCommand(DAC960_Command_T *Command)
 static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
 {
   DAC960_Controller_T *Controller = Command->Controller;
-  DECLARE_COMPLETION_ONSTACK(Completion);
+  DECLARE_COMPLETION(Completion);
   unsigned long flags;
   Command->Completion = &Completion;
 
@@ -2530,6 +2531,7 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
        blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
        disk->queue = RequestQueue;
        sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
+       sprintf(disk->devfs_name, "rd/host%d/target%d", Controller->ControllerNumber, n);
        disk->major = MajorNumber;
        disk->first_minor = n << DAC960_MaxPartitionsBits;
        disk->fops = &DAC960_BlockDeviceOperations;
@@ -2708,12 +2710,14 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
   void __iomem *BaseAddress;
   int i;
 
-  Controller = kzalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
+  Controller = (DAC960_Controller_T *)
+       kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
   if (Controller == NULL) {
        DAC960_Error("Unable to allocate Controller structure for "
                        "Controller at\n", NULL);
        return NULL;
   }
+  memset(Controller, 0, sizeof(DAC960_Controller_T));
   Controller->ControllerNumber = DAC960_ControllerCount;
   DAC960_Controllers[DAC960_ControllerCount++] = Controller;
   Controller->Bus = PCI_Device->bus->number;
@@ -3014,7 +3018,7 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
      Acquire shared access to the IRQ Channel.
   */
   IRQ_Channel = PCI_Device->irq;
-  if (request_irq(IRQ_Channel, InterruptHandler, IRQF_SHARED,
+  if (request_irq(IRQ_Channel, InterruptHandler, SA_SHIRQ,
                      Controller->FullModelName, Controller) < 0)
   {
        DAC960_Error("Unable to acquire IRQ Channel %d for Controller at\n",
@@ -3654,8 +3658,8 @@ static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
              (NewEnquiry->EventLogSequenceNumber !=
               OldEnquiry->EventLogSequenceNumber) ||
              Controller->MonitoringTimerCount == 0 ||
-             time_after_eq(jiffies, Controller->SecondaryMonitoringTime
-              + DAC960_SecondaryMonitoringInterval))
+             (jiffies - Controller->SecondaryMonitoringTime
+              >= DAC960_SecondaryMonitoringInterval))
            {
              Controller->V1.NeedLogicalDriveInformation = true;
              Controller->V1.NewEventLogSequenceNumber =
@@ -4779,16 +4783,15 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
              (NewPhysicalDeviceInfo->LogicalUnit !=
               PhysicalDeviceInfo->LogicalUnit))
            {
-             PhysicalDeviceInfo =
+             PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
                kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
              InquiryUnitSerialNumber =
+               (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
                  kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
                          GFP_ATOMIC);
-             if (InquiryUnitSerialNumber == NULL ||
-                 PhysicalDeviceInfo == NULL)
+             if (InquiryUnitSerialNumber == NULL &&
+                 PhysicalDeviceInfo != NULL)
                {
-                 kfree(InquiryUnitSerialNumber);
-                 InquiryUnitSerialNumber = NULL;
                  kfree(PhysicalDeviceInfo);
                  PhysicalDeviceInfo = NULL;
                }
@@ -5641,8 +5644,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
       unsigned int StatusChangeCounter =
        Controller->V2.HealthStatusBuffer->StatusChangeCounter;
       boolean ForceMonitoringCommand = false;
-      if (time_after(jiffies, Controller->SecondaryMonitoringTime
-         + DAC960_SecondaryMonitoringInterval))
+      if (jiffies - Controller->SecondaryMonitoringTime
+         > DAC960_SecondaryMonitoringInterval)
        {
          int LogicalDriveNumber;
          for (LogicalDriveNumber = 0;
@@ -5670,8 +5673,8 @@ static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
           ControllerInfo->ConsistencyChecksActive +
           ControllerInfo->RebuildsActive +
           ControllerInfo->OnlineExpansionsActive == 0 ||
-          time_before(jiffies, Controller->PrimaryMonitoringTime
-          + DAC960_MonitoringTimerInterval)) &&
+          jiffies - Controller->PrimaryMonitoringTime
+          < DAC960_MonitoringTimerInterval) &&
          !ForceMonitoringCommand)
        {
          Controller->MonitoringTimer.expires =
@@ -5808,8 +5811,8 @@ static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
       Controller->ProgressBufferLength = Length;
       if (Controller->EphemeralProgressMessage)
        {
-         if (time_after_eq(jiffies, Controller->LastProgressReportTime
-             + DAC960_ProgressReportingInterval))
+         if (jiffies - Controller->LastProgressReportTime
+             >= DAC960_ProgressReportingInterval)
            {
              printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
                     Controller->ControllerNumber, Buffer);
@@ -6229,9 +6232,6 @@ static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
   unsigned long flags;
   unsigned char Channel, TargetID, LogicalDriveNumber;
   unsigned short LogicalDeviceNumber;
-  wait_queue_t __wait;
-  
-  init_waitqueue_entry(&__wait, current);
 
   spin_lock_irqsave(&Controller->queue_lock, flags);
   while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
@@ -6414,18 +6414,11 @@ static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
                                        .SegmentByteCount =
            CommandMailbox->ControllerInfo.DataTransferSize;
          DAC960_ExecuteCommand(Command);
-         add_wait_queue(&Controller->CommandWaitQueue, &__wait);
-         set_current_state(TASK_UNINTERRUPTIBLE);
-         
          while (Controller->V2.NewControllerInformation->PhysicalScanActive)
            {
              DAC960_ExecuteCommand(Command);
-             schedule_timeout(HZ);
-             set_current_state(TASK_UNINTERRUPTIBLE);
+             sleep_on_timeout(&Controller->CommandWaitQueue, HZ);
            }
-         current->state = TASK_RUNNING;
-         remove_wait_queue(&Controller->CommandWaitQueue, &__wait);
-          
          DAC960_UserCritical("Discovery Completed\n", Controller);
        }
     }
@@ -7221,4 +7214,3 @@ module_init(DAC960_init_module);
 module_exit(DAC960_cleanup_module);
 
 MODULE_LICENSE("GPL");
-MODULE_VERSION(DAC960_DriverVersion);