Commit d34a3643 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: svc: clean up hotplug/unplug request handlers

Clean up hotplug/unplug request handlers somewhat.

Also add a debug message to both handlers that includes the interface id.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent f1e941a6
......@@ -480,22 +480,25 @@ static void svc_process_hotplug(struct work_struct *work)
static int gb_svc_intf_hotplug_recv(struct gb_operation *op)
{
struct gb_svc *svc = op->connection->private;
struct gb_message *request = op->request;
struct gb_svc_intf_hotplug_request *request;
struct svc_hotplug *svc_hotplug;
if (request->payload_size < sizeof(svc_hotplug->data)) {
if (op->request->payload_size < sizeof(*request)) {
dev_warn(&svc->dev, "short hotplug request received (%zu < %zu)\n",
request->payload_size,
sizeof(svc_hotplug->data));
op->request->payload_size, sizeof(*request));
return -EINVAL;
}
request = op->request->payload;
dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id);
svc_hotplug = kmalloc(sizeof(*svc_hotplug), GFP_KERNEL);
if (!svc_hotplug)
return -ENOMEM;
svc_hotplug->connection = op->connection;
memcpy(&svc_hotplug->data, op->request->payload, sizeof(svc_hotplug->data));
memcpy(&svc_hotplug->data, request, sizeof(svc_hotplug->data));
INIT_WORK(&svc_hotplug->work, svc_process_hotplug);
queue_work(system_unbound_wq, &svc_hotplug->work);
......@@ -506,20 +509,21 @@ static int gb_svc_intf_hotplug_recv(struct gb_operation *op)
static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op)
{
struct gb_svc *svc = op->connection->private;
struct gb_message *request = op->request;
struct gb_svc_intf_hot_unplug_request *hot_unplug = request->payload;
struct gb_svc_intf_hot_unplug_request *request;
struct gb_host_device *hd = op->connection->hd;
struct gb_interface *intf;
u8 intf_id;
if (request->payload_size < sizeof(*hot_unplug)) {
if (op->request->payload_size < sizeof(*request)) {
dev_warn(&svc->dev, "short hot unplug request received (%zu < %zu)\n",
request->payload_size,
sizeof(*hot_unplug));
op->request->payload_size, sizeof(*request));
return -EINVAL;
}
intf_id = hot_unplug->intf_id;
request = op->request->payload;
intf_id = request->intf_id;
dev_dbg(&svc->dev, "%s - id = %u\n", __func__, intf_id);
intf = gb_interface_find(hd, intf_id);
if (!intf) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment