discover/device-handler: Remove default option if device removed v1.2.1
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Wed, 29 Jun 2016 05:43:20 +0000 (15:43 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Thu, 14 Jul 2016 03:49:34 +0000 (13:49 +1000)
If one of a device's boot options is the current default boot option,
make sure the default boot is cancelled before the device is removed.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/device-handler.c

index e230e7669ac31e3c4e04a35b35cf71be8155eb81..682a4e9ae865944d4acea0c62c5b9418ffe36227 100644 (file)
@@ -359,6 +359,15 @@ void device_handler_remove(struct device_handler *handler,
        struct discover_boot_option *opt, *tmp;
        unsigned int i;
 
        struct discover_boot_option *opt, *tmp;
        unsigned int i;
 
+       list_for_each_entry_safe(&device->boot_options, opt, tmp, list) {
+               if (opt == handler->default_boot_option) {
+                       pb_log("Default option %s cancelled since device removed",
+                                       opt->option->name);
+                       device_handler_cancel_default(handler);
+                       break;
+               }
+       }
+
        for (i = 0; i < handler->n_devices; i++)
                if (handler->devices[i] == device)
                        break;
        for (i = 0; i < handler->n_devices; i++)
                if (handler->devices[i] == device)
                        break;