diff -r d1441d87f5c1 -r ecac8252f114 master/module.c --- a/master/module.c Tue Sep 26 15:25:49 2006 +0000 +++ b/master/module.c Tue Sep 26 16:16:13 2006 +0000 @@ -420,34 +420,41 @@ goto out_release; } - if (!try_module_get(master->device->module)) { + if (!try_module_get(master->device->module)) { // possible race? EC_ERR("Failed to reserve device module!\n"); goto out_release; } - ec_master_measure_bus_time(master); - ec_master_idle_stop(master); - ec_master_reset(master); + if (!master->device->link_state) { + EC_ERR("Link is DOWN.\n"); + goto out_module_put; + } + + ec_master_reset(master); // also stops idle mode master->mode = EC_MASTER_MODE_OPERATION; - if (!master->device->link_state) EC_WARN("Link is DOWN.\n"); + if (ec_master_measure_bus_time(master)) { + EC_ERR("Bus time measuring failed!\n"); + goto out_reset; + } if (ec_master_bus_scan(master)) { EC_ERR("Bus scan failed!\n"); - goto out_module_put; - } - - EC_INFO("Master %i is ready.\n", master_index); + goto out_reset; + } + + EC_INFO("Successfully requested master %i.\n", master_index); return master; + out_reset: + ec_master_reset(master); + ec_master_idle_start(master); out_module_put: module_put(master->device->module); - ec_master_reset(master); - ec_master_idle_start(master); out_release: master->reserved = 0; out_return: - EC_ERR("Failed requesting master %i.\n", master_index); + EC_ERR("Failed to request master %i.\n", master_index); return NULL; } @@ -473,7 +480,7 @@ module_put(master->device->module); master->reserved = 0; - EC_INFO("Released master %i.\n", master->index); + EC_INFO("Successfully released master %i.\n", master->index); return; }