summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-03-11 14:07:36 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-04-16 11:41:46 +0800
commit12a5c9153ce95ddde7fb14eaba9d779933a3637c (patch)
tree0919a8d387e617c01b4a462d7cd9fe0cedbc709c /discover/device-handler.c
parentbd06734362bb727b09b943688d9b69aa0a84590d (diff)
downloadtalos-petitboot-12a5c9153ce95ddde7fb14eaba9d779933a3637c.tar.gz
talos-petitboot-12a5c9153ce95ddde7fb14eaba9d779933a3637c.zip
discover: Consolidate user events by device ID
Currently, we assume all user events are for a new device. This means that we can never add boot options to an existing device. This change tries to find an existing (matching by ID) device before creating a new one in the user event add path. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/device-handler.c')
-rw-r--r--discover/device-handler.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index ab27b51..4ba7405 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -347,23 +347,25 @@ static int handle_add_user_event(struct device_handler *handler,
assert(event->device);
- device = talloc_zero(handler, struct device);
+ device = device_handler_find(handler, event->device);
- if (!device)
- goto fail;
+ if (!device) {
+ device = talloc_zero(handler, struct device);
- device->id = talloc_strdup(device, event->device);
- list_init(&device->boot_options);
+ if (!device)
+ goto fail;
- parse_user_event(device, event);
+ device->id = talloc_strdup(device, event->device);
+ list_init(&device->boot_options);
- discover_server_notify_device_add(handler->server, device);
+ /* add device to handler device array */
+ device_handler_add(handler, device);
- list_for_each_entry(&device->boot_options, opt, list)
- discover_server_notify_boot_option_add(handler->server, opt);
+ discover_server_notify_device_add(handler->server, device);
+ }
- /* add device to handler device array */
- device_handler_add(handler, device);
+ opt = parse_user_event(device, event);
+ discover_server_notify_boot_option_add(handler->server, opt);
return 0;
OpenPOWER on IntegriCloud