greybus: svc: clean up hotplug/unplug request handlers
authorJohan Hovold <johan@hovoldconsulting.com>
Wed, 2 Dec 2015 17:23:26 +0000 (18:23 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 3 Dec 2015 00:55:45 +0000 (16:55 -0800)
Clean up hotplug/unplug request handlers somewhat.

Also add a debug message to both handlers that includes the interface id.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/svc.c

index f9ca08b34cd0f1638a2635f44bc891ff20125128..2c2dd8e66d7d98ad50f01edb3b50abdc2a03d0cf 100644 (file)
@@ -480,22 +480,25 @@ free_svc_hotplug:
 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) {