int EvRegisterLocalEventClass(char *className, EvAccess_t classAccessCode, EvClassID_t *classID) { return EvRegisterEventClass(EG_LOCAL, className, EAC_NONE, classAccessCode, classID); }
/* * EvCreateGroup() creates a new event group. The user ID passed in is * used to register an event subscription for creater. If the controCB * is passed in the subscription in delivered using it. This subscription * is for control events to be sent to the creator. * * If the type field is set to local, the a local event group will be * created. Since the system creates one local group at startup it is * questionable as to whether this is useful for more groups. * * If the type field is set to indicate a master then this system is * set up to serve an inter system event group as the master. This means * this instance of the event broker assignes event class IDs and is used * as the communications path to member instances. * * If the type field indicates this is a member, the event group control * is set up on this system and this system will send events generated * to the master system to be echoed back to all other members. * * IF the user ID in not valid then -EPERM is returned. If the event group * identifed by masterName has already been created then -EEXIST is returned. * If no kernel space can be allocated for the control data then -ENOSPC is * returned. * * Otherwise the event group control structures will be allocated and * a zero will be returned to indicate success. */ int EvCreateGroup(char *groupName, char *memberName, EvType_t type, EvAccess_t groupAccessCode, EvAccess_t controlAccessCode, short hashSize, EvGroupID_t masterID, EvGroupID_t memberID, EvGroupID_t *groupID) { EvGroupInfo_t *EGroup; unsigned long Flags; unsigned short ControlClass; int Loop; int RetVal; write_lock_irqsave(&EvGroupLock, Flags); /* If event group exists then return error. */ if (_EvGetGroup(groupName) != NULL) { write_unlock_irqrestore(&EvGroupLock, Flags); return -EV_ERROR_GROUP_EXIST; } /* Create the event group control struct an link into list. */ if (EvGroupHead == NULL) { if ((EvGroupHead = kmalloc (sizeof(EvGroupInfo_t), GFP_ATOMIC)) == NULL) { write_unlock_irqrestore(&EvGroupLock, Flags); return -EV_ERROR_MEM_ALLOC; } EGroup = EvGroupHead; } else { EGroup = EvGroupHead; while (EGroup->EgiNext) { EGroup = EGroup->EgiNext; } if ((EGroup->EgiNext = kmalloc(sizeof(EvGroupInfo_t), GFP_ATOMIC)) == NULL) { write_unlock_irqrestore(&EvGroupLock, Flags); return -EV_ERROR_MEM_ALLOC; } EGroup = EGroup->EgiNext; } strncpy(EGroup->EgiName, groupName, 16); EGroup->EgiID = KernelNextGroup++; strncpy(EGroup->EgiMemberName, memberName, 16); EGroup->EgiType = type; if (type == EG_MASTER) { /* If master prepare to assign members. */ EGroup->EgiMemberID = 0; EGroup->EgiNextMemberID = 1; EGroup->EgiMasterID = EGroup->EgiID; EGroup->EgiMembers = NULL; } else { /* If not next member not used and member ID is from master */ EGroup->EgiMemberID = memberID; EGroup->EgiNextMemberID = -1; EGroup->EgiMasterID = masterID; EGroup->EgiMembers = NULL; } /* Set returned ID value. */ *groupID = EGroup->EgiID; /* Prepare the hash list to control event class assignments. */ if (hashSize == 0) { EGroup->EgiHashSize = EV_NUM_LOCAL_HASHES; } else { EGroup->EgiHashSize = hashSize; } EGroup->EgiClassHash = kmalloc(sizeof(EvClassInfo_t) * hashSize, GFP_ATOMIC); /* Clear the group event control data. */ EGroup->EgiGroupDest.EdID = 0; EGroup->EgiGroupDest.EdUinfo = NULL; EGroup->EgiGroupDest.EdCB = NULL; EGroup->EgiGroupDest.EdKinfo = NULL; EGroup->EgiUseCount = 0; EGroup->EgiNextClass = 0; /* Zero is the control class. */ EGroup->EgiLock = RW_LOCK_UNLOCKED; for (Loop = 0; Loop < hashSize; Loop++) { EGroup->EgiClassHash[Loop].EciLock = SPIN_LOCK_UNLOCKED; EGroup->EgiClassHash[Loop].EciNext = NULL; } EGroup->EgiPendRemoteList = NULL; EGroup->EgiNext = NULL; /* The first class if events created for a event group is a * control class. It is not needed to worry that that this * is coordinated between the master and member because as * the first it always gets the same ID. */ EGroup->EgiAccessCode = groupAccessCode; write_unlock_irqrestore(&EvGroupLock, Flags); if ((RetVal = EvRegisterEventClass(EGroup->EgiID, "Control", groupAccessCode, controlAccessCode, &ControlClass))) { printk("Event Broker: %s Error %d\n", "Add group failed to register control class", RetVal); } return EV_NOERR; }