return NULL;
technology = technology_find(type);
- if (technology != NULL)
+ if (technology != NULL) {
+ __sync_fetch_and_add(&technology->refcount, 1);
return technology;
+ }
/* First check if we have a driver for this technology type */
for (list = driver_list; list; list = list->next) {
{
DBG("technology %p", technology);
- if (__sync_fetch_and_sub(&technology->refcount, 1) != 1)
+ if (__sync_fetch_and_sub(&technology->refcount, 1) > 0)
return;
if (technology->driver) {
technology->device_list = g_slist_remove(technology->device_list,
device);
+ technology_put(technology);
+
return 0;
}