IOReturn CLASS::newUserClient(task_t owningTask, void* securityID, UInt32 type, IOUserClient ** handler) { IOUserClient *client; if (type != kGUXUCType) return kIOReturnUnsupported; if (!handler) return kIOReturnBadArgument; client = OSTypeAlloc(GenericUSBXHCIUserClient); if (!client) return kIOReturnNoMemory; if (!client->initWithTask(owningTask, securityID, type)) { client->release(); return kIOReturnInternalError; } if (!client->attach(this)) { client->release(); return kIOReturnInternalError; } if (!client->start(this)) { client->detach(this); client->release(); return kIOReturnInternalError; } *handler = client; return kIOReturnSuccess; }
IOReturn IOI2CDevice::newUserClient( task_t owningTask, void *securityID, UInt32 type, OSDictionary *properties, IOUserClient **handler) { IOUserClient *client; OSObject *temp; DLOG("%s::newUserClient\n", getName()); if (type != kIOI2CUserClientType) return super::newUserClient(owningTask,securityID,type,properties,handler); if (IOUserClient::clientHasPrivilege(securityID, "root") != kIOReturnSuccess) { ERRLOG("%s::newUserClient: Can't create user client, not privileged\n", getName()); return kIOReturnNotPrivileged; } temp = OSMetaClass::allocClassWithName("IOI2CUserClient"); if (!temp) return kIOReturnNoMemory; if (OSDynamicCast(IOUserClient, temp)) client = (IOUserClient *) temp; else { temp->release(); return kIOReturnUnsupported; } if ( !client->initWithTask(owningTask, securityID, type, properties) ) { client->release(); return kIOReturnBadArgument; } if ( !client->attach(this) ) { client->release(); return kIOReturnUnsupported; } if ( !client->start(this) ) { client->detach(this); client->release(); return kIOReturnUnsupported; } *handler = client; return kIOReturnSuccess; }
IOReturn IOI2CInterface::newUserClient( task_t owningTask, void * security_id, UInt32 type, IOUserClient ** handler ) { IOReturn err = kIOReturnSuccess; IOUserClient * newConnect = 0; if (type) return (kIOReturnBadArgument); newConnect = IOI2CInterfaceUserClient::withTask(owningTask); if (newConnect) { if (!newConnect->attach(this) || !newConnect->start(this)) { newConnect->detach( this ); newConnect->release(); newConnect = 0; } } *handler = newConnect; return (err); }