scsi: megaraid: cleanup formatting of megaraid
Subsystems (2)
PATCH 1/1 scsi: megaraid: cleanup formatting of megaraid
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
--- drivers/scsi/megaraid.c | 2026 ++++++++++++++++++--------------------- drivers/scsi/megaraid.h | 988 ++++++++++--------- 2 files changed, 1417 insertions(+), 1597 deletions(-)
drivers/scsi/megaraid.c +935 -1091
@@ -53,29 +53,34 @@#define MEGARAID_MODULE_VERSION "2.00.4" -MODULE_AUTHOR ("[email protected]" ); -MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver" ); -MODULE_LICENSE ("GPL" ); +MODULE_AUTHOR ("[email protected]" ); +MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver" ); +MODULE_LICENSE ("GPL" );MODULE_VERSION (MEGARAID_MODULE_VERSION );static DEFINE_MUTEX (megadev_mutex);static unsigned int max_cmd_per_lun =DEF_CMD_PER_LUN ;module_param (max_cmd_per_lun, uint,0 ); -MODULE_PARM_DESC (max_cmd_per_lun,"Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)" ); +MODULE_PARM_DESC ( + max_cmd_per_lun, +"Maximum number of commands which can be issued to a single LUN (default=DEF_CMD_PER_LUN=63)" );static unsigned short int max_sectors_per_io =MAX_SECTORS_PER_IO ;module_param (max_sectors_per_io, ushort,0 ); -MODULE_PARM_DESC (max_sectors_per_io,"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" ); - +MODULE_PARM_DESC ( + max_sectors_per_io, +"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" );static unsigned short int max_mbox_busy_wait =MBOX_BUSY_WAIT ;module_param (max_mbox_busy_wait, ushort,0 ); -MODULE_PARM_DESC (max_mbox_busy_wait,"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" ); +MODULE_PARM_DESC ( + max_mbox_busy_wait, +"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" ); -#define RDINDOOR (adapter) readl((adapter)->mmio_base + 0x20) -#define RDOUTDOOR (adapter) readl((adapter)->mmio_base + 0x2C) -#define WRINDOOR (adapter,value) writel(value, (adapter)->mmio_base + 0x20) -#define WROUTDOOR (adapter,value) writel(value, (adapter)->mmio_base + 0x2C) +#define RDINDOOR (adapter) readl((adapter)->mmio_base + 0x20) +#define RDOUTDOOR (adapter) readl((adapter)->mmio_base + 0x2C) +#define WRINDOOR (adapter, value) writel(value, (adapter)->mmio_base + 0x20) +#define WROUTDOOR (adapter, value) writel(value, (adapter)->mmio_base + 0x2C)/* * Global variables
@@ -88,17 +93,17 @@ static struct proc_dir_entry *mega_proc_dir_entry;/* For controller re-ordering */ static struct mega_hbas mega_hbas[MAX_CONTROLLERS ]; -static long -megadev_unlocked_ioctl (struct file *filep,unsigned int cmd,unsigned long arg); +static long megadev_unlocked_ioctl (struct file *filep,unsigned int cmd, +unsigned long arg);/* * The File Operations structure for the serial/ioctl interface of the driver */ static const struct file_operations megadev_fops = { - .owner =THIS_MODULE , - .unlocked_ioctl = megadev_unlocked_ioctl, - .open = megadev_open, - .llseek = noop_llseek, + .owner =THIS_MODULE , + .unlocked_ioctl = megadev_unlocked_ioctl, + .open = megadev_open, + .llseek = noop_llseek, };/*
@@ -114,8 +119,7 @@ static u32 driver_ver = 0x02000000;/* major number used by the device for character interface */ static int major; -#define IS_RAID_CH (hba, ch) (((hba)->mega_ch_class >> (ch)) & 0x01) - +#define IS_RAID_CH (hba, ch) (((hba)->mega_ch_class >> (ch)) & 0x01)/* * Debug variable to print some diagnostic messages
@@ -128,22 +132,21 @@ static int trace_level;* * Allocates a 8 byte aligned memory for the handshake mailbox. */ -static int -mega_setup_mailbox (adapter_t *adapter) +static int mega_setup_mailbox (adapter_t *adapter) { -unsigned long align; +unsigned long align; - adapter->una_mbox64 =dma_alloc_coherent (&adapter->dev->dev, -sizeof (mbox64_t), - &adapter->una_mbox64_dma, -GFP_KERNEL ); + adapter->una_mbox64 = +dma_alloc_coherent (&adapter->dev->dev,sizeof (mbox64_t), + &adapter->una_mbox64_dma,GFP_KERNEL ); + +if (!adapter->una_mbox64) +return -1 ; -if ( !adapter->una_mbox64 )return -1 ; - adapter->mbox = &adapter->una_mbox64->mbox; - adapter->mbox = (mbox_t *)((((unsigned long ) adapter->mbox) +15 ) & - (~0UL ^0xFUL )); + adapter->mbox = (mbox_t *)((((unsigned long )adapter->mbox) +15 ) & + (~0UL ^0xFUL )); adapter->mbox64 = (mbox64_t *)(((unsigned long )adapter->mbox) -8 );
@@ -154,22 +157,21 @@ mega_setup_mailbox(adapter_t *adapter)/* * Register the mailbox if the controller is an io-mapped controller */ -if ( adapter->flag &BOARD_IOMAP ) { - +if (adapter->flag &BOARD_IOMAP ) {outb (adapter->mbox_dma &0xFF , - adapter->host->io_port +MBOX_PORT0 ); + adapter->host->io_port +MBOX_PORT0 );outb ((adapter->mbox_dma >>8 ) &0xFF , - adapter->host->io_port +MBOX_PORT1 ); + adapter->host->io_port +MBOX_PORT1 );outb ((adapter->mbox_dma >>16 ) &0xFF , - adapter->host->io_port +MBOX_PORT2 ); + adapter->host->io_port +MBOX_PORT2 );outb ((adapter->mbox_dma >>24 ) &0xFF , - adapter->host->io_port +MBOX_PORT3 ); + adapter->host->io_port +MBOX_PORT3 );outb (ENABLE_MBOX_BYTE , - adapter->host->io_port +ENABLE_MBOX_REGION ); + adapter->host->io_port +ENABLE_MBOX_REGION );irq_ack (adapter);
@@ -179,7 +181,6 @@ mega_setup_mailbox(adapter_t *adapter)return 0 ; } -/* * mega_query_adapter() * @adapter - pointer to our soft state
@@ -187,14 +188,13 @@ mega_setup_mailbox(adapter_t *adapter)* Issue the adapter inquiry commands to the controller and find out * information and parameter about the devices attached */ -static int -mega_query_adapter (adapter_t *adapter) +static int mega_query_adapter (adapter_t *adapter) { -dma_addr_t prod_info_dma_handle; -mega_inquiry3 *inquiry3; -struct mbox_out mbox; -u8 *raw_mbox = (u8 *)&mbox; -int retval; +dma_addr_t prod_info_dma_handle; +mega_inquiry3 *inquiry3; +struct mbox_out mbox; +u8 *raw_mbox = (u8 *)&mbox; +int retval;/* Initialize adapter inquiry mailbox */
@@ -210,23 +210,24 @@ mega_query_adapter(adapter_t *adapter) inquiry3 = (mega_inquiry3 *)adapter->mega_buffer; - raw_mbox[0 ] =FC_NEW_CONFIG ;/* i.e. mbox->cmd=0xA1 */ - raw_mbox[2 ] =NC_SUBOP_ENQUIRY3 ;/* i.e. 0x0F */ - raw_mbox[3 ] =ENQ3_GET_SOLICITED_FULL ;/* i.e. 0x02 */ + raw_mbox[0 ] =FC_NEW_CONFIG ;/* i.e. mbox->cmd=0xA1 */ + raw_mbox[2 ] =NC_SUBOP_ENQUIRY3 ;/* i.e. 0x0F */ + raw_mbox[3 ] =ENQ3_GET_SOLICITED_FULL ;/* i.e. 0x02 */ /* Issue a blocking command to the card */ if ((retval =issue_scb_block (adapter, raw_mbox))) {/* the adapter does not support 40ld */ -mraid_ext_inquiry *ext_inq; -mraid_inquiry *inq; -dma_addr_t dma_handle; +mraid_ext_inquiry *ext_inq; +mraid_inquiry *inq; +dma_addr_t dma_handle; ext_inq =dma_alloc_coherent (&adapter->dev->dev,sizeof (mraid_ext_inquiry), &dma_handle,GFP_KERNEL ); -if ( ext_inq ==NULL )return -1 ; +if (ext_inq ==NULL ) +return -1 ; inq = &ext_inq->raid_inq;
@@ -242,48 +243,45 @@ mega_query_adapter(adapter_t *adapter)* mraid_inquiry structure */ mega_8_to_40ld (inq, inquiry3, - (mega_product_info *)&adapter->product_info); + (mega_product_info *)&adapter->product_info); -dma_free_coherent (&adapter->dev->dev, -sizeof (mraid_ext_inquiry), ext_inq, - dma_handle); +dma_free_coherent (&adapter->dev->dev,sizeof (mraid_ext_inquiry), + ext_inq, dma_handle); - }else {/*adapter supports 40ld */ + }else {/*adapter supports 40ld */ adapter->flag |=BOARD_40LD ;/* * get product_info, which is static information and will be * unchanged */ - prod_info_dma_handle =dma_map_single (&adapter->dev->dev, - (void *)&adapter->product_info, -sizeof (mega_product_info), -DMA_FROM_DEVICE ); + prod_info_dma_handle =dma_map_single ( + &adapter->dev->dev, (void *)&adapter->product_info, +sizeof (mega_product_info),DMA_FROM_DEVICE ); mbox.xferaddr = prod_info_dma_handle; - raw_mbox[0 ] =FC_NEW_CONFIG ;/* i.e. mbox->cmd=0xA1 */ - raw_mbox[2 ] =NC_SUBOP_PRODUCT_INFO ;/* i.e. 0x0E */ + raw_mbox[0 ] =FC_NEW_CONFIG ;/* i.e. mbox->cmd=0xA1 */ + raw_mbox[2 ] =NC_SUBOP_PRODUCT_INFO ;/* i.e. 0x0E */ if ((retval =issue_scb_block (adapter, raw_mbox)))dev_warn (&adapter->dev->dev, -"Product_info cmd failed with error: %d\n" , - retval); +"Product_info cmd failed with error: %d\n" , + retval);dma_unmap_single (&adapter->dev->dev, prod_info_dma_handle,sizeof (mega_product_info),DMA_FROM_DEVICE ); } -/* * kernel scans the channels from 0 to <= max_channel */ adapter->host->max_channel = - adapter->product_info.nchannels +NVIRT_CHAN -1 ; + adapter->product_info.nchannels +NVIRT_CHAN -1 ; - adapter->host->max_id =16 ;/* max targets per channel */ + adapter->host->max_id =16 ;/* max targets per channel */ - adapter->host->max_lun =7 ;/* Up to 7 luns for non disk devices */ + adapter->host->max_lun =7 ;/* Up to 7 luns for non disk devices */ adapter->host->cmd_per_lun = max_cmd_per_lun;
@@ -291,7 +289,7 @@ mega_query_adapter(adapter_t *adapter) adapter->max_cmds = adapter->product_info.max_commands; -if (adapter->max_cmds >MAX_COMMANDS ) +if (adapter->max_cmds >MAX_COMMANDS ) adapter->max_cmds =MAX_COMMANDS ; adapter->host->can_queue = adapter->max_cmds -1 ;
@@ -310,32 +308,27 @@ mega_query_adapter(adapter_t *adapter)sparse warnings. */ if (adapter->product_info.subsysvid ==PCI_VENDOR_ID_HP ) {snprintf (adapter->fw_version,sizeof (adapter->fw_version), -"%c%d%d.%d%d" , - adapter->product_info.fw_version[2 ], -0 , - adapter->product_info.fw_version[1 ] &0x0f , -0 , +"%c%d%d.%d%d" , adapter->product_info.fw_version[2 ],0 , + adapter->product_info.fw_version[1 ] &0x0f ,0 , adapter->product_info.fw_version[0 ] &0x0f );snprintf (adapter->bios_version,sizeof (adapter->fw_version), -"%c%d%d.%d%d" , - adapter->product_info.bios_version[2 ], -0 , - adapter->product_info.bios_version[1 ] &0x0f , -0 , +"%c%d%d.%d%d" , adapter->product_info.bios_version[2 ], +0 , adapter->product_info.bios_version[1 ] &0x0f ,0 , adapter->product_info.bios_version[0 ] &0x0f ); }else {memcpy (adapter->fw_version, - (char *)adapter->product_info.fw_version,4 ); + (char *)adapter->product_info.fw_version,4 ); adapter->fw_version[4 ] =0 ;memcpy (adapter->bios_version, - (char *)adapter->product_info.bios_version,4 ); + (char *)adapter->product_info.bios_version,4 ); adapter->bios_version[4 ] =0 ; }dev_notice (&adapter->dev->dev,"[%s:%s] detected %d logical drives\n" , - adapter->fw_version, adapter->bios_version, adapter->numldrv); + adapter->fw_version, adapter->bios_version, + adapter->numldrv);/* * Do we support extended (>10 bytes) cdbs
@@ -344,7 +337,6 @@ mega_query_adapter(adapter_t *adapter)if (adapter->support_ext_cdb)dev_notice (&adapter->dev->dev,"supports extended CDBs\n" ); -return 0 ; }
@@ -354,10 +346,9 @@ mega_query_adapter(adapter_t *adapter)* * Runs through the list of pending requests. */ -static inline void -mega_runpendq (adapter_t *adapter) +static inline void mega_runpendq (adapter_t *adapter) { -if (!list_empty (&adapter->pending_list)) +if (!list_empty (&adapter->pending_list))__mega_runpendq (adapter); }
@@ -370,9 +361,9 @@ mega_runpendq(adapter_t *adapter)*/ static int megaraid_queue_lck (struct scsi_cmnd *scmd) { -adapter_t *adapter; -scb_t *scb; -int busy=0 ; +adapter_t *adapter; +scb_t *scb; +int busy =0 ;unsigned long flags; adapter = (adapter_t *)scmd->device->host->hostdata;
@@ -403,14 +394,14 @@ static int megaraid_queue_lck(struct scsi_cmnd *scmd)mega_runpendq (adapter); busy =0 ; - out: +out:spin_unlock_irqrestore (&adapter->lock, flags);return busy; }static DEF_SCSI_QCMD (megaraid_queue) -/** +/** * mega_allocate_scb() * @adapter: pointer to our soft state * @cmd: scsi command from the mid-layer
@@ -418,15 +409,14 @@ static DEF_SCSI_QCMD(megaraid_queue)* Allocate a SCB structure. This is the central structure for controller * commands. */ -static inline scb_t * -mega_allocate_scb (adapter_t *adapter,struct scsi_cmnd *cmd) +static inline scb_t *mega_allocate_scb (adapter_t *adapter, +struct scsi_cmnd *cmd) {struct list_head *head = &adapter->free_list; -scb_t *scb; +scb_t *scb;/* Unlink command from Free List */ -if ( !list_empty (head) ) { - +if (!list_empty (head)) { scb =list_entry (head->next, scb_t, list);list_del_init (head->next);
@@ -450,29 +440,27 @@ mega_allocate_scb(adapter_t *adapter, struct scsi_cmnd *cmd)* Calculate the logical drive number based on the information in scsi command * and the channel number. */ -static inline int -mega_get_ldrv_num (adapter_t *adapter,struct scsi_cmnd *cmd,int channel) +static inline int mega_get_ldrv_num (adapter_t *adapter,struct scsi_cmnd *cmd, +int channel) { -int tgt; -int ldrv_num; +int tgt; +int ldrv_num; tgt = cmd->device->id; - -if ( tgt > adapter->this_id ) - tgt--;/* we do not get inquires for initiator id */ - ldrv_num = (channel *15 ) + tgt; +if (tgt > adapter->this_id) + tgt--;/* we do not get inquires for initiator id */ + ldrv_num = (channel *15 ) + tgt;/* * If we have a logical drive with boot enabled, project it first */ -if ( adapter->boot_ldrv_enabled ) { -if ( ldrv_num ==0 ) { +if (adapter->boot_ldrv_enabled) { +if (ldrv_num ==0 ) { ldrv_num = adapter->boot_ldrv; - } -else { -if ( ldrv_num <= adapter->boot_ldrv ) { + }else { +if (ldrv_num <= adapter->boot_ldrv) { ldrv_num--; } }
@@ -488,7 +476,7 @@ mega_get_ldrv_num(adapter_t *adapter, struct scsi_cmnd *cmd, int channel)* These is valid only for IO commands. */ -if (adapter->support_random_del && adapter->read_ldidmap ) +if (adapter->support_random_del && adapter->read_ldidmap)switch (cmd->cmnd[0 ]) {case READ_6 :case WRITE_6 :
@@ -513,18 +501,18 @@ mega_get_ldrv_num(adapter_t *adapter, struct scsi_cmnd *cmd, int channel)* We also re-order the logical drives and physical devices based on their * boot settings. */ -static scb_t * -mega_build_cmd (adapter_t *adapter,struct scsi_cmnd *cmd,int *busy) +static scb_t *mega_build_cmd (adapter_t *adapter,struct scsi_cmnd *cmd, +int *busy) { -mega_passthru *pthru; -scb_t *scb; -mbox_t *mbox; -u32 seg; -char islogical; -int max_ldrv_num; -int channel =0 ; -int target =0 ; -int ldrv_num =0 ;/* logical drive number */ +mega_passthru *pthru; +scb_t *scb; +mbox_t *mbox; +u32 seg; +char islogical; +int max_ldrv_num; +int channel =0 ; +int target =0 ; +int ldrv_num =0 ;/* logical drive number */ /* * We know what channels our logical drives are on - mega_find_card()
@@ -538,15 +526,14 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* the physical devices on virtual channel which is obviously converted * to actual channel on the HBA. */ -if ( adapter->boot_pdrv_enabled ) { -if ( islogical ) { +if (adapter->boot_pdrv_enabled) { +if (islogical) {/* logical channel */ channel = cmd->device->channel - - adapter->product_info.nchannels; - } -else { + adapter->product_info.nchannels; + }else {/* this is physical channel */ - channel = cmd->device->channel; + channel = cmd->device->channel; target = cmd->device->id;/*
@@ -554,29 +541,24 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* exposed first IF both the channels are SCSI, then * booting from the second channel is not allowed. */ -if ( target ==0 ) { +if (target ==0 ) { target = adapter->boot_pdrv_tgt; - } -else if ( target == adapter->boot_pdrv_tgt ) { + }else if (target == adapter->boot_pdrv_tgt) { target =0 ; } } - } -else { -if ( islogical ) { + }else { +if (islogical) {/* this is the logical channel */ - channel = cmd->device->channel; - } -else { + channel = cmd->device->channel; + }else {/* physical channel */ - channel = cmd->device->channel -NVIRT_CHAN ; + channel = cmd->device->channel -NVIRT_CHAN ; target = cmd->device->id; } } - -if (islogical) { - +if (islogical) {/* have just LUN 0 for each target on virtual channels */ if (cmd->device->lun) { cmd->result = (DID_BAD_TARGET <<16 );
@@ -586,26 +568,25 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) ldrv_num =mega_get_ldrv_num (adapter, cmd, channel); - max_ldrv_num = (adapter->flag &BOARD_40LD ) ? -MAX_LOGICAL_DRIVES_40LD :MAX_LOGICAL_DRIVES_8LD ; +MAX_LOGICAL_DRIVES_40LD : +MAX_LOGICAL_DRIVES_8LD ;/* * max_ldrv_num increases by 0x80 if some logical drive was * deleted. */ -if (adapter->read_ldidmap) +if (adapter->read_ldidmap) max_ldrv_num +=0x80 ; -if (ldrv_num > max_ldrv_num ) { +if (ldrv_num > max_ldrv_num) { cmd->result = (DID_BAD_TARGET <<16 );scsi_done (cmd);return NULL ; } - } -else { -if ( cmd->device->lun >7 ) { + }else { +if (cmd->device->lun >7 ) {/* * Do not support lun >7 for physically accessed * devices
@@ -621,7 +602,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* Logical drive commands * */ -if (islogical) { +if (islogical) {switch (cmd->cmnd[0 ]) {case TEST_UNIT_READY :#if MEGA_HAVE_CLUSTERING
@@ -629,13 +610,13 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* Do we support clustering and is the support enabled * If no, return success always */ -if ( !adapter->has_cluster ) { +if (!adapter->has_cluster) { cmd->result = (DID_OK <<16 );scsi_done (cmd);return NULL ; } -if (!(scb =mega_allocate_scb (adapter, cmd))) { +if (!(scb =mega_allocate_scb (adapter, cmd))) { *busy =1 ;return NULL ; }
@@ -671,19 +652,18 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)case READ_CAPACITY :case INQUIRY : -if (!(adapter->flag & (1L << cmd->device->channel))) { - +if (!(adapter->flag & (1L << cmd->device->channel))) {dev_notice (&adapter->dev->dev, -"scsi%d: scanning scsi channel %d " -"for logical drives\n" , - adapter->host->host_no, - cmd->device->channel); +"scsi%d: scanning scsi channel %d " +"for logical drives\n" , + adapter->host->host_no, + cmd->device->channel); adapter->flag |= (1L << cmd->device->channel); }/* Allocate a SCB and initialize passthru */ -if (!(scb =mega_allocate_scb (adapter, cmd))) { +if (!(scb =mega_allocate_scb (adapter, cmd))) { *busy =1 ;return NULL ; }
@@ -701,17 +681,18 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) pthru->cdblen = cmd->cmd_len;memcpy (pthru->cdb, cmd->cmnd, cmd->cmd_len); -if ( adapter->has_64bit_addr ) { +if (adapter->has_64bit_addr) { mbox->m_out.cmd =MEGA_MBOXCMD_PASSTHRU64 ; - } -else { + }else { mbox->m_out.cmd =MEGA_MBOXCMD_PASSTHRU ; } scb->dma_direction =DMA_FROM_DEVICE ; - pthru->numsgelements =mega_build_sglist (adapter, scb, - &pthru->dataxferaddr, &pthru->dataxferlen); + pthru->numsgelements = +mega_build_sglist (adapter, scb, + &pthru->dataxferaddr, + &pthru->dataxferlen); mbox->m_out.xferaddr = scb->pthru_dma_addr;
@@ -725,7 +706,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)case WRITE_12 :/* Allocate a SCB and initialize mailbox */ -if (!(scb =mega_allocate_scb (adapter, cmd))) { +if (!(scb =mega_allocate_scb (adapter, cmd))) { *busy =1 ;return NULL ; }
@@ -738,26 +719,25 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* A little hack: 2nd bit is zero for all scsi read * commands and is set for all scsi write commands */ -if ( adapter->has_64bit_addr ) { - mbox->m_out.cmd = (*cmd->cmnd &0x02 ) ? -MEGA_MBOXCMD_LWRITE64 : -MEGA_MBOXCMD_LREAD64 ; - } -else { +if (adapter->has_64bit_addr) { + mbox->m_out.cmd = + (*cmd->cmnd &0x02 ) ? +MEGA_MBOXCMD_LWRITE64 : +MEGA_MBOXCMD_LREAD64 ; + }else { mbox->m_out.cmd = (*cmd->cmnd &0x02 ) ? -MEGA_MBOXCMD_LWRITE : -MEGA_MBOXCMD_LREAD ; +MEGA_MBOXCMD_LWRITE : +MEGA_MBOXCMD_LREAD ; }/* * 6-byte READ(0x08) or WRITE(0x0A) cdb */ -if ( cmd->cmd_len ==6 ) { - mbox->m_out.numsectors = (u32 ) cmd->cmnd[4 ]; - mbox->m_out.lba = - ((u32 )cmd->cmnd[1 ] <<16 ) | - ((u32 )cmd->cmnd[2 ] <<8 ) | - (u32 )cmd->cmnd[3 ]; +if (cmd->cmd_len ==6 ) { + mbox->m_out.numsectors = (u32 )cmd->cmnd[4 ]; + mbox->m_out.lba = ((u32 )cmd->cmnd[1 ] <<16 ) | + ((u32 )cmd->cmnd[2 ] <<8 ) | + (u32 )cmd->cmnd[3 ]; mbox->m_out.lba &=0x1FFFFF ;
@@ -768,12 +748,12 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* drive was deleted */ if (*cmd->cmnd ==READ_6 ) { - adapter->nreads[ldrv_num%0x80 ]++; - adapter->nreadblocks[ldrv_num%0x80 ] += + adapter->nreads[ldrv_num %0x80 ]++; + adapter->nreadblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }else { - adapter->nwrites[ldrv_num%0x80 ]++; - adapter->nwriteblocks[ldrv_num%0x80 ] += + adapter->nwrites[ldrv_num %0x80 ]++; + adapter->nwriteblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }#endif
@@ -782,24 +762,23 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)/* * 10-byte READ(0x28) or WRITE(0x2A) cdb */ -if ( cmd->cmd_len ==10 ) { +if (cmd->cmd_len ==10 ) { mbox->m_out.numsectors = (u32 )cmd->cmnd[8 ] | ((u32 )cmd->cmnd[7 ] <<8 ); - mbox->m_out.lba = - ((u32 )cmd->cmnd[2 ] <<24 ) | - ((u32 )cmd->cmnd[3 ] <<16 ) | - ((u32 )cmd->cmnd[4 ] <<8 ) | - (u32 )cmd->cmnd[5 ]; + mbox->m_out.lba = ((u32 )cmd->cmnd[2 ] <<24 ) | + ((u32 )cmd->cmnd[3 ] <<16 ) | + ((u32 )cmd->cmnd[4 ] <<8 ) | + (u32 )cmd->cmnd[5 ];#if MEGA_HAVE_STATS if (*cmd->cmnd ==READ_10 ) { - adapter->nreads[ldrv_num%0x80 ]++; - adapter->nreadblocks[ldrv_num%0x80 ] += + adapter->nreads[ldrv_num %0x80 ]++; + adapter->nreadblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }else { - adapter->nwrites[ldrv_num%0x80 ]++; - adapter->nwriteblocks[ldrv_num%0x80 ] += + adapter->nwrites[ldrv_num %0x80 ]++; + adapter->nwriteblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }#endif
@@ -808,12 +787,11 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)/* * 12-byte READ(0xA8) or WRITE(0xAA) cdb */ -if ( cmd->cmd_len ==12 ) { - mbox->m_out.lba = - ((u32 )cmd->cmnd[2 ] <<24 ) | - ((u32 )cmd->cmnd[3 ] <<16 ) | - ((u32 )cmd->cmnd[4 ] <<8 ) | - (u32 )cmd->cmnd[5 ]; +if (cmd->cmd_len ==12 ) { + mbox->m_out.lba = ((u32 )cmd->cmnd[2 ] <<24 ) | + ((u32 )cmd->cmnd[3 ] <<16 ) | + ((u32 )cmd->cmnd[4 ] <<8 ) | + (u32 )cmd->cmnd[5 ]; mbox->m_out.numsectors = ((u32)cmd->cmnd[6] << 24) |
@@ -823,12 +801,12 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)#if MEGA_HAVE_STATS if (*cmd->cmnd ==READ_12 ) { - adapter->nreads[ldrv_num%0x80 ]++; - adapter->nreadblocks[ldrv_num%0x80 ] += + adapter->nreads[ldrv_num %0x80 ]++; + adapter->nreadblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }else { - adapter->nwrites[ldrv_num%0x80 ]++; - adapter->nwriteblocks[ldrv_num%0x80 ] += + adapter->nwrites[ldrv_num %0x80 ]++; + adapter->nwriteblocks[ldrv_num %0x80 ] += mbox->m_out.numsectors; }#endif
@@ -837,16 +815,17 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)/* * If it is a read command */ -if ( (*cmd->cmnd &0x0F ) ==0x08 ) { +if ((*cmd->cmnd &0x0F ) ==0x08 ) { scb->dma_direction =DMA_FROM_DEVICE ; - } -else { + }else { scb->dma_direction =DMA_TO_DEVICE ; }/* Calculate Scatter-Gather info */ - mbox->m_out.numsgelements =mega_build_sglist (adapter, scb, - (u32 *)&mbox->m_out.xferaddr, &seg); + mbox->m_out.numsgelements = +mega_build_sglist (adapter, scb, + (u32 *)&mbox->m_out.xferaddr, + &seg);return scb;
@@ -857,22 +836,22 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)/* * Do we support clustering and is the support enabled */ -if ( ! adapter->has_cluster ) { - +if (!adapter->has_cluster) { cmd->result = (DID_BAD_TARGET <<16 );scsi_done (cmd);return NULL ; }/* Allocate a SCB and initialize mailbox */ -if (!(scb =mega_allocate_scb (adapter, cmd))) { +if (!(scb =mega_allocate_scb (adapter, cmd))) { *busy =1 ;return NULL ; } scb->raw_mbox[0 ] =MEGA_CLUSTER_CMD ; - scb->raw_mbox[2 ] = ( *cmd->cmnd ==RESERVE ) ? -MEGA_RESERVE_LD :MEGA_RELEASE_LD ; + scb->raw_mbox[2 ] = (*cmd->cmnd ==RESERVE ) ? +MEGA_RESERVE_LD : +MEGA_RELEASE_LD ; scb->raw_mbox[3 ] = ldrv_num;
@@ -893,7 +872,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)*/ else {/* Allocate a SCB and initialize passthru */ -if (!(scb =mega_allocate_scb (adapter, cmd))) { +if (!(scb =mega_allocate_scb (adapter, cmd))) { *busy =1 ;return NULL ; }
@@ -901,38 +880,32 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) mbox = (mbox_t *)scb->raw_mbox;memset (mbox,0 ,sizeof (scb->raw_mbox)); -if ( adapter->support_ext_cdb ) { - -mega_prepare_extpassthru (adapter, scb, cmd, - channel, target); +if (adapter->support_ext_cdb) { +mega_prepare_extpassthru (adapter, scb, cmd, channel, + target); mbox->m_out.cmd =MEGA_MBOXCMD_EXTPTHRU ; mbox->m_out.xferaddr = scb->epthru_dma_addr; - } -else { - + }else { pthru =mega_prepare_passthru (adapter, scb, cmd, - channel, target); + channel, target);/* Initialize mailbox */ -if ( adapter->has_64bit_addr ) { +if (adapter->has_64bit_addr) { mbox->m_out.cmd =MEGA_MBOXCMD_PASSTHRU64 ; - } -else { + }else { mbox->m_out.cmd =MEGA_MBOXCMD_PASSTHRU ; } mbox->m_out.xferaddr = scb->pthru_dma_addr; - }return scb; }return NULL ; } -/** * mega_prepare_passthru() * @adapter: pointer to our soft state
@@ -943,14 +916,14 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)* * prepare a command for the scsi physical devices. */ -static mega_passthru * -mega_prepare_passthru (adapter_t *adapter,scb_t *scb,struct scsi_cmnd *cmd, -int channel,int target) +static mega_passthru *mega_prepare_passthru (adapter_t *adapter,scb_t *scb, +struct scsi_cmnd *cmd,int channel, +int target) {mega_passthru *pthru; pthru = scb->pthru; -memset (pthru,0 ,sizeof (mega_passthru)); +memset (pthru,0 ,sizeof (mega_passthru));/* 0=6sec/1=60sec/2=10min/3=3hrs */ pthru->timeout =2 ;
@@ -961,8 +934,8 @@ mega_prepare_passthru(adapter_t *adapter, scb_t *scb, struct scsi_cmnd *cmd, pthru->channel = (adapter->flag &BOARD_40LD ) ?0 : channel; - pthru->target = (adapter->flag &BOARD_40LD ) ? - (channel <<4 ) | target : target; + pthru->target = + (adapter->flag &BOARD_40LD ) ? (channel <<4 ) | target : target; pthru->cdblen = cmd->cmd_len; pthru->logdrv = cmd->device->lun;
@@ -976,26 +949,25 @@ mega_prepare_passthru(adapter_t *adapter, scb_t *scb, struct scsi_cmnd *cmd,switch (cmd->cmnd[0 ]) {case INQUIRY :case READ_CAPACITY : -if (!(adapter->flag & (1L << cmd->device->channel))) { - +if (!(adapter->flag & (1L << cmd->device->channel))) {dev_notice (&adapter->dev->dev, -"scsi%d: scanning scsi channel %d [P%d] " -"for physical devices\n" , - adapter->host->host_no, - cmd->device->channel, channel); +"scsi%d: scanning scsi channel %d [P%d] " +"for physical devices\n" , + adapter->host->host_no, cmd->device->channel, + channel); adapter->flag |= (1L << cmd->device->channel); } fallthrough;default : - pthru->numsgelements =mega_build_sglist (adapter, scb, - &pthru->dataxferaddr, &pthru->dataxferlen); + pthru->numsgelements = +mega_build_sglist (adapter, scb, &pthru->dataxferaddr, + &pthru->dataxferlen);break ; }return pthru; } -/** * mega_prepare_extpassthru() * @adapter: pointer to our soft state
@@ -1007,12 +979,12 @@ mega_prepare_passthru(adapter_t *adapter, scb_t *scb, struct scsi_cmnd *cmd,* prepare a command for the scsi physical devices. This rountine prepares * commands for devices which can take extended CDBs (>10 bytes) */ -static mega_ext_passthru * -mega_prepare_extpassthru (adapter_t *adapter,scb_t *scb, -struct scsi_cmnd *cmd, -int channel,int target) +static mega_ext_passthru *mega_prepare_extpassthru (adapter_t *adapter, +scb_t *scb, +struct scsi_cmnd *cmd, +int channel,int target) { -mega_ext_passthru *epthru; +mega_ext_passthru *epthru; epthru = scb->epthru;memset (epthru,0 ,sizeof (mega_ext_passthru));
@@ -1025,8 +997,8 @@ mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb, epthru->islogical =0 ; epthru->channel = (adapter->flag &BOARD_40LD ) ?0 : channel; - epthru->target = (adapter->flag &BOARD_40LD ) ? - (channel <<4 ) | target : target; + epthru->target = + (adapter->flag &BOARD_40LD ) ? (channel <<4 ) | target : target; epthru->cdblen = cmd->cmd_len; epthru->logdrv = cmd->device->lun;
@@ -1036,43 +1008,40 @@ mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb,/* Not sure about the direction */ scb->dma_direction =DMA_BIDIRECTIONAL ; -switch (cmd->cmnd[0 ]) { +switch (cmd->cmnd[0 ]) {case INQUIRY :case READ_CAPACITY : -if (!(adapter->flag & (1L << cmd->device->channel))) { - +if (!(adapter->flag & (1L << cmd->device->channel))) {dev_notice (&adapter->dev->dev, -"scsi%d: scanning scsi channel %d [P%d] " -"for physical devices\n" , - adapter->host->host_no, - cmd->device->channel, channel); +"scsi%d: scanning scsi channel %d [P%d] " +"for physical devices\n" , + adapter->host->host_no, cmd->device->channel, + channel); adapter->flag |= (1L << cmd->device->channel); } fallthrough;default : - epthru->numsgelements =mega_build_sglist (adapter, scb, - &epthru->dataxferaddr, &epthru->dataxferlen); + epthru->numsgelements = +mega_build_sglist (adapter, scb, &epthru->dataxferaddr, + &epthru->dataxferlen);break ; }return epthru; } -static void -__mega_runpendq (adapter_t *adapter) +static void __mega_runpendq (adapter_t *adapter) {scb_t *scb;struct list_head *pos, *next;/* Issue any pending commands to the card */ -list_for_each_safe (pos, next, &adapter->pending_list) { - + list_for_each_safe (pos, next, &adapter->pending_list) { scb =list_entry (pos, scb_t, list); -if ( !(scb->state &SCB_ISSUED ) ) { - -if (issue_scb (adapter, scb) !=0 ) +if (!(scb->state &SCB_ISSUED )) { +if (issue_scb (adapter, scb) !=0 )return ; } }
@@ -1080,7 +1049,6 @@ __mega_runpendq(adapter_t *adapter)return ; } -/** * issue_scb() * @adapter: pointer to our soft state
@@ -1090,29 +1058,28 @@ __mega_runpendq(adapter_t *adapter)* busy. We also take the scb from the pending list if the mailbox is * available. */ -static int -issue_scb (adapter_t *adapter,scb_t *scb) +static int issue_scb (adapter_t *adapter,scb_t *scb) { -volatile mbox64_t *mbox64 = adapter->mbox64; -volatile mbox_t *mbox = adapter->mbox; -unsigned int i =0 ; +volatile mbox64_t *mbox64 = adapter->mbox64; +volatile mbox_t *mbox = adapter->mbox; +unsigned int i =0 ; -if (unlikely (mbox->m_in.busy)) { +if (unlikely (mbox->m_in.busy)) {do {udelay (1 ); i++; - }while ( mbox->m_in.busy && (i < max_mbox_busy_wait) ); + }while (mbox->m_in.busy && (i < max_mbox_busy_wait)); -if (mbox->m_in.busy)return -1 ; +if (mbox->m_in.busy) +return -1 ; }/* Copy mailbox data into host structure */ -memcpy ((char *)&mbox->m_out, (char *)scb->raw_mbox, -sizeof (struct mbox_out )); - - mbox->m_out.cmdid = scb->idx;/* Set cmdid */ - mbox->m_in.busy =1 ;/* Set busy */ +memcpy ((char *)&mbox->m_out, (char *)scb->raw_mbox, +sizeof (struct mbox_out )); + mbox->m_out.cmdid = scb->idx;/* Set cmdid */ + mbox->m_in.busy =1 ;/* Set busy */ /* * Increment the pending queue counter
@@ -1138,12 +1105,11 @@ issue_scb(adapter_t *adapter, scb_t *scb)*/ scb->state |=SCB_ISSUED ; -if (likely (adapter->flag &BOARD_MEMMAP ) ) { +if (likely (adapter->flag &BOARD_MEMMAP )) { mbox->m_in.poll =0 ; mbox->m_in.ack =0 ;WRINDOOR (adapter, adapter->mbox_dma |0x1 ); - } -else { + }else {irq_enable (adapter);issue_command (adapter); }
@@ -1154,8 +1120,7 @@ issue_scb(adapter_t *adapter, scb_t *scb)/* * Wait until the controller's mailbox is available */ -static inline int -mega_busywait_mbox (adapter_t *adapter) +static inline int mega_busywait_mbox (adapter_t *adapter) {if (adapter->mbox->m_in.busy)return __mega_busywait_mbox (adapter);
@@ -1169,19 +1134,18 @@ mega_busywait_mbox (adapter_t *adapter)* * Issue a scb in synchronous and non-interrupt mode */ -static int -issue_scb_block (adapter_t *adapter,u_char *raw_mbox) +static int issue_scb_block (adapter_t *adapter,u_char *raw_mbox) {volatile mbox64_t *mbox64 = adapter->mbox64;volatile mbox_t *mbox = adapter->mbox; -u8 byte; +u8 byte;/* Wait until mailbox is free */ -if (mega_busywait_mbox (adapter)) +if (mega_busywait_mbox (adapter)) goto bug_blocked_mailbox;/* Copy mailbox data into host structure */ -memcpy ((char *) mbox, raw_mbox,sizeof (struct mbox_out )); +memcpy ((char *)mbox, raw_mbox,sizeof (struct mbox_out )); mbox->m_out.cmdid =0xFE ; mbox->m_in.busy =1 ;
@@ -1199,19 +1163,19 @@ issue_scb_block(adapter_t *adapter, u_char *raw_mbox) mbox64->xfer_segment_hi =0 ; } -if (likely (adapter->flag &BOARD_MEMMAP ) ) { +if (likely (adapter->flag &BOARD_MEMMAP )) { mbox->m_in.poll =0 ; mbox->m_in.ack =0 ; mbox->m_in.numstatus =0xFF ; mbox->m_in.status =0xFF ;WRINDOOR (adapter, adapter->mbox_dma |0x1 ); -while ((volatile u8 )mbox->m_in.numstatus ==0xFF ) +while ((volatile u8 )mbox->m_in.numstatus ==0xFF )cpu_relax (); mbox->m_in.numstatus =0xFF ; -while ( (volatile u8 )mbox->m_in.poll !=0x77 ) +while ((volatile u8 )mbox->m_in.poll !=0x77 )cpu_relax (); mbox->m_in.poll =0 ;
@@ -1219,10 +1183,9 @@ issue_scb_block(adapter_t *adapter, u_char *raw_mbox)WRINDOOR (adapter, adapter->mbox_dma |0x2 ); -while (RDINDOOR (adapter) &0x2 ) +while (RDINDOOR (adapter) &0x2 )cpu_relax (); - } -else { + }else {irq_disable (adapter);issue_command (adapter);
@@ -1238,11 +1201,10 @@ issue_scb_block(adapter_t *adapter, u_char *raw_mbox) bug_blocked_mailbox:dev_warn (&adapter->dev->dev,"Blocked mailbox......!!\n" ); -udelay (1000 ); +udelay (1000 );return -1 ; } -/** * megaraid_isr_iomapped() * @irq: irq
@@ -1252,17 +1214,15 @@ issue_scb_block(adapter_t *adapter, u_char *raw_mbox)* Find out if our device is interrupting. If yes, acknowledge the interrupt * and service the completed commands. */ -static irqreturn_t -megaraid_isr_iomapped (int irq,void *devp) +static irqreturn_t megaraid_isr_iomapped (int irq,void *devp) { -adapter_t *adapter = devp; -unsigned long flags; -u8 status; -u8 nstatus; -u8 completed[MAX_FIRMWARE_STATUS ]; -u8 byte; -int handled =0 ; - +adapter_t *adapter = devp; +unsigned long flags; +u8 status; +u8 nstatus; +u8 completed[MAX_FIRMWARE_STATUS ]; +u8 byte; +int handled =0 ;/* * loop till F/W has more commands for us to complete.
@@ -1272,7 +1232,7 @@ megaraid_isr_iomapped(int irq, void *devp) do { /* Check if a valid interrupt is pending */ byte = irq_state(adapter); - if( (byte & VALID_INTR_BYTE) == 0 ) { + if ((byte & VALID_INTR_BYTE) == 0) { /* * No more pending commands */
@@ -1280,8 +1240,8 @@ megaraid_isr_iomapped(int irq, void *devp) }set_irq_state (adapter, byte); -while ((nstatus = (volatile u8 )adapter->mbox->m_in.numstatus) - ==0xFF ) +while ((nstatus = (volatile u8 )adapter->mbox->m_in.numstatus) == +0xFF )cpu_relax (); adapter->mbox->m_in.numstatus =0xFF ;
@@ -1292,8 +1252,8 @@ megaraid_isr_iomapped(int irq, void *devp)*/ atomic_sub (nstatus, &adapter->pend_cmds); -memcpy (completed, (void *)adapter->mbox->m_in.completed, - nstatus); +memcpy (completed, (void *)adapter->mbox->m_in.completed, + nstatus);/* Acknowledge interrupt */ irq_ack (adapter);
@@ -1305,20 +1265,19 @@ megaraid_isr_iomapped(int irq, void *devp) handled =1 ;/* Loop through any pending requests */ -if (atomic_read (&adapter->quiescent) ==0 ) { +if (atomic_read (&adapter->quiescent) ==0 ) {mega_runpendq (adapter); } - }while (1 ); + }while (1 ); - out_unlock: +out_unlock:spin_unlock_irqrestore (&adapter->lock, flags);return IRQ_RETVAL (handled); } -/** * megaraid_isr_memmapped() * @irq: irq
@@ -1328,17 +1287,15 @@ megaraid_isr_iomapped(int irq, void *devp)* Find out if our device is interrupting. If yes, acknowledge the interrupt * and service the completed commands. */ -static irqreturn_t -megaraid_isr_memmapped (int irq,void *devp) +static irqreturn_t megaraid_isr_memmapped (int irq,void *devp) { -adapter_t *adapter = devp; -unsigned long flags; -u8 status; -u32 dword =0 ; -u8 nstatus; -u8 completed[MAX_FIRMWARE_STATUS ]; -int handled =0 ; - +adapter_t *adapter = devp; +unsigned long flags; +u8 status; +u32 dword =0 ; +u8 nstatus; +u8 completed[MAX_FIRMWARE_STATUS ]; +int handled =0 ;/* * loop till F/W has more commands for us to complete.
@@ -1348,7 +1305,7 @@ megaraid_isr_memmapped(int irq, void *devp) do { /* Check if a valid interrupt is pending */ dword = RDOUTDOOR(adapter); - if(dword != 0x10001234) { + if (dword != 0x10001234) { /* * No more pending commands */
@@ -1356,8 +1313,8 @@ megaraid_isr_memmapped(int irq, void *devp) }WROUTDOOR (adapter,0x10001234 ); -while ((nstatus = (volatile u8 )adapter->mbox->m_in.numstatus) - ==0xFF ) { +while ((nstatus = (volatile u8 )adapter->mbox->m_in.numstatus) == +0xFF ) {cpu_relax (); } adapter->mbox->m_in.numstatus =0xFF ;
@@ -1369,15 +1326,15 @@ megaraid_isr_memmapped(int irq, void *devp)*/ atomic_sub (nstatus, &adapter->pend_cmds); -memcpy (completed, (void *)adapter->mbox->m_in.completed, - nstatus); +memcpy (completed, (void *)adapter->mbox->m_in.completed, + nstatus);/* Acknowledge interrupt */ WRINDOOR (adapter,0x2 ); handled =1 ; -while (RDINDOOR (adapter) &0x02 ) +while (RDINDOOR (adapter) &0x02 )cpu_relax ();mega_cmd_done (adapter, completed, nstatus, status);
@@ -1385,13 +1342,13 @@ megaraid_isr_memmapped(int irq, void *devp)mega_rundoneq (adapter);/* Loop through any pending requests */ -if (atomic_read (&adapter->quiescent) ==0 ) { +if (atomic_read (&adapter->quiescent) ==0 ) {mega_runpendq (adapter); } - }while (1 ); + }while (1 ); - out_unlock: +out_unlock:spin_unlock_irqrestore (&adapter->lock, flags);
@@ -1406,26 +1363,25 @@ megaraid_isr_memmapped(int irq, void *devp)* * Complete the commands and call the scsi mid-layer callback hooks. */ -static void -mega_cmd_done (adapter_t *adapter,u8 completed[],int nstatus,int status) +static void mega_cmd_done (adapter_t *adapter,u8 completed[],int nstatus, +int status) { -mega_ext_passthru *epthru =NULL ; -struct scatterlist *sgl; -struct scsi_cmnd *cmd =NULL ; -mega_passthru *pthru =NULL ; -mbox_t *mbox =NULL ; -u8 c; -scb_t *scb; -int islogical; -int cmdid; -int i; +mega_ext_passthru *epthru =NULL ; +struct scatterlist *sgl; +struct scsi_cmnd *cmd =NULL ; +mega_passthru *pthru =NULL ; +mbox_t *mbox =NULL ; +u8 c; +scb_t *scb; +int islogical; +int cmdid; +int i;/* * for all the commands completed, call the mid-layer callback routine * and free the scb. */ -for ( i =0 ; i < nstatus; i++ ) { - +for (i =0 ; i < nstatus; i++) { cmdid = completed[i];/*
@@ -1449,10 +1405,11 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)/* * Make sure f/w has completed a valid command */ -if ( !(scb->state &SCB_ISSUED ) || scb->cmd ==NULL ) { -dev_crit (&adapter->dev->dev,"invalid command " -"Id %d, scb->state:%x, scsi cmd:%p\n" , - cmdid, scb->state, scb->cmd); +if (!(scb->state &SCB_ISSUED ) || scb->cmd ==NULL ) { +dev_crit (&adapter->dev->dev, +"invalid command " +"Id %d, scb->state:%x, scsi cmd:%p\n" , + cmdid, scb->state, scb->cmd);continue ; }
@@ -1460,16 +1417,15 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)/* * Was a abort issued for this command */ -if ( scb->state &SCB_ABORT ) { - +if (scb->state &SCB_ABORT ) {dev_warn (&adapter->dev->dev, -"aborted cmd [%x] complete\n" , - scb->idx); +"aborted cmd [%x] complete\n" , + scb->idx); scb->cmd->result = (DID_ABORT <<16 );list_add_tail (SCSI_LIST (scb->cmd), - &adapter->completed_list); + &adapter->completed_list);mega_free_scb (adapter, scb);
@@ -1479,18 +1435,16 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)/* * Was a reset issued for this command */ -if ( scb->state &SCB_RESET ) { - +if (scb->state &SCB_RESET ) {dev_warn (&adapter->dev->dev, -"reset cmd [%x] complete\n" , - scb->idx); +"reset cmd [%x] complete\n" , scb->idx); scb->cmd->result = (DID_RESET <<16 );list_add_tail (SCSI_LIST (scb->cmd), - &adapter->completed_list); + &adapter->completed_list); -mega_free_scb (adapter, scb); +mega_free_scb (adapter, scb);continue ; }
@@ -1502,35 +1456,35 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)#if MEGA_HAVE_STATS { +int logdrv = mbox->m_out.logdrv; -int logdrv = mbox->m_out.logdrv; - - islogical = adapter->logdrv_chan[cmd->channel]; -/* + islogical = adapter->logdrv_chan[cmd->channel]; +/* * Maintain an error counter for the logical drive. * Some application like SNMP agent need such * statistics */ -if ( status && islogical && (cmd->cmnd[0 ] ==READ_6 || - cmd->cmnd[0 ] ==READ_10 || - cmd->cmnd[0 ] ==READ_12 )) { -/* +if (status && islogical && + (cmd->cmnd[0 ] ==READ_6 || + cmd->cmnd[0 ] ==READ_10 || + cmd->cmnd[0 ] ==READ_12 )) { +/* * Logical drive number increases by 0x80 when * a logical drive is deleted */ - adapter->rd_errors[logdrv%0x80 ]++; - } + adapter->rd_errors[logdrv %0x80 ]++; + } -if ( status && islogical && (cmd->cmnd[0 ] ==WRITE_6 || - cmd->cmnd[0 ] ==WRITE_10 || - cmd->cmnd[0 ] ==WRITE_12 )) { -/* +if (status && islogical && + (cmd->cmnd[0 ] ==WRITE_6 || + cmd->cmnd[0 ] ==WRITE_10 || + cmd->cmnd[0 ] ==WRITE_12 )) { +/* * Logical drive number increases by 0x80 when * a logical drive is deleted */ - adapter->wr_errors[logdrv%0x80 ]++; - } - + adapter->wr_errors[logdrv %0x80 ]++; + } }#endif }
@@ -1542,18 +1496,17 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)* PJ */ islogical = adapter->logdrv_chan[cmd->device->channel]; -if ( cmd->cmnd[0 ] ==INQUIRY && !islogical ) { - +if (cmd->cmnd[0 ] ==INQUIRY && !islogical) { sgl =scsi_sglist (cmd); -if (sg_page (sgl) ) { - c = *(unsigned char *)sg_virt (&sgl[0 ]); +if (sg_page (sgl)) { + c = *(unsigned char *)sg_virt (&sgl[0 ]); }else {dev_warn (&adapter->dev->dev,"invalid sg\n" ); c =0 ; } -if (IS_RAID_CH (adapter, cmd->device->channel) && - ((c &0x1F ) ==TYPE_DISK )) { +if (IS_RAID_CH (adapter, cmd->device->channel) && + ((c &0x1F ) ==TYPE_DISK )) { status =0xF0 ; } }
@@ -1563,27 +1516,24 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)/* Convert MegaRAID status to Linux error code */ switch (status) { -case 0x00 :/* SUCCESS , i.e. SCSI_STATUS_GOOD */ +case 0x00 :/* SUCCESS , i.e. SCSI_STATUS_GOOD */ cmd->result |= (DID_OK <<16 );break ; -case 0x02 :/* ERROR_ABORTED, i.e. +case 0x02 :/* ERROR_ABORTED, i.e. SCSI_STATUS_CHECK_CONDITION */ /* set sense_buffer and result fields */ -if ( mbox->m_out.cmd ==MEGA_MBOXCMD_PASSTHRU || - mbox->m_out.cmd ==MEGA_MBOXCMD_PASSTHRU64 ) { - +if (mbox->m_out.cmd ==MEGA_MBOXCMD_PASSTHRU || + mbox->m_out.cmd ==MEGA_MBOXCMD_PASSTHRU64 ) {memcpy (cmd->sense_buffer, pthru->reqsensearea, -14 ); +14 ); cmd->result =SAM_STAT_CHECK_CONDITION ; - } -else { + }else {if (mbox->m_out.cmd ==MEGA_MBOXCMD_EXTPTHRU ) { -memcpy (cmd->sense_buffer, - epthru->reqsensearea,14 ); + epthru->reqsensearea,14 ); cmd->result =SAM_STAT_CHECK_CONDITION ; }else
@@ -1592,7 +1542,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) }break ; -case 0x08 :/* ERR_DEST_DRIVE_FAILED, i.e. +case 0x08 :/* ERR_DEST_DRIVE_FAILED, i.e. SCSI_STATUS_BUSY */ cmd->result |= (DID_BUS_BUSY <<16 ) | status;break ;
@@ -1603,25 +1553,23 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)* If TEST_UNIT_READY fails, we know * MEGA_RESERVATION_STATUS failed */ -if ( cmd->cmnd[0 ] ==TEST_UNIT_READY ) { +if (cmd->cmnd[0 ] ==TEST_UNIT_READY ) { cmd->result |= (DID_ERROR <<16 ) | -SAM_STAT_RESERVATION_CONFLICT ; - } -else -/* +SAM_STAT_RESERVATION_CONFLICT ; + }else +/* * Error code returned is 1 if Reserve or Release * failed or the input parameter is invalid */ -if ( status ==1 && - (cmd->cmnd[0 ] ==RESERVE || - cmd->cmnd[0 ] ==RELEASE ) ) { - - cmd->result |= (DID_ERROR <<16 ) | -SAM_STAT_RESERVATION_CONFLICT ; - } - else +if (status ==1 && (cmd->cmnd[0 ] ==RESERVE || + cmd->cmnd[0 ] ==RELEASE )) { + cmd->result |= + (DID_ERROR <<16 ) | +SAM_STAT_RESERVATION_CONFLICT ; + } else#endif - cmd->result |= (DID_BAD_TARGET <<16 )|status; + cmd->result |= + (DID_BAD_TARGET <<16 ) | status; }mega_free_scb (adapter, scb);
@@ -1631,21 +1579,18 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) } } -/* * mega_runpendq() * * Run through the list of completed requests and finish it */ -static void -mega_rundoneq (adapter_t *adapter) +static void mega_rundoneq (adapter_t *adapter) {struct scsi_cmnd *cmd;struct list_head *pos; -list_for_each (pos, &adapter->completed_list) { - -struct scsi_pointer * spos = (struct scsi_pointer *)pos; + list_for_each (pos, &adapter->completed_list) { +struct scsi_pointer *spos = (struct scsi_pointer *)pos; cmd = list_entry(spos, struct scsi_cmnd, SCp);scsi_done (cmd);
@@ -1654,16 +1599,13 @@ mega_rundoneq (adapter_t *adapter)INIT_LIST_HEAD (&adapter->completed_list); } -/* * Free a SCB structure * Note: We assume the scsi commands associated with this scb is not free yet. */ -static void -mega_free_scb (adapter_t *adapter,scb_t *scb) +static void mega_free_scb (adapter_t *adapter,scb_t *scb) { -switch ( scb->dma_type ) { - +switch (scb->dma_type) {case MEGA_DMA_TYPE_NONE :break ;
@@ -1686,9 +1628,7 @@ mega_free_scb(adapter_t *adapter, scb_t *scb)list_add (&scb->list, &adapter->free_list); } - -static int -__mega_busywait_mbox (adapter_t *adapter) +static int __mega_busywait_mbox (adapter_t *adapter) {volatile mbox_t *mbox = adapter->mbox;long counter;
@@ -1699,20 +1639,19 @@ __mega_busywait_mbox (adapter_t *adapter)udelay (100 );cond_resched (); } -return -1 ;/* give up after 1 second */ +return -1 ;/* give up after 1 second */ }/* * Copies data to SGLIST * Note: For 64 bit cards, we need a minimum of one SG element for read/write */ -static int -mega_build_sglist (adapter_t *adapter,scb_t *scb,u32 *buf,u32 *len) +static int mega_build_sglist (adapter_t *adapter,scb_t *scb,u32 *buf,u32 *len) {struct scatterlist *sg; -struct scsi_cmnd *cmd; -int sgcnt; -int idx; +struct scsi_cmnd *cmd; +int sgcnt; +int idx; cmd = scb->cmd;
@@ -1737,7 +1676,7 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)return 0 ; } -scsi_for_each_sg (cmd, sg, sgcnt, idx) { + scsi_for_each_sg (cmd, sg, sgcnt, idx) {if (adapter->has_64bit_addr) { scb->sgl64[idx].address =sg_dma_address (sg); *len += scb->sgl64[idx].length =sg_dma_len (sg);
@@ -1754,16 +1693,14 @@ mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)return sgcnt; } -/* * mega_8_to_40ld() * * takes all info in AdapterInquiry structure and puts it into ProductInfo and * Enquiry3 structures for later use */ -static void -mega_8_to_40ld (mraid_inquiry *inquiry,mega_inquiry3 *enquiry3, -mega_product_info *product_info) +static void mega_8_to_40ld (mraid_inquiry *inquiry,mega_inquiry3 *enquiry3, +mega_product_info *product_info) {int i;
@@ -1795,17 +1732,15 @@ mega_8_to_40ld(mraid_inquiry *inquiry, mega_inquiry3 *enquiry3, enquiry3->pdrv_state[i] = inquiry->pdrv_info.pdrv_state[i]; } -static inline void -mega_free_sgl (adapter_t *adapter) +static inline void mega_free_sgl (adapter_t *adapter) { -scb_t *scb; -int i; - -for (i =0 ; i < adapter->max_cmds; i++) { +scb_t *scb; +int i; +for (i =0 ; i < adapter->max_cmds; i++) { scb = &adapter->scb_list[i]; -if ( scb->sgl64 ) { +if (scb->sgl64) {dma_free_coherent (&adapter->dev->dev,sizeof (mega_sgl64) * adapter->sglen, scb->sgl64, scb->sgl_dma_addr);
@@ -1813,7 +1748,7 @@ mega_free_sgl(adapter_t *adapter) scb->sgl64 =NULL ; } -if ( scb->pthru ) { +if (scb->pthru) {dma_free_coherent (&adapter->dev->dev,sizeof (mega_passthru), scb->pthru, scb->pthru_dma_addr);
@@ -1821,34 +1756,31 @@ mega_free_sgl(adapter_t *adapter) scb->pthru =NULL ; } -if ( scb->epthru ) { +if (scb->epthru) {dma_free_coherent (&adapter->dev->dev,sizeof (mega_ext_passthru), scb->epthru, scb->epthru_dma_addr); scb->epthru =NULL ; } - } } -/* * Get information about the card/driver */ -const char * -megaraid_info (struct Scsi_Host *host) +const char *megaraid_info (struct Scsi_Host *host) {static char buffer[512 ];adapter_t *adapter; adapter = (adapter_t *)host->hostdata; -sprintf (buffer, -"LSI Logic MegaRAID %s %d commands %d targs %d chans %d luns" , - adapter->fw_version, adapter->product_info.max_commands, - adapter->host->max_id, adapter->host->max_channel, - (u32 )adapter->host->max_lun); +sprintf (buffer, +"LSI Logic MegaRAID %s %d commands %d targs %d chans %d luns" , + adapter->fw_version, adapter->product_info.max_commands, + adapter->host->max_id, adapter->host->max_channel, + (u32 )adapter->host->max_lun);return buffer; }
@@ -1856,15 +1788,14 @@ megaraid_info(struct Scsi_Host *host)* Abort a previous SCSI request. Only commands on the pending list can be * aborted. All the commands issued to the F/W must complete. */ -static int -megaraid_abort (struct scsi_cmnd *cmd) +static int megaraid_abort (struct scsi_cmnd *cmd) { -adapter_t *adapter; -int rval; +adapter_t *adapter; +int rval; adapter = (adapter_t *)cmd->device->host->hostdata; - rval =megaraid_abort_and_reset (adapter, cmd,SCB_ABORT ); + rval =megaraid_abort_and_reset (adapter, cmd,SCB_ABORT );/* * This is required here to complete any completed requests
@@ -1875,13 +1806,11 @@ megaraid_abort(struct scsi_cmnd *cmd)return rval; } - -static int -megaraid_reset (struct scsi_cmnd *cmd) +static int megaraid_reset (struct scsi_cmnd *cmd) { -adapter_t *adapter; -megacmd_t mc; -int rval; +adapter_t *adapter; +megacmd_t mc; +int rval; adapter = (adapter_t *)cmd->device->host->hostdata;
@@ -1889,17 +1818,16 @@ megaraid_reset(struct scsi_cmnd *cmd) mc.cmd =MEGA_CLUSTER_CMD ; mc.opcode =MEGA_RESET_RESERVATIONS ; -if (mega_internal_command (adapter, &mc,NULL ) !=0 ) { +if (mega_internal_command (adapter, &mc,NULL ) !=0 ) {dev_warn (&adapter->dev->dev,"reservation reset failed\n" ); - } -else { + }else {dev_info (&adapter->dev->dev,"reservation reset\n" ); }#endif spin_lock_irq (&adapter->lock); - rval =megaraid_abort_and_reset (adapter, cmd,SCB_RESET ); + rval =megaraid_abort_and_reset (adapter, cmd,SCB_RESET );/* * This is required here to complete any completed requests
@@ -1920,22 +1848,20 @@ megaraid_reset(struct scsi_cmnd *cmd)* Try to locate the scsi command in the pending queue. If found and is not * issued to the controller, abort/reset it. Otherwise return failure */ -static int -megaraid_abort_and_reset (adapter_t *adapter,struct scsi_cmnd *cmd,int aor) +static int megaraid_abort_and_reset (adapter_t *adapter,struct scsi_cmnd *cmd, +int aor) { -struct list_head *pos, *next; -scb_t *scb; +struct list_head *pos, *next; +scb_t *scb;dev_warn (&adapter->dev->dev,"%s cmd=%x <c=%d t=%d l=%d>\n" , - (aor ==SCB_ABORT )?"ABORTING" :"RESET" , - cmd->cmnd[0 ], cmd->device->channel, - cmd->device->id, (u32 )cmd->device->lun); + (aor ==SCB_ABORT ) ?"ABORTING" :"RESET" , cmd->cmnd[0 ], + cmd->device->channel, cmd->device->id, (u32 )cmd->device->lun); -if (list_empty (&adapter->pending_list)) +if (list_empty (&adapter->pending_list))return FAILED ; -list_for_each_safe (pos, next, &adapter->pending_list) { - + list_for_each_safe (pos, next, &adapter->pending_list) { scb =list_entry (pos, scb_t, list);if (scb->cmd == cmd) {/* Found command */
@@ -1948,37 +1874,35 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor)* completes this command, we will return appropriate * status from ISR. */ -if ( scb->state &SCB_ISSUED ) { - +if (scb->state &SCB_ISSUED ) {dev_warn (&adapter->dev->dev, -"%s[%x], fw owner\n" , - (aor==SCB_ABORT ) ?"ABORTING" :"RESET" , - scb->idx); +"%s[%x], fw owner\n" , + (aor ==SCB_ABORT ) ?"ABORTING" : +"RESET" , + scb->idx);return FAILED ; - } -else { - + }else {/* * Not yet issued! Remove from the pending * list */ dev_warn (&adapter->dev->dev, -"%s-[%x], driver owner\n" , - (aor==SCB_ABORT ) ?"ABORTING" :"RESET" , - scb->idx); +"%s-[%x], driver owner\n" , + (aor ==SCB_ABORT ) ?"ABORTING" : +"RESET" , + scb->idx);mega_free_scb (adapter, scb); -if ( aor ==SCB_ABORT ) { +if (aor ==SCB_ABORT ) { cmd->result = (DID_ABORT <<16 ); - } -else { + }else { cmd->result = (DID_RESET <<16 ); }list_add_tail (SCSI_LIST (cmd), - &adapter->completed_list); + &adapter->completed_list);return SUCCESS ; }
@@ -1988,12 +1912,12 @@ megaraid_abort_and_reset(adapter_t *adapter, struct scsi_cmnd *cmd, int aor)return FAILED ; } -static inline int -make_local_pdev (adapter_t *adapter,struct pci_dev **pdev) +static inline int make_local_pdev (adapter_t *adapter,struct pci_dev **pdev) { *pdev =pci_alloc_dev (NULL ); -if ( *pdev ==NULL )return -1 ; +if (*pdev ==NULL ) +return -1 ;memcpy (*pdev, adapter->dev,sizeof (struct pci_dev ));
@@ -2005,8 +1929,7 @@ make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)return 0 ; } -static inline void -free_local_pdev (struct pci_dev *pdev) +static inline void free_local_pdev (struct pci_dev *pdev) {kfree (pdev); }
@@ -2018,22 +1941,20 @@ free_local_pdev(struct pci_dev *pdev)* * allocates memory for inquiry structure */ -static inline void * -mega_allocate_inquiry (dma_addr_t *dma_handle,struct pci_dev *pdev) +static inline void *mega_allocate_inquiry (dma_addr_t *dma_handle, +struct pci_dev *pdev) { -return dma_alloc_coherent (&pdev->dev,sizeof (mega_inquiry3), - dma_handle,GFP_KERNEL ); +return dma_alloc_coherent (&pdev->dev,sizeof (mega_inquiry3), dma_handle, +GFP_KERNEL ); } - -static inline void -mega_free_inquiry (void *inquiry,dma_addr_t dma_handle,struct pci_dev *pdev) +static inline void mega_free_inquiry (void *inquiry,dma_addr_t dma_handle, +struct pci_dev *pdev) {dma_free_coherent (&pdev->dev,sizeof (mega_inquiry3), inquiry, dma_handle); } -#ifdef CONFIG_PROC_FS /* Following code handles /proc fs */
@@ -2044,42 +1965,40 @@ mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)* * Display configuration information about the controller. */ -static int -proc_show_config (struct seq_file *m,void *v) +static int proc_show_config (struct seq_file *m,void *v) { -adapter_t *adapter = m->private;seq_puts (m,MEGARAID_VERSION ); -if (adapter->product_info.product_name[0 ]) +if (adapter->product_info.product_name[0 ])seq_printf (m,"%s\n" , adapter->product_info.product_name);seq_puts (m,"Controller Type: " ); -if ( adapter->flag &BOARD_MEMMAP ) +if (adapter->flag &BOARD_MEMMAP )seq_puts (m,"438/466/467/471/493/518/520/531/532\n" );else seq_puts (m,"418/428/434\n" ); -if (adapter->flag &BOARD_40LD ) +if (adapter->flag &BOARD_40LD )seq_puts (m,"Controller Supports 40 Logical Drives\n" ); -if (adapter->flag &BOARD_64BIT ) +if (adapter->flag &BOARD_64BIT )seq_puts (m,"Controller capable of 64-bit memory addressing\n" ); -if ( adapter->has_64bit_addr ) +if (adapter->has_64bit_addr)seq_puts (m,"Controller using 64-bit memory addressing\n" );else -seq_puts (m,"Controller is not using 64-bit memory addressing\n" ); +seq_puts (m, +"Controller is not using 64-bit memory addressing\n" ); -seq_printf (m,"Base = %08lx, Irq = %d, " , - adapter->base, adapter->host->irq); +seq_printf (m,"Base = %08lx, Irq = %d, " , adapter->base, + adapter->host->irq); -seq_printf (m,"Logical Drives = %d, Channels = %d\n" , - adapter->numldrv, adapter->product_info.nchannels); +seq_printf (m,"Logical Drives = %d, Channels = %d\n" , adapter->numldrv, + adapter->product_info.nchannels); -seq_printf (m,"Version =%s:%s, DRAM = %dMb\n" , - adapter->fw_version, adapter->bios_version, - adapter->product_info.dram_size); +seq_printf (m,"Version =%s:%s, DRAM = %dMb\n" , adapter->fw_version, + adapter->bios_version, adapter->product_info.dram_size);seq_printf (m,"Controller Queue Depth = %d, Driver Queue Depth = %d\n" , adapter->product_info.max_commands, adapter->max_cmds);
@@ -2108,18 +2027,17 @@ proc_show_config(struct seq_file *m, void *v)* * Display statistical information about the I/O activity. */ -static int -proc_show_stat (struct seq_file *m,void *v) +static int proc_show_stat (struct seq_file *m,void *v) {adapter_t *adapter = m->private;#if MEGA_HAVE_STATS -int i; +int i;#endif seq_puts (m,"Statistical Information for this controller\n" );seq_printf (m,"pend_cmds = %d\n" ,atomic_read (&adapter->pend_cmds));#if MEGA_HAVE_STATS -for (i =0 ; i < adapter->numldrv; i++) { +for (i =0 ; i < adapter->numldrv; i++) {seq_printf (m,"Logical Drive %d:\n" , i);seq_printf (m,"\tReads Issued = %lu, Writes Issued = %lu\n" , adapter->nreads[i], adapter->nwrites[i]);
@@ -2134,7 +2052,6 @@ proc_show_stat(struct seq_file *m, void *v)return 0 ; } -/** * proc_show_mbox() * @m: Synthetic file construction data
@@ -2143,11 +2060,10 @@ proc_show_stat(struct seq_file *m, void *v)* Display mailbox information for the last command issued. This information * is good for debugging. */ -static int -proc_show_mbox (struct seq_file *m,void *v) +static int proc_show_mbox (struct seq_file *m,void *v) { -adapter_t *adapter = m->private; -volatile mbox_t *mbox = adapter->mbox; +adapter_t *adapter = m->private; +volatile mbox_t *mbox = adapter->mbox;seq_puts (m,"Contents of Mail Box Structure\n" );seq_printf (m," Fw Command = 0x%02x\n" , mbox->m_out.cmd);
@@ -2162,7 +2078,6 @@ proc_show_mbox(struct seq_file *m, void *v)return 0 ; } -/** * proc_show_rebuild_rate() * @m: Synthetic file construction data
@@ -2170,33 +2085,32 @@ proc_show_mbox(struct seq_file *m, void *v)* * Display current rebuild rate */ -static int -proc_show_rebuild_rate (struct seq_file *m,void *v) +static int proc_show_rebuild_rate (struct seq_file *m,void *v) { -adapter_t *adapter = m->private; -dma_addr_t dma_handle; -caddr_t inquiry; -struct pci_dev *pdev; +adapter_t *adapter = m->private; +dma_addr_t dma_handle; +caddr_t inquiry; +struct pci_dev *pdev; -if (make_local_pdev (adapter, &pdev) !=0 ) +if (make_local_pdev (adapter, &pdev) !=0 )return 0 ; -if ( (inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) +if ((inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) goto free_pdev; -if (mega_adapinq (adapter, dma_handle) !=0 ) { +if (mega_adapinq (adapter, dma_handle) !=0 ) {seq_puts (m,"Adapter inquiry failed.\n" );dev_warn (&adapter->dev->dev,"inquiry failed\n" ); goto free_inquiry; } -if ( adapter->flag &BOARD_40LD ) +if (adapter->flag &BOARD_40LD )seq_printf (m,"Rebuild Rate: [%d%%]\n" , ((mega_inquiry3 *)inquiry)->rebuild_rate);else seq_printf (m,"Rebuild Rate: [%d%%]\n" , - ((mraid_ext_inquiry *) - inquiry)->raid_inq.adapter_info.rebuild_rate); + ((mraid_ext_inquiry *)inquiry) + ->raid_inq.adapter_info.rebuild_rate); free_inquiry:mega_free_inquiry (inquiry, dma_handle, pdev);
@@ -2205,7 +2119,6 @@ proc_show_rebuild_rate(struct seq_file *m, void *v)return 0 ; } -/** * proc_show_battery() * @m: Synthetic file construction data
@@ -2213,33 +2126,31 @@ proc_show_rebuild_rate(struct seq_file *m, void *v)* * Display information about the battery module on the controller. */ -static int -proc_show_battery (struct seq_file *m,void *v) +static int proc_show_battery (struct seq_file *m,void *v) { -adapter_t *adapter = m->private; -dma_addr_t dma_handle; -caddr_t inquiry; -struct pci_dev *pdev; -u8 battery_status; +adapter_t *adapter = m->private; +dma_addr_t dma_handle; +caddr_t inquiry; +struct pci_dev *pdev; +u8 battery_status; -if (make_local_pdev (adapter, &pdev) !=0 ) +if (make_local_pdev (adapter, &pdev) !=0 )return 0 ; -if ( (inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) +if ((inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) goto free_pdev; -if (mega_adapinq (adapter, dma_handle) !=0 ) { +if (mega_adapinq (adapter, dma_handle) !=0 ) {seq_puts (m,"Adapter inquiry failed.\n" );dev_warn (&adapter->dev->dev,"inquiry failed\n" ); goto free_inquiry; } -if ( adapter->flag &BOARD_40LD ) { +if (adapter->flag &BOARD_40LD ) { battery_status = ((mega_inquiry3 *)inquiry)->battery_status; - } -else { - battery_status = ((mraid_ext_inquiry *)inquiry)-> - raid_inq.adapter_info.battery_status; + }else { + battery_status = ((mraid_ext_inquiry *)inquiry) + ->raid_inq.adapter_info.battery_status; }/*
@@ -2247,28 +2158,28 @@ proc_show_battery(struct seq_file *m, void *v)*/ seq_printf (m,"Battery Status:[%d]" , battery_status); -if (battery_status ==MEGA_BATT_CHARGE_DONE ) +if (battery_status ==MEGA_BATT_CHARGE_DONE )seq_puts (m," Charge Done" ); -if (battery_status &MEGA_BATT_MODULE_MISSING ) +if (battery_status &MEGA_BATT_MODULE_MISSING )seq_puts (m," Module Missing" ); - -if (battery_status &MEGA_BATT_LOW_VOLTAGE ) + +if (battery_status &MEGA_BATT_LOW_VOLTAGE )seq_puts (m," Low Voltage" ); - -if (battery_status &MEGA_BATT_TEMP_HIGH ) + +if (battery_status &MEGA_BATT_TEMP_HIGH )seq_puts (m," Temperature High" ); - -if (battery_status &MEGA_BATT_PACK_MISSING ) + +if (battery_status &MEGA_BATT_PACK_MISSING )seq_puts (m," Pack Missing" ); - -if (battery_status &MEGA_BATT_CHARGE_INPROG ) + +if (battery_status &MEGA_BATT_CHARGE_INPROG )seq_puts (m," Charge In-progress" ); - -if (battery_status &MEGA_BATT_CHARGE_FAIL ) + +if (battery_status &MEGA_BATT_CHARGE_FAIL )seq_puts (m," Charge Fail" ); - -if (battery_status &MEGA_BATT_CYCLES_EXCEEDED ) + +if (battery_status &MEGA_BATT_CYCLES_EXCEEDED )seq_puts (m," Cycles Exceeded" );seq_putc (m,'\n' );
@@ -2280,14 +2191,12 @@ proc_show_battery(struct seq_file *m, void *v)return 0 ; } -/* * Display scsi inquiry */ -static void -mega_print_inquiry (struct seq_file *m,char *scsi_inq) +static void mega_print_inquiry (struct seq_file *m,char *scsi_inq) { -int i; +int i;seq_puts (m," Vendor: " );seq_write (m, scsi_inq +8 ,8 );
@@ -2303,7 +2212,7 @@ mega_print_inquiry(struct seq_file *m, char *scsi_inq)seq_printf (m," ANSI SCSI revision: %02x" , scsi_inq[2 ] &0x07 ); -if ( (scsi_inq[2 ] &0x07 ) ==1 && (scsi_inq[3 ] &0x0f ) ==1 ) +if ((scsi_inq[2 ] &0x07 ) ==1 && (scsi_inq[3 ] &0x0f ) ==1 )seq_puts (m," CCS\n" );else seq_putc (m,'\n' );
@@ -2317,60 +2226,56 @@ mega_print_inquiry(struct seq_file *m, char *scsi_inq)* * Display information about the physical drives. */ -static int -proc_show_pdrv (struct seq_file *m,adapter_t *adapter,int channel) +static int proc_show_pdrv (struct seq_file *m,adapter_t *adapter,int channel) { -dma_addr_t dma_handle; -char *scsi_inq; -dma_addr_t scsi_inq_dma_handle; -caddr_t inquiry; -struct pci_dev *pdev; -u8 *pdrv_state; -u8 state; -int tgt; -int max_channels; -int i; - -if (make_local_pdev (adapter, &pdev) !=0 ) +dma_addr_t dma_handle; +char *scsi_inq; +dma_addr_t scsi_inq_dma_handle; +caddr_t inquiry; +struct pci_dev *pdev; +u8 *pdrv_state; +u8 state; +int tgt; +int max_channels; +int i; + +if (make_local_pdev (adapter, &pdev) !=0 )return 0 ; -if ( (inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) +if ((inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) goto free_pdev; -if (mega_adapinq (adapter, dma_handle) !=0 ) { +if (mega_adapinq (adapter, dma_handle) !=0 ) {seq_puts (m,"Adapter inquiry failed.\n" );dev_warn (&adapter->dev->dev,"inquiry failed\n" ); goto free_inquiry; } - scsi_inq =dma_alloc_coherent (&pdev->dev,256 , &scsi_inq_dma_handle,GFP_KERNEL ); -if ( scsi_inq ==NULL ) { +if (scsi_inq ==NULL ) {seq_puts (m,"memory not available for scsi inq.\n" ); goto free_inquiry; } -if ( adapter->flag &BOARD_40LD ) { +if (adapter->flag &BOARD_40LD ) { pdrv_state = ((mega_inquiry3 *)inquiry)->pdrv_state; - } -else { - pdrv_state = ((mraid_ext_inquiry *)inquiry)-> - raid_inq.pdrv_info.pdrv_state; + }else { + pdrv_state = ((mraid_ext_inquiry *)inquiry) + ->raid_inq.pdrv_info.pdrv_state; } max_channels = adapter->product_info.nchannels; -if ( channel >= max_channels ) { +if (channel >= max_channels) { goto free_pci; } -for ( tgt =0 ; tgt <=MAX_TARGET ; tgt++ ) { - - i = channel*16 + tgt; +for (tgt =0 ; tgt <=MAX_TARGET ; tgt++) { + i = channel *16 + tgt; state = *(pdrv_state + i); -switch ( state &0x0F ) { +switch (state &0x0F ) {case PDRV_ONLINE :seq_printf (m,"Channel:%2d Id:%2d State: Online" , channel, tgt);
@@ -2403,9 +2308,9 @@ proc_show_pdrv(struct seq_file *m, adapter_t *adapter, int channel)* devices are available through /proc/scsi/scsi */ memset (scsi_inq,0 ,256 ); -if (mega_internal_dev_inquiry (adapter, channel, tgt, - scsi_inq_dma_handle) || - (scsi_inq[0 ] &0x1F ) !=TYPE_DISK ) { +if (mega_internal_dev_inquiry (adapter, channel, tgt, + scsi_inq_dma_handle) || + (scsi_inq[0 ] &0x1F ) !=TYPE_DISK ) {continue ; }
@@ -2433,13 +2338,11 @@ proc_show_pdrv(struct seq_file *m, adapter_t *adapter, int channel)* * Display information about the physical drives on physical channel 0. */ -static int -proc_show_pdrv_ch0 (struct seq_file *m,void *v) +static int proc_show_pdrv_ch0 (struct seq_file *m,void *v) {return proc_show_pdrv (m, m->private,0 ); } -/** * proc_show_pdrv_ch1() * @m: Synthetic file construction data
@@ -2447,13 +2350,11 @@ proc_show_pdrv_ch0(struct seq_file *m, void *v)* * Display information about the physical drives on physical channel 1. */ -static int -proc_show_pdrv_ch1 (struct seq_file *m,void *v) +static int proc_show_pdrv_ch1 (struct seq_file *m,void *v) {return proc_show_pdrv (m, m->private,1 ); } -/** * proc_show_pdrv_ch2() * @m: Synthetic file construction data
@@ -2461,13 +2362,11 @@ proc_show_pdrv_ch1(struct seq_file *m, void *v)* * Display information about the physical drives on physical channel 2. */ -static int -proc_show_pdrv_ch2 (struct seq_file *m,void *v) +static int proc_show_pdrv_ch2 (struct seq_file *m,void *v) {return proc_show_pdrv (m, m->private,2 ); } -/** * proc_show_pdrv_ch3() * @m: Synthetic file construction data
@@ -2475,13 +2374,11 @@ proc_show_pdrv_ch2(struct seq_file *m, void *v)* * Display information about the physical drives on physical channel 3. */ -static int -proc_show_pdrv_ch3 (struct seq_file *m,void *v) +static int proc_show_pdrv_ch3 (struct seq_file *m,void *v) {return proc_show_pdrv (m, m->private,3 ); } -/** * proc_show_rdrv() * @m: Synthetic file construction data
@@ -2492,28 +2389,28 @@ proc_show_pdrv_ch3(struct seq_file *m, void *v)* We do not print the inquiry information since its already available through * /proc/scsi/scsi interface */ -static int -proc_show_rdrv (struct seq_file *m,adapter_t *adapter,int start,int end ) +static int proc_show_rdrv (struct seq_file *m,adapter_t *adapter,int start, +int end) { -dma_addr_t dma_handle; -logdrv_param *lparam; -megacmd_t mc; -char *disk_array; -dma_addr_t disk_array_dma_handle; -caddr_t inquiry; -struct pci_dev *pdev; -u8 *rdrv_state; -int num_ldrv; -u32 array_sz; -int i; - -if (make_local_pdev (adapter, &pdev) !=0 ) +dma_addr_t dma_handle; +logdrv_param *lparam; +megacmd_t mc; +char *disk_array; +dma_addr_t disk_array_dma_handle; +caddr_t inquiry; +struct pci_dev *pdev; +u8 *rdrv_state; +int num_ldrv; +u32 array_sz; +int i; + +if (make_local_pdev (adapter, &pdev) !=0 )return 0 ; -if ( (inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) +if ((inquiry =mega_allocate_inquiry (&dma_handle, pdev)) ==NULL ) goto free_pdev; -if (mega_adapinq (adapter, dma_handle) !=0 ) { +if (mega_adapinq (adapter, dma_handle) !=0 ) {seq_puts (m,"Adapter inquiry failed.\n" );dev_warn (&adapter->dev->dev,"inquiry failed\n" ); goto free_inquiry;
@@ -2521,64 +2418,60 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )memset (&mc,0 ,sizeof (megacmd_t)); -if ( adapter->flag &BOARD_40LD ) { +if (adapter->flag &BOARD_40LD ) { array_sz =sizeof (disk_array_40ld); rdrv_state = ((mega_inquiry3 *)inquiry)->ldrv_state; num_ldrv = ((mega_inquiry3 *)inquiry)->num_ldrv; - } -else { + }else { array_sz =sizeof (disk_array_8ld); - rdrv_state = ((mraid_ext_inquiry *)inquiry)-> - raid_inq.logdrv_info.ldrv_state; + rdrv_state = ((mraid_ext_inquiry *)inquiry) + ->raid_inq.logdrv_info.ldrv_state; - num_ldrv = ((mraid_ext_inquiry *)inquiry)-> - raid_inq.logdrv_info.num_ldrv; + num_ldrv = ((mraid_ext_inquiry *)inquiry) + ->raid_inq.logdrv_info.num_ldrv; } disk_array =dma_alloc_coherent (&pdev->dev, array_sz, &disk_array_dma_handle,GFP_KERNEL ); -if ( disk_array ==NULL ) { +if (disk_array ==NULL ) {seq_puts (m,"memory not available.\n" ); goto free_inquiry; } mc.xferaddr = (u32 )disk_array_dma_handle; -if ( adapter->flag &BOARD_40LD ) { +if (adapter->flag &BOARD_40LD ) { mc.cmd =FC_NEW_CONFIG ; mc.opcode =OP_DCMD_READ_CONFIG ; -if (mega_internal_command (adapter, &mc,NULL ) ) { +if (mega_internal_command (adapter, &mc,NULL )) {seq_puts (m,"40LD read config failed.\n" ); goto free_pci; } - } -else { + }else { mc.cmd =NEW_READ_CONFIG_8LD ; -if (mega_internal_command (adapter, &mc,NULL ) ) { +if (mega_internal_command (adapter, &mc,NULL )) { mc.cmd =READ_CONFIG_8LD ; -if (mega_internal_command (adapter, &mc,NULL ) ) { +if (mega_internal_command (adapter, &mc,NULL )) {seq_puts (m,"8LD read config failed.\n" ); goto free_pci; } } } -for ( i = start; i < ( (end+1 < num_ldrv) ? end+1 : num_ldrv ); i++ ) { - -if ( adapter->flag &BOARD_40LD ) { +for (i = start; i < ((end +1 < num_ldrv) ? end +1 : num_ldrv); i++) { +if (adapter->flag &BOARD_40LD ) { lparam = - &((disk_array_40ld *)disk_array)->ldrv[i].lparam; - } -else { + &((disk_array_40ld *)disk_array)->ldrv[i].lparam; + }else { lparam = - &((disk_array_8ld *)disk_array)->ldrv[i].lparam; + &((disk_array_8ld *)disk_array)->ldrv[i].lparam; }/*
@@ -2587,7 +2480,7 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )*/ seq_printf (m,"Logical drive:%2d:, " , i); -switch ( rdrv_state[i] &0x0F ) { +switch (rdrv_state[i] &0x0F ) {case RDRV_OFFLINE :seq_puts (m,"state: offline" );break ;
@@ -2609,21 +2502,21 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )* Check if check consistency or initialization is going on * for this logical drive. */ -if ( (rdrv_state[i] &0xF0 ) ==0x20 ) +if ((rdrv_state[i] &0xF0 ) ==0x20 )seq_puts (m,", check-consistency in progress" ); -else if ( (rdrv_state[i] &0xF0 ) ==0x10 ) +else if ((rdrv_state[i] &0xF0 ) ==0x10 )seq_puts (m,", initialization in progress" ); - +seq_putc (m,'\n' );seq_printf (m,"Span depth:%3d, " , lparam->span_depth);seq_printf (m,"RAID level:%3d, " , lparam->level);seq_printf (m,"Stripe size:%3d, " , - lparam->stripe_sz ? lparam->stripe_sz/2 :128 ); + lparam->stripe_sz ? lparam->stripe_sz /2 :128 );seq_printf (m,"Row size:%3d\n" , lparam->row_size);seq_puts (m,"Read Policy: " ); -switch (lparam->read_ahead) { +switch (lparam->read_ahead) {case NO_READ_AHEAD :seq_puts (m,"No read ahead, " );break ;
@@ -2633,11 +2526,10 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )case ADAP_READ_AHEAD :seq_puts (m,"Adaptive, " );break ; - }seq_puts (m,"Write Policy: " ); -switch (lparam->write_mode) { +switch (lparam->write_mode) {case WRMODE_WRITE_THRU :seq_puts (m,"Write thru, " );break ;
@@ -2647,7 +2539,7 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end ) }seq_puts (m,"Cache Policy: " ); -switch (lparam->direct_io) { +switch (lparam->direct_io) {case CACHED_IO :seq_puts (m,"Cached IO\n\n" );break ;
@@ -2674,13 +2566,11 @@ proc_show_rdrv(struct seq_file *m, adapter_t *adapter, int start, int end )* * Display real time information about the logical drives 0 through 9. */ -static int -proc_show_rdrv_10 (struct seq_file *m,void *v) +static int proc_show_rdrv_10 (struct seq_file *m,void *v) {return proc_show_rdrv (m, m->private,0 ,9 ); } -/** * proc_show_rdrv_20() * @m: Synthetic file construction data
@@ -2688,13 +2578,11 @@ proc_show_rdrv_10(struct seq_file *m, void *v)* * Display real time information about the logical drives 0 through 9. */ -static int -proc_show_rdrv_20 (struct seq_file *m,void *v) +static int proc_show_rdrv_20 (struct seq_file *m,void *v) {return proc_show_rdrv (m, m->private,10 ,19 ); } -/** * proc_show_rdrv_30() * @m: Synthetic file construction data
@@ -2702,13 +2590,11 @@ proc_show_rdrv_20(struct seq_file *m, void *v)* * Display real time information about the logical drives 0 through 9. */ -static int -proc_show_rdrv_30 (struct seq_file *m,void *v) +static int proc_show_rdrv_30 (struct seq_file *m,void *v) {return proc_show_rdrv (m, m->private,20 ,29 ); } -/** * proc_show_rdrv_40() * @m: Synthetic file construction data
@@ -2716,8 +2602,7 @@ proc_show_rdrv_30(struct seq_file *m, void *v)* * Display real time information about the logical drives 0 through 9. */ -static int -proc_show_rdrv_40 (struct seq_file *m,void *v) +static int proc_show_rdrv_40 (struct seq_file *m,void *v) {return proc_show_rdrv (m, m->private,30 ,39 ); }
@@ -2729,8 +2614,7 @@ proc_show_rdrv_40(struct seq_file *m, void *v)* * Creates /proc entries for our controllers. */ -static void -mega_create_proc_entry (int index,struct proc_dir_entry *parent) +static void mega_create_proc_entry (int index,struct proc_dir_entry *parent) {adapter_t *adapter = hba_soft_state[index];struct proc_dir_entry *dir;
@@ -2743,82 +2627,80 @@ mega_create_proc_entry(int index, struct proc_dir_entry *parent)return ; } -proc_create_single_data ("config" ,S_IRUSR , dir, - proc_show_config, adapter); -proc_create_single_data ("stat" ,S_IRUSR , dir, - proc_show_stat, adapter); -proc_create_single_data ("mailbox" ,S_IRUSR , dir, - proc_show_mbox, adapter); +proc_create_single_data ("config" ,S_IRUSR , dir, proc_show_config, + adapter); +proc_create_single_data ("stat" ,S_IRUSR , dir, proc_show_stat, adapter); +proc_create_single_data ("mailbox" ,S_IRUSR , dir, proc_show_mbox, + adapter);#if MEGA_HAVE_ENH_PROC proc_create_single_data ("rebuild-rate" ,S_IRUSR , dir, - proc_show_rebuild_rate, adapter); + proc_show_rebuild_rate, adapter);proc_create_single_data ("battery-status" ,S_IRUSR , dir, - proc_show_battery, adapter); + proc_show_battery, adapter);proc_create_single_data ("diskdrives-ch0" ,S_IRUSR , dir, - proc_show_pdrv_ch0, adapter); + proc_show_pdrv_ch0, adapter);proc_create_single_data ("diskdrives-ch1" ,S_IRUSR , dir, - proc_show_pdrv_ch1, adapter); + proc_show_pdrv_ch1, adapter);proc_create_single_data ("diskdrives-ch2" ,S_IRUSR , dir, - proc_show_pdrv_ch2, adapter); + proc_show_pdrv_ch2, adapter);proc_create_single_data ("diskdrives-ch3" ,S_IRUSR , dir, - proc_show_pdrv_ch3, adapter); + proc_show_pdrv_ch3, adapter);proc_create_single_data ("raiddrives-0-9" ,S_IRUSR , dir, - proc_show_rdrv_10, adapter); + proc_show_rdrv_10, adapter);proc_create_single_data ("raiddrives-10-19" ,S_IRUSR , dir, - proc_show_rdrv_20, adapter); + proc_show_rdrv_20, adapter);proc_create_single_data ("raiddrives-20-29" ,S_IRUSR , dir, - proc_show_rdrv_30, adapter); + proc_show_rdrv_30, adapter);proc_create_single_data ("raiddrives-30-39" ,S_IRUSR , dir, - proc_show_rdrv_40, adapter); + proc_show_rdrv_40, adapter);#endif }#else -static inline void mega_create_proc_entry (int index,struct proc_dir_entry *parent) +static inline void mega_create_proc_entry (int index, +struct proc_dir_entry *parent) { }#endif -/* * megaraid_biosparam() * * Return the disk geometry for a particular disk */ -static int -megaraid_biosparam (struct scsi_device *sdev,struct block_device *bdev, -sector_t capacity,int geom[]) +static int megaraid_biosparam (struct scsi_device *sdev, +struct block_device *bdev,sector_t capacity, +int geom[]) { -adapter_t *adapter; -int heads; -int sectors; -int cylinders; +adapter_t *adapter; +int heads; +int sectors; +int cylinders;/* Get pointer to host config structure */ adapter = (adapter_t *)sdev->host->hostdata;if (IS_RAID_CH (adapter, sdev->channel)) { -/* Default heads (64) & sectors (32) */ - heads =64 ; - sectors =32 ; - cylinders = (ulong )capacity / (heads * sectors); +/* Default heads (64) & sectors (32) */ + heads =64 ; + sectors =32 ; + cylinders = (ulong )capacity / (heads * sectors); -/* +/* * Handle extended translation size for logical drives * > 1Gb */ -if ((ulong )capacity >=0x200000 ) { - heads =255 ; - sectors =63 ; - cylinders = (ulong )capacity / (heads * sectors); - } +if ((ulong )capacity >=0x200000 ) { + heads =255 ; + sectors =63 ; + cylinders = (ulong )capacity / (heads * sectors); + } -/* return result */ - geom[0 ] = heads; - geom[1 ] = sectors; - geom[2 ] = cylinders; - } -else { +/* return result */ + geom[0 ] = heads; + geom[1 ] = sectors; + geom[2 ] = cylinders; + }else {if (scsi_partsize (bdev, capacity, geom))return 0 ;
@@ -2855,14 +2737,12 @@ megaraid_biosparam(struct scsi_device *sdev, struct block_device *bdev,* scatter-gather list pointer, passthru and extended passthru structure * pointers. */ -static int -mega_init_scb (adapter_t *adapter) +static int mega_init_scb (adapter_t *adapter) { -scb_t *scb; -int i; - -for ( i =0 ; i < adapter->max_cmds; i++ ) { +scb_t *scb; +int i; +for (i =0 ; i < adapter->max_cmds; i++) { scb = &adapter->scb_list[i]; scb->sgl64 =NULL ;
@@ -2871,46 +2751,49 @@ mega_init_scb(adapter_t *adapter) scb->epthru =NULL ; } -for ( i =0 ; i < adapter->max_cmds; i++ ) { - +for (i =0 ; i < adapter->max_cmds; i++) { scb = &adapter->scb_list[i]; scb->idx = i; - scb->sgl64 =dma_alloc_coherent (&adapter->dev->dev, -sizeof (mega_sgl64) * adapter->sglen, - &scb->sgl_dma_addr,GFP_KERNEL ); + scb->sgl64 = +dma_alloc_coherent (&adapter->dev->dev, +sizeof (mega_sgl64) * adapter->sglen, + &scb->sgl_dma_addr,GFP_KERNEL ); scb->sgl = (mega_sglist *)scb->sgl64; -if ( !scb->sgl ) { -dev_warn (&adapter->dev->dev,"RAID: Can't allocate sglist\n" ); +if (!scb->sgl) { +dev_warn (&adapter->dev->dev, +"RAID: Can't allocate sglist\n" );mega_free_sgl (adapter);return -1 ; } - scb->pthru =dma_alloc_coherent (&adapter->dev->dev, -sizeof (mega_passthru), - &scb->pthru_dma_addr,GFP_KERNEL ); + scb->pthru = +dma_alloc_coherent (&adapter->dev->dev, +sizeof (mega_passthru), + &scb->pthru_dma_addr,GFP_KERNEL ); -if ( !scb->pthru ) { -dev_warn (&adapter->dev->dev,"RAID: Can't allocate passthru\n" ); +if (!scb->pthru) { +dev_warn (&adapter->dev->dev, +"RAID: Can't allocate passthru\n" );mega_free_sgl (adapter);return -1 ; } - scb->epthru =dma_alloc_coherent (&adapter->dev->dev, -sizeof (mega_ext_passthru), - &scb->epthru_dma_addr,GFP_KERNEL ); + scb->epthru = +dma_alloc_coherent (&adapter->dev->dev, +sizeof (mega_ext_passthru), + &scb->epthru_dma_addr,GFP_KERNEL ); -if ( !scb->epthru ) { +if (!scb->epthru) {dev_warn (&adapter->dev->dev, -"Can't allocate extended passthru\n" ); +"Can't allocate extended passthru\n" );mega_free_sgl (adapter);return -1 ; } - scb->dma_type =MEGA_DMA_TYPE_NONE ;/*
@@ -2926,27 +2809,25 @@ mega_init_scb(adapter_t *adapter)return 0 ; } -/** * megadev_open() * @inode: unused * @filep: unused * * Routines for the character/ioctl interface to the driver. Find out if this -* is a valid open. +* is a valid open. */ -static int -megadev_open (struct inode *inode,struct file *filep) +static int megadev_open (struct inode *inode,struct file *filep) {/* * Only allow superuser to access private ioctl interface */ -if ( !capable (CAP_SYS_ADMIN ) )return -EACCES ; +if (!capable (CAP_SYS_ADMIN )) +return -EACCES ;return 0 ; } -/** * megadev_ioctl() * @filep: Our device file
@@ -2958,31 +2839,31 @@ megadev_open (struct inode *inode, struct file *filep)* ioctl to new ioctl command), and issue a synchronous command to the * controller. */ -static int -megadev_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) +static int megadev_ioctl (struct file *filep,unsigned int cmd, +unsigned long arg) { -adapter_t *adapter; -nitioctl_t uioc; -int adapno; -int rval; -mega_passthru __user *upthru;/* user address for passthru */ -mega_passthru *pthru;/* copy user passthru here */ -dma_addr_t pthru_dma_hndl; -void *data =NULL ;/* data to be transferred */ -dma_addr_t data_dma_hndl;/* dma handle for data xfer area */ -megacmd_t mc; +adapter_t *adapter; +nitioctl_t uioc; +int adapno; +int rval; +mega_passthru __user *upthru;/* user address for passthru */ +mega_passthru *pthru;/* copy user passthru here */ +dma_addr_t pthru_dma_hndl; +void *data =NULL ;/* data to be transferred */ +dma_addr_t data_dma_hndl;/* dma handle for data xfer area */ +megacmd_t mc;#if MEGA_HAVE_STATS -megastat_t __user *ustats =NULL ; -int num_ldrv =0 ; +megastat_t __user *ustats =NULL ; +int num_ldrv =0 ;#endif -u32 uxferaddr =0 ; -struct pci_dev *pdev; +u32 uxferaddr =0 ; +struct pci_dev *pdev;/* * Make sure only USCSICMD are issued through this interface. * MIMD application would still fire different command. */ -if ( (_IOC_TYPE (cmd) !=MEGAIOC_MAGIC ) && (cmd !=USCSICMD ) ) { +if ((_IOC_TYPE (cmd) !=MEGAIOC_MAGIC ) && (cmd !=USCSICMD )) {return -EINVAL ; }
@@ -2995,20 +2876,18 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)* addresses. */ memset (&uioc,0 ,sizeof (nitioctl_t)); -if ( (rval =mega_m_to_n ( (void __user *)arg, &uioc)) !=0 ) +if ((rval =mega_m_to_n ((void __user *)arg, &uioc)) !=0 )return rval; - -switch ( uioc.opcode ) { - +switch (uioc.opcode) {case GET_DRIVER_VER : -if (put_user (driver_ver, (u32 __user *)uioc.uioc_uaddr) ) +if (put_user (driver_ver, (u32 __user *)uioc.uioc_uaddr))return (-EFAULT );break ;case GET_N_ADAP : -if (put_user (hba_count, (u32 __user *)uioc.uioc_uaddr) ) +if (put_user (hba_count, (u32 __user *)uioc.uioc_uaddr))return (-EFAULT );/*
@@ -3023,11 +2902,11 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)/* * Which adapter */ -if ( (adapno =GETADAP (uioc.adapno)) >= hba_count ) +if ((adapno =GETADAP (uioc.adapno)) >= hba_count)return (-ENODEV ); -if (copy_to_user (uioc.uioc_uaddr, mcontroller+adapno, -sizeof (struct mcontroller )) ) +if (copy_to_user (uioc.uioc_uaddr, mcontroller + adapno, +sizeof (struct mcontroller )))return (-EFAULT );break ;
@@ -3037,43 +2916,44 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)/* * Which adapter */ -if ( (adapno =GETADAP (uioc.adapno)) >= hba_count ) +if ((adapno =GETADAP (uioc.adapno)) >= hba_count)return (-ENODEV ); adapter = hba_soft_state[adapno]; ustats = uioc.uioc_uaddr; -if (copy_from_user (&num_ldrv, &ustats->num_ldrv,sizeof (int )) ) +if (copy_from_user (&num_ldrv, &ustats->num_ldrv,sizeof (int )))return (-EFAULT );/* * Check for the validity of the logical drive number */ -if ( num_ldrv >=MAX_LOGICAL_DRIVES_40LD )return -EINVAL ; +if (num_ldrv >=MAX_LOGICAL_DRIVES_40LD ) +return -EINVAL ; -if (copy_to_user (ustats->nreads, adapter->nreads, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->nreads, adapter->nreads, + num_ldrv *sizeof (u32)))return -EFAULT ; -if (copy_to_user (ustats->nreadblocks, adapter->nreadblocks, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->nreadblocks, adapter->nreadblocks, + num_ldrv *sizeof (u32)))return -EFAULT ; -if (copy_to_user (ustats->nwrites, adapter->nwrites, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->nwrites, adapter->nwrites, + num_ldrv *sizeof (u32)))return -EFAULT ; -if (copy_to_user (ustats->nwriteblocks, adapter->nwriteblocks, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->nwriteblocks, adapter->nwriteblocks, + num_ldrv *sizeof (u32)))return -EFAULT ; -if (copy_to_user (ustats->rd_errors, adapter->rd_errors, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->rd_errors, adapter->rd_errors, + num_ldrv *sizeof (u32)))return -EFAULT ; -if (copy_to_user (ustats->wr_errors, adapter->wr_errors, - num_ldrv*sizeof (u32)) ) +if (copy_to_user (ustats->wr_errors, adapter->wr_errors, + num_ldrv *sizeof (u32)))return -EFAULT ;return 0 ;
@@ -3084,7 +2964,7 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)/* * Which adapter */ -if ( (adapno =GETADAP (uioc.adapno)) >= hba_count ) +if ((adapno =GETADAP (uioc.adapno)) >= hba_count)return (-ENODEV ); adapter = hba_soft_state[adapno];
@@ -3093,22 +2973,22 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)* Deletion of logical drive is a special case. The adapter * should be quiescent before this command is issued. */ -if ( uioc.uioc_rmbox[0 ] ==FC_DEL_LOGDRV && - uioc.uioc_rmbox[2 ] ==OP_DEL_LOGDRV ) { - +if (uioc.uioc_rmbox[0 ] ==FC_DEL_LOGDRV && + uioc.uioc_rmbox[2 ] ==OP_DEL_LOGDRV ) {/* * Do we support this feature */ -if ( !adapter->support_random_del ) { -dev_warn (&adapter->dev->dev,"logdrv " -"delete on non-supporting F/W\n" ); +if (!adapter->support_random_del) { +dev_warn (&adapter->dev->dev, +"logdrv " +"delete on non-supporting F/W\n" );return (-EINVAL ); } - rval =mega_del_logdrv ( adapter, uioc.uioc_rmbox[3 ] ); + rval =mega_del_logdrv (adapter, uioc.uioc_rmbox[3 ]); -if ( rval ==0 ) { +if (rval ==0 ) {memset (&mc,0 ,sizeof (megacmd_t)); mc.status = rval;
@@ -3122,9 +3002,8 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)* This interface only support the regular passthru commands. * Reject extended passthru and 64-bit passthru */ -if ( uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_PASSTHRU64 || - uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_EXTPTHRU ) { - +if (uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_PASSTHRU64 || + uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_EXTPTHRU ) {dev_warn (&adapter->dev->dev,"rejected passthru\n" );return (-EINVAL );
@@ -3134,18 +3013,18 @@ megadev_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)* For all internal commands, the buffer must be allocated in * <4GB address range */ -if (make_local_pdev (adapter, &pdev) !=0 ) +if (make_local_pdev (adapter, &pdev) !=0 )return -EIO ;/* Is it a passthru command or a DCMD */ -if ( uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_PASSTHRU ) { +if (uioc.uioc_rmbox[0 ] ==MEGA_MBOXCMD_PASSTHRU ) {/* Passthru commands */ pthru =dma_alloc_coherent (&pdev->dev,sizeof (mega_passthru), &pthru_dma_hndl,GFP_KERNEL ); -if ( pthru ==NULL ) { +if (pthru ==NULL ) {free_local_pdev (pdev);return (-ENOMEM );
Lines of this file are not shown. View the raw message.
drivers/scsi/megaraid.h +482 -506
988 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.3
Part of the diff is not shown here. View the raw message.
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Quoted 5 lines
static unsigned short int
max_sectors_per_io=MAX_SECTORS_PER_IO;module_param(max_sectors_per_io, ushort, 0);drivers/scsi/megaraid.c +0
-2-MODULE_PARM_DESC (max_sectors_per_io,"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" ); -
drivers/scsi/megaraid.c line 78
Quoted 10 lines
drivers/scsi/megaraid.c +6
-1+MODULE_PARM_DESC ( + max_sectors_per_io, +"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" );static unsigned short int max_mbox_busy_wait =MBOX_BUSY_WAIT ;module_param (max_mbox_busy_wait, ushort,0 ); -MODULE_PARM_DESC (max_mbox_busy_wait,"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" ); +MODULE_PARM_DESC ( + max_mbox_busy_wait, +"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" );
This code is longer for no real improvement.
Quoted 6 lines
/*
* The File Operations structure for the serial/ioctl interface of the driver */
static const structfile_operationsmegadev_fops= {drivers/scsi/megaraid.c +0
-1- .owner = THIS_MODULE,
drivers/scsi/megaraid.c static struct proc_dir_entry *mega_proc_dir_entry; · line 109
Quoted 10 lines
drivers/scsi/megaraid.c +4
-3- .unlocked_ioctl = megadev_unlocked_ioctl, - .open = megadev_open, - .llseek = noop_llseek, + .owner = THIS_MODULE, + .unlocked_ioctl = megadev_unlocked_ioctl, + .open = megadev_open, + .llseek = noop_llseek, };/*
Readability loss.
drivers/scsi/megaraid.c mega_query_adapter(adapter_t *adapter) · line 260
Quoted 8 lines
drivers/scsi/megaraid.c +3
-4- prod_info_dma_handle =dma_map_single (&adapter->dev->dev, - (void *)&adapter->product_info, -sizeof (mega_product_info), -DMA_FROM_DEVICE ); + prod_info_dma_handle =dma_map_single ( + &adapter->dev->dev, (void *)&adapter->product_info, +sizeof (mega_product_info),DMA_FROM_DEVICE );
Note the orphaned first parameter and odd indentation.
drivers/scsi/megaraid.c static int megaraid_queue_lck(struct scsi_cmnd *scmd) · line 407
Quoted 8 lines
static
DEF_SCSI_QCMD(megaraid_queue)drivers/scsi/megaraid.c +1
-1-/** +/** * mega_allocate_scb() * @adapter: pointer to our soft state * @cmd: scsi command from the mid-layer
Indentation error.
drivers/scsi/megaraid.c static DEF_SCSI_QCMD(megaraid_queue) · line 415
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -418,15 +409,14 @@ static DEF_SCSI_QCMD(megaraid_queue)* Allocate a SCB structure. This is the central structure for controller * commands. */ -static inline scb_t * -mega_allocate_scb (adapter_t *adapter,struct scsi_cmnd *cmd) +static inline scb_t *mega_allocate_scb (adapter_t *adapter, +struct scsi_cmnd *cmd) {struct list_head *head = &adapter->free_list;
Same.
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 574
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -586,26 +568,25 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) ldrv_num =mega_get_ldrv_num (adapter, cmd, channel); - max_ldrv_num = (adapter->flag &BOARD_40LD ) ? -MAX_LOGICAL_DRIVES_40LD :MAX_LOGICAL_DRIVES_8LD ; +MAX_LOGICAL_DRIVES_40LD : +MAX_LOGICAL_DRIVES_8LD ;
Churn, if not readability loss. Note the indentation change here is inconsistent with the indentation change noted above.
Quoted 6 lines
drivers/scsi/megaraid.c +0
-4* 6-byte READ(0x08) or WRITE(0x0A) cdb */ -if ( cmd->cmd_len ==6 ) { - mbox->m_out.numsectors = (u32 ) cmd->cmnd[4 ]; - mbox->m_out.lba = - ((u32)cmd->cmnd[1] << 16) |
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 743
Quoted 10 lines
drivers/scsi/megaraid.c +5
-2- ((u32 )cmd->cmnd[2 ] <<8 ) | - (u32 )cmd->cmnd[3 ]; +if (cmd->cmd_len ==6 ) { + mbox->m_out.numsectors = (u32 )cmd->cmnd[4 ]; + mbox->m_out.lba = ((u32 )cmd->cmnd[1 ] <<16 ) | + ((u32 )cmd->cmnd[2 ] <<8 ) | + (u32 )cmd->cmnd[3 ]; mbox->m_out.lba &=0x1FFFFF ;
Here, the orphaned term is moved up, next to the =. And yet,
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 831
Quoted 11 lines
drivers/scsi/megaraid.c +4
-2/* Calculate Scatter-Gather info */ - mbox->m_out.numsgelements =mega_build_sglist (adapter, scb, - (u32 *)&mbox->m_out.xferaddr, &seg); + mbox->m_out.numsgelements = +mega_build_sglist (adapter, scb, + (u32 *)&mbox->m_out.xferaddr, + &seg);return scb;
... here the first term is moved down and orphaned, which is another inconsistency.
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 137 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Quoted 5 lines
static unsigned short int
max_sectors_per_io=MAX_SECTORS_PER_IO;module_param(max_sectors_per_io, ushort, 0);drivers/scsi/megaraid.c +0
-2-MODULE_PARM_DESC (max_sectors_per_io,"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" ); -drivers/scsi/megaraid.c line 78
Quoted 10 lines
drivers/scsi/megaraid.c +6
-1+MODULE_PARM_DESC ( + max_sectors_per_io, +"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" );static unsigned short int max_mbox_busy_wait =MBOX_BUSY_WAIT ;module_param (max_mbox_busy_wait, ushort,0 ); -MODULE_PARM_DESC (max_mbox_busy_wait,"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" ); +MODULE_PARM_DESC ( + max_mbox_busy_wait, +"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" );This code is longer for no real improvement.
Quoted 6 lines
/*
* The File Operations structure for the serial/ioctl interface of the driver */
static const structfile_operationsmegadev_fops= {drivers/scsi/megaraid.c +0
-1- .owner = THIS_MODULE,drivers/scsi/megaraid.c static struct proc_dir_entry *mega_proc_dir_entry; · line 109
Quoted 10 lines
drivers/scsi/megaraid.c +4
-3- .unlocked_ioctl = megadev_unlocked_ioctl, - .open = megadev_open, - .llseek = noop_llseek, + .owner = THIS_MODULE, + .unlocked_ioctl = megadev_unlocked_ioctl, + .open = megadev_open, + .llseek = noop_llseek, };/* Readability loss.
drivers/scsi/megaraid.c mega_query_adapter(adapter_t *adapter) · line 260
Quoted 8 lines
drivers/scsi/megaraid.c +3
-4- prod_info_dma_handle =dma_map_single (&adapter->dev->dev, - (void *)&adapter->product_info, -sizeof (mega_product_info), -DMA_FROM_DEVICE ); + prod_info_dma_handle =dma_map_single ( + &adapter->dev->dev, (void *)&adapter->product_info, +sizeof (mega_product_info),DMA_FROM_DEVICE );Note the orphaned first parameter and odd indentation.
drivers/scsi/megaraid.c static int megaraid_queue_lck(struct scsi_cmnd *scmd) · line 407
Quoted 8 lines
static
DEF_SCSI_QCMD(megaraid_queue)drivers/scsi/megaraid.c +1
-1-/** +/** * mega_allocate_scb() * @adapter: pointer to our soft state * @cmd: scsi command from the mid-layer Indentation error.
drivers/scsi/megaraid.c static DEF_SCSI_QCMD(megaraid_queue) · line 415
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -418,15 +409,14 @@ static DEF_SCSI_QCMD(megaraid_queue)* Allocate a SCB structure. This is the central structure for controller * commands. */ -static inline scb_t * -mega_allocate_scb (adapter_t *adapter,struct scsi_cmnd *cmd) +static inline scb_t *mega_allocate_scb (adapter_t *adapter, +struct scsi_cmnd *cmd) {struct list_head *head = &adapter->free_list;Same.
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 574
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -586,26 +568,25 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) ldrv_num =mega_get_ldrv_num (adapter, cmd, channel); - max_ldrv_num = (adapter->flag &BOARD_40LD ) ? -MAX_LOGICAL_DRIVES_40LD :MAX_LOGICAL_DRIVES_8LD ; +MAX_LOGICAL_DRIVES_40LD : +MAX_LOGICAL_DRIVES_8LD ;Churn, if not readability loss. Note the indentation change here is inconsistent with the indentation change noted above.
Quoted 6 lines
drivers/scsi/megaraid.c +0
-4* 6-byte READ(0x08) or WRITE(0x0A) cdb */ -if ( cmd->cmd_len ==6 ) { - mbox->m_out.numsectors = (u32 ) cmd->cmnd[4 ]; - mbox->m_out.lba = - ((u32)cmd->cmnd[1] << 16) |drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 743
Quoted 10 lines
drivers/scsi/megaraid.c +5
-2- ((u32 )cmd->cmnd[2 ] <<8 ) | - (u32 )cmd->cmnd[3 ]; +if (cmd->cmd_len ==6 ) { + mbox->m_out.numsectors = (u32 )cmd->cmnd[4 ]; + mbox->m_out.lba = ((u32 )cmd->cmnd[1 ] <<16 ) | + ((u32 )cmd->cmnd[2 ] <<8 ) | + (u32 )cmd->cmnd[3 ]; mbox->m_out.lba &=0x1FFFFF ;Here, the orphaned term is moved up, next to the =. And yet,
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 831
Quoted 11 lines
drivers/scsi/megaraid.c +4
-2/* Calculate Scatter-Gather info */ - mbox->m_out.numsgelements =mega_build_sglist (adapter, scb, - (u32 *)&mbox->m_out.xferaddr, &seg); + mbox->m_out.numsgelements = +mega_build_sglist (adapter, scb, + (u32 *)&mbox->m_out.xferaddr, + &seg);return scb;... here the first term is moved down and orphaned, which is another inconsistency.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 19 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 15 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Problems with clang-format should be fixed, I'll take a look.
I was reviewing this file for another issue and could not get past how horredously bad it was and really did not want to manually fix the 400+ formatting errors. I will drop this patch and use the use these files to verify the .clang-format .
Tom
Quoted 111 lines
Quoted 109 lines
Quoted 6 lines
static unsigned short int max_sectors_per_io = MAX_SECTORS_PER_IO; module_param(max_sectors_per_io, ushort, 0);drivers/scsi/megaraid.c +0
-2-MODULE_PARM_DESC (max_sectors_per_io,"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" ); -drivers/scsi/megaraid.c line 78
Quoted 10 lines
drivers/scsi/megaraid.c +6
-1+MODULE_PARM_DESC ( + max_sectors_per_io, +"Maximum number of sectors per I/O request (default=MAX_SECTORS_PER_IO=128)" );static unsigned short int max_mbox_busy_wait =MBOX_BUSY_WAIT ;module_param (max_mbox_busy_wait, ushort,0 ); -MODULE_PARM_DESC (max_mbox_busy_wait,"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" ); +MODULE_PARM_DESC ( + max_mbox_busy_wait, +"Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)" );This code is longer for no real improvement.
Quoted 5 lines
/*
* The File Operations structure for the serial/ioctl interface of the driver */
static const structfile_operationsmegadev_fops= {drivers/scsi/megaraid.c +0
-1- .owner = THIS_MODULE,drivers/scsi/megaraid.c static struct proc_dir_entry *mega_proc_dir_entry; · line 109
Quoted 10 lines
drivers/scsi/megaraid.c +4
-3- .unlocked_ioctl = megadev_unlocked_ioctl, - .open = megadev_open, - .llseek = noop_llseek, + .owner = THIS_MODULE, + .unlocked_ioctl = megadev_unlocked_ioctl, + .open = megadev_open, + .llseek = noop_llseek, };/* Readability loss.
drivers/scsi/megaraid.c mega_query_adapter(adapter_t *adapter) · line 260
Quoted 8 lines
drivers/scsi/megaraid.c +3
-4- prod_info_dma_handle =dma_map_single (&adapter->dev->dev, - (void *)&adapter->product_info, -sizeof (mega_product_info), -DMA_FROM_DEVICE ); + prod_info_dma_handle =dma_map_single ( + &adapter->dev->dev, (void *)&adapter->product_info, +sizeof (mega_product_info),DMA_FROM_DEVICE );Note the orphaned first parameter and odd indentation.
drivers/scsi/megaraid.c static int megaraid_queue_lck(struct scsi_cmnd *scmd) · line 407
Quoted 7 lines
static
DEF_SCSI_QCMD(megaraid_queue)drivers/scsi/megaraid.c +1
-1-/** +/** * mega_allocate_scb() * @adapter: pointer to our soft state * @cmd: scsi command from the mid-layer Indentation error.
drivers/scsi/megaraid.c static DEF_SCSI_QCMD(megaraid_queue) · line 415
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -418,15 +409,14 @@ static DEF_SCSI_QCMD(megaraid_queue)* Allocate a SCB structure. This is the central structure for controller * commands. */ -static inline scb_t * -mega_allocate_scb (adapter_t *adapter,struct scsi_cmnd *cmd) +static inline scb_t *mega_allocate_scb (adapter_t *adapter, +struct scsi_cmnd *cmd) {struct list_head *head = &adapter->free_list;Same.
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 574
Quoted 10 lines
drivers/scsi/megaraid.c +2
-2@@ -586,26 +568,25 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) ldrv_num =mega_get_ldrv_num (adapter, cmd, channel); - max_ldrv_num = (adapter->flag &BOARD_40LD ) ? -MAX_LOGICAL_DRIVES_40LD :MAX_LOGICAL_DRIVES_8LD ; +MAX_LOGICAL_DRIVES_40LD : +MAX_LOGICAL_DRIVES_8LD ;Churn, if not readability loss. Note the indentation change here is inconsistent with the indentation change noted above.
Quoted 6 lines
drivers/scsi/megaraid.c +0
-4* 6-byte READ(0x08) or WRITE(0x0A) cdb */ -if ( cmd->cmd_len ==6 ) { - mbox->m_out.numsectors = (u32 ) cmd->cmnd[4 ]; - mbox->m_out.lba = - ((u32)cmd->cmnd[1] << 16) |drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 743
Quoted 10 lines
drivers/scsi/megaraid.c +5
-2- ((u32 )cmd->cmnd[2 ] <<8 ) | - (u32 )cmd->cmnd[3 ]; +if (cmd->cmd_len ==6 ) { + mbox->m_out.numsectors = (u32 )cmd->cmnd[4 ]; + mbox->m_out.lba = ((u32 )cmd->cmnd[1 ] <<16 ) | + ((u32 )cmd->cmnd[2 ] <<8 ) | + (u32 )cmd->cmnd[3 ]; mbox->m_out.lba &=0x1FFFFF ;Here, the orphaned term is moved up, next to the =. And yet,
drivers/scsi/megaraid.c mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy) · line 831
Quoted 10 lines
drivers/scsi/megaraid.c +4
-2/* Calculate Scatter-Gather info */ - mbox->m_out.numsgelements =mega_build_sglist (adapter, scb, - (u32 *)&mbox->m_out.xferaddr, &seg); + mbox->m_out.numsgelements = +mega_build_sglist (adapter, scb, + (u32 *)&mbox->m_out.xferaddr, + &seg);return scb;... here the first term is moved down and orphaned, which is another inconsistency.
Quoted 21 lines · Tom Rix
Quoted 19 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 15 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Quoted 6 lines
Problems with clang-format should be fixed, I'll take a look.
I was reviewing this file for another issue and could not get past how horredously bad it was and really did not want to manually fix the 400+ formatting errors. I will drop this patch and use the use these files to verify the .clang-format .
I think this is more an issue with clang-format than with checkpatch.
If you have specific issues with what checkpatch reports for this file (or any other file), let me know.
Quoted 22 lines · Joe Perches
Quoted 21 lines · Tom Rix
Quoted 18 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 14 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Problems with clang-format should be fixed, I'll take a look.
Quoted 8 lines
Quoted 4 lines
I was reviewing this file for another issue and could not get past how horredously bad it was and really did not want to manually fix the 400+ formatting errors. I will drop this patch and use the use these files to verify the .clang-format .
I think this is more an issue with clang-format than with checkpatch.
If you have specific issues with what checkpatch reports for this file (or any other file), let me know.
Yes, I agree. Its a clang-format problem.
I will be looking to minimize the .clang-format settings to only those that agree with checkpatch.
Then add settings back in later if their problems can be worked out.
Tom
Quoted 32 lines · Tom Rix
Quoted 22 lines · Joe Perches
Quoted 21 lines · Tom Rix
Quoted 18 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 14 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Problems with clang-format should be fixed, I'll take a look.
Quoted 8 lines
Quoted 4 lines
I was reviewing this file for another isseue and could not get past how horredously bad it was and really did not want to manually fix the 400+ formatting errors. I will drop this patch and use the use these files to verify the .clang-format .
I think this is more an issue with clang-format than with checkpatch.
If you have specific issues with what checkpatch reports for this file (or any other file), let me know.
Quoted 6 lines
Yes, I agree. Its a clang-format problem.
I will be looking to minimize the .clang-format settings to only those that agree with checkpatch.
Then add settings back in later if their problems can be worked out.
Another option would be to use:
./scripts/checkpatch.pl -f --fix[-inplace] [--types=<list>] <files>
where types is an optional list of specific things to change
see:
./scripts/checkpatch.pl --list-types --verbose
to show the possible types.
Only some of these types can be changed with --fix or --fix-inplace
If using checkpatch to change formatting, it sometimes can be useful to run checkpatch --fix multiple times on the same file as a checkpatch --fix can create a change than checkpatch will suggest should itself be fixed.
Of course another option is to do nothing as many will complain, sometimes senselessly, about 'churn'.
Quoted 51 lines · Joe Perches
Quoted 29 lines · Tom Rix
Quoted 28 lines · Joe Perches
Quoted 19 lines · Tom Rix
Quoted 18 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Quoted 14 lines · Finn Thain
Quoted 5 lines · On Thu, 27 Jan 2022, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
That method seems like a good recipe for endless churn unless checkpatch and clang-format really agree about these style rules.
Why use checkpatch to assess code style, if we could simply diff the existing source with the output from clang-format... but it seems that clang-format harms readability, makes indentation errors and uses inconsistent style rules. Some examples:
Quoted 6 lines
Problems with clang-format should be fixed, I'll take a look.
I was reviewing this file for another isseue and could not get past how horredously bad it was and really did not want to manually fix the 400+ formatting errors. I will drop this patch and use the use these files to verify the .clang-format .
I think this is more an issue with clang-format than with checkpatch.
Quoted 8 lines
Quoted 2 lines
If you have specific issues with what checkpatch reports for this file (or any other file), let me know.
Yes, I agree. Its a clang-format problem.
I will be looking to minimize the .clang-format settings to only those that agree with checkpatch.
Then add settings back in later if their problems can be worked out.
Another option would be to use:
./scripts/checkpatch.pl -f --fix[-inplace] [--types=<list>] <files>where types is an optional list of specific things to change
see:
./scripts/checkpatch.pl --list-types --verboseto show the possible types.
Only some of these types can be changed with --fix or --fix-inplace
Quoted 7 lines
If using checkpatch to change formatting, it sometimes can be useful to run checkpatch --fix multiple times on the same file as a checkpatch --fix can create a change than checkpatch will suggest should itself be fixed.
Of course another option is to do nothing as many will complain, sometimes senselessly, about 'churn'.
A testsuite for the fixers may help with churn
Any interest or thought on organization ?
I can take stab at one.
Tom
Quoted 3 lines
(adding checkpatch reviewers Dwaipayan and Lukas)
Original thread: https://lore.kernel.org/lkml/[email protected]/
Quoted 19 lines · Tom Rix
Quoted 18 lines · Joe Perches
Another option would be to use:
./scripts/checkpatch.pl -f --fix[-inplace] [--types=<list>] <files>where types is an optional list of specific things to change
see:
./scripts/checkpatch.pl --list-types --verboseto show the possible types.
Only some of these types can be changed with --fix or --fix-inplace
If using checkpatch to change formatting, it sometimes can be useful to run checkpatch --fix multiple times on the same file as a checkpatch --fix can create a change than checkpatch will suggest should itself be fixed.
Quoted 4 lines
Quoted 2 lines
Of course another option is to do nothing as many will complain, sometimes senselessly, about 'churn'.
A testsuite for the fixers may help with churn
Likely not, as IMO churn is an 'eye of beholder' issue.
Quoted 1 line
Any interest or thought on organization ?
Not really.
The checkpatch --fix code isn't perfect as it's just regexes.
When writing the --fix code, I've always just used the kernel sources and git history to inspect/verify suggested changes.
Quoted 1 line
I can take stab at one.
Enjoy.
Quoted 4 lines · Tom Rix
A testsuite for the fixers may help with churn
Any interest or thought on organization ?
Here's one way:
1. Identify some source files that are exemplary (i.e. good style).
2. Run a new script to introduce style mistakes into those files.
3. Run the Reformatter Under Test on those files.
4. Compare the output with the original files.
But that's not sufficient to prevent more style patches (churn). We still need a way to avoid wasting everyone's time writing, submitting, reviewing and merging the inevitably incomplete style patches that may contain regressions and cause conflicts.
The tooling I would like to see is not a script to introduce style mistakes but an editor for binaries, such that C is not the "source" at all but only an ephemeral representation to make it easier for humans to effect changes to binaries (and debug info, commentary etc.)
Nonetheless, perfecting the clang-format tool is a good step towards a better workflow, which I described once before.
https://lore.kernel.org/r/[email protected]/
Quoted 3 lines · Nick Desaulniers
+ Miguel (the clang-format maintainer), Joe (checkpatch maintainer) These criticisms are worth reviewing.
Indeed, thanks Nick. In my upgrade to clang-format 11 (from the current clang-format 4), I will check whether some of these improve.
Cheers,
Miguel
Quoted 5 lines · On 1/27/22 07:19, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
Isn't this the kind of patches that carries more risk than value? Additionally, this patch conflicts with a patch series that I plan to post soon.
Thanks,
Bart.
Quoted 10 lines · Bart Van Assche
Quoted 5 lines · On 1/27/22 07:19, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
Isn't this the kind of patches that carries more risk than value? Additionally, this patch conflicts with a patch series that I plan to post soon.
Thanks,
I have dropped this patch.
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
So you could do two patches, first would be fixing formatting problems and second would new stuff.
As it is your new patch will have to both for now.
Tom
Quoted 4 lines
Bart.
Quoted 9 lines · Tom Rix
Quoted 8 lines · Bart Van Assche
Quoted 5 lines · On 1/27/22 07:19, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
Isn't this the kind of patches that carries more risk than value?
Risk for whitespace style reformatting patches is quite low.
Nominally, clang-format changes should not produce a different compiled object file unless __LINE__/__DATE__/__TIME__ style changes occur.
If it does, the clang-format tool is broken.
Quoted 2 lines
Quoted 2 lines
Additionally, this patch conflicts with a patch series that I plan to post soon.
[]
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Especially so for any automation.
Quoted 17 lines · Joe Perches
Quoted 8 lines · Tom Rix
Quoted 7 lines · Bart Van Assche
Quoted 5 lines · On 1/27/22 07:19, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
Isn't this the kind of patches that carries more risk than value?
Risk for whitespace style reformatting patches is quite low.
Nominally, clang-format changes should not produce a different compiled object file unless __LINE__/__DATE__/__TIME__ style changes occur.
If it does, the clang-format tool is broken.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Additionally, this patch conflicts with a patch series that I plan to post soon.
[]
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Especially so for any automation.
In practice everything is up to the maintainer.
If some maintainer wants fix their formatting then clang-format should just work
It isn't likely they will have time to hand fix every file.
Tom
Quoted 2 lines
Quoted 26 lines · Tom Rix
Quoted 24 lines · Joe Perches
Quoted 8 lines · Tom Rix
Quoted 7 lines · Bart Van Assche
Quoted 5 lines · On 1/27/22 07:19, [email protected] wrote:
From: Tom Rix <[email protected]>
checkpatch reports several hundred formatting errors. Run these files through clang-format and knock off some of them.
Isn't this the kind of patches that carries more risk than value?
Risk for whitespace style reformatting patches is quite low.
Nominally, clang-format changes should not produce a different compiled object file unless __LINE__/__DATE__/__TIME__ style changes occur.
If it does, the clang-format tool is broken.
Quoted 2 lines
Quoted 2 lines
Additionally, this patch conflicts with a patch series that I plan to post soon.
[]
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Quoted 7 lines
Quoted 1 line
Especially so for any automation.
In practice everything is up to the maintainer.
If some maintainer wants fix their formatting then clang-format should just work
It isn't likely they will have time to hand fix every file.
A follow up issue in the clang project has been raised by Konrad, here
https://github.com/llvm/llvm-project/issues/54137
Tom
Quoted 5 lines
Tom
Quoted 2 lines
Quoted 8 lines · Tom Rix
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Especially so for any automation.
In practice everything is up to the maintainer.
Quoted 9 lines
Quoted 4 lines
If some maintainer wants fix their formatting then clang-format should just work
It isn't likely they will have time to hand fix every file.
A follow up issue in the clang project has been raised by Konrad, here
Why request a "leave" option for every style rule? Why not just a "leave" option for the most contentious rules?
The response from the developers that anyone who wants to leave existing code unmolested by certain rules should "wake up and smell the coffee" is obnoxious, IMO.
Presumably clang-format must grow until it has sufficient program logic and config options to cater to every exception to every rule. How long will that take? Some carefully chosen "leave" options might make the program much more useful in the near term.
Quoted 9 lines
Tom
Quoted 5 lines
Tom
Quoted 2 lines
(Resending in plain text format to make mailing lists happy.)
Hi Finn,
Quoted 17 lines · Finn Thain
Quoted 13 lines · Tom Rix
Quoted 12 lines
Quoted 5 lines
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Especially so for any automation.
In practice everything is up to the maintainer.
If some maintainer wants fix their formatting then clang-format should just work
It isn't likely they will have time to hand fix every file.
Quoted 7 lines
Quoted 4 lines
A follow up issue in the clang project has been raised by Konrad, here
Why request a "leave" option for every style rule? Why not just a "leave" option for the most contentious rules?
Getting to the point that every style option can be disabled individually is not an operation done in one go. I plan on presenting the changes required to exactly one style option and from there I'm all ears if you have style options that you consider "contentious". We could certainly tackle them next. But for starters I think it's fine to just show the impact of changing one style option only.
Quoted 3 lines
Quoted 3 lines
The response from the developers that anyone who wants to leave existing code unmolested by certain rules should "wake up and smell the coffee" is obnoxious, IMO.
I hear you, I like tea better than coffee ;). In all seriousness, I'm here to help and I don't judge the developers for protecting their code and having an opinion about other projects. We're here to talk and find a solution, nothing more. Let's try to ignore the sarcastic undertone in the dialogue.
Quoted 4 lines
Quoted 4 lines
Presumably clang-format must grow until it has sufficient program logic and config options to cater to every exception to every rule. How long will that take? Some carefully chosen "leave" options might make the program much more useful in the near term.
That's what I aim at. I hope I've outlined this in the first paragraph of this email. One baby step at a time...
- Konrad
Quoted 13 lines
Quoted 12 lines
Tom
Quoted 5 lines
Tom
Quoted 2 lines
A message that is not in the archive (sent off-list or not yet received): CABRYuGk+1AGpvfkR7=LTCm+bN4kt55fwQnQXCjidSXWxuMWsiQ@mail.gmail.com
Hi Konrad,
Quoted 23 lines · Konrad Wilhelm Kleine
Quoted 21 lines · Finn Thain
Quoted 18 lines · Tom Rix
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Long term, it would be good have a reliable way to automatically fix either new files or really broken old files.
That's really a maintainer preference no?
Quoted 8 lines
Quoted 1 line
Especially so for any automation.
In practice everything is up to the maintainer.
If some maintainer wants fix their formatting then clang-format should just work
It isn't likely they will have time to hand fix every file.
A follow up issue in the clang project has been raised by Konrad, here
Quoted 8 lines
Quoted 3 lines
Why request a "leave" option for every style rule? Why not just a "leave" option for the most contentious rules?
Getting to the point that every style option can be disabled individually is not an operation done in one go. I plan on presenting the changes required to exactly one style option and from there I'm all ears if you have style options that you consider "contentious".
Sure, I'll provide an example of that below in case you're interested in what I happen to find contentious. But this isn't about my taste.
The issue is really about removing an obstacle to wider adoption of clang-formt. Therefore, shouldn't you be asking, what style rules have already proven to be contentious within the project?
You can look to kernel subsystem style rules for examples of that. E.g. some might argue that comments should always be left unmolested (where they exist for the benefit of human readers and not tooling).
Others might argue that they should always be changed from,
/*
* this style
* of multiline comment
*/
to
/* this style
* of multiline comment
*/
For another example, the mailing lists recently saw another style rule difference between subsystems:
https://lore.kernel.org/all/20220301055231.GI2812@kadam/
Joe said, in effect, "leave" whereas others seem to have different views.
Finally, here's an example that I personally found contentious. drivers/scsi/NCR5380.c line 2306:
dsprintk(NDEBUG_ABORT, instance, "abort: removed %p from sense queue\n", cmd);
Note the spaces (for alignment) following the tabs (for scope). I mention this example not because I expect the world to "wake up and smell the coffee" one day and embrace spaces-after-tabs.
I mention it because I expect the tabs/spaces/both issue to remain contentious indefinitely (within any sufficiently large project).
I can think of another good example (line wrap) but I'll stop here.
Quoted 8 lines · Finn Thain
Others might argue that they should always be changed from,
/*
* this style
* of multiline comment
*/
Quoted 5 lines
to
/* this style
* of multiline comment
*/
In general, for things that the coding style guide talks about, we should follow them, even if some subsystems do not (they can always override in their folder if they really, really want it). So, here for instance, the first one should be used.
Cheers,
Miguel
Quoted 11 lines · Miguel Ojeda
Quoted 10 lines · Finn Thain
Others might argue that they should always be changed from,
/*
* this style
* of multiline comment
*/to
Quoted 8 lines
Quoted 3 lines
/* this style
* of multiline comment
*/In general, for things that the coding style guide talks about, we should follow them, even if some subsystems do not (they can always override in their folder if they really, really want it). So, here for instance, the first one should be used.
It's up to individual maintainers to each decide on what might be considered unnecessary churn for the subsystems they control.
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
Quoted 4 lines · Joe Perches
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
I'm often backporting patches to older kernels and I think the churn argument has not been emphasized enough. Backporting patches is a normal aspect of a product lifecycle since a kernel version is chosen when development of a product starts and bugfixes are cherry-picked from upstream selectively.
Thanks,
Bart.
Quoted 10 lines · Bart Van Assche
Quoted 4 lines · Joe Perches
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
I'm often backporting patches to older kernels and I think the churn argument has not been emphasized enough. Backporting patches is a normal aspect of a product lifecycle since a kernel version is chosen when development of a product starts and bugfixes are cherry-picked from upstream selectively.
Stable backporting is almost certainly what people get _paid_ to do.
IMO the most important tree is the current one not backports to stable.
Hi Bart,
Quoted 4 lines · Bart Van Assche
Quoted 3 lines · Joe Perches
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
Quoted 8 lines
Quoted 1 line
I think the churn argument is overstated.
I'm often backporting patches to older kernels and I think the churn argument has not been emphasized enough. Backporting patches is a normal aspect of a product lifecycle since a kernel version is chosen when development of a product starts and bugfixes are cherry-picked from upstream selectively.
That should not be an issue. One of the benefits of having a canonical form for source code is that you also get a canonical form for patches.
Let's say you receive a patch (or wish to cherry-pick one) that could be applied to your backport branch, except for superficial changes that cause a (canonical) patch to be rejected.
In principle, you can still apply the patch automatically. You "only" require a canonical reformatter that preserves line numbering, and a tree close to the tree on which the patch was based.
The process goes like this:
1. Checkout base tree
2. Reformat all the files mentioned in the bad patch, but confined to those lines that appear in the patch.
3. Apply the patch and commit
Finally you'd cherry-pick that commit for your backport branch.
In case you receive a patch that's whitespace-damaged, you can do this first:
1. Checkout base tree
2. Damage all the files mentioned in the bad patch
$ perl -i -p -e 's/\s+/ /g' ...
3. Do the same to the bad patch
4. Apply the bad patch
5. Reformat the files changed by the patch into canonical form
6. Tag that as "B"
7. Checkout base tree
8. Reformat the same files into canonical form
9. Tag that as "A"
10. Produce a good patch
$ git diff A..BYou can now apply the good patch to your branch. Since it is in canonical form, it may still fail to apply (but see above for the solution).
This second example is not really a job for reviewers/maintainers but it could be performed automatically by tooling like patchwork.
Quoted 21 lines · Joe Perches
Quoted 11 lines · Miguel Ojeda
Quoted 10 lines · Finn Thain
Others might argue that they should always be changed from,
/*
* this style
* of multiline comment
*/to
Quoted 8 lines
Quoted 3 lines
/* this style
* of multiline comment
*/In general, for things that the coding style guide talks about, we should follow them, even if some subsystems do not (they can always override in their folder if they really, really want it). So, here for instance, the first one should be used.
Quoted 8 lines
It's up to individual maintainers to each decide on what might be considered unnecessary churn for the subsystems they control.
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
If you would have clang-format override the committer and retrospectively apply subsystem style rules (rather than the rules used by a majority of subsystems or those preferred by Linus for example) it would add friction to code re-use, movement, comparison, any tree-wide program transformation, and also subsystem boundary changes.
Per-subsystem style rules are inherently contentious and therefore good candidates for the "leave alone" functionality discussed in the issue tracker.
Quoted 8 lines · Joe Perches
It's up to individual maintainers to each decide on what might be considered unnecessary churn for the subsystems they control.
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
I was only pointing out that, for the global .clang-format file, the style in coding-style.rst should be followed. Then subsystem maintainers may override it if really needed.
I definitely agree that we should aim to have a consistent style. However, by allowing a few exceptions, some major subsystems may start using clang-format sooner.
Cheers,
Miguel
Quoted 14 lines · Joe Perches
Quoted 13 lines · Miguel Ojeda
Quoted 12 lines · Finn Thain
Others might argue that they should always be changed from,
/*
* this style
* of multiline comment
*/to
/* this style
* of multiline comment
*/
Quoted 6 lines
Quoted 4 lines
In general, for things that the coding style guide talks about, we should follow them, even if some subsystems do not (they can always override in their folder if they really, really want it). So, here for instance, the first one should be used.
It's up to individual maintainers to each decide on what might be considered unnecessary churn for the subsystems they control.
clang-format does not have an opt-in mechanism like indent, it is all-or-nothing
What is done is all the settings in .clang-format and the default settings.
The churn level will be very high.
Until clang-format has an opt-in mechanism, I do not think clang-format should be used.
.clang-format should be moved to staging/ to reflect its not being ready status.
staging/ would be a good long term home. it's content should not need backporting and is more likely to have style issues.
Tom
Quoted 7 lines
One argument is that churn leads to difficulty in backporting fixes to older 'stable' versions.
I think the churn argument is overstated.
Quoted 2 lines · Tom Rix
The churn level will be very high.
Nobody is planning to reformat the entire kernel, at least not until the tool is close enough to the kernel style, which will take a while.
Quoted 5 lines
Until clang-format has an opt-in mechanism, I do not think clang-format should be used.
.clang-format should be moved to staging/ to reflect its not being ready status.
What is not ready about it?
It is a fairly useful tool that some people is already using, either for full file formatting or for sections within their editor.
Cheers,
Miguel
Quoted 6 lines · Miguel Ojeda
Quoted 2 lines · Tom Rix
The churn level will be very high.
Nobody is planning to reformat the entire kernel, at least not until the tool is close enough to the kernel style, which will take a while.
I rather doubt clang-format will ever be 'close enough'.
A human's sense of 'taste' for reading code is very different than what an automated tool produces.
For instance, clang-format does a quite poor job when comments are intermixed with definitions.
Also, try looking at the changes clang-format does on a file chosen at random:
$ clang-format -i drivers/hid/hid-sony.c $ git diff drivers/hid/hid-sony.c [...]
o columnarized definitions -> not columnarized
o odd line continuation placement using spaces and not tabs before \
o odd array definition layouts
o per line definitions with comments poorly laid out
o individual line definitions rewrapped
o enum definitions on multiple lines compressed to single lines
o u8 array definition layouts where the first element has a separate meaning than the subsequent elements are compressed and made difficult to understand
I think _some_ clang-format output is ok, but the concept of enabling/disabling specific reformatting bits would be quite useful.
And sprinkling "clang-format on/off" lines in the code is not good.
Any control codes that determine when source code layout might be immutable or allowed to be modified could be should be tool name agnostic.
Quoted 5 lines · Joe Perches
I rather doubt clang-format will ever be 'close enough'.
A human's sense of 'taste' for reading code is very different than what an automated tool produces.
Maybe, but it is a trade-off. If it is close enough, the benefits of automatic formatting may overcome the downsides.
Quoted 12 lines
Also, try looking at the changes clang-format does on a file chosen at random:
o columnarized definitions -> not columnarized
o odd line continuation placement using spaces and not tabs before \
o odd array definition layouts
o per line definitions with comments poorly laid out
o individual line definitions rewrapped
o enum definitions on multiple lines compressed to single lines
o u8 array definition layouts where the first element has a separate meaning than the subsequent elements are compressed and made difficult to understand
I am not sure what you are trying to show here -- some of these are precisely the things that the tool could improve or have already improved, and we may just need to use the new option.
For instance, for the columnarized macros case, it is possible to align them since clang-format 9. For array of structures, there is also a new alignment option since clang-format 13. Etc.
For the wrapping and related bits, now that the limit on 80 is a bit more fuzzy, we could perhaps tweak the penalties to improve the decision making.
In summary, what we should be trying to do is improve the tool configuration and tool itself to see if we can get it to be close enough to the kernel style to make it more widely used.
Quoted 4 lines
I think _some_ clang-format output is ok, but the concept of enabling/disabling specific reformatting bits would be quite useful.
And sprinkling "clang-format on/off" lines in the code is not good.
Definitely, but it is fine in some exceptional cases.
Quoted 3 lines
Any control codes that determine when source code layout might be immutable or allowed to be modified could be should be tool name agnostic.
I don't see why would that be a problem, and I don't understand why we would use several different formatting tools (the point is to be consistent, after all); but sure, we could propose an alternative spelling.
Cheers,
Miguel
Quoted 8 lines · Miguel Ojeda
Quoted 5 lines · Joe Perches
I rather doubt clang-format will ever be 'close enough'.
A human's sense of 'taste' for reading code is very different than what an automated tool produces.
Maybe,
Hey again Miguel.
Is that statement really disputable?
Quoted 2 lines
but it is a trade-off. If it is close enough, the benefits of automatic formatting may overcome the downsides.
IYO. I think using an SCCS with better language understanding rather than a line oriented one could be an improvement. Such a tool could allow arbitrary style reformatting at check-in/check-out.
Quoted 13 lines
Quoted 12 lines
Also, try looking at the changes clang-format does on a file chosen at random:
o columnarized definitions -> not columnarized
o odd line continuation placement using spaces and not tabs before \
o odd array definition layouts
o per line definitions with comments poorly laid out
o individual line definitions rewrapped
o enum definitions on multiple lines compressed to single lines
o u8 array definition layouts where the first element has a separate meaning than the subsequent elements are compressed and made difficult to understand
Quoted 3 lines
I am not sure what you are trying to show here -- some of these are precisely the things that the tool could improve or have already improved, and we may just need to use the new option.
All of these existing code are more human readable than the code reformatted using clang-format.
I used whatever is the latest clang-format here with today's -next.
https://releases.llvm.org/download.html
Quoted 3 lines
For instance, for the columnarized macros case, it is possible to align them since clang-format 9. For array of structures, there is also a new alignment option since clang-format 13. Etc.
Then perhaps you as the maintainer of the kernel's .clang-format file could update the entries for those new options.
I believe the minimum clang version is already 11. Maybe higher. I don't track clang or use it very much. The clang version I use though is 13.
Quoted 3 lines
For the wrapping and related bits, now that the limit on 80 is a bit more fuzzy, we could perhaps tweak the penalties to improve the decision making.
Please have at it.
But perhaps tweaking will just improve some cases and worsen others.
Quoted 10 lines
In summary, what we should be trying to do is improve the tool configuration and tool itself to see if we can get it to be close enough to the kernel style to make it more widely used.
Quoted 4 lines
I think _some_ clang-format output is ok, but the concept of enabling/disabling specific reformatting bits would be quite useful.
And sprinkling "clang-format on/off" lines in the code is not good.
Definitely, but it is fine in some exceptional cases.
I don't think so.
Quoted 8 lines
Quoted 3 lines
Any control codes that determine when source code layout might be immutable or allowed to be modified could be should be tool name agnostic.
I don't see why would that be a problem, and I don't understand why we would use several different formatting tools (the point is to be consistent, after all); but sure, we could propose an alternative spelling.
Thanks.
There is no "one true editor".
There will not be "one true source code formatter" either.
cheers not jeers, just keep at it. Joe
Quoted 2 lines · Joe Perches
Is that statement really disputable?
By "Maybe", I only mean that you may be right (or not), i.e. we cannot really show one way or the other with data.
But note that many people (including projects, companies and even programming languages) prefer consistency and automated formatting vs. the alternative.
Quoted 3 lines
IYO. I think using an SCCS with better language understanding rather than a line oriented one could be an improvement. Such a tool could allow arbitrary style reformatting at check-in/check-out.
clang-format is not line oriented. In fact, you may be able to get quite close to what you suggest with clang-format if you have a project that is automatically formatted.
Quoted 2 lines
All of these existing code are more human readable than the code reformatted using clang-format.
That is subjective (for some it may be good enough), and anyway you compared it to the current config file (clang-format 4). The point I raised is that clang-format 13 and future versions should be closer to what you expect.
And by saying "I rather doubt clang-format will ever be 'close enough'.", then there is little incentive for the clang-format team to actually add support the things we need...
Quoted 2 lines
I used whatever is the latest clang-format here with today's -next.
https://releases.llvm.org/download.html
I think this may be the source of confusion -- even if you use clang-format 13, you need to edit the config file to use the new options.
In other words, when I said something is supported since e.g. clang-format 9, one still needs to enable it in the config file.
Quoted 2 lines
Then perhaps you as the maintainer of the kernel's .clang-format file could update the entries for those new options.
No, I cannot, because that is an error, thus breaks users of old clang-format versions.
That is why I suggested to track the minimum LLVM supported version in the kernel, i.e. go at least to LLVM 11. And then over time keep upgrading it and getting better output.
Quoted 3 lines
I believe the minimum clang version is already 11. Maybe higher. I don't track clang or use it very much. The clang version I use though is 13.
Yes, I am aware, please see above. The issue and why I did not "just do it" is that people could have been using clang-format from e.g. their distro, but compiling with GCC.
Quoted 1 line
But perhaps tweaking will just improve some cases and worsen others.
Yes, of course.
Quoted 1 line
I don't think so.
Why?
Quoted 2 lines
There is no "one true editor".
There will not be "one true source code formatter" either.
Not for every project, but for a single project, there can definitely be a "single formatter". In fact, that is what many other projects do in practice in order to reach a point where automatic formatting is done.
Cheers,
Miguel
Quoted 3 lines · Joe Perches
Is that statement really disputable?
If there was such a thing as an indisputable statement, a set of universally accepted style rules would soon follow, I suspect.
...
Quoted 4 lines
There is no "one true editor".
There will not be "one true source code formatter" either.
It only has to be sufficiently good that it produces a consensus.
Quoted 4 lines · Miguel Ojeda
Quoted 1 line · Tom Rix
The churn level will be very high.
Nobody is planning to reformat the entire kernel, at least not until the tool is close enough to the kernel style, which will take a while.
The churn on a single file like this is high.
There is no way to separate just one type of change, you get all the changes.
Not having an opt-in/out per type of change is a flaw that makes clang-format not ready.
Tom
Quoted 14 lines
Quoted 6 lines
Until clang-format has an opt-in mechanism, I do not think clang-format should be used.
.clang-format should be moved to staging/ to reflect its not being ready status.
What is not ready about it?
It is a fairly useful tool that some people is already using, either for full file formatting or for sections within their editor.
Cheers,
Miguel
Quoted 5 lines · Joe Perches
Quoted 2 lines · Tom Rix
Quoted 1 line · Bart Van Assche
Isn't this the kind of patches that carries more risk than value?
Risk for whitespace style reformatting patches is quite low.
But the annoyance factor for patches that reformat an entire source file is very high. It forces everyone who has conflicting patches pending to wait until the reformatting patch went in, rebase their tree and also to resolve the complicated merge conflicts that are the result of the reformatting patch. I have already had to do this several times in the past.
Thanks,
Bart.