static int set_powered(struct connman_device *device, connman_bool_t powered)
{
struct connman_device_driver *driver = device->driver;
- enum connman_service_type type;
int err;
DBG("device %p powered %d", device, powered);
if (!driver)
return -EINVAL;
- type = __connman_device_get_service_type(device);
-
if (powered == TRUE) {
if (driver->enable) {
device->powered_pending = powered;
err = driver->enable(device);
if (err == 0)
- __connman_notifier_enable(type);
+ __connman_technology_enable_device(device);
} else
err = -EINVAL;
} else {
if (driver->disable) {
err = driver->disable(device);
if (err == 0)
- __connman_notifier_disable(type);
+ __connman_technology_disable_device(device);
} else
err = -EINVAL;
}
static int setup_device(struct connman_device *device)
{
- enum connman_service_type type;
int err;
DBG("device %p", device);
__connman_technology_add_device(device);
- type = __connman_device_get_service_type(device);
- __connman_notifier_register(type);
-
switch (device->mode) {
case CONNMAN_DEVICE_MODE_UNKNOWN:
case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
static void remove_device(struct connman_device *device)
{
- enum connman_service_type type;
-
DBG("device %p", device);
__connman_device_disable(device);
break;
}
- type = __connman_device_get_service_type(device);
- __connman_notifier_unregister(type);
-
__connman_technology_remove_device(device);
unregister_interface(&device->element);
int connman_device_set_powered(struct connman_device *device,
connman_bool_t powered)
{
- enum connman_service_type type;
-
DBG("driver %p powered %d", device, powered);
if (device->timeout > 0) {
device->powered = powered;
device->powered_pending = powered;
- type = __connman_device_get_service_type(device);
-
if (device->powered == TRUE)
- __connman_notifier_enable(type);
+ __connman_technology_enable_device(device);
else
- __connman_notifier_disable(type);
+ __connman_technology_disable_device(device);
if (device->registered == FALSE)
return 0;
int __connman_device_enable(struct connman_device *device)
{
- enum connman_service_type type;
int err;
DBG("device %p", device);
device->powered = TRUE;
- type = __connman_device_get_service_type(device);
- __connman_notifier_enable(type);
+ __connman_technology_enable_device(device);
return 0;
}
int __connman_device_disable(struct connman_device *device)
{
- enum connman_service_type type;
int err;
DBG("device %p", device);
device->powered = FALSE;
- type = __connman_device_get_service_type(device);
- __connman_notifier_disable(type);
+ __connman_technology_disable_device(device);
return 0;
}
char *path;
GHashTable *rfkill_list;
GSList *device_list;
+ gint enabled;
};
static void free_rfkill(gpointer data)
DBG("device %p", device);
type = __connman_device_get_service_type(device);
+ __connman_notifier_register(type);
technology = technology_get(type);
if (technology == NULL)
int __connman_technology_remove_device(struct connman_device *device)
{
struct connman_technology *technology;
+ enum connman_service_type type;
DBG("device %p", device);
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_unregister(type);
+
technology = g_hash_table_lookup(device_table, device);
if (technology == NULL)
return -ENXIO;
return 0;
}
+int __connman_technology_enable_device(struct connman_device *device)
+{
+ struct connman_technology *technology;
+ enum connman_service_type type;
+
+ DBG("device %p", device);
+
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_enable(type);
+
+ technology = g_hash_table_lookup(device_table, device);
+ if (technology == NULL)
+ return -ENXIO;
+
+ if (g_atomic_int_exchange_and_add(&technology->enabled, 1) == 0) {
+ technology->state = CONNMAN_TECHNOLOGY_STATE_ENABLED;
+ state_changed(technology);
+ }
+
+ return 0;
+}
+
+int __connman_technology_disable_device(struct connman_device *device)
+{
+ struct connman_technology *technology;
+ enum connman_service_type type;
+
+ DBG("device %p", device);
+
+ type = __connman_device_get_service_type(device);
+ __connman_notifier_disable(type);
+
+ technology = g_hash_table_lookup(device_table, device);
+ if (technology == NULL)
+ return -ENXIO;
+
+ if (g_atomic_int_dec_and_test(&technology->enabled) == TRUE) {
+ technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE;
+ state_changed(technology);
+ }
+
+ return 0;
+}
+
int __connman_technology_add_rfkill(unsigned int index,
enum connman_service_type type,
connman_bool_t softblock,