2021-04-10 06:49:44

by Luo Jiaxing

[permalink] [raw]
Subject: [PATCH v1 0/8] scsi: megaraid: some misc clean up patches

There are several kinds of error are reported by checkpatch.pl.

So fix them together.

Luo Jiaxing (8):
scsi: megaraid: clean up for white space
scsi: megaraid_sas: use parentheses to enclose macros with complex
values
scsi: megaraid: clean up for blank lines
scsi: megaraid: clean up for open/close brace
scsi: megaraid: clean up for "foo * bar"
scsi: megaraid: clean up for code indent
scsi: megaraid: clean up for trailing statements
scsi: megaraid: clean up for static variable initialise to 0

drivers/scsi/megaraid/mbox_defs.h | 23 +++---
drivers/scsi/megaraid/mega_common.h | 18 ++---
drivers/scsi/megaraid/megaraid_ioctl.h | 12 +--
drivers/scsi/megaraid/megaraid_mbox.c | 115 ++++++++++++---------------
drivers/scsi/megaraid/megaraid_mbox.h | 2 +-
drivers/scsi/megaraid/megaraid_mm.c | 66 +++++++--------
drivers/scsi/megaraid/megaraid_mm.h | 1 -
drivers/scsi/megaraid/megaraid_sas.h | 52 +-----------
drivers/scsi/megaraid/megaraid_sas_base.c | 69 +++++++---------
drivers/scsi/megaraid/megaraid_sas_debugfs.c | 1 -
drivers/scsi/megaraid/megaraid_sas_fusion.c | 16 ++--
drivers/scsi/megaraid/megaraid_sas_fusion.h | 1 -
12 files changed, 149 insertions(+), 227 deletions(-)

--
2.7.4


2021-04-10 06:50:30

by Luo Jiaxing

[permalink] [raw]
Subject: [PATCH v1 4/8] scsi: megaraid: clean up for open/close brace

There are few kinds of error about open/close brace is reported by
checkpatch.pl:

ERROR: open brace '{' following function definitions go on the next line
int
megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend) {

ERROR: else should follow close brace '}'
+ }
+ else

So fix them all.

Signed-off-by: Jianqin Xie <[email protected]>
Signed-off-by: Luo Jiaxing <[email protected]>
---
drivers/scsi/megaraid/megaraid_mbox.c | 57 ++++++++++-------------------
drivers/scsi/megaraid/megaraid_mm.c | 10 ++---
drivers/scsi/megaraid/megaraid_sas_base.c | 7 ++--
drivers/scsi/megaraid/megaraid_sas_fusion.c | 11 +++---
4 files changed, 31 insertions(+), 54 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 6d76b15..d3fcaca 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -537,8 +537,7 @@ megaraid_detach_one(struct pci_dev *pdev)
pdev->subsystem_device));

return;
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_NOTICE
"megaraid: detaching device %#4.04x:%#4.04x:%#4.04x:%#4.04x\n",
pdev->vendor, pdev->device, pdev->subsystem_vendor,
@@ -1545,8 +1544,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
vaddr = (caddr_t) sg_virt(&sgl[0]);

memset(vaddr, 0, scp->cmnd[4]);
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_WARNING
"megaraid mailbox: invalid sg:%d\n",
__LINE__));
@@ -1705,8 +1703,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
((uint32_t)scp->cmnd[7] << 16) |
((uint32_t)scp->cmnd[8] << 8) |
(uint32_t)scp->cmnd[9];
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_WARNING
"megaraid: unsupported CDB length\n"));

@@ -1762,8 +1759,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
scp->result = (DID_BAD_TARGET << 16);
return NULL;
}
- }
- else { // Passthru device commands
+ } else { // Passthru device commands

// Do not allow access to target id > 15 or LUN > 7
if (target > 15 || SCP2LUN(scp) > 7) {
@@ -1830,8 +1826,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
mbox64->xferaddr_lo = (uint32_t)ccb->epthru_dma_h;
mbox64->xferaddr_hi = 0;
mbox->xferaddr = 0xFFFFFFFF;
- }
- else {
+ } else {
mbox->cmd = MBOXCMD_PASSTHRU64;

megaraid_mbox_prepare_pthru(adapter, scb, scp);
@@ -1961,8 +1956,7 @@ megaraid_mbox_prepare_pthru(adapter_t *adapter, scb_t *scb,
pthru->dataxferlen = scsi_bufflen(scp);
pthru->dataxferaddr = ccb->sgl_dma_h;
pthru->numsge = megaraid_mbox_mksgl(adapter, scb);
- }
- else {
+ } else {
pthru->dataxferaddr = 0;
pthru->dataxferlen = 0;
pthru->numsge = 0;
@@ -2010,8 +2004,7 @@ megaraid_mbox_prepare_epthru(adapter_t *adapter, scb_t *scb,
epthru->dataxferlen = scsi_bufflen(scp);
epthru->dataxferaddr = ccb->sgl_dma_h;
epthru->numsge = megaraid_mbox_mksgl(adapter, scb);
- }
- else {
+ } else {
epthru->dataxferaddr = 0;
epthru->dataxferlen = 0;
epthru->numsge = 0;
@@ -2100,8 +2093,7 @@ megaraid_ack_sequence(adapter_t *adapter)
// a cmm command
scb = adapter->uscb_list + (completed[i] -
MBOX_MAX_SCSI_CMDS);
- }
- else {
+ } else {
// an os command
scb = adapter->kscb_list + completed[i];
}
@@ -2303,8 +2295,7 @@ megaraid_mbox_dpc(unsigned long devp)

scp->result = DRIVER_SENSE << 24 |
DID_OK << 16 | CHECK_CONDITION << 1;
- }
- else {
+ } else {
if (mbox->cmd == MBOXCMD_EXTPTHRU) {

memcpy(scp->sense_buffer,
@@ -2335,8 +2326,7 @@ megaraid_mbox_dpc(unsigned long devp)
if (scp->cmnd[0] == TEST_UNIT_READY) {
scp->result = DID_ERROR << 16 |
RESERVATION_CONFLICT << 1;
- }
- else
+ } else
/*
* Error code returned is 1 if Reserve or Release
* failed or the input parameter is invalid
@@ -2346,8 +2336,7 @@ megaraid_mbox_dpc(unsigned long devp)

scp->result = DID_ERROR << 16 |
RESERVATION_CONFLICT << 1;
- }
- else {
+ } else {
scp->result = DID_BAD_TARGET << 16 | status;
}
}
@@ -2485,8 +2474,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
"megaraid abort: %d[%d:%d], invalid state\n",
scb->sno, scb->dev_channel, scb->dev_target));
BUG();
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_WARNING
"megaraid abort: %d[%d:%d], fw owner\n",
scb->sno, scb->dev_channel, scb->dev_target));
@@ -2621,8 +2609,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)

rval = FAILED;
goto out;
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_NOTICE
"megaraid mbox: reset sequence completed successfully\n"));
}
@@ -2642,8 +2629,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
if (mbox_post_sync_cmd_fast(adapter, raw_mbox) == 0) {
con_log(CL_ANN,
(KERN_INFO "megaraid: reservation reset\n"));
- }
- else {
+ } else {
rval = FAILED;
con_log(CL_ANN, (KERN_WARNING
"megaraid: reservation reset failed\n"));
@@ -3147,8 +3133,7 @@ megaraid_mbox_get_max_sg(adapter_t *adapter)
// Issue the command
if (mbox_post_sync_cmd(adapter, raw_mbox) == 0) {
nsg = *(uint8_t *)adapter->ibuf;
- }
- else {
+ } else {
nsg = MBOX_DEFAULT_SG_SIZE;
}

@@ -3940,21 +3925,18 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
"megaraid: sysfs get ld map timed out\n"));

rval = -ETIME;
- }
- else {
+ } else {
rval = mbox->status;
}

if (rval == 0) {
memcpy(raid_dev->curr_ldmap, ldmap,
sizeof(raid_dev->curr_ldmap));
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_NOTICE
"megaraid: get ld map failed with %x\n", rval));
}
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_NOTICE
"megaraid: could not issue ldmap command:%x\n", rval));
}
@@ -4050,8 +4032,7 @@ megaraid_sysfs_show_ldnum(struct device *dev, struct device_attribute *attr, cha
break;
}
}
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_NOTICE
"megaraid: sysfs get ld map failed: %x\n",
rval));
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 2939f0e..864cbb6 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -390,8 +390,7 @@ mimd_to_kioc(mimd_t __user *umimd, mraid_mmadp_t *adp, uioc_t *kioc)

if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
return (-ENOMEM);
- }
- else {
+ } else {
con_log(CL_ANN, (KERN_WARNING
"megaraid cmm: Invalid subop\n"));
return (-EINVAL);
@@ -539,8 +538,7 @@ mraid_mm_attach_buf(mraid_mmadp_t *adp, uioc_t *kioc, int xferlen)

spin_unlock_irqrestore(&pool->lock, flags);
return 0;
- }
- else {
+ } else {
spin_unlock_irqrestore(&pool->lock, flags);
continue;
}
@@ -760,10 +758,8 @@ ioctl_done(uioc_t *kioc)
if (adapter) {
mraid_mm_dealloc_kioc(adapter, kioc);
}
- }
- else {
+ } else
wake_up(&wait_q);
- }
}


diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 7ff5820..40c77bb 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3199,8 +3199,7 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
spin_unlock_irqrestore(&poll_aen_lock, flags);
wake_up(&megasas_poll_wait);
kill_fasync(&megasas_async_queue, SIGIO, POLL_IN);
- }
- else
+ } else
cmd->abort_aen = 0;

instance->aen_cmd = NULL;
@@ -5686,8 +5685,8 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
* return: void
*/
static void
-megasas_destroy_irqs(struct megasas_instance *instance) {
-
+megasas_destroy_irqs(struct megasas_instance *instance)
+{
int i;
int count;
struct megasas_irq_context *irq_ctx;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 7d10448..4591262 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -908,8 +908,8 @@ megasas_alloc_rdpq_fusion(struct megasas_instance *instance)
}

static void
-megasas_free_rdpq_fusion(struct megasas_instance *instance) {
-
+megasas_free_rdpq_fusion(struct megasas_instance *instance)
+{
int i;
struct fusion_context *fusion;

@@ -932,8 +932,8 @@ megasas_free_rdpq_fusion(struct megasas_instance *instance) {
}

static void
-megasas_free_reply_fusion(struct megasas_instance *instance) {
-
+megasas_free_reply_fusion(struct megasas_instance *instance)
+{
struct fusion_context *fusion;

fusion = instance->ctrl_context;
@@ -1296,7 +1296,8 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
* issue and receive command.
*/
int
-megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend) {
+megasas_sync_pd_seq_num(struct megasas_instance *instance, bool pend)
+{
int ret = 0;
size_t pd_seq_map_sz;
struct megasas_cmd *cmd;
--
2.7.4

2021-04-10 06:50:56

by Luo Jiaxing

[permalink] [raw]
Subject: [PATCH v1 6/8] scsi: megaraid: clean up for code indent

Following error is reported by checkpatch.pl

ERROR: code indent should use tabs where possible
+^I^I unsigned long arg)$

So fix them all.

Signed-off-by: Luo Jiaxing <[email protected]>
---
drivers/scsi/megaraid/mega_common.h | 2 +-
drivers/scsi/megaraid/megaraid_mm.c | 2 +-
drivers/scsi/megaraid/megaraid_sas_base.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index 2a0981b..9a19eec 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -249,7 +249,7 @@ typedef struct {
* ### Helper routines ###
*/
#define LSI_DBGLVL mraid_debug_level // each LLD must define a global
- // mraid_debug_level
+ // mraid_debug_level

#ifdef DEBUG
#if defined (_ASSERT_PANIC)
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 234885c..1d6244e 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -213,7 +213,7 @@ mraid_mm_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)

static long
mraid_mm_unlocked_ioctl(struct file *filep, unsigned int cmd,
- unsigned long arg)
+ unsigned long arg)
{
int err;

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2b17529..f29a3716 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4821,7 +4821,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)

if (!cmd) {
dev_warn(&instance->pdev->dev,
- "megasas_ld_list_query: Failed to get cmd\n");
+ "%s: Failed to get cmd\n", __func__);
return -ENOMEM;
}

--
2.7.4

2021-04-10 06:51:00

by Luo Jiaxing

[permalink] [raw]
Subject: [PATCH v1 2/8] scsi: megaraid_sas: use parentheses to enclose macros with complex values

checkpatch.pl report several error below:

ERROR: Macros with complex values should be enclosed in parentheses
+#define SCP2LUN(scp) (u32)(scp)->device->lun // to LUN

ERROR: Macros with complex values should be enclosed in parentheses
+#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp))

So fix those by enclosed by parentheses.

Signed-off-by: Jianqin Xie <[email protected]>
Signed-off-by: Luo Jiaxing <[email protected]>
---
drivers/scsi/megaraid/mbox_defs.h | 2 +-
drivers/scsi/megaraid/mega_common.h | 16 ++++++++--------
drivers/scsi/megaraid/megaraid_sas.h | 6 +++---
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/megaraid/mbox_defs.h b/drivers/scsi/megaraid/mbox_defs.h
index 5001624..3efbfdb 100644
--- a/drivers/scsi/megaraid/mbox_defs.h
+++ b/drivers/scsi/megaraid/mbox_defs.h
@@ -124,7 +124,7 @@
#define FC_MAX_PHYSICAL_DEVICES 256
#define MAX_MBOX_CHANNELS 5
#define MAX_MBOX_TARGET 15
-#define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
+#define MBOX_MAX_PHYSICAL_DRIVES (MAX_MBOX_CHANNELS * MAX_MBOX_TARGET)
#define MAX_ROW_SIZE_40LD 32
#define MAX_ROW_SIZE_8LD 8
#define SPAN_DEPTH_8_SPANS 8
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index 2ad0aa2..2a0981b 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -196,22 +196,22 @@ typedef struct {


// conversion from scsi command
-#define SCP2HOST(scp) (scp)->device->host // to host
-#define SCP2HOSTDATA(scp) SCP2HOST(scp)->hostdata // to soft state
-#define SCP2CHANNEL(scp) (scp)->device->channel // to channel
-#define SCP2TARGET(scp) (scp)->device->id // to target
-#define SCP2LUN(scp) (u32)(scp)->device->lun // to LUN
+#define SCP2HOST(scp) ((scp)->device->host) // to host
+#define SCP2HOSTDATA(scp) (SCP2HOST(scp)->hostdata) // to soft state
+#define SCP2CHANNEL(scp) ((scp)->device->channel) // to channel
+#define SCP2TARGET(scp) ((scp)->device->id) // to target
+#define SCP2LUN(scp) ((u32)(scp)->device->lun) // to LUN

// generic macro to convert scsi command and host to controller's soft state
#define SCSIHOST2ADAP(host) (((caddr_t *)(host->hostdata))[0])
-#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp))
+#define SCP2ADAPTER(scp) ((adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp)))


#define MRAID_IS_LOGICAL(adp, scp) \
- (SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
+ ((SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0)

#define MRAID_IS_LOGICAL_SDEV(adp, sdev) \
- (sdev->channel == (adp)->max_channel) ? 1 : 0
+ ((sdev->channel == (adp)->max_channel) ? 1 : 0)

/**
* MRAID_GET_DEVICE_MAP - device ids
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index b5a765b..b652a84 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -154,9 +154,9 @@
#define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
#define MFI_INIT_HOTPLUG 0x00000010
#define MFI_STOP_ADP 0x00000020
-#define MFI_RESET_FLAGS MFI_INIT_READY| \
- MFI_INIT_MFIMODE| \
- MFI_INIT_ABORT
+#define MFI_RESET_FLAGS (MFI_INIT_READY | \
+ MFI_INIT_MFIMODE | \
+ MFI_INIT_ABORT)
#define MFI_ADP_TRIGGER_SNAP_DUMP 0x00000100
#define MPI2_IOCINIT_MSGFLAG_RDPQ_ARRAY_MODE (0x01)

--
2.7.4