static int put_mod(mod_record_t* mod_record) { int ret = 0; unsigned long flags; PRINT_INFO("put mod %s\n", mod_record->name); spin_lock_irqsave(&mod_lock, flags); if (mod_record->no_share) ret = _switch_gate(mod_record->type, 0); else { mod_record->ref--; if(mod_record->ref <= 0) { ret = _switch_gate(mod_record->type, 0); mod_record->ref = 0; mod_record->flag = 0; } } spin_unlock_irqrestore(&mod_lock, flags); return ret; }
static int put_mod(mod_record_t* mod_record) { int ret = 0; unsigned long flags; PRINT_INFO("put mod %s\n", mod_record->name); spin_lock_irqsave(&gate_lock, flags); ret = _switch_gate(mod_record->type, 0); spin_unlock_irqrestore(&gate_lock, flags); return ret; }
static int get_mod(mod_record_t* mod_record) { int ret = 0; unsigned long flags; PRINT_INFO("get mod %s\n", mod_record->name); spin_lock_irqsave(&mod_lock, flags); if (mod_record->no_share) ret = _switch_gate(mod_record->type, 1); else { if(mod_record->ref > 0) mod_record->ref++; else { mod_record->ref = 1; mod_record->flag = 1; ret = _switch_gate(mod_record->type, 1); } } spin_unlock_irqrestore(&mod_lock, flags); return ret; }