diff options
author | Johan Hovold <johan@hovoldconsulting.com> | 2016-07-20 16:40:20 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-07-20 10:16:54 -0700 |
commit | a212b7586712208804d3d51efa9fdf6e23b2480a (patch) | |
tree | 0b7e9a3c655c1ff196fac6ed14593d9c0c029b95 | |
parent | 6633d80afbeecd91d5d786d6fbb32cdb8bc0a567 (diff) | |
download | op-kernel-dev-a212b7586712208804d3d51efa9fdf6e23b2480a.zip op-kernel-dev-a212b7586712208804d3d51efa9fdf6e23b2480a.tar.gz |
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: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
-rw-r--r-- | drivers/staging/greybus/interface.c | 32 | ||||
-rw-r--r-- | drivers/staging/greybus/interface.h | 11 | ||||
-rw-r--r-- | drivers/staging/greybus/module.c | 2 |
3 files changed, 29 insertions, 16 deletions
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 22b7342..e21491b 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -494,10 +494,11 @@ 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", + [GB_INTERFACE_TYPE_INVALID] = "invalid", + [GB_INTERFACE_TYPE_UNKNOWN] = "unknown", + [GB_INTERFACE_TYPE_DUMMY] = "dummy", + [GB_INTERFACE_TYPE_UNIPRO] = "unipro", + [GB_INTERFACE_TYPE_GREYBUS] = "greybus", }; return types[intf->type]; @@ -545,8 +546,8 @@ static umode_t interface_unipro_is_visible(struct kobject *kobj, struct gb_interface *intf = to_gb_interface(dev); switch (intf->type) { - case GB_SVC_INTF_TYPE_UNIPRO: - case GB_SVC_INTF_TYPE_GREYBUS: + case GB_INTERFACE_TYPE_UNIPRO: + case GB_INTERFACE_TYPE_GREYBUS: return attr->mode; default: return 0; @@ -560,7 +561,7 @@ static umode_t interface_greybus_is_visible(struct kobject *kobj, struct gb_interface *intf = to_gb_interface(dev); switch (intf->type) { - case GB_SVC_INTF_TYPE_GREYBUS: + case GB_INTERFACE_TYPE_GREYBUS: return attr->mode; default: return 0; @@ -574,8 +575,8 @@ static umode_t interface_power_is_visible(struct kobject *kobj, struct gb_interface *intf = to_gb_interface(dev); switch (intf->type) { - case GB_SVC_INTF_TYPE_UNIPRO: - case GB_SVC_INTF_TYPE_GREYBUS: + case GB_INTERFACE_TYPE_UNIPRO: + case GB_INTERFACE_TYPE_GREYBUS: return attr->mode; default: return 0; @@ -825,21 +826,22 @@ static int gb_interface_activate_operation(struct gb_interface *intf) return ret; } - intf->type = type; - switch (type) { case GB_SVC_INTF_TYPE_DUMMY: + intf->type = GB_INTERFACE_TYPE_DUMMY; /* FIXME: handle as an error for now */ return -ENODEV; case GB_SVC_INTF_TYPE_UNIPRO: + intf->type = GB_INTERFACE_TYPE_UNIPRO; dev_err(&intf->dev, "interface type UniPro not supported\n"); /* FIXME: check if this is a Toshiba bridge before retrying? */ return -EAGAIN; case GB_SVC_INTF_TYPE_GREYBUS: + intf->type = GB_INTERFACE_TYPE_GREYBUS; break; default: 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; } @@ -1134,15 +1136,17 @@ int gb_interface_add(struct gb_interface *intf) gb_interface_type_string(intf)); 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", intf->vendor_id, intf->product_id); /* 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", intf->ddbl1_manufacturer_id, intf->ddbl1_product_id); break; + default: + break; } return 0; diff --git a/drivers/staging/greybus/interface.h b/drivers/staging/greybus/interface.h index 05a3909..bba1881 100644 --- a/drivers/staging/greybus/interface.h +++ b/drivers/staging/greybus/interface.h @@ -10,6 +10,14 @@ #ifndef __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_INIT_STATUS BIT(1) #define GB_INTERFACE_QUIRK_NO_ARA_IDS BIT(2) @@ -26,7 +34,8 @@ struct gb_interface { u8 interface_id; /* Physical location within the Endo */ u8 device_id; u8 features; /* Feature flags set in the manifest */ - u8 type; + + enum gb_interface_type type; u32 ddbl1_manufacturer_id; u32 ddbl1_product_id; diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 242be49..3ae5876 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -153,7 +153,7 @@ static void gb_module_register_interface(struct gb_interface *intf) break; } if (ret) { - if (intf->type != GB_SVC_INTF_TYPE_DUMMY) { + if (intf->type != GB_INTERFACE_TYPE_DUMMY) { dev_err(&module->dev, "failed to activate interface %u: %d\n", intf_id, ret); |