Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

greybus: bundle: Initialize all bundles on link-up

An interface can have 1 or more bundles. On link-up event, we must initialize
all the bundles associated with the interface.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

Viresh Kumar and committed by
Greg Kroah-Hartman
bb97ea81 7c183f70

+23 -11
+1 -3
drivers/staging/greybus/ap.c
··· 146 146 management->link_up.interface_id); 147 147 return; 148 148 } 149 - ret = gb_bundle_init(intf, 150 - management->link_up.interface_id, 151 - management->link_up.device_id); 149 + ret = gb_bundles_init(intf, management->link_up.device_id); 152 150 if (ret) { 153 151 dev_err(hd->parent, 154 152 "error %d initializing bundles for interface %hhu\n",
+20 -7
drivers/staging/greybus/bundle.c
··· 146 146 } 147 147 } 148 148 149 - int gb_bundle_init(struct gb_interface *intf, u8 bundle_id, u8 device_id) 149 + int gb_bundle_init(struct gb_bundle *bundle, u8 device_id) 150 150 { 151 - struct gb_bundle *bundle; 151 + struct gb_interface *intf = bundle->intf; 152 152 int ret; 153 153 154 - bundle = gb_bundle_find(intf, bundle_id); 155 - if (!bundle) { 156 - dev_err(intf->hd->parent, "bundle %hhu not found\n", bundle_id); 157 - return -ENOENT; 158 - } 159 154 bundle->device_id = device_id; 160 155 161 156 ret = svc_set_route_send(bundle, intf->hd); ··· 168 173 } 169 174 170 175 return 0; 176 + } 177 + 178 + int gb_bundles_init(struct gb_interface *intf, u8 device_id) 179 + { 180 + struct gb_bundle *bundle; 181 + int ret = 0; 182 + 183 + list_for_each_entry(bundle, &intf->bundles, links) { 184 + ret = gb_bundle_init(bundle, device_id); 185 + if (ret) { 186 + dev_err(intf->hd->parent, 187 + "Failed to initialize bundle %hhu\n", 188 + bundle->id); 189 + break; 190 + } 191 + } 192 + 193 + return ret; 171 194 } 172 195 173 196 struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id)
+2 -1
drivers/staging/greybus/bundle.h
··· 31 31 struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, 32 32 u8 class_type); 33 33 void gb_bundle_destroy(struct gb_interface *intf); 34 - int gb_bundle_init(struct gb_interface *intf, u8 module_id, u8 device_id); 34 + int gb_bundle_init(struct gb_bundle *bundle, u8 device_id); 35 + int gb_bundles_init(struct gb_interface *intf, u8 device_id); 35 36 36 37 struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id); 37 38 void gb_bundle_bind_protocols(void);