Skip to content

Commit cc72c44

Browse files
ChaitanayaKulkarniChristoph Hellwig
authored andcommitted
nvme: remove zeroout memset call for struct
Declare and initialize structure variables to zero values so that we can remove zeroout memset calls in the host/core.c. Signed-off-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent f66e280 commit cc72c44

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

drivers/nvme/host/core.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,7 @@ EXPORT_SYMBOL_GPL(__nvme_check_ready);
721721

722722
static int nvme_toggle_streams(struct nvme_ctrl *ctrl, bool enable)
723723
{
724-
struct nvme_command c;
725-
726-
memset(&c, 0, sizeof(c));
724+
struct nvme_command c = { };
727725

728726
c.directive.opcode = nvme_admin_directive_send;
729727
c.directive.nsid = cpu_to_le32(NVME_NSID_ALL);
@@ -748,9 +746,8 @@ static int nvme_enable_streams(struct nvme_ctrl *ctrl)
748746
static int nvme_get_stream_params(struct nvme_ctrl *ctrl,
749747
struct streams_directive_params *s, u32 nsid)
750748
{
751-
struct nvme_command c;
749+
struct nvme_command c = { };
752750

753-
memset(&c, 0, sizeof(c));
754751
memset(s, 0, sizeof(*s));
755752

756753
c.directive.opcode = nvme_admin_directive_recv;
@@ -1460,10 +1457,9 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
14601457
unsigned int dword11, void *buffer, size_t buflen, u32 *result)
14611458
{
14621459
union nvme_result res = { 0 };
1463-
struct nvme_command c;
1460+
struct nvme_command c = { };
14641461
int ret;
14651462

1466-
memset(&c, 0, sizeof(c));
14671463
c.features.opcode = op;
14681464
c.features.fid = cpu_to_le32(fid);
14691465
c.features.dword11 = cpu_to_le32(dword11);
@@ -1591,9 +1587,8 @@ int nvme_getgeo(struct block_device *bdev, struct hd_geometry *geo)
15911587
static void nvme_init_integrity(struct gendisk *disk, u16 ms, u8 pi_type,
15921588
u32 max_integrity_segments)
15931589
{
1594-
struct blk_integrity integrity;
1590+
struct blk_integrity integrity = { };
15951591

1596-
memset(&integrity, 0, sizeof(integrity));
15971592
switch (pi_type) {
15981593
case NVME_NS_DPS_PI_TYPE3:
15991594
integrity.profile = &t10_pi_type3_crc;
@@ -1964,13 +1959,12 @@ static int nvme_send_ns_pr_command(struct nvme_ns *ns, struct nvme_command *c,
19641959
static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
19651960
u64 key, u64 sa_key, u8 op)
19661961
{
1967-
struct nvme_command c;
1962+
struct nvme_command c = { };
19681963
u8 data[16] = { 0, };
19691964

19701965
put_unaligned_le64(key, &data[0]);
19711966
put_unaligned_le64(sa_key, &data[8]);
19721967

1973-
memset(&c, 0, sizeof(c));
19741968
c.common.opcode = op;
19751969
c.common.cdw10 = cpu_to_le32(cdw10);
19761970

@@ -2042,9 +2036,8 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
20422036
bool send)
20432037
{
20442038
struct nvme_ctrl *ctrl = data;
2045-
struct nvme_command cmd;
2039+
struct nvme_command cmd = { };
20462040

2047-
memset(&cmd, 0, sizeof(cmd));
20482041
if (send)
20492042
cmd.common.opcode = nvme_admin_security_send;
20502043
else

0 commit comments

Comments
 (0)