Skip to content

Commit 353d689

Browse files
hreineckedwsuse
authored andcommitted
Use argument structure for nvme_capacity_mgmt()
Use an argument structure instead of passing all arguments one by one. This allows for a future expansion of the argument list without having to change the library ABI. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 7459192 commit 353d689

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

src/nvme/ioctl.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,21 +1381,21 @@ int nvme_directive_recv(struct nvme_directive_recv_args *args)
13811381
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
13821382
}
13831383

1384-
int nvme_capacity_mgmt(int fd, __u8 op, __u16 element_id,
1385-
__u32 dw11, __u32 dw12,
1386-
__u32 timeout, __u32 *result)
1384+
int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args)
13871385
{
1388-
__u32 dw10 = op | element_id << 16;
1386+
__u32 cdw10 = args->op | args->element_id << 16;
13891387

13901388
struct nvme_passthru_cmd cmd = {
13911389
.opcode = nvme_admin_capacity_mgmt,
1392-
.cdw10 = dw10,
1393-
.cdw11 = dw11,
1394-
.cdw12 = dw12,
1395-
.timeout_ms = timeout,
1390+
.cdw10 = cdw10,
1391+
.cdw11 = args->cdw11,
1392+
.cdw12 = args->cdw12,
1393+
.timeout_ms = args->timeout,
13961394
};
13971395

1398-
return nvme_submit_admin_passthru(fd, &cmd, result);
1396+
if (args->args_size < sizeof(*args))
1397+
return -EINVAL;
1398+
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
13991399
}
14001400

14011401
int nvme_lockdown(int fd, __u8 scp, __u8 prhbt, __u8 ifc, __u8 ofi,

src/nvme/ioctl.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3327,13 +3327,26 @@ static inline int nvme_directive_recv_stream_allocate(int fd, __u32 nsid,
33273327
* Endurance Group or NVM Set to be created
33283328
* @timeout: Timeout in ms
33293329
* @result: If successful, the CQE dword0 value
3330+
*/
3331+
struct nvme_capacity_mgmt_args {
3332+
int args_size;
3333+
int fd;
3334+
__u8 op;
3335+
__u16 element_id;
3336+
__u32 cdw11;
3337+
__u32 cdw12;
3338+
__u32 timeout;
3339+
__u32 *result;
3340+
};
3341+
3342+
/**
3343+
* nvme_capacity_mgmt() -
3344+
* @args: &struct nvme_capacity_mgmt_args argument structure
33303345
*
33313346
* Return: The nvme command status if a response was received (see
33323347
* &enum nvme_status_field) or -1 with errno set otherwise.
33333348
*/
3334-
int nvme_capacity_mgmt(int fd, __u8 op, __u16 element_id,
3335-
__u32 dw11, __u32 dw12,
3336-
__u32 timeout, __u32 *result);
3349+
int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args);
33373350

33383351
/**
33393352
* nvme_lockdown() - Issue lockdown command

0 commit comments

Comments
 (0)