From 57536b8359c5c99f015cd97c597e2de82ce9144f Mon Sep 17 00:00:00 2001 From: Joey Lee Date: Thu, 21 Oct 2010 10:56:53 +0200 Subject: [PATCH] device: Set element driver when probing a device driver When a device shows up through rtnl before the device driver is created, the device's element driver pointer will not be set. The bug is not visible with built-in devices, it only appears with removable ones or with those that are completely removed from the bus when being rfkilled. --- src/connman.h | 2 ++ src/device.c | 2 ++ src/element.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/connman.h b/src/connman.h index 5c17a68..8aaac3a 100644 --- a/src/connman.h +++ b/src/connman.h @@ -190,6 +190,8 @@ gboolean __connman_element_device_isfiltered(const char *devname); int __connman_detect_init(void); void __connman_detect_cleanup(void); +void __connman_element_set_driver(struct connman_element *element); + #include int __connman_ipconfig_init(void); diff --git a/src/device.c b/src/device.c index 373eb5f..1b721ee 100644 --- a/src/device.c +++ b/src/device.c @@ -586,6 +586,8 @@ static void probe_driver(struct connman_element *element, gpointer user_data) element->device->driver = driver; + __connman_element_set_driver(element); + setup_device(element->device); } diff --git a/src/element.c b/src/element.c index 74383cc..a5700f2 100644 --- a/src/element.c +++ b/src/element.c @@ -1322,6 +1322,28 @@ void connman_element_set_error(struct connman_element *element, __connman_service_indicate_error(service, convert_error(error)); } +void __connman_element_set_driver(struct connman_element *element) +{ + GSList *list; + + DBG("element %p name %s driver %p", element, element->name, + element->driver); + + if (element->driver) + return; + + for (list = driver_list; list; list = list->next) { + struct connman_driver *driver = list->data; + + if (match_driver(element, driver) == FALSE) + continue; + + element->driver = driver; + + break; + } +} + int __connman_element_init(const char *device, const char *nodevice) { struct connman_element *element; -- 2.7.4