return 0;
}
-static int gb_svc_intf_hotplug_recv(struct gb_operation *op)
+/*
+ * 'struct svc_hotplug' should be freed by svc_process_hotplug() before it
+ * returns, irrespective of success or Failure in bringing up the module.
+ */
+static void svc_process_hotplug(struct work_struct *work)
{
- struct gb_message *request = op->request;
- struct gb_svc_intf_hotplug_request *hotplug = request->payload;
- struct gb_svc *svc = op->connection->private;
- struct greybus_host_device *hd = op->connection->bundle->intf->hd;
- struct device *dev = &op->connection->dev;
+ struct svc_hotplug *svc_hotplug = container_of(work, struct svc_hotplug,
+ work);
+ struct gb_svc_intf_hotplug_request *hotplug = &svc_hotplug->data;
+ struct gb_connection *connection = svc_hotplug->connection;
+ struct gb_svc *svc = connection->private;
+ struct greybus_host_device *hd = connection->bundle->intf->hd;
+ struct device *dev = &connection->dev;
struct gb_interface *intf;
u8 intf_id, device_id;
- u32 unipro_mfg_id;
- u32 unipro_prod_id;
- u32 ara_vend_id;
- u32 ara_prod_id;
int ret;
- if (request->payload_size < sizeof(*hotplug)) {
- dev_err(dev, "%s: short hotplug request received\n", __func__);
- return -EINVAL;
- }
-
/*
* Grab the information we need.
- *
- * XXX I'd really like to acknowledge receipt, and then
- * XXX continue processing the request. There's no need
- * XXX for the SVC to wait. In fact, it might be best to
- * XXX have the SVC get acknowledgement before we proceed.
*/
intf_id = hotplug->intf_id;
- unipro_mfg_id = le32_to_cpu(hotplug->data.unipro_mfg_id);
- unipro_prod_id = le32_to_cpu(hotplug->data.unipro_prod_id);
- ara_vend_id = le32_to_cpu(hotplug->data.ara_vend_id);
- ara_prod_id = le32_to_cpu(hotplug->data.ara_prod_id);
intf = gb_interface_create(hd, intf_id);
if (!intf) {
dev_err(dev, "%s: Failed to create interface with id %hhu\n",
__func__, intf_id);
- return -EINVAL;
+ goto free_svc_hotplug;
}
+ intf->unipro_mfg_id = le32_to_cpu(hotplug->data.unipro_mfg_id);
+ intf->unipro_prod_id = le32_to_cpu(hotplug->data.unipro_prod_id);
+ intf->ara_vend_id = le32_to_cpu(hotplug->data.ara_vend_id);
+ intf->ara_prod_id = le32_to_cpu(hotplug->data.ara_prod_id);
+
/*
* Create a device id for the interface:
* - device id 0 (GB_DEVICE_ID_SVC) belongs to the SVC