greybus: interface: add interface-type attribute

Add an interface-type string attribute that represents the detected
interface type as either "dummy", "unipro", "greybus", or "unknown".

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Johan Hovold 2016-07-19 15:24:46 +02:00 committed by Greg Kroah-Hartman
parent d29b67d44a
commit 1bb61840c4
3 changed files with 34 additions and 0 deletions

View File

@ -82,6 +82,14 @@ Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The ID of a Greybus interface.
What: /sys/bus/greybus/devices/N-M.I/interface_type
Date: June 2016
KernelVersion: 4.XX
Contact: Greg Kroah-Hartman <greg@kroah.com>
Description:
The type of a Greybus interface; "dummy", "unipro", "greybus",
or "unknown".
What: /sys/bus/greybus/devices/N-M.I/power_now
Date: March 2016
KernelVersion: 4.XX

View File

@ -491,6 +491,27 @@ static ssize_t power_now_show(struct device *dev,
}
static DEVICE_ATTR_RO(power_now);
static const char *gb_interface_type_string(struct gb_interface *intf)
{
static const char * const types[] = {
[GB_SVC_INTF_TYPE_UNKNOWN] = "unknown",
[GB_SVC_INTF_TYPE_DUMMY] = "dummy",
[GB_SVC_INTF_TYPE_UNIPRO] = "unipro",
[GB_SVC_INTF_TYPE_GREYBUS] = "greybus",
};
return types[intf->type];
}
static ssize_t interface_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_interface *intf = to_gb_interface(dev);
return sprintf(buf, "%s\n", gb_interface_type_string(intf));
}
static DEVICE_ATTR_RO(interface_type);
static struct attribute *interface_attrs[] = {
&dev_attr_ddbl1_manufacturer_id.attr,
&dev_attr_ddbl1_product_id.attr,
@ -501,6 +522,7 @@ static struct attribute *interface_attrs[] = {
&dev_attr_voltage_now.attr,
&dev_attr_current_now.attr,
&dev_attr_power_now.attr,
&dev_attr_interface_type.attr,
NULL,
};
ATTRIBUTE_GROUPS(interface);
@ -721,6 +743,8 @@ static int gb_interface_activate_operation(struct gb_interface *intf)
return ret;
}
intf->type = type;
switch (type) {
case GB_SVC_INTF_TYPE_DUMMY:
dev_info(&intf->dev, "dummy interface detected\n");
@ -734,6 +758,7 @@ static int gb_interface_activate_operation(struct gb_interface *intf)
break;
default:
dev_err(&intf->dev, "unknown interface type: %u\n", type);
intf->type = GB_SVC_INTF_TYPE_UNKNOWN;
return -ENODEV;
}

View File

@ -26,6 +26,7 @@ struct gb_interface {
u8 interface_id; /* Physical location within the Endo */
u8 device_id;
u8 features; /* Feature flags set in the manifest */
u8 type;
u32 ddbl1_manufacturer_id;
u32 ddbl1_product_id;