Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 1 | /* |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 2 | * Greybus interface code |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2014 Google Inc. |
Alex Elder | a46e967 | 2014-12-12 12:08:42 -0600 | [diff] [blame] | 5 | * Copyright 2014 Linaro Ltd. |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 6 | * |
| 7 | * Released under the GPLv2 only. |
| 8 | */ |
| 9 | |
| 10 | #include "greybus.h" |
| 11 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 12 | /* interface sysfs attributes */ |
| 13 | #define gb_interface_attr(field, type) \ |
| 14 | static ssize_t field##_show(struct device *dev, \ |
| 15 | struct device_attribute *attr, \ |
| 16 | char *buf) \ |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 17 | { \ |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 18 | struct gb_interface *intf = to_gb_interface(dev); \ |
Viresh Kumar | 2c7df74 | 2015-12-18 15:04:27 +0530 | [diff] [blame] | 19 | return scnprintf(buf, PAGE_SIZE, type"\n", intf->field); \ |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 20 | } \ |
| 21 | static DEVICE_ATTR_RO(field) |
| 22 | |
Viresh Kumar | 0e9403a0 | 2015-12-22 22:04:34 +0530 | [diff] [blame] | 23 | gb_interface_attr(ddbl1_manufacturer_id, "0x%08x"); |
| 24 | gb_interface_attr(ddbl1_product_id, "0x%08x"); |
Viresh Kumar | 2c7df74 | 2015-12-18 15:04:27 +0530 | [diff] [blame] | 25 | gb_interface_attr(interface_id, "%u"); |
Viresh Kumar | 2c7df74 | 2015-12-18 15:04:27 +0530 | [diff] [blame] | 26 | gb_interface_attr(vendor_string, "%s"); |
| 27 | gb_interface_attr(product_string, "%s"); |
Viresh Kumar | 57c6bcc | 2015-12-28 11:59:00 +0530 | [diff] [blame] | 28 | gb_interface_attr(serial_number, "0x%016llx"); |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 29 | |
Michael Scott | d5a2656 | 2016-02-08 17:08:46 -0800 | [diff] [blame] | 30 | static ssize_t vendor_id_show(struct device *dev, |
| 31 | struct device_attribute *attr, |
| 32 | char *buf) |
| 33 | { |
| 34 | struct gb_interface *intf = to_gb_interface(dev); |
| 35 | |
| 36 | /* clear the upper 16-bits to keep userspace "simple" */ |
| 37 | return scnprintf(buf, PAGE_SIZE, "0x%04x\n", |
| 38 | (0x0000FFFF & intf->vendor_id)); |
| 39 | } |
| 40 | static DEVICE_ATTR_RO(vendor_id); |
| 41 | |
| 42 | static ssize_t product_id_show(struct device *dev, struct device_attribute *attr, |
| 43 | char *buf) |
| 44 | { |
| 45 | struct gb_interface *intf = to_gb_interface(dev); |
| 46 | |
| 47 | /* clear the upper 16-bits to keep userspace "simple" */ |
| 48 | return scnprintf(buf, PAGE_SIZE, "0x%04x\n", |
| 49 | (0x0000FFFF & intf->product_id)); |
| 50 | } |
| 51 | static DEVICE_ATTR_RO(product_id); |
| 52 | |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 53 | static ssize_t version_show(struct device *dev, struct device_attribute *attr, |
| 54 | char *buf) |
| 55 | { |
| 56 | struct gb_interface *intf = to_gb_interface(dev); |
| 57 | |
| 58 | return scnprintf(buf, PAGE_SIZE, "%u.%u\n", intf->version_major, |
| 59 | intf->version_minor); |
| 60 | } |
| 61 | static DEVICE_ATTR_RO(version); |
| 62 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 63 | static struct attribute *interface_attrs[] = { |
Viresh Kumar | 0e9403a0 | 2015-12-22 22:04:34 +0530 | [diff] [blame] | 64 | &dev_attr_ddbl1_manufacturer_id.attr, |
| 65 | &dev_attr_ddbl1_product_id.attr, |
Johan Hovold | 320421a | 2015-11-25 15:58:58 +0100 | [diff] [blame] | 66 | &dev_attr_interface_id.attr, |
Johan Hovold | 9f59263 | 2015-11-25 15:58:56 +0100 | [diff] [blame] | 67 | &dev_attr_vendor_id.attr, |
| 68 | &dev_attr_product_id.attr, |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 69 | &dev_attr_vendor_string.attr, |
| 70 | &dev_attr_product_string.attr, |
Viresh Kumar | 57c6bcc | 2015-12-28 11:59:00 +0530 | [diff] [blame] | 71 | &dev_attr_serial_number.attr, |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 72 | &dev_attr_version.attr, |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 73 | NULL, |
| 74 | }; |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 75 | ATTRIBUTE_GROUPS(interface); |
Greg Kroah-Hartman | ab88eb5 | 2014-12-11 17:10:59 -0500 | [diff] [blame] | 76 | |
| 77 | |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 78 | /* XXX This could be per-host device */ |
Greg Kroah-Hartman | 4901175 | 2014-12-19 14:56:37 -0800 | [diff] [blame] | 79 | static DEFINE_SPINLOCK(gb_interfaces_lock); |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 80 | |
Greg Kroah-Hartman | df67155 | 2014-12-21 14:10:26 -0800 | [diff] [blame] | 81 | // FIXME, odds are you don't want to call this function, rework the caller to |
| 82 | // not need it please. |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 83 | struct gb_interface *gb_interface_find(struct gb_host_device *hd, |
Viresh Kumar | c9d9d0d | 2015-04-01 20:31:58 +0530 | [diff] [blame] | 84 | u8 interface_id) |
Viresh Kumar | 9ca4d62 | 2014-11-14 17:25:06 +0530 | [diff] [blame] | 85 | { |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 86 | struct gb_interface *intf; |
Viresh Kumar | 9ca4d62 | 2014-11-14 17:25:06 +0530 | [diff] [blame] | 87 | |
Greg Kroah-Hartman | 1cd56a8 | 2014-12-19 14:56:36 -0800 | [diff] [blame] | 88 | list_for_each_entry(intf, &hd->interfaces, links) |
Viresh Kumar | c9d9d0d | 2015-04-01 20:31:58 +0530 | [diff] [blame] | 89 | if (intf->interface_id == interface_id) |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 90 | return intf; |
Viresh Kumar | 9ca4d62 | 2014-11-14 17:25:06 +0530 | [diff] [blame] | 91 | |
| 92 | return NULL; |
| 93 | } |
| 94 | |
Viresh Kumar | 51b5d8d | 2015-05-20 17:33:51 +0530 | [diff] [blame] | 95 | static void gb_interface_release(struct device *dev) |
Alex Elder | 697e55d | 2014-10-20 23:01:04 -0500 | [diff] [blame] | 96 | { |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 97 | struct gb_interface *intf = to_gb_interface(dev); |
Alex Elder | 697e55d | 2014-10-20 23:01:04 -0500 | [diff] [blame] | 98 | |
Johan Hovold | eeb6a6f | 2015-11-11 10:07:05 +0100 | [diff] [blame] | 99 | kfree(intf->product_string); |
| 100 | kfree(intf->vendor_string); |
| 101 | |
Johan Hovold | c634650 | 2015-12-15 15:28:56 +0100 | [diff] [blame] | 102 | if (intf->control) |
| 103 | gb_control_destroy(intf->control); |
| 104 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 105 | kfree(intf); |
Alex Elder | 697e55d | 2014-10-20 23:01:04 -0500 | [diff] [blame] | 106 | } |
| 107 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 108 | struct device_type greybus_interface_type = { |
| 109 | .name = "greybus_interface", |
Viresh Kumar | 51b5d8d | 2015-05-20 17:33:51 +0530 | [diff] [blame] | 110 | .release = gb_interface_release, |
Greg Kroah-Hartman | f0f61b9 | 2014-10-24 17:34:46 +0800 | [diff] [blame] | 111 | }; |
| 112 | |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 113 | /* |
Bryan O'Donoghue | 464dc8c | 2015-08-17 00:57:16 +0100 | [diff] [blame] | 114 | * A Greybus module represents a user-replaceable component on an Ara |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 115 | * phone. An interface is the physical connection on that module. A |
| 116 | * module may have more than one interface. |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 117 | * |
Viresh Kumar | c9d9d0d | 2015-04-01 20:31:58 +0530 | [diff] [blame] | 118 | * Create a gb_interface structure to represent a discovered interface. |
| 119 | * The position of interface within the Endo is encoded in "interface_id" |
| 120 | * argument. |
| 121 | * |
Greg Kroah-Hartman | df67155 | 2014-12-21 14:10:26 -0800 | [diff] [blame] | 122 | * Returns a pointer to the new interfce or a null pointer if a |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 123 | * failure occurs due to memory exhaustion. |
| 124 | */ |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 125 | struct gb_interface *gb_interface_create(struct gb_host_device *hd, |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 126 | u8 interface_id) |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 127 | { |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 128 | struct gb_interface *intf; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 129 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 130 | intf = kzalloc(sizeof(*intf), GFP_KERNEL); |
| 131 | if (!intf) |
Johan Hovold | 8b0df4b | 2015-11-25 15:59:04 +0100 | [diff] [blame] | 132 | return NULL; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 133 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 134 | intf->hd = hd; /* XXX refcount? */ |
Viresh Kumar | c9d9d0d | 2015-04-01 20:31:58 +0530 | [diff] [blame] | 135 | intf->interface_id = interface_id; |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 136 | INIT_LIST_HEAD(&intf->bundles); |
Greg Kroah-Hartman | 86cad66 | 2014-12-23 15:16:50 -0800 | [diff] [blame] | 137 | INIT_LIST_HEAD(&intf->manifest_descs); |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 138 | |
Viresh Kumar | c3add78 | 2015-07-01 12:13:58 +0530 | [diff] [blame] | 139 | /* Invalid device id to start with */ |
| 140 | intf->device_id = GB_DEVICE_ID_BAD; |
| 141 | |
Johan Hovold | 8b0df4b | 2015-11-25 15:59:04 +0100 | [diff] [blame] | 142 | intf->dev.parent = &hd->dev; |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 143 | intf->dev.bus = &greybus_bus_type; |
| 144 | intf->dev.type = &greybus_interface_type; |
| 145 | intf->dev.groups = interface_groups; |
Johan Hovold | 2adaefb | 2015-11-25 15:59:02 +0100 | [diff] [blame] | 146 | intf->dev.dma_mask = hd->dev.dma_mask; |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 147 | device_initialize(&intf->dev); |
Johan Hovold | 8b0df4b | 2015-11-25 15:59:04 +0100 | [diff] [blame] | 148 | dev_set_name(&intf->dev, "%d-%d", hd->bus_id, interface_id); |
Greg Kroah-Hartman | f0f61b9 | 2014-10-24 17:34:46 +0800 | [diff] [blame] | 149 | |
Johan Hovold | c634650 | 2015-12-15 15:28:56 +0100 | [diff] [blame] | 150 | intf->control = gb_control_create(intf); |
| 151 | if (!intf->control) { |
| 152 | put_device(&intf->dev); |
| 153 | return NULL; |
| 154 | } |
| 155 | |
Greg Kroah-Hartman | 4901175 | 2014-12-19 14:56:37 -0800 | [diff] [blame] | 156 | spin_lock_irq(&gb_interfaces_lock); |
Viresh Kumar | 928f2ab | 2015-06-04 18:16:45 +0530 | [diff] [blame] | 157 | list_add(&intf->links, &hd->interfaces); |
Greg Kroah-Hartman | 4901175 | 2014-12-19 14:56:37 -0800 | [diff] [blame] | 158 | spin_unlock_irq(&gb_interfaces_lock); |
Viresh Kumar | 0a68a16 | 2014-11-13 18:14:37 +0530 | [diff] [blame] | 159 | |
Greg Kroah-Hartman | 4ab9b3c | 2014-12-19 14:56:31 -0800 | [diff] [blame] | 160 | return intf; |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | /* |
Johan Hovold | febe252 | 2015-11-11 10:07:06 +0100 | [diff] [blame] | 164 | * Tear down a previously set up interface. |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 165 | */ |
Viresh Kumar | 80d1ede | 2015-09-23 16:48:10 -0700 | [diff] [blame] | 166 | void gb_interface_remove(struct gb_interface *intf) |
Alex Elder | e1e9dbd | 2014-10-01 21:54:11 -0500 | [diff] [blame] | 167 | { |
Alex Elder | fe53b45 | 2015-06-12 10:21:11 -0500 | [diff] [blame] | 168 | struct gb_bundle *bundle; |
| 169 | struct gb_bundle *next; |
Viresh Kumar | 2352a73 | 2015-04-02 17:53:47 +0530 | [diff] [blame] | 170 | |
Johan Hovold | 141af4f | 2015-12-15 15:28:57 +0100 | [diff] [blame] | 171 | if (intf->disconnected) |
| 172 | gb_control_disable(intf->control); |
| 173 | |
Alex Elder | fe53b45 | 2015-06-12 10:21:11 -0500 | [diff] [blame] | 174 | list_for_each_entry_safe(bundle, next, &intf->bundles, links) |
| 175 | gb_bundle_destroy(bundle); |
Alex Elder | 697e55d | 2014-10-20 23:01:04 -0500 | [diff] [blame] | 176 | |
Viresh Kumar | 907d1e1 | 2016-02-19 15:57:46 +0530 | [diff] [blame] | 177 | if (device_is_registered(&intf->dev)) { |
Johan Hovold | ab66dd7 | 2015-12-07 15:05:45 +0100 | [diff] [blame] | 178 | device_del(&intf->dev); |
Viresh Kumar | 907d1e1 | 2016-02-19 15:57:46 +0530 | [diff] [blame] | 179 | dev_info(&intf->dev, "Interface removed\n"); |
| 180 | } |
Johan Hovold | ab66dd7 | 2015-12-07 15:05:45 +0100 | [diff] [blame] | 181 | |
Johan Hovold | c634650 | 2015-12-15 15:28:56 +0100 | [diff] [blame] | 182 | gb_control_disable(intf->control); |
Johan Hovold | 47091af | 2015-11-25 15:59:26 +0100 | [diff] [blame] | 183 | |
Johan Hovold | ab66dd7 | 2015-12-07 15:05:45 +0100 | [diff] [blame] | 184 | spin_lock_irq(&gb_interfaces_lock); |
| 185 | list_del(&intf->links); |
| 186 | spin_unlock_irq(&gb_interfaces_lock); |
| 187 | |
| 188 | put_device(&intf->dev); |
Alex Elder | 574341c | 2014-10-16 06:35:35 -0500 | [diff] [blame] | 189 | } |
| 190 | |
Johan Hovold | 2537636 | 2015-11-03 18:03:23 +0100 | [diff] [blame] | 191 | void gb_interfaces_remove(struct gb_host_device *hd) |
Viresh Kumar | 80d1ede | 2015-09-23 16:48:10 -0700 | [diff] [blame] | 192 | { |
| 193 | struct gb_interface *intf, *temp; |
| 194 | |
| 195 | list_for_each_entry_safe(intf, temp, &hd->interfaces, links) |
| 196 | gb_interface_remove(intf); |
| 197 | } |
| 198 | |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 199 | /** |
Viresh Kumar | b950dc2 | 2015-07-03 17:00:26 +0530 | [diff] [blame] | 200 | * gb_interface_init |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 201 | * |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 202 | * Create connection for control CPort and then request/parse manifest. |
| 203 | * Finally initialize all the bundles to set routes via SVC and initialize all |
| 204 | * connections. |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 205 | */ |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 206 | int gb_interface_init(struct gb_interface *intf, u8 device_id) |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 207 | { |
Johan Hovold | 708d07a | 2015-12-07 15:05:44 +0100 | [diff] [blame] | 208 | struct gb_bundle *bundle, *tmp; |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 209 | int ret, size; |
| 210 | void *manifest; |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 211 | |
Viresh Kumar | c3add78 | 2015-07-01 12:13:58 +0530 | [diff] [blame] | 212 | intf->device_id = device_id; |
| 213 | |
Johan Hovold | c634650 | 2015-12-15 15:28:56 +0100 | [diff] [blame] | 214 | /* Establish control connection */ |
| 215 | ret = gb_control_enable(intf->control); |
| 216 | if (ret) |
Johan Hovold | 0bf1f24 | 2015-12-07 15:05:34 +0100 | [diff] [blame] | 217 | return ret; |
Johan Hovold | 0bf1f24 | 2015-12-07 15:05:34 +0100 | [diff] [blame] | 218 | |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 219 | /* Get manifest size using control protocol on CPort */ |
| 220 | size = gb_control_get_manifest_size_operation(intf); |
| 221 | if (size <= 0) { |
Johan Hovold | 5626e0b | 2015-12-07 15:05:46 +0100 | [diff] [blame] | 222 | dev_err(&intf->dev, "failed to get manifest size: %d\n", size); |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 223 | if (size) |
| 224 | return size; |
| 225 | else |
| 226 | return -EINVAL; |
| 227 | } |
| 228 | |
| 229 | manifest = kmalloc(size, GFP_KERNEL); |
| 230 | if (!manifest) |
| 231 | return -ENOMEM; |
| 232 | |
| 233 | /* Get manifest using control protocol on CPort */ |
| 234 | ret = gb_control_get_manifest_operation(intf, manifest, size); |
| 235 | if (ret) { |
Johan Hovold | 5626e0b | 2015-12-07 15:05:46 +0100 | [diff] [blame] | 236 | dev_err(&intf->dev, "failed to get manifest: %d\n", ret); |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 237 | goto free_manifest; |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | /* |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 241 | * Parse the manifest and build up our data structures representing |
| 242 | * what's in it. |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 243 | */ |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 244 | if (!gb_manifest_parse(intf, manifest, size)) { |
Johan Hovold | 5626e0b | 2015-12-07 15:05:46 +0100 | [diff] [blame] | 245 | dev_err(&intf->dev, "failed to parse manifest\n"); |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 246 | ret = -EINVAL; |
| 247 | goto free_manifest; |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 248 | } |
| 249 | |
Viresh Kumar | d39bf70 | 2015-12-28 11:59:01 +0530 | [diff] [blame] | 250 | ret = gb_control_get_interface_version_operation(intf); |
| 251 | if (ret) |
| 252 | goto free_manifest; |
| 253 | |
Johan Hovold | b807aa7 | 2016-01-19 12:51:21 +0100 | [diff] [blame] | 254 | ret = gb_control_get_bundle_versions(intf->control); |
| 255 | if (ret) |
| 256 | goto free_manifest; |
| 257 | |
Johan Hovold | ab66dd7 | 2015-12-07 15:05:45 +0100 | [diff] [blame] | 258 | /* Register the interface and its bundles. */ |
| 259 | ret = device_add(&intf->dev); |
| 260 | if (ret) { |
| 261 | dev_err(&intf->dev, "failed to register interface: %d\n", ret); |
| 262 | goto free_manifest; |
| 263 | } |
| 264 | |
Viresh Kumar | 907d1e1 | 2016-02-19 15:57:46 +0530 | [diff] [blame] | 265 | dev_info(&intf->dev, "Interface added: VID=0x%08x, PID=0x%08x\n", |
| 266 | intf->vendor_id, intf->product_id); |
| 267 | dev_info(&intf->dev, "DDBL1 Manufacturer=0x%08x, Product=0x%08x\n", |
| 268 | intf->ddbl1_manufacturer_id, intf->ddbl1_product_id); |
| 269 | |
Johan Hovold | 708d07a | 2015-12-07 15:05:44 +0100 | [diff] [blame] | 270 | list_for_each_entry_safe_reverse(bundle, tmp, &intf->bundles, links) { |
| 271 | ret = gb_bundle_add(bundle); |
| 272 | if (ret) { |
| 273 | gb_bundle_destroy(bundle); |
| 274 | continue; |
| 275 | } |
Johan Hovold | 708d07a | 2015-12-07 15:05:44 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | ret = 0; |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 279 | |
Viresh Kumar | 6c68da2 | 2015-06-22 16:42:27 +0530 | [diff] [blame] | 280 | free_manifest: |
| 281 | kfree(manifest); |
| 282 | return ret; |
Viresh Kumar | 676daaf | 2014-11-14 17:25:07 +0530 | [diff] [blame] | 283 | } |