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

greybus: interface: use an enum for interface type

Use an enum for the interface type instead of using the SVC protocol
values directly.
Suggested-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarSandeep Patil <sspatil@google.com>
Reviewed-by: default avatarPatrick Titiano <ptitiano@baylibre.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 6633d80a
...@@ -494,10 +494,11 @@ static DEVICE_ATTR_RO(power_now); ...@@ -494,10 +494,11 @@ static DEVICE_ATTR_RO(power_now);
static const char *gb_interface_type_string(struct gb_interface *intf) static const char *gb_interface_type_string(struct gb_interface *intf)
{ {
static const char * const types[] = { static const char * const types[] = {
[GB_SVC_INTF_TYPE_UNKNOWN] = "unknown", [GB_INTERFACE_TYPE_INVALID] = "invalid",
[GB_SVC_INTF_TYPE_DUMMY] = "dummy", [GB_INTERFACE_TYPE_UNKNOWN] = "unknown",
[GB_SVC_INTF_TYPE_UNIPRO] = "unipro", [GB_INTERFACE_TYPE_DUMMY] = "dummy",
[GB_SVC_INTF_TYPE_GREYBUS] = "greybus", [GB_INTERFACE_TYPE_UNIPRO] = "unipro",
[GB_INTERFACE_TYPE_GREYBUS] = "greybus",
}; };
return types[intf->type]; return types[intf->type];
...@@ -545,8 +546,8 @@ static umode_t interface_unipro_is_visible(struct kobject *kobj, ...@@ -545,8 +546,8 @@ static umode_t interface_unipro_is_visible(struct kobject *kobj,
struct gb_interface *intf = to_gb_interface(dev); struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) { switch (intf->type) {
case GB_SVC_INTF_TYPE_UNIPRO: case GB_INTERFACE_TYPE_UNIPRO:
case GB_SVC_INTF_TYPE_GREYBUS: case GB_INTERFACE_TYPE_GREYBUS:
return attr->mode; return attr->mode;
default: default:
return 0; return 0;
...@@ -560,7 +561,7 @@ static umode_t interface_greybus_is_visible(struct kobject *kobj, ...@@ -560,7 +561,7 @@ static umode_t interface_greybus_is_visible(struct kobject *kobj,
struct gb_interface *intf = to_gb_interface(dev); struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) { switch (intf->type) {
case GB_SVC_INTF_TYPE_GREYBUS: case GB_INTERFACE_TYPE_GREYBUS:
return attr->mode; return attr->mode;
default: default:
return 0; return 0;
...@@ -574,8 +575,8 @@ static umode_t interface_power_is_visible(struct kobject *kobj, ...@@ -574,8 +575,8 @@ static umode_t interface_power_is_visible(struct kobject *kobj,
struct gb_interface *intf = to_gb_interface(dev); struct gb_interface *intf = to_gb_interface(dev);
switch (intf->type) { switch (intf->type) {
case GB_SVC_INTF_TYPE_UNIPRO: case GB_INTERFACE_TYPE_UNIPRO:
case GB_SVC_INTF_TYPE_GREYBUS: case GB_INTERFACE_TYPE_GREYBUS:
return attr->mode; return attr->mode;
default: default:
return 0; return 0;
...@@ -825,21 +826,22 @@ static int gb_interface_activate_operation(struct gb_interface *intf) ...@@ -825,21 +826,22 @@ static int gb_interface_activate_operation(struct gb_interface *intf)
return ret; return ret;
} }
intf->type = type;
switch (type) { switch (type) {
case GB_SVC_INTF_TYPE_DUMMY: case GB_SVC_INTF_TYPE_DUMMY:
intf->type = GB_INTERFACE_TYPE_DUMMY;
/* FIXME: handle as an error for now */ /* FIXME: handle as an error for now */
return -ENODEV; return -ENODEV;
case GB_SVC_INTF_TYPE_UNIPRO: case GB_SVC_INTF_TYPE_UNIPRO:
intf->type = GB_INTERFACE_TYPE_UNIPRO;
dev_err(&intf->dev, "interface type UniPro not supported\n"); dev_err(&intf->dev, "interface type UniPro not supported\n");
/* FIXME: check if this is a Toshiba bridge before retrying? */ /* FIXME: check if this is a Toshiba bridge before retrying? */
return -EAGAIN; return -EAGAIN;
case GB_SVC_INTF_TYPE_GREYBUS: case GB_SVC_INTF_TYPE_GREYBUS:
intf->type = GB_INTERFACE_TYPE_GREYBUS;
break; break;
default: default:
dev_err(&intf->dev, "unknown interface type: %u\n", type); dev_err(&intf->dev, "unknown interface type: %u\n", type);
intf->type = GB_SVC_INTF_TYPE_UNKNOWN; intf->type = GB_INTERFACE_TYPE_UNKNOWN;
return -ENODEV; return -ENODEV;
} }
...@@ -1134,15 +1136,17 @@ int gb_interface_add(struct gb_interface *intf) ...@@ -1134,15 +1136,17 @@ int gb_interface_add(struct gb_interface *intf)
gb_interface_type_string(intf)); gb_interface_type_string(intf));
switch (intf->type) { switch (intf->type) {
case GB_SVC_INTF_TYPE_GREYBUS: case GB_INTERFACE_TYPE_GREYBUS:
dev_info(&intf->dev, "Ara VID=0x%08x, PID=0x%08x\n", dev_info(&intf->dev, "Ara VID=0x%08x, PID=0x%08x\n",
intf->vendor_id, intf->product_id); intf->vendor_id, intf->product_id);
/* fall-through */ /* fall-through */
case GB_SVC_INTF_TYPE_UNIPRO: case GB_INTERFACE_TYPE_UNIPRO:
dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n", dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n",
intf->ddbl1_manufacturer_id, intf->ddbl1_manufacturer_id,
intf->ddbl1_product_id); intf->ddbl1_product_id);
break; break;
default:
break;
} }
return 0; return 0;
......
...@@ -10,6 +10,14 @@ ...@@ -10,6 +10,14 @@
#ifndef __INTERFACE_H #ifndef __INTERFACE_H
#define __INTERFACE_H #define __INTERFACE_H
enum gb_interface_type {
GB_INTERFACE_TYPE_INVALID = 0,
GB_INTERFACE_TYPE_UNKNOWN,
GB_INTERFACE_TYPE_DUMMY,
GB_INTERFACE_TYPE_UNIPRO,
GB_INTERFACE_TYPE_GREYBUS,
};
#define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES BIT(0) #define GB_INTERFACE_QUIRK_NO_CPORT_FEATURES BIT(0)
#define GB_INTERFACE_QUIRK_NO_INIT_STATUS BIT(1) #define GB_INTERFACE_QUIRK_NO_INIT_STATUS BIT(1)
#define GB_INTERFACE_QUIRK_NO_ARA_IDS BIT(2) #define GB_INTERFACE_QUIRK_NO_ARA_IDS BIT(2)
...@@ -26,7 +34,8 @@ struct gb_interface { ...@@ -26,7 +34,8 @@ struct gb_interface {
u8 interface_id; /* Physical location within the Endo */ u8 interface_id; /* Physical location within the Endo */
u8 device_id; u8 device_id;
u8 features; /* Feature flags set in the manifest */ u8 features; /* Feature flags set in the manifest */
u8 type;
enum gb_interface_type type;
u32 ddbl1_manufacturer_id; u32 ddbl1_manufacturer_id;
u32 ddbl1_product_id; u32 ddbl1_product_id;
......
...@@ -153,7 +153,7 @@ static void gb_module_register_interface(struct gb_interface *intf) ...@@ -153,7 +153,7 @@ static void gb_module_register_interface(struct gb_interface *intf)
break; break;
} }
if (ret) { if (ret) {
if (intf->type != GB_SVC_INTF_TYPE_DUMMY) { if (intf->type != GB_INTERFACE_TYPE_DUMMY) {
dev_err(&module->dev, dev_err(&module->dev,
"failed to activate interface %u: %d\n", "failed to activate interface %u: %d\n",
intf_id, ret); intf_id, ret);
......
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