mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 05:55:06 +07:00
greybus: introduce gb_operation_errno_map()
Define gb_operation_errno_map(), which maps an operation->errno into the u8 value that represents it in the status field of an operation response header. It'll be used in an upcoming patch. Make gb_operation_status_map() a private function. It's not used outside "operation.c" and I don't believe it ever should be. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
d4a1ff674d
commit
0c90fff4e3
@ -411,7 +411,7 @@ static void gb_operation_message_free(struct gb_message *message)
|
||||
* Map an enum gb_operation_status value (which is represented in a
|
||||
* message as a single byte) to an appropriate Linux negative errno.
|
||||
*/
|
||||
int gb_operation_status_map(u8 status)
|
||||
static int gb_operation_status_map(u8 status)
|
||||
{
|
||||
switch (status) {
|
||||
case GB_OP_SUCCESS:
|
||||
@ -438,6 +438,39 @@ int gb_operation_status_map(u8 status)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Map a Linux errno value (from operation->errno) into the value
|
||||
* that should represent it in a response message status sent
|
||||
* over the wire. Returns an enum gb_operation_status value (which
|
||||
* is represented in a message as a single byte).
|
||||
*/
|
||||
static u8 gb_operation_errno_map(int errno)
|
||||
{
|
||||
switch (errno) {
|
||||
case 0:
|
||||
return GB_OP_SUCCESS;
|
||||
case -EINTR:
|
||||
return GB_OP_INTERRUPTED;
|
||||
case -ETIMEDOUT:
|
||||
return GB_OP_TIMEOUT;
|
||||
case -ENOMEM:
|
||||
return GB_OP_NO_MEMORY;
|
||||
case -EPROTONOSUPPORT:
|
||||
return GB_OP_PROTOCOL_BAD;
|
||||
case -EMSGSIZE:
|
||||
return GB_OP_OVERFLOW; /* Could be underflow too */
|
||||
case -EINVAL:
|
||||
return GB_OP_INVALID;
|
||||
case -EAGAIN:
|
||||
return GB_OP_RETRY;
|
||||
case -EILSEQ:
|
||||
return GB_OP_MALFUNCTION;
|
||||
case -EIO:
|
||||
default:
|
||||
return GB_OP_UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a Greybus operation to be sent over the given connection.
|
||||
* The request buffer will be big enough for a payload of the given
|
||||
@ -656,6 +689,7 @@ int gb_operation_response_send(struct gb_operation *operation, int errno)
|
||||
pr_err("request result already set\n");
|
||||
return -EIO; /* Shouldn't happen */
|
||||
}
|
||||
(void)gb_operation_errno_map; /* avoid a build warning */
|
||||
gb_operation_destroy(operation);
|
||||
|
||||
return 0;
|
||||
|
@ -104,8 +104,6 @@ int gb_operation_response_send(struct gb_operation *operation, int errno);
|
||||
|
||||
void gb_operation_cancel(struct gb_operation *operation, int errno);
|
||||
|
||||
int gb_operation_status_map(u8 status);
|
||||
|
||||
void greybus_data_sent(struct greybus_host_device *hd,
|
||||
void *header, int status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user