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

greybus: svc: move endo id and ap interface id to svc

Move endo_id and AP interface id to the svc device.

The endo abstraction is about to be removed, and these attributes are
arguable attributes of the svc anyway.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 88f7b96d
...@@ -268,7 +268,7 @@ gb_connection_svc_connection_create(struct gb_connection *connection) ...@@ -268,7 +268,7 @@ gb_connection_svc_connection_create(struct gb_connection *connection)
intf = connection->bundle->intf; intf = connection->bundle->intf;
ret = gb_svc_connection_create(hd->svc, ret = gb_svc_connection_create(hd->svc,
hd->endo->ap_intf_id, hd->svc->ap_intf_id,
connection->hd_cport_id, connection->hd_cport_id,
intf->interface_id, intf->interface_id,
connection->intf_cport_id, connection->intf_cport_id,
...@@ -289,7 +289,7 @@ gb_connection_svc_connection_destroy(struct gb_connection *connection) ...@@ -289,7 +289,7 @@ gb_connection_svc_connection_destroy(struct gb_connection *connection)
return; return;
gb_svc_connection_destroy(connection->hd->svc, gb_svc_connection_destroy(connection->hd->svc,
connection->hd->endo->ap_intf_id, connection->hd->svc->ap_intf_id,
connection->hd_cport_id, connection->hd_cport_id,
connection->bundle->intf->interface_id, connection->bundle->intf->interface_id,
connection->intf_cport_id); connection->intf_cport_id);
......
...@@ -75,36 +75,7 @@ static const struct attribute_group svc_group = { ...@@ -75,36 +75,7 @@ static const struct attribute_group svc_group = {
.name = "svc", .name = "svc",
}; };
static ssize_t id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_endo *endo = to_gb_endo(dev);
return sprintf(buf, "0x%04x\n", endo->id);
}
static DEVICE_ATTR_RO(id);
static ssize_t ap_intf_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_endo *endo = to_gb_endo(dev);
return sprintf(buf, "%u\n", endo->ap_intf_id);
}
static DEVICE_ATTR_RO(ap_intf_id);
static struct attribute *endo_attrs[] = {
&dev_attr_id.attr,
&dev_attr_ap_intf_id.attr,
NULL,
};
static const struct attribute_group endo_group = {
.attrs = endo_attrs,
};
static const struct attribute_group *endo_groups[] = { static const struct attribute_group *endo_groups[] = {
&endo_group,
&svc_group, &svc_group,
NULL, NULL,
}; };
...@@ -490,8 +461,6 @@ struct gb_endo *gb_endo_create(struct gb_host_device *hd, u16 endo_id, ...@@ -490,8 +461,6 @@ struct gb_endo *gb_endo_create(struct gb_host_device *hd, u16 endo_id,
retval = -EINVAL; retval = -EINVAL;
goto free_endo; goto free_endo;
} }
endo->id = endo_id;
endo->ap_intf_id = ap_intf_id;
/* Register Endo device */ /* Register Endo device */
retval = gb_endo_register(hd, endo); retval = gb_endo_register(hd, endo);
......
...@@ -24,6 +24,31 @@ struct svc_hotplug { ...@@ -24,6 +24,31 @@ struct svc_hotplug {
}; };
static ssize_t endo_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "0x%04x\n", svc->endo_id);
}
static DEVICE_ATTR_RO(endo_id);
static ssize_t ap_intf_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "%u\n", svc->ap_intf_id);
}
static DEVICE_ATTR_RO(ap_intf_id);
static struct attribute *svc_attrs[] = {
&dev_attr_endo_id.attr,
&dev_attr_ap_intf_id.attr,
NULL,
};
ATTRIBUTE_GROUPS(svc);
/* /*
* AP's SVC cport is required early to get messages from the SVC. This happens * AP's SVC cport is required early to get messages from the SVC. This happens
* even before the Endo is created and hence any modules or interfaces. * even before the Endo is created and hence any modules or interfaces.
...@@ -339,8 +364,6 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -339,8 +364,6 @@ static int gb_svc_hello(struct gb_operation *op)
struct gb_host_device *hd = connection->hd; struct gb_host_device *hd = connection->hd;
struct gb_svc_hello_request *hello_request; struct gb_svc_hello_request *hello_request;
struct gb_interface *intf; struct gb_interface *intf;
u16 endo_id;
u8 interface_id;
int ret; int ret;
/* /*
...@@ -355,8 +378,8 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -355,8 +378,8 @@ static int gb_svc_hello(struct gb_operation *op)
} }
hello_request = op->request->payload; hello_request = op->request->payload;
endo_id = le16_to_cpu(hello_request->endo_id); svc->endo_id = le16_to_cpu(hello_request->endo_id);
interface_id = hello_request->interface_id; svc->ap_intf_id = hello_request->interface_id;
ret = device_add(&svc->dev); ret = device_add(&svc->dev);
if (ret) { if (ret) {
...@@ -365,7 +388,7 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -365,7 +388,7 @@ static int gb_svc_hello(struct gb_operation *op)
} }
/* Setup Endo */ /* Setup Endo */
ret = greybus_endo_setup(hd, endo_id, interface_id); ret = greybus_endo_setup(hd, svc->endo_id, svc->ap_intf_id);
if (ret) if (ret)
return ret; return ret;
...@@ -373,7 +396,7 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -373,7 +396,7 @@ static int gb_svc_hello(struct gb_operation *op)
* Endo and its modules are ready now, fix AP's partially initialized * Endo and its modules are ready now, fix AP's partially initialized
* svc protocol and its connection. * svc protocol and its connection.
*/ */
intf = gb_ap_interface_create(hd, connection, interface_id); intf = gb_ap_interface_create(hd, connection, svc->ap_intf_id);
if (!intf) { if (!intf) {
gb_endo_remove(hd->endo); gb_endo_remove(hd->endo);
return ret; return ret;
...@@ -385,7 +408,6 @@ static int gb_svc_hello(struct gb_operation *op) ...@@ -385,7 +408,6 @@ static int gb_svc_hello(struct gb_operation *op)
static void svc_intf_remove(struct gb_connection *connection, static void svc_intf_remove(struct gb_connection *connection,
struct gb_interface *intf) struct gb_interface *intf)
{ {
struct gb_host_device *hd = connection->hd;
struct gb_svc *svc = connection->private; struct gb_svc *svc = connection->private;
u8 intf_id = intf->interface_id; u8 intf_id = intf->interface_id;
u8 device_id; u8 device_id;
...@@ -396,7 +418,7 @@ static void svc_intf_remove(struct gb_connection *connection, ...@@ -396,7 +418,7 @@ static void svc_intf_remove(struct gb_connection *connection,
/* /*
* Destroy the two-way route between the AP and the interface. * Destroy the two-way route between the AP and the interface.
*/ */
gb_svc_route_destroy(svc, hd->endo->ap_intf_id, intf_id); gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id);
ida_simple_remove(&svc->device_id_map, device_id); ida_simple_remove(&svc->device_id_map, device_id);
} }
...@@ -486,7 +508,7 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -486,7 +508,7 @@ static void svc_process_hotplug(struct work_struct *work)
/* /*
* Create a two-way route between the AP and the new interface * Create a two-way route between the AP and the new interface
*/ */
ret = gb_svc_route_create(svc, hd->endo->ap_intf_id, GB_DEVICE_ID_AP, ret = gb_svc_route_create(svc, svc->ap_intf_id, GB_DEVICE_ID_AP,
intf_id, device_id); intf_id, device_id);
if (ret) { if (ret) {
pr_err("%d: Route create operation failed, interface %hhu device_id %hhu (%d)\n", pr_err("%d: Route create operation failed, interface %hhu device_id %hhu (%d)\n",
...@@ -504,7 +526,7 @@ static void svc_process_hotplug(struct work_struct *work) ...@@ -504,7 +526,7 @@ static void svc_process_hotplug(struct work_struct *work)
goto free_svc_hotplug; goto free_svc_hotplug;
destroy_route: destroy_route:
gb_svc_route_destroy(svc, hd->endo->ap_intf_id, intf_id); gb_svc_route_destroy(svc, svc->ap_intf_id, intf_id);
svc_id_free: svc_id_free:
/* /*
* XXX Should we tell SVC that this id doesn't belong to interface * XXX Should we tell SVC that this id doesn't belong to interface
...@@ -688,6 +710,7 @@ static int gb_svc_connection_init(struct gb_connection *connection) ...@@ -688,6 +710,7 @@ static int gb_svc_connection_init(struct gb_connection *connection)
svc->dev.parent = &hd->dev; svc->dev.parent = &hd->dev;
svc->dev.bus = &greybus_bus_type; svc->dev.bus = &greybus_bus_type;
svc->dev.type = &greybus_svc_type; svc->dev.type = &greybus_svc_type;
svc->dev.groups = svc_groups;
svc->dev.dma_mask = svc->dev.parent->dma_mask; svc->dev.dma_mask = svc->dev.parent->dma_mask;
device_initialize(&svc->dev); device_initialize(&svc->dev);
......
...@@ -22,6 +22,9 @@ struct gb_svc { ...@@ -22,6 +22,9 @@ struct gb_svc {
struct gb_connection *connection; struct gb_connection *connection;
enum gb_svc_state state; enum gb_svc_state state;
struct ida device_id_map; struct ida device_id_map;
u16 endo_id;
u8 ap_intf_id;
}; };
#define to_gb_svc(d) container_of(d, struct gb_svc, d) #define to_gb_svc(d) container_of(d, struct gb_svc, d)
......
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