case GB_SVC_PWRMON_GET_SAMPLE_NOSUPP:
return -ENOMSG;
default:
- return -EIO;
+ return -EREMOTEIO;
}
}
case GB_SVC_PWRMON_GET_SAMPLE_NOSUPP:
return -ENOMSG;
default:
- return -EIO;
+ return -EREMOTEIO;
}
}
if (result) {
dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n",
intf_id, attr, selector, result);
- return -EIO;
+ return -EREMOTEIO;
}
if (value)
if (result) {
dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n",
intf_id, attr, selector, value, result);
- return -EIO;
+ return -EREMOTEIO;
}
return 0;
}
EXPORT_SYMBOL_GPL(gb_svc_connection_create);
+void gb_svc_connection_quiescing(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
+ u8 intf2_id, u16 cport2_id)
+{
+ /* FIXME: implement */
+
+ dev_dbg(&svc->dev, "%s - (%u:%u %u:%u)\n", __func__,
+ intf1_id, cport1_id, intf2_id, cport2_id);
+}
+EXPORT_SYMBOL_GPL(gb_svc_connection_quiescing);
+
void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id,
u8 intf2_id, u16 cport2_id)
{
&pwrmon_debugfs_current_fops);
debugfs_create_file("power_now", S_IRUGO, dir, rail,
&pwrmon_debugfs_power_fops);
- };
+ }
kfree(rail_names);
return;
return NULL;
}
-static void gb_svc_intf_reenable(struct gb_svc *svc, struct gb_interface *intf)
-{
- int ret;
-
- mutex_lock(&intf->mutex);
-
- /* Mark as disconnected to prevent I/O during disable. */
- intf->disconnected = true;
- gb_interface_disable(intf);
- intf->disconnected = false;
-
- ret = gb_interface_enable(intf);
- if (ret) {
- dev_err(&svc->dev, "failed to enable interface %u: %d\n",
- intf->interface_id, ret);
-
- gb_interface_deactivate(intf);
- }
-
- mutex_unlock(&intf->mutex);
-}
-
static void gb_svc_process_hello_deferred(struct gb_operation *operation)
{
struct gb_connection *connection = operation->connection;
ret);
}
-static void gb_svc_process_intf_hotplug(struct gb_operation *operation)
-{
- struct gb_svc_intf_hotplug_request *request;
- struct gb_connection *connection = operation->connection;
- struct gb_svc *svc = gb_connection_get_data(connection);
- struct gb_host_device *hd = connection->hd;
- struct gb_module *module;
- u8 intf_id;
- int ret;
-
- /* The request message size has already been verified. */
- request = operation->request->payload;
- intf_id = request->intf_id;
-
- dev_dbg(&svc->dev, "%s - id = %u\n", __func__, intf_id);
-
- /* All modules are considered 1x2 for now */
- module = gb_svc_module_lookup(svc, intf_id);
- if (module) {
- dev_info(&svc->dev, "mode switch detected on interface %u\n",
- intf_id);
-
- return gb_svc_intf_reenable(svc, module->interfaces[0]);
- }
-
- module = gb_module_create(hd, intf_id, 1);
- if (!module) {
- dev_err(&svc->dev, "failed to create module\n");
- return;
- }
-
- ret = gb_module_add(module);
- if (ret) {
- gb_module_put(module);
- return;
- }
-
- list_add(&module->hd_node, &hd->modules);
-}
-
-static void gb_svc_process_intf_hot_unplug(struct gb_operation *operation)
-{
- struct gb_svc *svc = gb_connection_get_data(operation->connection);
- struct gb_svc_intf_hot_unplug_request *request;
- struct gb_module *module;
- u8 intf_id;
-
- /* The request message size has already been verified. */
- request = operation->request->payload;
- intf_id = request->intf_id;
-
- dev_dbg(&svc->dev, "%s - id = %u\n", __func__, intf_id);
-
- /* All modules are considered 1x2 for now */
- module = gb_svc_module_lookup(svc, intf_id);
- if (!module) {
- dev_warn(&svc->dev, "could not find hot-unplug interface %u\n",
- intf_id);
- return;
- }
-
- module->disconnected = true;
-
- gb_module_del(module);
- list_del(&module->hd_node);
- gb_module_put(module);
-}
-
static void gb_svc_process_module_inserted(struct gb_operation *operation)
{
struct gb_svc_module_inserted_request *request;
return;
}
- if (result_code) {
- dev_warn(&svc->dev,
- "mailbox event %u with UniPro error: 0x%04x\n",
- intf_id, result_code);
- goto err_disable_interface;
- }
-
- if (mailbox != GB_SVC_INTF_MAILBOX_GREYBUS) {
- dev_warn(&svc->dev,
- "mailbox event %u with unexected value: 0x%08x\n",
- intf_id, mailbox);
- goto err_disable_interface;
- }
-
- dev_info(&svc->dev, "mode switch detected on interface %u\n", intf_id);
-
- gb_svc_intf_reenable(svc, intf);
-
- return;
-
-err_disable_interface:
- mutex_lock(&intf->mutex);
- gb_interface_disable(intf);
- gb_interface_deactivate(intf);
- mutex_unlock(&intf->mutex);
+ gb_interface_mailbox_event(intf, result_code, mailbox);
}
static void gb_svc_process_deferred_request(struct work_struct *work)
case GB_SVC_TYPE_SVC_HELLO:
gb_svc_process_hello_deferred(operation);
break;
- case GB_SVC_TYPE_INTF_HOTPLUG:
- gb_svc_process_intf_hotplug(operation);
- break;
- case GB_SVC_TYPE_INTF_HOT_UNPLUG:
- gb_svc_process_intf_hot_unplug(operation);
- break;
case GB_SVC_TYPE_MODULE_INSERTED:
gb_svc_process_module_inserted(operation);
break;
return 0;
}
-/*
- * Bringing up a module can be time consuming, as that may require lots of
- * initialization on the module side. Over that, we may also need to download
- * the firmware first and flash that on the module.
- *
- * In order not to make other svc events wait for all this to finish,
- * handle most of module hotplug stuff outside of the hotplug callback, with
- * help of a workqueue.
- */
-static int gb_svc_intf_hotplug_recv(struct gb_operation *op)
-{
- struct gb_svc *svc = gb_connection_get_data(op->connection);
- struct gb_svc_intf_hotplug_request *request;
-
- if (op->request->payload_size < sizeof(*request)) {
- dev_warn(&svc->dev, "short hotplug request received (%zu < %zu)\n",
- op->request->payload_size, sizeof(*request));
- return -EINVAL;
- }
-
- request = op->request->payload;
-
- dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id);
-
- return gb_svc_queue_deferred_request(op);
-}
-
-static int gb_svc_intf_hot_unplug_recv(struct gb_operation *op)
-{
- struct gb_svc *svc = gb_connection_get_data(op->connection);
- struct gb_svc_intf_hot_unplug_request *request;
-
- if (op->request->payload_size < sizeof(*request)) {
- dev_warn(&svc->dev, "short hot unplug request received (%zu < %zu)\n",
- op->request->payload_size, sizeof(*request));
- return -EINVAL;
- }
-
- request = op->request->payload;
-
- dev_dbg(&svc->dev, "%s - id = %u\n", __func__, request->intf_id);
-
- return gb_svc_queue_deferred_request(op);
-}
-
static int gb_svc_intf_reset_recv(struct gb_operation *op)
{
struct gb_svc *svc = gb_connection_get_data(op->connection);
if (!ret)
svc->state = GB_SVC_STATE_SVC_HELLO;
return ret;
- case GB_SVC_TYPE_INTF_HOTPLUG:
- return gb_svc_intf_hotplug_recv(op);
- case GB_SVC_TYPE_INTF_HOT_UNPLUG:
- return gb_svc_intf_hot_unplug_recv(op);
case GB_SVC_TYPE_INTF_RESET:
return gb_svc_intf_reset_recv(op);
case GB_SVC_TYPE_KEY_EVENT: