}
static DEVICE_ATTR_RO(state);
-static ssize_t protocol_show(struct device *dev, struct device_attribute *attr,
- char *buf)
+static ssize_t
+protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct gb_connection *connection = to_gb_connection(dev);
- return sprintf(buf, "%d", connection->protocol);
+ return sprintf(buf, "%d", connection->protocol_id);
}
-static DEVICE_ATTR_RO(protocol);
+static DEVICE_ATTR_RO(protocol_id);
static struct attribute *connection_attrs[] = {
&dev_attr_state.attr,
- &dev_attr_protocol.attr,
+ &dev_attr_protocol_id.attr,
NULL,
};
* pointer otherwise.
*/
struct gb_connection *gb_connection_create(struct gb_interface *interface,
- u16 cport_id, enum greybus_protocol protocol)
+ u16 cport_id, u8 protocol_id)
{
struct gb_connection *connection;
struct greybus_host_device *hd;
connection->interface = interface;
connection->interface_cport_id = cport_id;
- connection->protocol = protocol;
+ connection->protocol_id = protocol_id;
connection->state = GB_CONNECTION_STATE_DISABLED;
connection->dev.parent = &interface->dev;
/* Need to enable the connection to initialize it */
connection->state = GB_CONNECTION_STATE_ENABLED;
- switch (connection->protocol) {
+ switch (connection->protocol_id) {
case GREYBUS_PROTOCOL_I2C:
connection->handler = &gb_i2c_connection_handler;
break;
case GREYBUS_PROTOCOL_LED:
case GREYBUS_PROTOCOL_VENDOR:
default:
- gb_connection_err(connection, "unimplemented protocol %u",
- (u32)connection->protocol);
+ gb_connection_err(connection, "unimplemented protocol %hhu",
+ connection->protocol_id);
ret = -ENXIO;
break;
}
struct rb_node hd_node;
struct list_head interface_links;
- enum greybus_protocol protocol;
+ u8 protocol_id;
+
enum gb_connection_state state;
struct list_head operations;
#define to_gb_connection(d) container_of(d, struct gb_connection, dev)
struct gb_connection *gb_connection_create(struct gb_interface *interface,
- u16 cport_id, enum greybus_protocol protocol);
+ u16 cport_id, u8 protocol_id);
void gb_connection_destroy(struct gb_connection *connection);
int gb_connection_init(struct gb_connection *connection);
/*
* A CPort descriptor indicates the id of the interface within the
* module it's associated with, along with the CPort id used to
- * address the CPort. The protocol defines the format of messages
+ * address the CPort. The protocol id defines the format of messages
* exchanged using the CPort.
*/
struct greybus_descriptor_cport {
__u8 interface;
__le16 id;
- __u8 protocol; /* enum greybus_protocol */
+ __u8 protocol_id; /* enum greybus_protocol */
};
/*
while (true) {
struct manifest_desc *descriptor;
struct greybus_descriptor_cport *desc_cport;
- enum greybus_protocol protocol;
+ u8 protocol_id;
u16 cport_id;
bool found;
break;
/* Found one. Set up its function structure */
- protocol = (enum greybus_protocol)desc_cport->protocol;
+ protocol_id = desc_cport->protocol_id;
cport_id = le16_to_cpu(desc_cport->id);
- if (!gb_connection_create(interface, cport_id, protocol))
+ if (!gb_connection_create(interface, cport_id, protocol_id))
return 0; /* Error */
count++;
static void gb_operation_request_handle(struct gb_operation *operation)
{
- u8 protocol = operation->connection->protocol;
+ u8 protocol_id = operation->connection->protocol_id;
/* Subtract one from array size to stay within u8 range */
- if (protocol <= (u8)(ARRAY_SIZE(gb_operation_recv_handlers) - 1)) {
+ if (protocol_id <= (u8)(ARRAY_SIZE(gb_operation_recv_handlers) - 1)) {
gb_operation_recv_handler handler;
- handler = gb_operation_recv_handlers[protocol];
+ handler = gb_operation_recv_handlers[protocol_id];
if (handler) {
handler(operation); /* Handle the request */
return;
}
}
- gb_connection_err(operation->connection, "unrecognized protocol %u\n",
- (unsigned int)protocol);
+ gb_connection_err(operation->connection,
+ "unrecognized protocol id %hhu\n", protocol_id);
operation->result = GB_OP_PROTOCOL_BAD;
gb_operation_complete(operation);
}