From bb97ea813b1c31a0fc78af3d06a8dbd793ea372b Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Wed, 1 Apr 2015 20:32:01 +0530 Subject: [PATCH] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/ap.c | 4 +--- drivers/staging/greybus/bundle.c | 27 ++++++++++++++++++++------- drivers/staging/greybus/bundle.h | 3 ++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/staging/greybus/ap.c b/drivers/staging/greybus/ap.c index 132ecb4a7974..1dc13396a567 100644 --- a/drivers/staging/greybus/ap.c +++ b/drivers/staging/greybus/ap.c @@ -146,9 +146,7 @@ static void svc_management(struct svc_function_unipro_management *management, management->link_up.interface_id); return; } - ret = gb_bundle_init(intf, - management->link_up.interface_id, - management->link_up.device_id); + ret = gb_bundles_init(intf, management->link_up.device_id); if (ret) { dev_err(hd->parent, "error %d initializing bundles for interface %hhu\n", diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c index 47a3413b6f21..969197872484 100644 --- a/drivers/staging/greybus/bundle.c +++ b/drivers/staging/greybus/bundle.c @@ -146,16 +146,11 @@ void gb_bundle_destroy(struct gb_interface *intf) } } -int gb_bundle_init(struct gb_interface *intf, u8 bundle_id, u8 device_id) +int gb_bundle_init(struct gb_bundle *bundle, u8 device_id) { - struct gb_bundle *bundle; + struct gb_interface *intf = bundle->intf; int ret; - bundle = gb_bundle_find(intf, bundle_id); - if (!bundle) { - dev_err(intf->hd->parent, "bundle %hhu not found\n", bundle_id); - return -ENOENT; - } bundle->device_id = device_id; ret = svc_set_route_send(bundle, intf->hd); @@ -175,6 +170,24 @@ int gb_bundle_init(struct gb_interface *intf, u8 bundle_id, u8 device_id) return 0; } +int gb_bundles_init(struct gb_interface *intf, u8 device_id) +{ + struct gb_bundle *bundle; + int ret = 0; + + list_for_each_entry(bundle, &intf->bundles, links) { + ret = gb_bundle_init(bundle, device_id); + if (ret) { + dev_err(intf->hd->parent, + "Failed to initialize bundle %hhu\n", + bundle->id); + break; + } + } + + return ret; +} + struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id) { struct gb_bundle *bundle; diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h index 385c90a5e9f8..2948098070c4 100644 --- a/drivers/staging/greybus/bundle.h +++ b/drivers/staging/greybus/bundle.h @@ -31,7 +31,8 @@ struct gb_bundle { struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id, u8 class_type); void gb_bundle_destroy(struct gb_interface *intf); -int gb_bundle_init(struct gb_interface *intf, u8 module_id, u8 device_id); +int gb_bundle_init(struct gb_bundle *bundle, u8 device_id); +int gb_bundles_init(struct gb_interface *intf, u8 device_id); struct gb_bundle *gb_bundle_find(struct gb_interface *intf, u8 bundle_id); void gb_bundle_bind_protocols(void); -- 2.39.2