scsi: arcmsr: simplify all arcmsr_hbaX_get_config routine by call a new get_adapter_config function
PATCH 4/4 scsi: arcmsr: simplify all arcmsr_hbaX_get_config routine by call a new get_adapter_config function
From: Ching Huang <[email protected]>
simplify all arcmsr_hbaX_get_config routine by call a new get_adapter_config function
---
drivers/scsi/arcmsr/arcmsr_hba.c +48 -195
@@ -2956,75 +2956,66 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,static DEF_SCSI_QCMD (arcmsr_queue_command) -static bool arcmsr_hbaA_get_config(struct AdapterControlBlock *acb) +static void arcmsr_get_adapter_config(struct AdapterControlBlock *pACB, uint32_t *rwbuffer) { -struct MessageUnit_A __iomem *reg = acb->pmuA; -char *acb_firm_model = acb->firm_model; -char *acb_firm_version = acb->firm_version; -char *acb_device_map = acb->device_map; -char __iomem *iop_firm_model = (char __iomem *)(®->message_rwbuffer[15 ]); -char __iomem *iop_firm_version = (char __iomem *)(®->message_rwbuffer[17 ]); -char __iomem *iop_device_map = (char __iomem *)(®->message_rwbuffer[21 ]);int count; -arcmsr_wait_firmware_ready (acb); -writel (ARCMSR_INBOUND_MESG0_GET_CONFIG , ®->inbound_msgaddr0); -if (!arcmsr_hbaA_wait_msgint_ready (acb)) { -printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ -miscellaneous data' timeout \n" , acb->host->host_no); -return false; - } - count =8 ; -while (count){ - *acb_firm_model =readb (iop_firm_model); +uint32_t *acb_firm_model = (uint32_t *)pACB->firm_model; +uint32_t *acb_firm_version = (uint32_t *)pACB->firm_version; +uint32_t *acb_device_map = (uint32_t *)pACB->device_map; +uint32_t *firm_model = &rwbuffer[15 ]; +uint32_t *firm_version = &rwbuffer[17 ]; +uint32_t *device_map = &rwbuffer[21 ]; + + count =2 ; +while (count) { + *acb_firm_model =readl (firm_model); acb_firm_model++; - iop_firm_model++; + firm_model++; count--; } - - count =16 ; -while (count){ - *acb_firm_version =readb (iop_firm_version); + count =4 ; +while (count) { + *acb_firm_version =readl (firm_version); acb_firm_version++; - iop_firm_version++; + firm_version++; count--; } - - count=16 ; -while (count){ - *acb_device_map =readb (iop_device_map); + count =4 ; +while (count) { + *acb_device_map =readl (device_map); acb_device_map++; - iop_device_map++; + device_map++; count--; } + pACB->signature =readl (&rwbuffer[0 ]); + pACB->firm_request_len =readl (&rwbuffer[1 ]); + pACB->firm_numbers_queue =readl (&rwbuffer[2 ]); + pACB->firm_sdram_size =readl (&rwbuffer[3 ]); + pACB->firm_hd_channels =readl (&rwbuffer[4 ]); + pACB->firm_cfg_version =readl (&rwbuffer[25 ]);pr_notice ("Areca RAID Controller%d: Model %s, F/W %s\n" , - acb->host->host_no, - acb->firm_model, - acb->firm_version); - acb->signature =readl (®->message_rwbuffer[0 ]); - acb->firm_request_len =readl (®->message_rwbuffer[1 ]); - acb->firm_numbers_queue =readl (®->message_rwbuffer[2 ]); - acb->firm_sdram_size =readl (®->message_rwbuffer[3 ]); - acb->firm_hd_channels =readl (®->message_rwbuffer[4 ]); - acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ + pACB->host->host_no, + pACB->firm_model, + pACB->firm_version); +} + +static bool arcmsr_hbaA_get_config (struct AdapterControlBlock *acb) +{ +struct MessageUnit_A __iomem *reg = acb->pmuA; + +arcmsr_wait_firmware_ready (acb); +writel (ARCMSR_INBOUND_MESG0_GET_CONFIG , ®->inbound_msgaddr0); +if (!arcmsr_hbaA_wait_msgint_ready (acb)) { +printk (KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \ +miscellaneous data' timeout \n" , acb->host->host_no); +return false; + } +arcmsr_get_adapter_config (acb, reg->message_rwbuffer);return true; }static bool arcmsr_hbaB_get_config (struct AdapterControlBlock *acb) {struct MessageUnit_B *reg = acb->pmuB; -char *acb_firm_model = acb->firm_model; -char *acb_firm_version = acb->firm_version; -char *acb_device_map = acb->device_map; -char __iomem *iop_firm_model; -/*firm_model,15,60-67*/ -char __iomem *iop_firm_version; -/*firm_version,17,68-83*/ -char __iomem *iop_device_map; -/*firm_version,21,84-99*/ -int count; - - iop_firm_model = (char __iomem *)(®->message_rwbuffer[15 ]);/*firm_model,15,60-67*/ - iop_firm_version = (char __iomem *)(®->message_rwbuffer[17 ]);/*firm_version,17,68-83*/ - iop_device_map = (char __iomem *)(®->message_rwbuffer[21 ]);/*firm_version,21,84-99*/ arcmsr_wait_firmware_ready (acb);writel (ARCMSR_MESSAGE_START_DRIVER_MODE , reg->drv2iop_doorbell);
@@ -3038,46 +3029,7 @@ static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb) miscellaneous data' timeout \n", acb->host->host_no);return false; } - count =8 ; -while (count){ - *acb_firm_model =readb (iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count =16 ; -while (count){ - *acb_firm_version =readb (iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - - count =16 ; -while (count){ - *acb_device_map =readb (iop_device_map); - acb_device_map++; - iop_device_map++; - count--; - } - -pr_notice ("Areca RAID Controller%d: Model %s, F/W %s\n" , - acb->host->host_no, - acb->firm_model, - acb->firm_version); - - acb->signature =readl (®->message_rwbuffer[0 ]); -/*firm_signature,1,00-03*/ - acb->firm_request_len =readl (®->message_rwbuffer[1 ]); -/*firm_request_len,1,04-07*/ - acb->firm_numbers_queue =readl (®->message_rwbuffer[2 ]); -/*firm_numbers_queue,2,08-11*/ - acb->firm_sdram_size =readl (®->message_rwbuffer[3 ]); -/*firm_sdram_size,3,12-15*/ - acb->firm_hd_channels =readl (®->message_rwbuffer[4 ]); -/*firm_ide_channels,4,16-19*/ - acb->firm_cfg_version =readl (®->message_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ -/*firm_ide_channels,4,16-19*/ +arcmsr_get_adapter_config (acb, reg->message_rwbuffer);return true; }
@@ -3085,11 +3037,7 @@ static bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB) {uint32_t intmask_org;struct MessageUnit_C __iomem *reg = pACB->pmuC; -char *acb_firm_model = pACB->firm_model; -char *acb_firm_version = pACB->firm_version; -char __iomem *iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15 ]);/*firm_model,15,60-67*/ -char __iomem *iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17 ]);/*firm_version,17,68-83*/ -int count; +/* disable all outbound interrupt */ intmask_org =readl (®->host_int_mask);/* disable outbound message0 int */ writel (intmask_org|ARCMSR_HBCMU_ALL_INTMASKENABLE , ®->host_int_mask);
@@ -3104,47 +3052,14 @@ static bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB) miscellaneous data' timeout \n", pACB->host->host_no);return false; } - count =8 ; -while (count) { - *acb_firm_model =readb (iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count =16 ; -while (count) { - *acb_firm_version =readb (iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } -pr_notice ("Areca RAID Controller%d: Model %s, F/W %s\n" , - pACB->host->host_no, - pACB->firm_model, - pACB->firm_version); - pACB->firm_request_len =readl (®->msgcode_rwbuffer[1 ]);/*firm_request_len,1,04-07*/ - pACB->firm_numbers_queue =readl (®->msgcode_rwbuffer[2 ]);/*firm_numbers_queue,2,08-11*/ - pACB->firm_sdram_size =readl (®->msgcode_rwbuffer[3 ]);/*firm_sdram_size,3,12-15*/ - pACB->firm_hd_channels =readl (®->msgcode_rwbuffer[4 ]);/*firm_ide_channels,4,16-19*/ - pACB->firm_cfg_version =readl (®->msgcode_rwbuffer[25 ]);/*firm_cfg_version,25,100-103*/ -/*all interrupt service will be enable at arcmsr_iop_init*/ +arcmsr_get_adapter_config (pACB, reg->msgcode_rwbuffer);return true; }static bool arcmsr_hbaD_get_config (struct AdapterControlBlock *acb) { -char *acb_firm_model = acb->firm_model; -char *acb_firm_version = acb->firm_version; -char *acb_device_map = acb->device_map; -char __iomem *iop_firm_model; -char __iomem *iop_firm_version; -char __iomem *iop_device_map; -u32 count;struct MessageUnit_D *reg = acb->pmuD; - iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15 ]); - iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17 ]); - iop_device_map = (char __iomem *)(®->msgcode_rwbuffer[21 ]);if (readl (acb->pmuD->outbound_doorbell) &ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE ) { writel(ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE,
@@ -3159,54 +3074,14 @@ static bool arcmsr_hbaD_get_config(struct AdapterControlBlock *acb) "miscellaneous data timeout\n", acb->host->host_no);return false; } - count =8 ; -while (count) { - *acb_firm_model =readb (iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count =16 ; -while (count) { - *acb_firm_version =readb (iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - count =16 ; -while (count) { - *acb_device_map =readb (iop_device_map); - acb_device_map++; - iop_device_map++; - count--; - } - acb->signature =readl (®->msgcode_rwbuffer[0 ]); -/*firm_signature,1,00-03*/ - acb->firm_request_len =readl (®->msgcode_rwbuffer[1 ]); -/*firm_request_len,1,04-07*/ - acb->firm_numbers_queue =readl (®->msgcode_rwbuffer[2 ]); -/*firm_numbers_queue,2,08-11*/ - acb->firm_sdram_size =readl (®->msgcode_rwbuffer[3 ]); -/*firm_sdram_size,3,12-15*/ - acb->firm_hd_channels =readl (®->msgcode_rwbuffer[4 ]); -/*firm_hd_channels,4,16-19*/ - acb->firm_cfg_version =readl (®->msgcode_rwbuffer[25 ]); -pr_notice ("Areca RAID Controller%d: Model %s, F/W %s\n" , - acb->host->host_no, - acb->firm_model, - acb->firm_version); +arcmsr_get_adapter_config (acb, reg->msgcode_rwbuffer);return true; }static bool arcmsr_hbaE_get_config (struct AdapterControlBlock *pACB) { -char *acb_firm_model = pACB->firm_model; -char *acb_firm_version = pACB->firm_version;struct MessageUnit_E __iomem *reg = pACB->pmuE; -char __iomem *iop_firm_model = (char __iomem *)(®->msgcode_rwbuffer[15 ]); -char __iomem *iop_firm_version = (char __iomem *)(®->msgcode_rwbuffer[17 ]);uint32_t intmask_org; -int count;/* disable all outbound interrupt */ intmask_org =readl (®->host_int_mask);/* disable outbound message0 int */
@@ -3225,29 +3100,7 @@ static bool arcmsr_hbaE_get_config(struct AdapterControlBlock *pACB) "miscellaneous data timeout\n", pACB->host->host_no);return false; } - count =8 ; -while (count) { - *acb_firm_model =readb (iop_firm_model); - acb_firm_model++; - iop_firm_model++; - count--; - } - count =16 ; -while (count) { - *acb_firm_version =readb (iop_firm_version); - acb_firm_version++; - iop_firm_version++; - count--; - } - pACB->firm_request_len =readl (®->msgcode_rwbuffer[1 ]); - pACB->firm_numbers_queue =readl (®->msgcode_rwbuffer[2 ]); - pACB->firm_sdram_size =readl (®->msgcode_rwbuffer[3 ]); - pACB->firm_hd_channels =readl (®->msgcode_rwbuffer[4 ]); - pACB->firm_cfg_version =readl (®->msgcode_rwbuffer[25 ]); -pr_notice ("Areca RAID Controller%d: Model %s, F/W %s\n" , - pACB->host->host_no, - pACB->firm_model, - pACB->firm_version); +arcmsr_get_adapter_config (pACB, reg->msgcode_rwbuffer);return true; }
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Ching,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on scsi/for-next]
[also build test WARNING on next-20171213]
[cannot apply to v4.15-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ching-Huang/scsi-arcmsr-simplify-hba_get_config-routine/20171213-224803 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
vim +2971 drivers/scsi/arcmsr/arcmsr_hba.c
2958
2959 static void arcmsr_get_adapter_config(struct AdapterControlBlock *pACB, uint32_t *rwbuffer)
2960 {
2961 int count;
2962 uint32_t *acb_firm_model = (uint32_t *)pACB->firm_model;
2963 uint32_t *acb_firm_version = (uint32_t *)pACB->firm_version;
2964 uint32_t *acb_device_map = (uint32_t *)pACB->device_map;
2965 uint32_t *firm_model = &rwbuffer[15];
2966 uint32_t *firm_version = &rwbuffer[17];
2967 uint32_t *device_map = &rwbuffer[21];
2968
2969 count = 2;
2970 while (count) {
> 2971 *acb_firm_model = readl(firm_model);
2972 acb_firm_model++;
2973 firm_model++;
2974 count--;
2975 }
2976 count = 4;
2977 while (count) {
2978 *acb_firm_version = readl(firm_version);
2979 acb_firm_version++;
2980 firm_version++;
2981 count--;
2982 }
2983 count = 4;
2984 while (count) {
2985 *acb_device_map = readl(device_map);
2986 acb_device_map++;
2987 device_map++;
2988 count--;
2989 }
2990 pACB->signature = readl(&rwbuffer[0]);
2991 pACB->firm_request_len = readl(&rwbuffer[1]);
2992 pACB->firm_numbers_queue = readl(&rwbuffer[2]);
> 2993 pACB->firm_sdram_size = readl(&rwbuffer[3]);
> 2994 pACB->firm_hd_channels = readl(&rwbuffer[4]);
2995 pACB->firm_cfg_version = readl(&rwbuffer[25]);
2996 pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n",
2997 pACB->host->host_no,
2998 pACB->firm_model,
2999 pACB->firm_version);
3000 }
3001
3002 static bool arcmsr_hbaA_get_config(struct AdapterControlBlock *acb)
3003 {
3004 struct MessageUnit_A __iomem *reg = acb->pmuA;
3005
3006 arcmsr_wait_firmware_ready(acb);
3007 writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0);
3008 if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
3009 printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
3010 miscellaneous data' timeout \n", acb->host->host_no);
3011 return false;
3012 }
> 3013 arcmsr_get_adapter_config(acb, reg->message_rwbuffer);
3014 return true;
3015 }
3016 static bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb)
3017 {
3018 struct MessageUnit_B *reg = acb->pmuB;
3019
3020 arcmsr_wait_firmware_ready(acb);
3021 writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell);
3022 if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
3023 printk(KERN_ERR "arcmsr%d: can't set driver mode.\n", acb->host->host_no);
3024 return false;
3025 }
3026 writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell);
3027 if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
3028 printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
3029 miscellaneous data' timeout \n", acb->host->host_no);
3030 return false;
3031 }
> 3032 arcmsr_get_adapter_config(acb, reg->message_rwbuffer); 3033 return true;
3034 }
3035
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 8 lines · kbuild test robot
Hi Ching,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on scsi/for-next]
[also build test WARNING on next-20171213]
[cannot apply to v4.15-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
As what I have said in [PATCH 0/4], this serial patches are apply to Martin's 4.16/scsi-queue only. Now scsi/for-next and next-20171213 are synchronized to Martin's 4.16/scsi-queue, so these patches can apply to them. But v4.15-rc3 has to do some patches like 4.16/scsi-queue done before, or this patch can not apply.
Quoted 96 lines
url: https://github.com/0day-ci/linux/commits/Ching-Huang/scsi-arcmsr-simplify-hba_get_config-routine/20171213-224803 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__sparse warnings: (new ones prefixed by >>)
vim +2971
drivers/scsi/arcmsr/arcmsr_hba.c2958
2959 static voidarcmsr_get_adapter_config(struct AdapterControlBlock *pACB, uint32_t *rwbuffer)
2960 {
2961 int count;
2962uint32_t*acb_firm_model= (uint32_t*)pACB->firm_model;
2963uint32_t*acb_firm_version= (uint32_t*)pACB->firm_version;
2964uint32_t*acb_device_map= (uint32_t*)pACB->device_map;
2965uint32_t*firm_model= &rwbuffer[15];
2966uint32_t*firm_version= &rwbuffer[17];
2967uint32_t*device_map= &rwbuffer[21];
2968
2969 count = 2;
2970 while (count) {Quoted 1 line
2971
*acb_firm_model=readl(firm_model);2972 acb_firm_model++;
2973 firm_model++;
2974 count--;
2975 }
2976 count = 4;
2977 while (count) {
2978*acb_firm_version=readl(firm_version);
2979 acb_firm_version++;
2980 firm_version++;
2981 count--;
2982 }
2983 count = 4;
2984 while (count) {
2985*acb_device_map=readl(device_map);
2986 acb_device_map++;
2987 device_map++;
2988 count--;
2989 }
2990pACB->signature=readl(&rwbuffer[0]);
2991pACB->firm_request_len=readl(&rwbuffer[1]);
2992pACB->firm_numbers_queue=readl(&rwbuffer[2]);Quoted 2 lines
2993
pACB->firm_sdram_size=readl(&rwbuffer[3]);
2994pACB->firm_hd_channels=readl(&rwbuffer[4]);2995
pACB->firm_cfg_version=readl(&rwbuffer[25]);
2996 pr_notice("Areca RAID Controller%d: Model %s, F/W %s\n",
2997pACB->host->host_no,
2998pACB->firm_model,
2999pACB->firm_version);
3000 }
3001
3002 static boolarcmsr_hbaA_get_config(struct AdapterControlBlock *acb)
3003 {
3004 structMessageUnit_A__iomem*reg =acb->pmuA;
3005
3006arcmsr_wait_firmware_ready(acb);
3007writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, ®->inbound_msgaddr0);
3008 if (!arcmsr_hbaA_wait_msgint_ready(acb)) {
3009 printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
3010 miscellaneous data' timeout \n",acb->host->host_no);
3011 return false;
3012 }Quoted 1 line
3013
arcmsr_get_adapter_config(acb, reg->message_rwbuffer);3014 return true;
3015 }
3016 static boolarcmsr_hbaB_get_config(struct AdapterControlBlock *acb)
3017 {
3018 structMessageUnit_B*reg =acb->pmuB;
3019
3020arcmsr_wait_firmware_ready(acb);
3021writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell);
3022 if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
3023printk(KERN_ERR "arcmsr%d: can't set driver mode.\n", acb->host->host_no);
3024 return false;
3025 }
3026writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell);
3027 if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
3028 printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
3029 miscellaneous data' timeout \n",acb->host->host_no);
3030 return false;
3031 }Quoted 1 line
3032
arcmsr_get_adapter_config(acb, reg->message_rwbuffer);3033 return true;
3034 }
3035---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation