aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorTushar Behera <tushar.behera@linaro.org>2013-06-10 00:50:55 -0400
committerMatthew Wilcox <matthew.r.wilcox@intel.com>2013-06-19 13:24:27 -0400
commit03ea83e9a37e41d436f8348e6eee3d8281bfff3a (patch)
treeaa8592c9e857efb09f2ad8f24a0107939ff9d730 /drivers/block
parenta2648ebb7ed69ef209d9c8a76fadeb3252d9a023 (diff)
NVMe: Use kzalloc instead of kmalloc+memset
Use kzalloc instead of kmalloc and a susbsequent memset. Signed-off-by: Tushar Behera <tushar.behera@linaro.org> Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com> Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nvme-scsi.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/block/nvme-scsi.c b/drivers/block/nvme-scsi.c
index 102de2f52b5c..4a4ff4eb8e23 100644
--- a/drivers/block/nvme-scsi.c
+++ b/drivers/block/nvme-scsi.c
@@ -933,13 +933,12 @@ static int nvme_trans_bdev_char_page(struct nvme_ns *ns, struct sg_io_hdr *hdr,
933 int res = SNTI_TRANSLATION_SUCCESS; 933 int res = SNTI_TRANSLATION_SUCCESS;
934 int xfer_len; 934 int xfer_len;
935 935
936 inq_response = kmalloc(EXTENDED_INQUIRY_DATA_PAGE_LENGTH, GFP_KERNEL); 936 inq_response = kzalloc(EXTENDED_INQUIRY_DATA_PAGE_LENGTH, GFP_KERNEL);
937 if (inq_response == NULL) { 937 if (inq_response == NULL) {
938 res = -ENOMEM; 938 res = -ENOMEM;
939 goto out_mem; 939 goto out_mem;
940 } 940 }
941 941
942 memset(inq_response, 0, EXTENDED_INQUIRY_DATA_PAGE_LENGTH);
943 inq_response[1] = INQ_BDEV_CHARACTERISTICS_PAGE; /* Page Code */ 942 inq_response[1] = INQ_BDEV_CHARACTERISTICS_PAGE; /* Page Code */
944 inq_response[2] = 0x00; /* Page Length MSB */ 943 inq_response[2] = 0x00; /* Page Length MSB */
945 inq_response[3] = 0x3C; /* Page Length LSB */ 944 inq_response[3] = 0x3C; /* Page Length LSB */
@@ -964,12 +963,11 @@ static int nvme_trans_log_supp_pages(struct nvme_ns *ns, struct sg_io_hdr *hdr,
964 int xfer_len; 963 int xfer_len;
965 u8 *log_response; 964 u8 *log_response;
966 965
967 log_response = kmalloc(LOG_PAGE_SUPPORTED_LOG_PAGES_LENGTH, GFP_KERNEL); 966 log_response = kzalloc(LOG_PAGE_SUPPORTED_LOG_PAGES_LENGTH, GFP_KERNEL);
968 if (log_response == NULL) { 967 if (log_response == NULL) {
969 res = -ENOMEM; 968 res = -ENOMEM;
970 goto out_mem; 969 goto out_mem;
971 } 970 }
972 memset(log_response, 0, LOG_PAGE_SUPPORTED_LOG_PAGES_LENGTH);
973 971
974 log_response[0] = LOG_PAGE_SUPPORTED_LOG_PAGES_PAGE; 972 log_response[0] = LOG_PAGE_SUPPORTED_LOG_PAGES_PAGE;
975 /* Subpage=0x00, Page Length MSB=0 */ 973 /* Subpage=0x00, Page Length MSB=0 */
@@ -1000,12 +998,11 @@ static int nvme_trans_log_info_exceptions(struct nvme_ns *ns,
1000 u8 temp_c; 998 u8 temp_c;
1001 u16 temp_k; 999 u16 temp_k;
1002 1000
1003 log_response = kmalloc(LOG_INFO_EXCP_PAGE_LENGTH, GFP_KERNEL); 1001 log_response = kzalloc(LOG_INFO_EXCP_PAGE_LENGTH, GFP_KERNEL);
1004 if (log_response == NULL) { 1002 if (log_response == NULL) {
1005 res = -ENOMEM; 1003 res = -ENOMEM;
1006 goto out_mem; 1004 goto out_mem;
1007 } 1005 }
1008 memset(log_response, 0, LOG_INFO_EXCP_PAGE_LENGTH);
1009 1006
1010 mem = dma_alloc_coherent(&dev->pci_dev->dev, 1007 mem = dma_alloc_coherent(&dev->pci_dev->dev,
1011 sizeof(struct nvme_smart_log), 1008 sizeof(struct nvme_smart_log),
@@ -1069,12 +1066,11 @@ static int nvme_trans_log_temperature(struct nvme_ns *ns, struct sg_io_hdr *hdr,
1069 u8 temp_c_cur, temp_c_thresh; 1066 u8 temp_c_cur, temp_c_thresh;
1070 u16 temp_k; 1067 u16 temp_k;
1071 1068
1072 log_response = kmalloc(LOG_TEMP_PAGE_LENGTH, GFP_KERNEL); 1069 log_response = kzalloc(LOG_TEMP_PAGE_LENGTH, GFP_KERNEL);
1073 if (log_response == NULL) { 1070 if (log_response == NULL) {
1074 res = -ENOMEM; 1071 res = -ENOMEM;
1075 goto out_mem; 1072 goto out_mem;
1076 } 1073 }
1077 memset(log_response, 0, LOG_TEMP_PAGE_LENGTH);
1078 1074
1079 mem = dma_alloc_coherent(&dev->pci_dev->dev, 1075 mem = dma_alloc_coherent(&dev->pci_dev->dev,
1080 sizeof(struct nvme_smart_log), 1076 sizeof(struct nvme_smart_log),
@@ -1380,12 +1376,11 @@ static int nvme_trans_mode_page_create(struct nvme_ns *ns,
1380 blk_desc_offset = mph_size; 1376 blk_desc_offset = mph_size;
1381 mode_pages_offset_1 = blk_desc_offset + blk_desc_len; 1377 mode_pages_offset_1 = blk_desc_offset + blk_desc_len;
1382 1378
1383 response = kmalloc(resp_size, GFP_KERNEL); 1379 response = kzalloc(resp_size, GFP_KERNEL);
1384 if (response == NULL) { 1380 if (response == NULL) {
1385 res = -ENOMEM; 1381 res = -ENOMEM;
1386 goto out_mem; 1382 goto out_mem;
1387 } 1383 }
1388 memset(response, 0, resp_size);
1389 1384
1390 res = nvme_trans_fill_mode_parm_hdr(&response[0], mph_size, cdb10, 1385 res = nvme_trans_fill_mode_parm_hdr(&response[0], mph_size, cdb10,
1391 llbaa, mode_data_length, blk_desc_len); 1386 llbaa, mode_data_length, blk_desc_len);
@@ -2480,12 +2475,11 @@ static int nvme_trans_read_capacity(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2480 } 2475 }
2481 id_ns = mem; 2476 id_ns = mem;
2482 2477
2483 response = kmalloc(resp_size, GFP_KERNEL); 2478 response = kzalloc(resp_size, GFP_KERNEL);
2484 if (response == NULL) { 2479 if (response == NULL) {
2485 res = -ENOMEM; 2480 res = -ENOMEM;
2486 goto out_dma; 2481 goto out_dma;
2487 } 2482 }
2488 memset(response, 0, resp_size);
2489 nvme_trans_fill_read_cap(response, id_ns, cdb16); 2483 nvme_trans_fill_read_cap(response, id_ns, cdb16);
2490 2484
2491 xfer_len = min(alloc_len, resp_size); 2485 xfer_len = min(alloc_len, resp_size);
@@ -2554,12 +2548,11 @@ static int nvme_trans_report_luns(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2554 goto out_dma; 2548 goto out_dma;
2555 } 2549 }
2556 2550
2557 response = kmalloc(resp_size, GFP_KERNEL); 2551 response = kzalloc(resp_size, GFP_KERNEL);
2558 if (response == NULL) { 2552 if (response == NULL) {
2559 res = -ENOMEM; 2553 res = -ENOMEM;
2560 goto out_dma; 2554 goto out_dma;
2561 } 2555 }
2562 memset(response, 0, resp_size);
2563 2556
2564 /* The first LUN ID will always be 0 per the SAM spec */ 2557 /* The first LUN ID will always be 0 per the SAM spec */
2565 for (lun_id = 0; lun_id < le32_to_cpu(id_ctrl->nn); lun_id++) { 2558 for (lun_id = 0; lun_id < le32_to_cpu(id_ctrl->nn); lun_id++) {
@@ -2600,12 +2593,11 @@ static int nvme_trans_request_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr,
2600 2593
2601 resp_size = ((desc_format) ? (DESC_FMT_SENSE_DATA_SIZE) : 2594 resp_size = ((desc_format) ? (DESC_FMT_SENSE_DATA_SIZE) :
2602 (FIXED_FMT_SENSE_DATA_SIZE)); 2595 (FIXED_FMT_SENSE_DATA_SIZE));
2603 response = kmalloc(resp_size, GFP_KERNEL); 2596 response = kzalloc(resp_size, GFP_KERNEL);
2604 if (response == NULL) { 2597 if (response == NULL) {
2605 res = -ENOMEM; 2598 res = -ENOMEM;
2606 goto out; 2599 goto out;
2607 } 2600 }
2608 memset(response, 0, resp_size);
2609 2601
2610 if (desc_format == DESCRIPTOR_FORMAT_SENSE_DATA_TYPE) { 2602 if (desc_format == DESCRIPTOR_FORMAT_SENSE_DATA_TYPE) {
2611 /* Descriptor Format Sense Data */ 2603 /* Descriptor Format Sense Data */