mirror of https://gitee.com/openkylin/linux.git
greybus: es2: implement shutdown callback
Implement the shutdown callback which is used to execute shutdown operations on offloaded connections. This adds a new shutdown ARPC. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
d2dee94b66
commit
77e52b3b0b
|
@ -81,6 +81,7 @@ struct arpc_response_message {
|
|||
#define ARPC_TYPE_CPORT_QUIESCE 0x02
|
||||
#define ARPC_TYPE_CPORT_CLEAR 0x03
|
||||
#define ARPC_TYPE_CPORT_FLUSH 0x04
|
||||
#define ARPC_TYPE_CPORT_SHUTDOWN 0x05
|
||||
|
||||
struct arpc_cport_reset_req {
|
||||
__le16 cport_id;
|
||||
|
@ -104,4 +105,10 @@ struct arpc_cport_flush_req {
|
|||
__le16 cport_id;
|
||||
} __packed;
|
||||
|
||||
struct arpc_cport_shutdown_req {
|
||||
__le16 cport_id;
|
||||
__le16 timeout;
|
||||
__u8 phase;
|
||||
} __packed;
|
||||
|
||||
#endif /* __ARPC_H */
|
||||
|
|
|
@ -783,6 +783,32 @@ static int es2_cport_flush(struct gb_host_device *hd, u16 cport_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int es2_cport_shutdown(struct gb_host_device *hd, u16 cport_id,
|
||||
u8 phase, unsigned int timeout)
|
||||
{
|
||||
struct es2_ap_dev *es2 = hd_to_es2(hd);
|
||||
struct device *dev = &es2->usb_dev->dev;
|
||||
struct arpc_cport_shutdown_req req;
|
||||
int result;
|
||||
int ret;
|
||||
|
||||
if (timeout > U16_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
req.cport_id = cpu_to_le16(cport_id);
|
||||
req.timeout = cpu_to_le16(timeout);
|
||||
req.phase = phase;
|
||||
ret = arpc_sync(es2, ARPC_TYPE_CPORT_SHUTDOWN, &req, sizeof(req),
|
||||
&result, ES2_ARPC_CPORT_TIMEOUT + timeout);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to send shutdown over cport %u: %d (%d)\n",
|
||||
cport_id, ret, result);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id,
|
||||
size_t peer_space, unsigned int timeout)
|
||||
{
|
||||
|
@ -1016,6 +1042,7 @@ static struct gb_hd_driver es2_driver = {
|
|||
.cport_disable = cport_disable,
|
||||
.cport_connected = es2_cport_connected,
|
||||
.cport_flush = es2_cport_flush,
|
||||
.cport_shutdown = es2_cport_shutdown,
|
||||
.cport_quiesce = es2_cport_quiesce,
|
||||
.cport_clear = es2_cport_clear,
|
||||
.latency_tag_enable = latency_tag_enable,
|
||||
|
|
Loading…
Reference in New Issue