Commit b7625799 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] DAC960 switched to alloc_disk()

parent 455053c6
...@@ -1958,7 +1958,7 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller) ...@@ -1958,7 +1958,7 @@ static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
Controller->RequestQueue = RequestQueue; Controller->RequestQueue = RequestQueue;
for (n = 0; n < DAC960_MaxLogicalDrives; n++) { for (n = 0; n < DAC960_MaxLogicalDrives; n++) {
struct gendisk *disk = &Controller->disks[n]; struct gendisk *disk = Controller->disks[n];
memset(disk, 0, sizeof(struct gendisk)); memset(disk, 0, sizeof(struct gendisk));
sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n); sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
disk->major = MajorNumber; disk->major = MajorNumber;
...@@ -1983,7 +1983,7 @@ static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller) ...@@ -1983,7 +1983,7 @@ static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber; int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
int disk; int disk;
for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
del_gendisk(&Controller->disks[disk]); del_gendisk(Controller->disks[disk]);
/* /*
Unregister the Block Device Major Number for this DAC960 Controller. Unregister the Block Device Major Number for this DAC960 Controller.
*/ */
...@@ -2018,7 +2018,7 @@ static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller) ...@@ -2018,7 +2018,7 @@ static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
{ {
int disk; int disk;
for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
set_capacity(Controller->disks + disk, disk_size(Controller, disk)); set_capacity(Controller->disks[disk], disk_size(Controller, disk));
} }
static int DAC960_revalidate(kdev_t dev) static int DAC960_revalidate(kdev_t dev)
...@@ -2026,7 +2026,7 @@ static int DAC960_revalidate(kdev_t dev) ...@@ -2026,7 +2026,7 @@ static int DAC960_revalidate(kdev_t dev)
int ctlr = DAC960_ControllerNumber(dev); int ctlr = DAC960_ControllerNumber(dev);
int disk = DAC960_LogicalDriveNumber(dev); int disk = DAC960_LogicalDriveNumber(dev);
DAC960_Controller_T *p = DAC960_Controllers[ctlr]; DAC960_Controller_T *p = DAC960_Controllers[ctlr];
set_capacity(&p->disks[disk], disk_size(p, disk)); set_capacity(p->disks[disk], disk_size(p, disk));
return 0; return 0;
} }
...@@ -2099,6 +2099,7 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType) ...@@ -2099,6 +2099,7 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType)
unsigned short VendorID = 0, DeviceID = 0; unsigned short VendorID = 0, DeviceID = 0;
unsigned int MemoryWindowSize = 0; unsigned int MemoryWindowSize = 0;
PCI_Device_T *PCI_Device = NULL; PCI_Device_T *PCI_Device = NULL;
int i;
switch (HardwareType) switch (HardwareType)
{ {
case DAC960_BA_Controller: case DAC960_BA_Controller:
...@@ -2199,6 +2200,11 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType) ...@@ -2199,6 +2200,11 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType)
goto Failure; goto Failure;
} }
memset(Controller, 0, sizeof(DAC960_Controller_T)); memset(Controller, 0, sizeof(DAC960_Controller_T));
for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
Controller->disks[i] = alloc_disk();
if (!Controller->disks[i])
goto Enomem;
}
Controller->ControllerNumber = DAC960_ControllerCount; Controller->ControllerNumber = DAC960_ControllerCount;
init_waitqueue_head(&Controller->CommandWaitQueue); init_waitqueue_head(&Controller->CommandWaitQueue);
init_waitqueue_head(&Controller->HealthStatusWaitQueue); init_waitqueue_head(&Controller->HealthStatusWaitQueue);
...@@ -2455,6 +2461,12 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType) ...@@ -2455,6 +2461,12 @@ static void DAC960_DetectControllers(DAC960_HardwareType_T HardwareType)
if (Controller->IRQ_Channel > 0) if (Controller->IRQ_Channel > 0)
free_irq(IRQ_Channel, Controller); free_irq(IRQ_Channel, Controller);
} }
return;
Enomem:
while (i--)
put_disk(Controller->disks[i]);
kfree(Controller);
goto Failure;
} }
...@@ -2493,7 +2505,10 @@ static void DAC960_SortControllers(void) ...@@ -2493,7 +2505,10 @@ static void DAC960_SortControllers(void)
DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber]; DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
if (!Controller->ControllerDetectionSuccessful) if (!Controller->ControllerDetectionSuccessful)
{ {
int i;
DAC960_Controllers[ControllerNumber] = NULL; DAC960_Controllers[ControllerNumber] = NULL;
for (i = 0; i < DAC960_MaxLogicalDrives; i++)
put_disk(Controller->disks[i]);
kfree(Controller); kfree(Controller);
} }
} }
...@@ -2534,6 +2549,7 @@ static void DAC960_InitializeController(DAC960_Controller_T *Controller) ...@@ -2534,6 +2549,7 @@ static void DAC960_InitializeController(DAC960_Controller_T *Controller)
static void DAC960_FinalizeController(DAC960_Controller_T *Controller) static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
{ {
int i;
if (Controller->ControllerInitialized) if (Controller->ControllerInitialized)
{ {
del_timer(&Controller->MonitoringTimer); del_timer(&Controller->MonitoringTimer);
...@@ -2578,6 +2594,8 @@ static void DAC960_FinalizeController(DAC960_Controller_T *Controller) ...@@ -2578,6 +2594,8 @@ static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
DAC960_UnregisterBlockDevice(Controller); DAC960_UnregisterBlockDevice(Controller);
DAC960_DestroyAuxiliaryStructures(Controller); DAC960_DestroyAuxiliaryStructures(Controller);
DAC960_Controllers[Controller->ControllerNumber] = NULL; DAC960_Controllers[Controller->ControllerNumber] = NULL;
for (i = 0; i < DAC960_MaxLogicalDrives; i++)
put_disk(Controller->disks[i]);
kfree(Controller); kfree(Controller);
} }
...@@ -2606,8 +2624,8 @@ static int DAC960_Initialize(void) ...@@ -2606,8 +2624,8 @@ static int DAC960_Initialize(void)
if (Controller == NULL) continue; if (Controller == NULL) continue;
DAC960_InitializeController(Controller); DAC960_InitializeController(Controller);
for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) { for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
set_capacity(&Controller->disks[disk], disk_size(Controller, disk)); set_capacity(Controller->disks[disk], disk_size(Controller, disk));
add_disk(&Controller->disks[disk]); add_disk(Controller->disks[disk]);
} }
} }
DAC960_CreateProcEntries(); DAC960_CreateProcEntries();
...@@ -5250,10 +5268,10 @@ static int DAC960_Open(Inode_T *Inode, File_T *File) ...@@ -5250,10 +5268,10 @@ static int DAC960_Open(Inode_T *Inode, File_T *File)
Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true; Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;
size = disk_size(Controller, LogicalDriveNumber); size = disk_size(Controller, LogicalDriveNumber);
/* BROKEN, same as modular ide-floppy/ide-disk; same fix - ->probe() */ /* BROKEN, same as modular ide-floppy/ide-disk; same fix - ->probe() */
set_capacity(&Controller->disks[LogicalDriveNumber], size); set_capacity(Controller->disks[LogicalDriveNumber], size);
add_disk(&Controller->disks[LogicalDriveNumber]); add_disk(Controller->disks[LogicalDriveNumber]);
} }
if (!get_capacity(&Controller->disks[LogicalDriveNumber])) if (!get_capacity(Controller->disks[LogicalDriveNumber]))
return -ENXIO; return -ENXIO;
/* /*
Increment Controller and Logical Drive Usage Counts. Increment Controller and Logical Drive Usage Counts.
......
...@@ -2360,7 +2360,7 @@ typedef struct DAC960_Controller ...@@ -2360,7 +2360,7 @@ typedef struct DAC960_Controller
boolean MonitoringAlertMode; boolean MonitoringAlertMode;
boolean SuppressEnclosureMessages; boolean SuppressEnclosureMessages;
Timer_T MonitoringTimer; Timer_T MonitoringTimer;
struct gendisk disks[DAC960_MaxLogicalDrives]; struct gendisk *disks[DAC960_MaxLogicalDrives];
DAC960_Command_T *FreeCommands; DAC960_Command_T *FreeCommands;
unsigned char *CombinedStatusBuffer; unsigned char *CombinedStatusBuffer;
unsigned char *CurrentStatusBuffer; unsigned char *CurrentStatusBuffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment