iteraid: misc trivial cleanups
PATCH 2/3 iteraid: misc trivial cleanups
* Fix noticed typos.
* Use C99 initializers.
* Remove unneeded prorotypes.
* Remove useless comments.
* Shrink vertical whitespace a bit. /************************************************************************
* Remove banners. ************************************************************************/
Signed-off-by Alexey Dobriyan <[email protected]>
---
drivers/scsi/iteraid.c | 497 +++++++++++++++---------------------------------- drivers/scsi/iteraid.h | 273 ++++++++------------------ 2 files changed, 240 insertions(+), 530 deletions(-)
drivers/scsi/iteraid.c +156 -341
@@ -70,7 +70,7 @@* ATAPI support ---> schedule is three weeks. (2003/02/28) * * Revision 1.3 2003/02/27 -* First relase ATAPI version. But there will be an error if no disc in the +* First release ATAPI version. But there will be an error if no disc in the * CD-ROM. Because the commands like TEST_UNIT_READY and READ_CAPACITY will * get the error response. This situration in WINDOWS will be then send the * REQUEST SENSE command to the device but in Linux, it will never get
@@ -274,39 +274,24 @@ static Scsi_Cmnd *it8212_req_last = NULLstatic unsigned int NumAdapters =0 ;/* Adapters number */ static PITE_ADAPTER ite_adapters[2 ];/* How many adapters support */ -/************************************************************************ -* Notifier blockto get a notify on system shutdown/halt/reboot. -************************************************************************/ +/* +* Notifier block to get a notify on system shutdown/halt/reboot. +*/ static int ite_halt (struct notifier_block *nb,ulong event,void *buf); -static struct notifier_block ite_notifier = { ite_halt,NULL ,0 +static struct notifier_block ite_notifier = { + .notifier_call = ite_halt, + .next =NULL , + .priority =0 };static struct semaphore mimd_entry_mtx;static spinlock_t queue_request_lock =SPIN_LOCK_UNLOCKED ;static spinlock_t io_request_lock =SPIN_LOCK_UNLOCKED ; -static int iteraid_detect (Scsi_Host_Template *); -static int iteraid_release (struct Scsi_Host *); -#if 0 -static int iteraid_command (Scsi_Cmnd *); -#endif -static int iteraid_queuecommand (Scsi_Cmnd *,void (*done) (Scsi_Cmnd *)); -static int iteraid_biosparam (struct scsi_device *,struct block_device *, -sector_t ,int *); -static int iteraid_proc_info (struct Scsi_Host *,char *buffer,char **start, -off_t offset,int length,int inout); - -static void TaskStart (PChannel ,Scsi_Cmnd *);static void TaskQueue (void );static void TaskDone (PChannel ,PSCSI_REQUEST_BLOCK ); -static u32 IdeSendCommand (PChannel ,PSCSI_REQUEST_BLOCK ); -//static void IdeMediaStatus(u8, PChannel, u8); -static void IdeSetupDma (PChannel ,unsigned long ,unsigned short ); -static void MapRequest (Scsi_Cmnd *,PSCSI_REQUEST_BLOCK );static u8 IssueIdentify (PChannel ,u8 ,u8 );static u8 IT8212ResetAdapter (PITE_ADAPTER ); -static void AtapiStartIo (PChannel ,PSCSI_REQUEST_BLOCK );static u8 AtapiInterrupt (PChannel ); -static void AtapiResetController (PITE_ADAPTER pAdap,PChannel pChan);static int itedev_open (struct inode *,struct file *); static int itedev_ioctl_entry(struct inode *, struct file *, unsigned int,
@@ -315,23 +300,21 @@ static int itedev_ioctl(struct inode *, unsigned long);static int itedev_close (struct inode *,struct file *); -#define DRV_VER_8212 "1.45" -static int driver_ver =145 ;/* Current driver version */ -static int ite_major =0 ;/* itedev chardev major number */ +static int driver_ver =145 ; +static int ite_major =0 ; -/************************************************************************ -* The File Operations structure for the ioctl interface of the driver. -************************************************************************/ -static struct file_operations itedev_fops = - {.owner =THIS_MODULE ,.ioctl = itedev_ioctl_entry,.open = -itedev_open,.release = itedev_close +static struct file_operations itedev_fops = { + .owner =THIS_MODULE , + .ioctl = itedev_ioctl_entry, + .open = itedev_open, + .release = itedev_close };#if (MARK_DEBUG_DUMP_MEM ) -/************************************************************************ +/* * Dump buffer. -************************************************************************/ +*/ static void HexDump (unsigned char *buf,int length) {unsigned int i =0 ;
@@ -351,9 +334,9 @@ static void HexDump(unsigned char *buf, } /* end HexDump */#endif -/************************************************************************ +/* * This routine maps ATAPI and IDE errors to specific SRB statuses. -************************************************************************/ +*/ static u8 MapError (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u8 errorByte;
@@ -569,25 +552,9 @@ static u8 MapError(PChannel pChan, PSCSIreturn srbStatus; }/* end MapError */ -#if 0 -/************************************************************************ -* Just get the higest bit value. -************************************************************************/ -static u8 RaidGetHighestBit (u8 Number) -{ -char bit; - -for (bit =7 ; bit >=0 ; bit--) { -if (Number & (1 << bit)) -return bit; - } -return 0xFF ; -}/* end RaidGetHighestBit */ -#endif - -/************************************************************************ +/* * Reset IDE controller or ATAPI device. -************************************************************************/ +*/ static void AtapiResetController (PITE_ADAPTER pAdap,PChannel pChan) {u8 resetResult;
@@ -681,9 +648,9 @@ static void AtapiResetController(PITE_ADprintk ("AtapiResetController exit\n" ); }/* end AtapiResetController */ -/************************************************************************ +/* * IDE start read/write transfer. -************************************************************************/ +*/ static void IdeStartTransfer (PChannel pChan,PSCSI_REQUEST_BLOCK Srb,u32 startingSector,u32 SectorNumber) {
@@ -815,9 +782,9 @@ static void IdeStartTransfer(PChannel pCdprintk ("IdeStartTransfer exit\n" ); }/* end IdeStartTransfer */ -/************************************************************************ +/* * Setup the PRD table. -************************************************************************/ +*/ static int IdeBuildSglist (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {int nents =0 ;
@@ -840,9 +807,9 @@ static int IdeBuildSglist(PChannel pChanreturn pci_map_sg (pChan->pPciDev, sg, nents, pChan->sg_dma_direction); }/* end IdeBuildSglist */ -/************************************************************************ +/* * Prepares a dma request. -************************************************************************/ +*/ static int IdeBuildDmaTable (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {unsigned long *table = pChan->dmatable_cpu;
@@ -905,9 +872,9 @@ static int IdeBuildDmaTable(PChannel pChreturn count; }/* end IdeBuildDmaTable */ -/************************************************************************ +/* * Prepares a dma scatter/gather request. -************************************************************************/ +*/ static void IdeBuildDmaSgTable (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {int use_sg =0 ;
@@ -929,9 +896,9 @@ static void IdeBuildDmaSgTable(PChannel } }/* end IdeBuildDmaSgTable */ -/************************************************************************ +/* * Setup DMA table for channel. -************************************************************************/ +*/ static void IdeSetupDma (PChannel pChan,unsigned long dma_base,unsigned short num_ports) {
@@ -950,9 +917,6 @@ IdeSetupDma(PChannel pChan, unsigned lon }memset (pChan->dmatable_cpu,0 ,PRD_ENTRIES *PRD_BYTES ); -/* -* Allocate SCATTER/GATHER table buffer. -*/ pChan->sg_table =kmalloc (sizeof (struct scatterlist ) *PRD_ENTRIES ,GFP_KERNEL );if (pChan->sg_table ==NULL ) {
@@ -964,9 +928,9 @@ IdeSetupDma(PChannel pChan, unsigned lonreturn ; }/* end IdeSetupDma */ -/************************************************************************ +/* * This will be only used in RAID mode. -************************************************************************/ +*/ static void IT8212ReconfigChannel (PChannel pChan,u8 ArrayId,u8 Operation) {u8 enableVirtualChannel;
@@ -989,16 +953,15 @@ static void IT8212ReconfigChannel(PChannpci_write_config_byte (pPciDev,0x43 , enableVirtualChannel); }/* end IT8212ReconfigChannel */ -/************************************************************************ -* Get the chip status. This is a vendor specific command. According to -* all of the device configurations, the BIOS then can consider the -* existing RAID configuration reasonable. If the existing RAID configur- -* ation is not reasonable, or if there is NO existing RAID configuration -* , the BIOS can ask the user to setup the RAID configuration. Finally, -* the BIOS or AP should send the SET CHIP STATUS to every virtual device. -* Only after receiving SET CHIP STATUS command, the corresponding virtual -* device will be active. -************************************************************************/ +/* +* This is a vendor specific command. According to all of the device +* configurations, the BIOS then can consider the existing RAID configuration +* reasonable. If the existing RAID configuration is not reasonable, or if +* there is NO existing RAID configuration, the BIOS can ask the user to setup +* the RAID configuration. Finally, the BIOS or AP should send the SET CHIP +* STATUS to every virtual device. Only after receiving SET CHIP STATUS +* command, the corresponding virtual device will be active. +*/ static u8 IT8212GetChipStatus (uioctl_t * ioc) {u8 PriMasterIsNull = FALSE;
@@ -1018,9 +981,6 @@ static u8 IT8212GetChipStatus(uioctl_t * pAdap = ite_adapters[0 ]; pChan = &pAdap->IDEChannel[0 ]; -/* -* Allocate space for PHYSICAL_DISK_STATUS. -*/ pPhyDiskInfo =kmalloc (sizeof (PHYSICAL_DISK_STATUS ) *4 ,GFP_KERNEL );if (pPhyDiskInfo ==NULL ) { printk("IT8212GetChipStatus: error kmalloc for "
@@ -1083,12 +1043,8 @@ static u8 IT8212GetChipStatus(uioctl_t *#if (0 )HexDump ((unsigned char *)pPhyDiskInfo,512 ); -#endif -/* -* Copy physical disk info to user area. -*/ copy_to_user ((unsigned short *)ioc->data, (unsigned char *)pPhyDiskInfo,512 );
@@ -1125,9 +1081,9 @@ exit:return srbStatus; }/* end IT8212GetChipStatus */ -/************************************************************************ +/* * Erase the partition table. -************************************************************************/ +*/ static unsigned char IT8212ErasePartition (uioctl_t * pioc) {unsigned char drvSelect;
@@ -1149,9 +1105,6 @@ static unsigned char IT8212ErasePartitioelse pChan = &pAdap->IDEChannel[1 ]; -/* -* Allocate 512 bytes for buffer. -*/ if ((buffer =kmalloc (512 ,GFP_KERNEL )) ==NULL ) {printk ("IT8212ErasePartition: error kmalloc.\n" );return -ENOMEM ;
@@ -1232,9 +1185,6 @@ exit:return srbStatus; }/* end IT8212ErasePartition */ -/************************************************************************ -* -************************************************************************/ static u32 IT8212TruncateReduentSectors (u32 OriginalSectorCount,u16 StripeSizeInKBytes) {
@@ -1251,9 +1201,9 @@ static u32 IT8212TruncateReduentSectors( stripeSizeInSector); }/* end IT8212TruncateReduentSectors */ -/************************************************************************ +/* * Calculate the addressable sector for this RAID. -************************************************************************/ +*/ static u32 IT8212DiskArrayAddressableSector (unsigned char *DiskArrayCreateInfo) {u8 DiskNo;
@@ -1272,7 +1222,6 @@ static u32 IT8212DiskArrayAddressableSecprintk ("createInfo->AddressableSectors[3] = 0x%X\n" , createInfo->AddressableSectors[3 ]);for (DiskNo =0 ; DiskNo <4 ; DiskNo++) { -/* * If disk exist. */
@@ -1287,7 +1236,6 @@ static u32 IT8212DiskArrayAddressableSec } }switch (createInfo->RaidType) { -/* * Containing 2 or 3 or 4 disks. */
@@ -1339,9 +1287,9 @@ static u32 IT8212DiskArrayAddressableSecreturn ArrayCapacity; }/* end IT8212DiskArrayAddressableSector */ -/************************************************************************ +/* * Create a new array. -************************************************************************/ +*/ static u8 IT8212CreateDiskArray (uioctl_t * pioc) {u8 i;
@@ -1358,21 +1306,23 @@ static u8 IT8212CreateDiskArray(uioctl_tPRAID_CREATE_INFO createInfo = (PRAID_CREATE_INFO ) pioc->data;PIDENTIFY_DATA2 identifyData;PIT8212_SET_CHIP_STATUS_INFO setChipStatus; -static const u16 IT8212TimingTable[7 ] = {0x3133 ,/* UDMA timimg register 01 */ -0x2121 ,/* UDMA timimg register 23 */ -0x9111 ,/* UDMA timimg register 45 */ -0x0091 ,/* UDMA timimg register 6 */ -0x3266 ,/* DMA timimg register 01 */ -0x0021 ,/* DMA timimg register 2 */ -0x0021 /* PIO timimg register */ +static const u16 IT8212TimingTable[7 ] = { +0x3133 ,/* UDMA timimg register 01 */ +0x2121 ,/* UDMA timimg register 23 */ +0x9111 ,/* UDMA timimg register 45 */ +0x0091 ,/* UDMA timimg register 6 */ +0x3266 ,/* DMA timimg register 01 */ +0x0021 ,/* DMA timimg register 2 */ +0x0021 /* PIO timimg register */ }; -static const u16 IT8212ClockTable[7 ] = {0x0505 ,/* UDMA clock register 01 */ -0x0005 ,/* UDMA clock register 23 */ -0x0500 ,/* UDMA clock register 45 */ -0x0000 ,/* UDMA clock register 6 */ -0x0005 ,/* DMA clock register 01 */ -0x0005 ,/* DMA clock register 2 */ -0x0005 /* PIO clock register */ +static const u16 IT8212ClockTable[7 ] = { +0x0505 ,/* UDMA clock register 01 */ +0x0005 ,/* UDMA clock register 23 */ +0x0500 ,/* UDMA clock register 45 */ +0x0000 ,/* UDMA clock register 6 */ +0x0005 ,/* DMA clock register 01 */ +0x0005 ,/* DMA clock register 2 */ +0x0005 /* PIO clock register */ };printk ("IT8212CreateDiskArray enter\n" );
@@ -1421,7 +1371,7 @@ static u8 IT8212CreateDiskArray(uioctl_tprintk ("createInfo->AddressableSectors[3] = 0x%lX\n" , createInfo->AddressableSectors[3 ]); -#endif /* */ +#endif switch (createInfo->RaidType) {case RAID_LEVEL_0 :case RAID_LEVEL_1 :
@@ -1441,9 +1391,6 @@ static u8 IT8212CreateDiskArray(uioctl_t pAdap = ite_adapters[0 ]; pChan = &pAdap->IDEChannel[0 ]; -/* -* Allocate 512-bytes buffer. -*/ if ((buffer =kmalloc (512 ,GFP_KERNEL )) ==NULL ) {printk ("IT8212CreateDiskArray: error kmalloc.\n" );return -ENOMEM ;
@@ -1451,7 +1398,6 @@ static u8 IT8212CreateDiskArray(uioctl_t identifyData = (PIDENTIFY_DATA2 ) buffer;/* -* 2003/05/08 * Remember the vendor specific parameters starts from word 129 not 128. */ setChipStatus = (PIT8212_SET_CHIP_STATUS_INFO ) (buffer +258 );
@@ -1460,10 +1406,6 @@ static u8 IT8212CreateDiskArray(uioctl_t* Configure to RAID or NORMAL. */ if (subCommand ==0x50 ) { - -/* -* Zero identify data structure. -*/ memset ((unsigned char *)identifyData,0 ,sizeof (IDENTIFY_DATA ));/*
@@ -1536,7 +1478,6 @@ static u8 IT8212CreateDiskArray(uioctl_t }#if (MARK_DEBUG_DUMP_MEM )HexDump (buffer,512 ); -#endif /*
@@ -1647,9 +1588,9 @@ exit: }/* end IT8212CreateDiskArray */ #if 0 -/************************************************************************ +/* * Return "virtual" drive 512 bytes identification data. -************************************************************************/ +*/ static u8 IT8212IssueIdentify (uioctl_t *pioc) {u8 channum;
@@ -1738,9 +1679,6 @@ static u8 IT8212IssueIdentify(uioctl_t * (unsigned short *)&pChan-> FullIdentifyData, 256); -/* -* Then copy to user area. -*/ copy_to_user((unsigned short *)(pioc->data + ((devnum + channum * 2) *
@@ -1782,9 +1720,9 @@ exit: } /* end IT8212IssueIdentify */#endif -/************************************************************************ +/* * Reset the controller. -************************************************************************/ +*/ static u8 IT8212ResetAdapter (PITE_ADAPTER pAdap) {u8 resetChannel[2 ];
@@ -1877,9 +1815,9 @@ static u8 IT8212ResetAdapter(PITE_ADAPTE } }/* end IT8212ResetAdapter */ -/************************************************************************ +/* * Rebuild disk array. -************************************************************************/ +*/ static u8 IT8212Rebuild (uioctl_t * pioc) {u8 rebuildDirection;
@@ -1902,7 +1840,7 @@ static u8 IT8212Rebuild(uioctl_t * pioc) pChan = &pAdap->IDEChannel[1 ];/* -* Selcet device. +* Select device. */ outb ((u8) ((apRebuildInfo->DiskArrayId &0x1 ) <<4 |0xA0 ), pChan->io_ports[IDE_SELECT_OFFSET ]);
@@ -1956,7 +1894,7 @@ static u8 IT8212Rebuild(uioctl_t * pioc)return SRB_STATUS_PENDING ; }/* end IT8212Rebuild */ -/************************************************************************ +/* * Switch to DMA mode if necessary. * * offset 0x50 = PCI Mode Control Register
@@ -1969,7 +1907,7 @@ static u8 IT8212Rebuild(uioctl_t * pioc)* Bit 5 = Secondary Channel Dev 0 Transfer Mode (1=MultiWord DMA, 0=Ultra DMA) * Bit 6 = Secondary Channel Dev 1 Transfer Mode (1=MultiWord DMA, 0=Ultra DMA) * Bit 7 = PCI Mode Reset -************************************************************************/ +*/ static void IT8212SwitchDmaMode (PChannel pChan,u8 DeviceId) {u8 pciControl;
@@ -2066,9 +2004,6 @@ static void IT8212SwitchDmaMode(PChannel pChan->ActiveDevice = device; }/* end IT8212SwitchDmaMode */ -/************************************************************************ -* IT8212 read/write routine. -************************************************************************/ static u32 IT8212ReadWrite (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u8 statusByte =0 ;
@@ -2149,9 +2084,6 @@ static u32 IT8212ReadWrite(PChannel pChaelse IdeBuildDmaSgTable (pChan, Srb); -/* -* Start transfer the data. -*/ IdeStartTransfer (pChan, Srb, startingSector, sectorNumber);/*
@@ -2161,9 +2093,9 @@ static u32 IT8212ReadWrite(PChannel pCha }/* end IT8212ReadWrite */ #if 0 -/************************************************************************ +/* * Setup the transfer mode. -************************************************************************/ +*/ static void IT8212SetTransferMode (PChannel pChan,u32 DiskId,u8 TransferMode,u8 ModeNumber) {
@@ -2219,9 +2151,6 @@ static void IT8212SetTransferMode(PChann#endif #if 0 -/************************************************************************ -* Set the best transfer mode for device. -************************************************************************/ static void IT8212SetBestTransferMode (PITE_ADAPTER pAdap,PChannel pChan,u8 channel) {
@@ -2285,13 +2214,11 @@ static void IT8212SetBestTransferMode(PIstatic const u8 ideClock[4 ] = {0xFD ,0xFD ,0xFB ,0xFB };/* -* 2003/07/24 * If running on Firmware mode, get cable status from it. */ for (i =0 ; i <2 ; i++) { -/* -* The dafault of cable status is in PCI configuration 0x40. +* The default of cable status is in PCI configuration 0x40. */ cableStatus[i] = pChan->Cable80[i];
@@ -2597,12 +2524,11 @@ static void IT8212SetBestTransferMode(PI#endif #if 0 -/************************************************************************ +/* * Initialize bypass(transparent) mode if BIOS is not ready. -************************************************************************/ +*/ static u8 IT8212InitBypassMode (struct pci_dev *pPciDev) { -/* * Reset local CPU, and set BIOS not ready. */
@@ -2621,10 +2547,10 @@ static u8 IT8212InitBypassMode(struct pc } /* end IT8212InitBypassMode */#endif -/************************************************************************ +/* * This is the interrupt service routine for ATAPI IDE miniport driver. -* TURE if expecting an interrupt. -************************************************************************/ +* TRUE if expecting an interrupt. +*/ static u8 IT8212Interrupt (PChannel pChan,u8 bypass_mode) {u8 statusByte;
@@ -2681,7 +2607,6 @@ static u8 IT8212Interrupt(PChannel pChanreturn AtapiInterrupt (pChan); pChan->ExpectingInterrupt = FALSE;if ((statusByte &IDE_STATUS_BUSY ) || (statusByte &IDE_STATUS_DRQ )) { -/* * Ensure BUSY and DRQ is non-asserted. */
@@ -2701,7 +2626,6 @@ static u8 IT8212Interrupt(PChannel pChan } }if (statusByte &IDE_STATUS_ERROR ) { -/* * Stop bus master operation. */
@@ -2720,12 +2644,12 @@ static u8 IT8212Interrupt(PChannel pChanreturn TRUE; }/* end IT8212Interrupt */ -/************************************************************************ +/* * This is the interrupt service routine for ATAPI IDE miniport driver. * TRUE if expecting an interrupt. Remember the ATAPI io registers are * different from IDE io registers and this is for each channel not for * entire controller. -************************************************************************/ +*/ static u8 AtapiInterrupt (PChannel pChan) {u32 wordCount;
@@ -2787,7 +2711,6 @@ static u8 AtapiInterrupt(PChannel pChan)*/ if (statusByte &IDE_STATUS_ERROR ) {if (srb->Cdb[0 ] !=SCSIOP_REQUEST_SENSE ) { -/* * Fail this request. */
@@ -2802,7 +2725,6 @@ static u8 AtapiInterrupt(PChannel pChan) interruptReason = (inb (pChan->io_ports[ATAPI_INTREASON_OFFSET ]) &0x3 ); wordsThisInterrupt =256 ;if (interruptReason ==0x1 && (statusByte &IDE_STATUS_DRQ )) { -/* * Write the packet. */
@@ -2814,7 +2736,6 @@ static u8 AtapiInterrupt(PChannel pChan)WriteBuffer (pChan, (unsigned short *)srb->Cdb,6 );return TRUE; }else if (interruptReason ==0x0 && (statusByte &IDE_STATUS_DRQ )) { -/* * Write the data. */
@@ -2826,7 +2747,7 @@ static u8 AtapiInterrupt(PChannel pChan) wordCount |=inb (pChan->io_ports[ATAPI_HCYL_OFFSET ]) <<8 ;/* -* Covert bytes to words. +* Convert bytes to words. */ wordCount >>=1 ;if (wordCount != pChan->WordsLeft) {
@@ -2872,14 +2793,10 @@ static u8 AtapiInterrupt(PChannel pChan) goto CompleteRequest; } -/* -* Advance data buffer pointer and bytes left. -*/ pChan->DataBuffer += wordCount; pChan->WordsLeft -= wordCount;return TRUE; }else if (interruptReason ==0x2 && (statusByte &IDE_STATUS_DRQ )) { -/* * Pick up bytes to transfer and convert to words. */
@@ -2887,7 +2804,7 @@ static u8 AtapiInterrupt(PChannel pChan) wordCount |=inb (pChan->io_ports[ATAPI_HCYL_OFFSET ]) <<8 ;/* -* Covert bytes to words. +* Convert bytes to words. */ wordCount >>=1 ;if (wordCount != pChan->WordsLeft) {
@@ -2914,7 +2831,6 @@ static u8 AtapiInterrupt(PChannel pChan)* field, in the INQUIRY response, to at least 2. */ if (srb->Cdb[0 ] ==SCSIOP_INQUIRY ) { -/* * Maybe it's not necessary in Linux driver. */
@@ -2931,9 +2847,6 @@ static u8 AtapiInterrupt(PChannel pChan) goto CompleteRequest; } -/* -* Advance data buffer pointer and bytes left. -*/ pChan->DataBuffer += wordCount; pChan->WordsLeft -= wordCount;
@@ -2941,7 +2854,6 @@ static u8 AtapiInterrupt(PChannel pChan)* Check for read command complete. */ if (pChan->WordsLeft ==0 ) { -/* * Work around to make many atapi devices return * correct sector size of 2048. Also certain devices
@@ -2973,7 +2885,6 @@ static u8 AtapiInterrupt(PChannel pChan) status =SRB_STATUS_SUCCESS ; CompleteRequest:if (status ==SRB_STATUS_ERROR ) { -/* * Map error to specific SRB status and handle request * sense.
@@ -2986,7 +2897,6 @@ CompleteRequest:*/ pChan->RDP = FALSE; }else { -/* * Wait for busy to drop. */
@@ -2998,10 +2908,6 @@ CompleteRequest:udelay (500 ); }if (i ==30 ) { - -/* -* Reset the controller. -*/ printk ("AtapiInterrupt: resetting due to BSY " "still up - %x.\n" , statusByte);AtapiResetController (pAdap, pChan);
@@ -3088,10 +2994,6 @@ CompleteRequest: }return TRUE; }else { - -/* -* Unexpected int. -*/ printk ("AtapiInterrupt: unexpected interrupt. intReason %x. " "status %x.\n" , interruptReason, statusByte);return FALSE;
@@ -3099,9 +3001,6 @@ CompleteRequest:return TRUE; }/* end AtapiInterrupt */ -/************************************************************************ -* IRQ handler. -************************************************************************/ static irqreturn_t Irq_Handler (int irq,void *dev_id,struct pt_regs *regs) {int handled =0 ;
@@ -3129,9 +3028,9 @@ static irqreturn_t Irq_Handler(int irq,return IRQ_RETVAL (handled); }/* end Irq_Handler */ -/************************************************************************ +/* * This routine handles IDE Verify. -************************************************************************/ +*/ static u8 IdeVerify (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u8 drvSelect;
@@ -3325,9 +3224,9 @@ IT8212MoveMemory(unsigned char *DestAddr } }/* end IT8212MoveMemory */ -/************************************************************************ +/* * Convert SCSI packet command to Atapi packet command. -************************************************************************/ +*/ static void Scsi2Atapi (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {
@@ -3384,7 +3283,7 @@ static void Scsi2Atapi(PChannel pChan, P modeSense10->Control = modeSense6->Control;/* -* 3. Becasuse we will fake a block descripter (-8), and +* 3. Because we will fake a block descripter (-8), and * translate the header (+4), so the requested length * should be modified. That is, -8+4=-4 bytes. */
@@ -3430,7 +3329,7 @@ static void Scsi2Atapi(PChannel pChan, P modeSelect10->Control = modeSelect6->Control;/* -* 3. Becasuse we will remove the block descripter (-8), +* 3. Because we will remove the block descripter (-8), * and translate the header (+4), so the requested * length should be modified. That is, -8+4=-4 bytes. */
@@ -3494,9 +3393,9 @@ static void Scsi2Atapi(PChannel pChan, P } }/* end Scsi2Atapi */ -/************************************************************************ +/* * Send ATAPI packet command to device. -************************************************************************/ +*/ static u32 AtapiSendCommand (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u8 statusByte;
@@ -3545,11 +3444,10 @@ static u32 AtapiSendCommand(PChannel pCh pChan->io_ports[ATAPI_SELECT_OFFSET]);/* -* Try to enable interrupt again. (2003/02/25) +* Try to enable interrupt again. */ #if (0 )outb (0x00 , pChan->io_ports[ATAPI_CONTROL_OFFSET ]); -#endif /*
@@ -3828,9 +3726,9 @@ static u32 AtapiSendCommand(PChannel pChreturn SRB_STATUS_PENDING ; }/* end AtapiSendCommand */ -/************************************************************************ +/* * Program ATA registers for IDE disk transfer. -************************************************************************/ +*/ static u32 IdeSendCommand (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u8 statusByte;
@@ -3964,11 +3862,11 @@ static u32 IdeSendCommand(PChannel pChanreturn status; }/* end IdeSendCommand */ -/************************************************************************ +/* * This routine is called from the SCSI port driver synchronized with * the kernel to start an IO request. If the current SRB is busy, return -* FALSE, else return TURE. -************************************************************************/ +* FALSE, else return TRUE. +*/ static void AtapiStartIo (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {u32 status =0 ;
@@ -4048,9 +3946,9 @@ busy: } }/* end AtapiStartIo */ -/************************************************************************ +/* * Convert Scsi_Cmnd structure to SCSI_REQUEST_BLOCK. -************************************************************************/ +*/ static void MapRequest (Scsi_Cmnd * pREQ,PSCSI_REQUEST_BLOCK Srb) { Srb->Length =sizeof (SCSI_REQUEST_BLOCK );
@@ -4097,10 +3995,10 @@ static void MapRequest(Scsi_Cmnd * pREQ, Srb->pREQ = pREQ; }/* end MapRequest */ -/************************************************************************ -* A task execution has been done. For OS request, we need to Notify OS +/* +* A task execution has been done. For OS request, we need to notify OS * and invoke next take which wait at queue. -************************************************************************/ +*/ static void TaskDone (PChannel pChan,PSCSI_REQUEST_BLOCK Srb) {Scsi_Cmnd *pREQ = Srb->pREQ;
@@ -4147,18 +4045,15 @@ static void TaskDone(PChannel pChan, PSCTaskQueue (); }/* end TaskDone */ -/************************************************************************ +/* * Start a command, doing convert first. -************************************************************************/ +*/ static void TaskStart (PChannel pChan,Scsi_Cmnd * pREQ) {PSCSI_REQUEST_BLOCK Srb;dprintk ("TaskStart(pChan=%p, pREQ=%p)\n" , pChan, pREQ); Srb = &pChan->_Srb; -/* -* Clear the SRB structure. -*/ memset (Srb,0 ,sizeof (SCSI_REQUEST_BLOCK ));/*
@@ -4172,10 +4067,10 @@ static void TaskStart(PChannel pChan, ScAtapiStartIo (pChan, Srb); }/* end TaskStart */ -/************************************************************************ +/* * Check if queue is empty. If there are request in queue, transfer the * request to HIM's request and execute the request. -************************************************************************/ +*/ static void TaskQueue (void ) {unsigned long flags;
@@ -4230,13 +4125,13 @@ check_next: } }/* end TaskQueue */ -/**************************************************************** +/* * Name: iteraid_queuecommand * Description: Process a queued command from the SCSI manager. * Parameters: SCpnt - Pointer to SCSI command structure. * done - Pointer to done function to call. * Returns: Status code. -****************************************************************/ +*/ static int iteraid_queuecommand (Scsi_Cmnd * SCpnt,void (*done) (Scsi_Cmnd *)) {unsigned long flags;
@@ -4261,25 +4156,19 @@ static int iteraid_queuecommand(Scsi_Cmn }/* end iteraid_queuecommand */ #if 0 -/**************************************************************** -* Name: internal_done :LOCAL -* Description: Done handler for non-queued commands -* Parameters: SCpnt - Pointer to SCSI command structure. -* Returns: Nothing. -****************************************************************/ +/* +* Done handler for non-queued commands +*/ static void internal_done (Scsi_Cmnd * SCpnt) { SCpnt->SCp.Status++; -}/* end internal_done */ +}#endif #if 0 -/**************************************************************** -* Name: iteraid_command -* Description: Process a command from the SCSI manager. -* Parameters: SCpnt - Pointer to SCSI command structure. -* Returns: Status code. -****************************************************************/ +/* +* Process a command from the SCSI manager. +*/ static int iteraid_command (Scsi_Cmnd * SCpnt) {unsigned long timeout;
@@ -4298,9 +4187,9 @@ static int iteraid_command(Scsi_Cmnd * S } /* end iteraid_command */#endif -/************************************************************************ +/* * Enables/disables media status notification. -************************************************************************/ +*/ #if 0 static void IdeMediaStatus (u8 EnableMSN,PChannel pChan,u8 Device) {
@@ -4352,11 +4241,11 @@ static void IdeMediaStatus(u8 EnableMSN, } }/* end IdeMediaStatus */ -#endif /* */ -/************************************************************************ +#endif +/* * Issue IDENTIFY command to a device. * Either the standard (EC) or the ATAPI packet (A1) IDENTIFY. -************************************************************************/ +*/ static u8 IssueIdentify (PChannel pChan,u8 DeviceNumber,u8 Command) {u8 statusByte =0 ;
@@ -4494,7 +4383,6 @@ static u8 IssueIdentify(PChannel pChan,/* * Check out a few capabilities / limitations of the device. -* 01/29/2003 */ if (pChan->FullIdentifyData.SpecialFunctionsEnabled &1 ) {
@@ -4555,9 +4443,9 @@ static u8 IssueIdentify(PChannel pChan,return TRUE; }/* end IssueIdentify() */ -/************************************************************************ +/* * Check this is the IDE or ATAPI disk then identify it. -************************************************************************/ +*/ static u8 iteraid_find_device (PChannel pChan,u8 channel) {u8 deviceNumber;
@@ -4697,9 +4585,9 @@ static u8 iteraid_find_device(PChannel p }/* end iteraid_find_device */ #if 0 -/************************************************************************ +/* * IDE disk hardware initialize. -************************************************************************/ +*/ static u8 AtapiHwInitialize (PITE_ADAPTER pAdap,PChannel pChan,u8 channel) {u8 i;
@@ -4746,9 +4634,9 @@ static u8 AtapiHwInitialize(PITE_ADAPTER } /* end AtapiHwInitialize */#endif -/************************************************************************ -* Initialize a adapter, return 0 means success. -************************************************************************/ +/* +* Initialize an adapter, return 0 means success. +*/ static int iteraid_init (PITE_ADAPTER pAdap,struct pci_dev *pPciDev) {u8 z;
@@ -4844,7 +4732,6 @@ static int iteraid_init(PITE_ADAPTER pAd* Change to bypass mode. */ IT8212InitBypassMode (pPciDev); -#endif /*
@@ -4852,7 +4739,6 @@ static int iteraid_init(PITE_ADAPTER pAd*/ #if (0 )AtapiHwInitialize (pAdap, pChan, z); -#endif /*
@@ -4860,12 +4746,8 @@ static int iteraid_init(PITE_ADAPTER pAd*/ iteraid_find_device (pChan, z); -/* -* Set the best transfer mode. -*/ #if (MARK_SET_BEST_TRANSFER )IT8212SetBestTransferMode (pAdap, pChan, z); -#endif /*
@@ -4877,9 +4759,9 @@ static int iteraid_init(PITE_ADAPTER pAdreturn 0 ; }/* end iteraid_init */ -/************************************************************************ -* This function will find and initialize any cards. -************************************************************************/ +/* +* Find and initialize any cards. +*/ static int iteraid_detect (Scsi_Host_Template * tpnt) {u8 i;
@@ -4904,9 +4786,6 @@ static int iteraid_detect(Scsi_Host_Tempif (pci_enable_device (pPciDev))continue ; -/* -* Allocate memory for Adapter. -*/ pAdap = (PITE_ADAPTER )kmalloc (sizeof (ITE_ADAPTER ),GFP_ATOMIC );if (pAdap ==NULL ) {printk ("iteraid_detect: pAdap allocate failed.\n" );
@@ -4957,14 +4836,8 @@ static int iteraid_detect(Scsi_Host_Temp ite_vhost->max_id =MAX_DEVICES ; ite_vhost->max_lun =1 ; -#if (0 ) -#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,5 ,0 ) +#if 0 scsi_set_device (ite_vhost, &pPciDev->dev); - -#elif LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,4 ,4 ) -scsi_set_pci_device (ite_vhost, pPciDev); - -#endif #endif /*
@@ -4983,7 +4856,7 @@ static int iteraid_detect(Scsi_Host_Tempregister_reboot_notifier (&ite_notifier);/* -* Initialize ioctl semphore. +* Initialize ioctl semaphore. */ init_MUTEX (&mimd_entry_mtx); }
@@ -4991,28 +4864,16 @@ static int iteraid_detect(Scsi_Host_Tempreturn 1 ; }/* end iteraid_detect() */ -/************************************************************************ -* Name: iteraid_release -* Description: Release resources allocated for a single each adapter. -* Parameters: pshost - Pointer to SCSI command structure. -* Returns: zero. -************************************************************************/ static int iteraid_release (struct Scsi_Host *pshost) {u8 i;PITE_ADAPTER pAdap; -/* -* Unregister the character device. -*/ if (ite_major >0 ) {unregister_chrdev (ite_major,"itedev" ); ite_major =-1 ; } -/* -* Free irq and memory. -*/ for (i =0 ; i < NumAdapters; i++) { pAdap = ite_adapters[i];if (pAdap->irqOwned)
@@ -5026,9 +4887,6 @@ static int iteraid_release(struct Scsi_H } } -/* -* Unregister the reboot notifier. -*/ unregister_reboot_notifier (&ite_notifier);/*
@@ -5038,9 +4896,6 @@ static int iteraid_release(struct Scsi_Hreturn 0 ; }/* end iteraid_Release */ -/************************************************************************ -* This is the new scsi eh reset function. -************************************************************************/ static int iteraid_reset_eh (Scsi_Cmnd * SCpnt) {u8 i;
@@ -5062,9 +4917,9 @@ static int iteraid_reset_eh(Scsi_Cmnd *return SUCCESS ; }/* end iteraid_reset_eh */ -/************************************************************************ +/* * The new error handling code. -************************************************************************/ +*/ static int iteraid_abort_eh (Scsi_Cmnd * SCpnt) {if (SCpnt ==NULL ) {
@@ -5072,17 +4927,11 @@ static int iteraid_abort_eh(Scsi_Cmnd *return FAILED ; }return SUCCESS ; -}/* end iteraid_abort_eh */ +} -/************************************************************************ -* Name: iteraid_biosparam -* Description: Process the biosparam request from the SCSI manager to -* return C/H/S data. -* Parameters: disk - Pointer to SCSI disk structure. -* dev - Major/minor number from kernel. -* geom - Pointer to integer array to place geometry data. -* Returns: zero. -************************************************************************/ +/* +* Process the biosparam request from the SCSI manager to return C/H/S data. +*/ static int iteraid_biosparam (struct scsi_device *sdev,struct block_device *bdev,sector_t capacity,int geom[]) {
@@ -5112,9 +4961,9 @@ static int iteraid_biosparam(struct scsireturn 0 ; }/* end iteraid_biosparam */ -/************************************************************************ +/* * Shutdown routine. -************************************************************************/ +*/ static int ite_halt (struct notifier_block *nb,ulong event,void *buf) { if (event != SYS_RESTART && event != SYS_HALT &&
@@ -5123,30 +4972,25 @@ static int ite_halt(struct notifier_bloc }unregister_reboot_notifier (&ite_notifier);return NOTIFY_OK ; -}/* end ite_halt */ +} -/************************************************************************ -* PROC information. -************************************************************************/ static int iteraid_proc_info (struct Scsi_Host *shost,char *buffer,char **start,off_t offset,int length,int inout) {return 0 ; -}/* end iteraid_proc_info */ +} -/************************************************************************ +/* * IOCTL open entry. -************************************************************************/ +*/ static int itedev_open (struct inode *inode,struct file *filep) { - -//MOD_INC_USE_COUNT; return 0 ; -}/* end itedev_open */ +} -/************************************************************************ +/* * IOCTL code entry. -************************************************************************/ +*/ static int itedev_ioctl_entry (struct inode *inode,struct file *filep,unsigned int cmd,unsigned long arg) {
@@ -5161,9 +5005,9 @@ static int itedev_ioctl_entry(struct inoreturn ret; }/* end itedev_ioctl_entry */ -/************************************************************************ +/* * Real IOCTL function handles ioctl for the character device. -************************************************************************/ +*/ static int itedev_ioctl (struct inode *inode,struct file *filep,unsigned int cmd,unsigned long arg) {
@@ -5184,17 +5028,11 @@ static int itedev_ioctl(struct inode *inif (_IOC_TYPE (cmd) !=ITE_IOCMAGIC )return -EINVAL ; -/* -* Allocate space for ioctl data structure. -*/ if ((pioc =kmalloc (sizeof (uioctl_t),GFP_KERNEL )) ==NULL ) {printk ("itedev_ioctl: error kmalloc on ioctl\n" );return -ENOMEM ; } -/* -* Get the user ioctl structure. -*/ if (copy_from_user (pioc, (uioctl_t *) arg,sizeof (uioctl_t))) {kfree (pioc);return -EFAULT ;
@@ -5207,17 +5045,11 @@ static int itedev_ioctl(struct inode *incase ITE_IOC_GET_PHY_DISK_STATUS :dprintk ("ITE_IOC_GET_PHY_DISK_STATUS\n" ); -/* -* Get the physical disk status. -*/ status =IT8212GetChipStatus (pioc);return 0 ;case ITE_IOC_CREATE_DISK_ARRAY :dprintk ("ITE_IOC_CREATE_DISK_ARRAY\n" ); -/* -* Create disk array. -*/ status =IT8212CreateDiskArray (pioc);if (status !=SRB_STATUS_SUCCESS )return status;
@@ -5301,34 +5133,22 @@ static int itedev_ioctl(struct inode *inif (progress !=0xFF ) progress =0x64 - progress; -/* -* Put the rebuild status to user space. -*/ return put_user (progress, (u8 *) pioc->data); exit:return 0 ;case ITE_IOC_RESET_ADAPTER :dprintk ("ITE_IOC_RESET_ADAPTER\n" ); -/* -* Reset the adapter. -*/ -#if (0 ) +#if 0 status =IT8212ResetAdapter ();#endif -/* -* Return TURE or FALSE to user space. -*/ put_user (status, (u8 __user *) arg);return 0 ;case ITE_IOC_GET_DRIVER_VERSION :dprintk ("ITE_IOC_GET_DRIVER_VERSION\n" ); -/* -* Get the current driver version. -*/ put_user (driver_ver, (int __user *)arg);return 0 ;default :
@@ -5336,19 +5156,14 @@ exit: }/* end switch */ }/* end itedev_ioctl */ -/************************************************************************ +/* * IOCTL close routine. -************************************************************************/ +*/ static int itedev_close (struct inode *inode,struct file *filep) { - -//MOD_DEC_USE_COUNT; return 0 ; -}/* end itedev_close */ +} -/************************************************************************ -* Scsi_Host_Template Initializer -************************************************************************/ static Scsi_Host_Template driver_template = { .proc_name ="IT8212" , .proc_info = iteraid_proc_info,
drivers/scsi/iteraid.h +84 -189
651 lines not on this page · raw message