Skip to content

Commit e465328

Browse files
hreineckedwsuse
authored andcommitted
Use argument structure for nvme_fw_commit()
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 aef4b82 commit e465328

2 files changed

Lines changed: 27 additions & 12 deletions

File tree

src/nvme/ioctl.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,19 +1225,21 @@ int nvme_fw_download(struct nvme_fw_download_args *args)
12251225
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
12261226
}
12271227

1228-
int nvme_fw_commit(int fd, __u8 slot, enum nvme_fw_commit_ca action, bool bpid,
1229-
__u32 *result)
1228+
int nvme_fw_commit(struct nvme_fw_commit_args *args)
12301229
{
1231-
__u32 cdw10 = NVME_SET(slot, FW_COMMIT_CDW10_FS) |
1232-
NVME_SET(action, FW_COMMIT_CDW10_CA) |
1233-
NVME_SET(bpid, FW_COMMIT_CDW10_BPID);
1230+
__u32 cdw10 = NVME_SET(args->slot, FW_COMMIT_CDW10_FS) |
1231+
NVME_SET(args->action, FW_COMMIT_CDW10_CA) |
1232+
NVME_SET(args->bpid, FW_COMMIT_CDW10_BPID);
12341233

12351234
struct nvme_passthru_cmd cmd = {
12361235
.opcode = nvme_admin_fw_commit,
12371236
.cdw10 = cdw10,
1237+
.timeout_ms = args->timeout,
12381238
};
12391239

1240-
return nvme_submit_admin_passthru(fd, &cmd, result);
1240+
if (args->args_size < sizeof(*args))
1241+
return -EINVAL;
1242+
return nvme_submit_admin_passthru(args->fd, &cmd, args->result);
12411243
}
12421244

12431245
int nvme_security_send(int fd, __u32 nsid, __u8 nssf, __u8 spsp0, __u8 spsp1,

src/nvme/ioctl.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,23 +2901,36 @@ struct nvme_fw_download_args {
29012901
int nvme_fw_download(struct nvme_fw_download_args *args);
29022902

29032903
/**
2904-
* nvme_fw_commit() - Commit firmware using the specified action
2904+
* nvme_fw_commit_args - Arguments for the NVMe Firmware Commit command
29052905
* @fd: File descriptor of nvme device
29062906
* @slot: Firmware slot to commit the downloaded image
29072907
* @action: Action to use for the firmware image, see &enum nvme_fw_commit_ca
29082908
* @bpid: Set to true to select the boot partition id
2909+
* @timeout: Timeout in ms
29092910
* @result: The command completion result from CQE dword0
2911+
*/
2912+
struct nvme_fw_commit_args {
2913+
int args_size;
2914+
int fd;
2915+
__u8 slot;
2916+
enum nvme_fw_commit_ca action;
2917+
bool bpid;
2918+
__u32 timeout;
2919+
__u32 *result;
2920+
};
2921+
2922+
/**
2923+
* nvme_fw_commit() - Commit firmware using the specified action
2924+
* @args: &struct nvme_fw_commit_args argument structure
29102925
*
29112926
* The Firmware Commit command modifies the firmware image or Boot Partitions.
29122927
*
29132928
* Return: The nvme command status if a response was received (see
29142929
* &enum nvme_status_field) or -1 with errno set otherwise. The command
2915-
* status
2916-
* response may specify additional
2917-
* reset actions required to complete the commit process.
2930+
* status response may specify additional reset actions required to complete
2931+
* the commit process.
29182932
*/
2919-
int nvme_fw_commit(int fd, __u8 slot, enum nvme_fw_commit_ca action, bool bpid,
2920-
__u32 *result);
2933+
int nvme_fw_commit(struct nvme_fw_commit_args *args);
29212934

29222935
/**
29232936
* nvme_security_send() -

0 commit comments

Comments
 (0)