Commit d38c9a80 authored by Himanshu Jha's avatar Himanshu Jha Committed by Martin K. Petersen

scsi: be2iscsi: Use kasprintf

Use kasprintf instead of combination of kmalloc and sprintf.  Also,
remove BEISCSI_MSI_NAME macro used to specify size of string as
kasprintf handles size computations.
Signed-off-by: default avatarHimanshu Jha <himanshujha199640@gmail.com>
Reviewed-by: default avatarKyle Fortin <kyle.fortin@oracle.com>
Reviewed-by: default avatarJitendra Bhivare <jitendra.bhivare@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent c58cc70f
...@@ -818,15 +818,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) ...@@ -818,15 +818,14 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
if (pcidev->msix_enabled) { if (pcidev->msix_enabled) {
for (i = 0; i < phba->num_cpus; i++) { for (i = 0; i < phba->num_cpus; i++) {
phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, phba->msi_name[i] = kasprintf(GFP_KERNEL,
GFP_KERNEL); "beiscsi_%02x_%02x",
phba->shost->host_no, i);
if (!phba->msi_name[i]) { if (!phba->msi_name[i]) {
ret = -ENOMEM; ret = -ENOMEM;
goto free_msix_irqs; goto free_msix_irqs;
} }
sprintf(phba->msi_name[i], "beiscsi_%02x_%02x",
phba->shost->host_no, i);
ret = request_irq(pci_irq_vector(pcidev, i), ret = request_irq(pci_irq_vector(pcidev, i),
be_isr_msix, 0, phba->msi_name[i], be_isr_msix, 0, phba->msi_name[i],
&phwi_context->be_eq[i]); &phwi_context->be_eq[i]);
...@@ -839,13 +838,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba) ...@@ -839,13 +838,12 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
goto free_msix_irqs; goto free_msix_irqs;
} }
} }
phba->msi_name[i] = kzalloc(BEISCSI_MSI_NAME, GFP_KERNEL); phba->msi_name[i] = kasprintf(GFP_KERNEL, "beiscsi_mcc_%02x",
phba->shost->host_no);
if (!phba->msi_name[i]) { if (!phba->msi_name[i]) {
ret = -ENOMEM; ret = -ENOMEM;
goto free_msix_irqs; goto free_msix_irqs;
} }
sprintf(phba->msi_name[i], "beiscsi_mcc_%02x",
phba->shost->host_no);
ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0, ret = request_irq(pci_irq_vector(pcidev, i), be_isr_mcc, 0,
phba->msi_name[i], &phwi_context->be_eq[i]); phba->msi_name[i], &phwi_context->be_eq[i]);
if (ret) { if (ret) {
......
...@@ -153,8 +153,6 @@ ...@@ -153,8 +153,6 @@
#define PAGES_REQUIRED(x) \ #define PAGES_REQUIRED(x) \
((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE)) ((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE))
#define BEISCSI_MSI_NAME 20 /* size of msi_name string */
#define MEM_DESCR_OFFSET 8 #define MEM_DESCR_OFFSET 8
#define BEISCSI_DEFQ_HDR 1 #define BEISCSI_DEFQ_HDR 1
#define BEISCSI_DEFQ_DATA 0 #define BEISCSI_DEFQ_DATA 0
......
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