Commit 8e363726 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: megaraid inline fixes

	inlined functions moved, a couple of heavy-weight ones (issue_scb()
and meg_cmd_done()) uninlined.
parent 3a79c899
......@@ -335,6 +335,18 @@ mega_query_adapter(adapter_t *adapter)
return 0;
}
/**
* mega_runpendq()
* @adapter - pointer to our soft state
*
* Runs through the list of pending requests.
*/
static inline void
mega_runpendq(adapter_t *adapter)
{
if(!list_empty(&adapter->pending_list))
__mega_runpendq(adapter);
}
/*
* megaraid_queue()
......@@ -384,6 +396,95 @@ megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
return busy;
}
/**
* mega_allocate_scb()
* @adapter - pointer to our soft state
* @cmd - scsi command from the mid-layer
*
* Allocate a SCB structure. This is the central structure for controller
* commands.
*/
static inline scb_t *
mega_allocate_scb(adapter_t *adapter, Scsi_Cmnd *cmd)
{
struct list_head *head = &adapter->free_list;
scb_t *scb;
/* Unlink command from Free List */
if( !list_empty(head) ) {
scb = list_entry(head->next, scb_t, list);
list_del_init(head->next);
scb->state = SCB_ACTIVE;
scb->cmd = cmd;
scb->dma_type = MEGA_DMA_TYPE_NONE;
return scb;
}
return NULL;
}
/**
* mega_get_ldrv_num()
* @adapter - pointer to our soft state
* @cmd - scsi mid layer command
* @channel - channel on the controller
*
* 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, Scsi_Cmnd *cmd, int channel)
{
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 we have a logical drive with boot enabled, project it first
*/
if( adapter->boot_ldrv_enabled ) {
if( ldrv_num == 0 ) {
ldrv_num = adapter->boot_ldrv;
}
else {
if( ldrv_num <= adapter->boot_ldrv ) {
ldrv_num--;
}
}
}
/*
* If "delete logical drive" feature is enabled on this controller.
* Do only if at least one delete logical drive operation was done.
*
* Also, after logical drive deletion, instead of logical drive number,
* the value returned should be 0x80+logical drive id.
*
* These is valid only for IO commands.
*/
if (adapter->support_random_del && adapter->read_ldidmap )
switch (cmd->cmnd[0]) {
case READ_6: /* fall through */
case WRITE_6: /* fall through */
case READ_10: /* fall through */
case WRITE_10:
ldrv_num += 0x80;
}
return ldrv_num;
}
/**
* mega_build_cmd()
......@@ -966,52 +1067,6 @@ mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb, Scsi_Cmnd *cmd,
return epthru;
}
/**
* mega_allocate_scb()
* @adapter - pointer to our soft state
* @cmd - scsi command from the mid-layer
*
* Allocate a SCB structure. This is the central structure for controller
* commands.
*/
static inline scb_t *
mega_allocate_scb(adapter_t *adapter, Scsi_Cmnd *cmd)
{
struct list_head *head = &adapter->free_list;
scb_t *scb;
/* Unlink command from Free List */
if( !list_empty(head) ) {
scb = list_entry(head->next, scb_t, list);
list_del_init(head->next);
scb->state = SCB_ACTIVE;
scb->cmd = cmd;
scb->dma_type = MEGA_DMA_TYPE_NONE;
return scb;
}
return NULL;
}
/**
* mega_runpendq()
* @adapter - pointer to our soft state
*
* Runs through the list of pending requests.
*/
static inline void
mega_runpendq(adapter_t *adapter)
{
if(!list_empty(&adapter->pending_list))
__mega_runpendq(adapter);
}
static void
__mega_runpendq(adapter_t *adapter)
{
......@@ -1043,7 +1098,7 @@ __mega_runpendq(adapter_t *adapter)
* busy. We also take the scb from the pending list if the mailbox is
* available.
*/
static inline int
static int
issue_scb(adapter_t *adapter, scb_t *scb)
{
volatile mbox64_t *mbox64 = adapter->mbox64;
......@@ -1104,6 +1159,16 @@ issue_scb(adapter_t *adapter, scb_t *scb)
return 0;
}
/*
* Wait until the controller's mailbox is available
*/
static inline int
mega_busywait_mbox (adapter_t *adapter)
{
if (adapter->mbox->m_in.busy)
return __mega_busywait_mbox(adapter);
return 0;
}
/**
* issue_scb_block()
......@@ -1350,7 +1415,7 @@ megaraid_isr_memmapped(int irq, void *devp, struct pt_regs *regs)
*
* Complete the comamnds and call the scsi mid-layer callback hooks.
*/
static inline void
static void
mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
{
mega_ext_passthru *epthru = NULL;
......@@ -1671,17 +1736,6 @@ mega_free_scb(adapter_t *adapter, scb_t *scb)
}
/*
* Wait until the controller's mailbox is available
*/
static inline int
mega_busywait_mbox (adapter_t *adapter)
{
if (adapter->mbox->m_in.busy)
return __mega_busywait_mbox(adapter);
return 0;
}
static int
__mega_busywait_mbox (adapter_t *adapter)
{
......@@ -2017,6 +2071,49 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
return FALSE;
}
static inline int
make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
{
*pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
if( *pdev == NULL ) return -1;
memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
if( pci_set_dma_mask(*pdev, 0xffffffff) != 0 ) {
kfree(*pdev);
return -1;
}
return 0;
}
static inline void
free_local_pdev(struct pci_dev *pdev)
{
kfree(pdev);
}
/**
* mega_allocate_inquiry()
* @dma_handle - handle returned for dma address
* @pdev - handle to pci device
*
* allocates memory for inquiry structure
*/
static inline void *
mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev)
{
return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle);
}
static inline void
mega_free_inquiry(void *inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
{
pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle);
}
#ifdef CONFIG_PROC_FS
/* Following code handles /proc fs */
......@@ -4233,67 +4330,6 @@ mega_support_cluster(adapter_t *adapter)
}
/**
* mega_get_ldrv_num()
* @adapter - pointer to our soft state
* @cmd - scsi mid layer command
* @channel - channel on the controller
*
* 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, Scsi_Cmnd *cmd, int channel)
{
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 we have a logical drive with boot enabled, project it first
*/
if( adapter->boot_ldrv_enabled ) {
if( ldrv_num == 0 ) {
ldrv_num = adapter->boot_ldrv;
}
else {
if( ldrv_num <= adapter->boot_ldrv ) {
ldrv_num--;
}
}
}
/*
* If "delete logical drive" feature is enabled on this controller.
* Do only if at least one delete logical drive operation was done.
*
* Also, after logical drive deletion, instead of logical drive number,
* the value returned should be 0x80+logical drive id.
*
* These is valid only for IO commands.
*/
if (adapter->support_random_del && adapter->read_ldidmap )
switch (cmd->cmnd[0]) {
case READ_6: /* fall through */
case WRITE_6: /* fall through */
case READ_10: /* fall through */
case WRITE_10:
ldrv_num += 0x80;
}
return ldrv_num;
}
/**
* mega_adapinq()
* @adapter - pointer to our soft state
......@@ -4329,27 +4365,6 @@ mega_adapinq(adapter_t *adapter, dma_addr_t dma_handle)
}
/**
* mega_allocate_inquiry()
* @dma_handle - handle returned for dma address
* @pdev - handle to pci device
*
* allocates memory for inquiry structure
*/
static inline caddr_t
mega_allocate_inquiry(dma_addr_t *dma_handle, struct pci_dev *pdev)
{
return pci_alloc_consistent(pdev, sizeof(mega_inquiry3), dma_handle);
}
static inline void
mega_free_inquiry(caddr_t inquiry, dma_addr_t dma_handle, struct pci_dev *pdev)
{
pci_free_consistent(pdev, sizeof(mega_inquiry3), inquiry, dma_handle);
}
/** mega_internal_dev_inquiry()
* @adapter - pointer to our soft state
* @ch - channel for this device
......@@ -4550,29 +4565,6 @@ mega_internal_done(Scsi_Cmnd *scmd)
}
static inline int
make_local_pdev(adapter_t *adapter, struct pci_dev **pdev)
{
*pdev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
if( *pdev == NULL ) return -1;
memcpy(*pdev, adapter->dev, sizeof(struct pci_dev));
if( pci_set_dma_mask(*pdev, 0xffffffff) != 0 ) {
kfree(*pdev);
return -1;
}
return 0;
}
static inline void
free_local_pdev(struct pci_dev *pdev)
{
kfree(pdev);
}
static struct scsi_host_template megaraid_template = {
.module = THIS_MODULE,
.name = "MegaRAID",
......
......@@ -990,14 +990,12 @@ typedef enum { LOCK_INT, LOCK_EXT } lockscope_t;
const char *megaraid_info (struct Scsi_Host *);
static int mega_query_adapter(adapter_t *);
static inline int issue_scb(adapter_t *, scb_t *);
static int issue_scb(adapter_t *, scb_t *);
static int mega_setup_mailbox(adapter_t *);
static int megaraid_queue (Scsi_Cmnd *, void (*)(Scsi_Cmnd *));
static scb_t * mega_build_cmd(adapter_t *, Scsi_Cmnd *, int *);
static inline scb_t *mega_allocate_scb(adapter_t *, Scsi_Cmnd *);
static void __mega_runpendq(adapter_t *);
static inline void mega_runpendq(adapter_t *);
static int issue_scb_block(adapter_t *, u_char *);
static irqreturn_t megaraid_isr_memmapped(int, void *, struct pt_regs *);
......@@ -1014,10 +1012,9 @@ static int mega_print_inquiry(char *, char *);
static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
u32 *buffer, u32 *length);
static inline int mega_busywait_mbox (adapter_t *);
static int __mega_busywait_mbox (adapter_t *);
static void mega_rundoneq (adapter_t *);
static inline void mega_cmd_done(adapter_t *, u8 [], int, int);
static void mega_cmd_done(adapter_t *, u8 [], int, int);
static inline void mega_free_sgl (adapter_t *adapter);
static void mega_8_to_40ld (mraid_inquiry *inquiry,
mega_inquiry3 *enquiry3, mega_product_info *);
......@@ -1025,8 +1022,8 @@ static void mega_8_to_40ld (mraid_inquiry *inquiry,
static int megadev_open (struct inode *, struct file *);
static int megadev_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
static int mega_m_to_n(void *, nitioctl_t *);
static int mega_n_to_m(void *, megacmd_t *);
static int mega_m_to_n(void __user *, nitioctl_t *);
static int mega_n_to_m(void __user *, megacmd_t *);
static int mega_init_scb (adapter_t *);
......@@ -1053,10 +1050,6 @@ static int proc_rdrv(adapter_t *, char *, int, int);
static int mega_adapinq(adapter_t *, dma_addr_t);
static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
static inline caddr_t mega_allocate_inquiry(dma_addr_t *, struct pci_dev *);
static inline void mega_free_inquiry(caddr_t, dma_addr_t, struct pci_dev *);
static inline int make_local_pdev(adapter_t *, struct pci_dev **);
static inline void free_local_pdev(struct pci_dev *);
static int mega_support_ext_cdb(adapter_t *);
static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
......@@ -1065,7 +1058,6 @@ static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
scb_t *, Scsi_Cmnd *, int, int);
static void mega_enum_raid_scsi(adapter_t *);
static void mega_get_boot_drv(adapter_t *);
static inline int mega_get_ldrv_num(adapter_t *, Scsi_Cmnd *, int);
static int mega_support_random_del(adapter_t *);
static int mega_del_logdrv(adapter_t *, int);
static int mega_do_del_logdrv(adapter_t *, int);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment