Get IOUSBInterface from IOUSBDevice functionality needs your expert review!!
Get IOUSBInterface from IOUSBDevice functionality needs your expert review!!
- Subject: Get IOUSBInterface from IOUSBDevice functionality needs your expert review!!
- From: Chinki <email@hidden>
- Date: Mon, 29 May 2006 10:57:32 +0530
Dear all,
Greetings !! Chinki again :)
Developing KEXT for usb bulk device on Mac OS X 10.4 PPC and Intel Mac.
Below is a small peice of code to get IOUSBInterface from IOUSBDevice. I would be thankful if you could please reveiw and send your useful comments for the same.
/////////////
IOUSBInterface* myDriver::GetProviderInterface(IOUSBDevice *fDevice)
{
IOUSBInterface *intf = NULL;
IOUSBFindInterfaceRequest request;
UInt8 numConf;
const IOUSBConfigurationDescriptor *confDesc = NULL;
IOReturn err;
//open the device
if(!fDevice->open(this)) {
DBLog(("Failed to open the device"));
return NULL;
}
// returns the number of configs in the device config descriptor
numConf = fDevice->GetNumConfigurations();
if (!numConf)
{
DBLog(("GetProviderInterface: unable to obtain the number of configurations"));
return NULL;
}
DBLog(("Number of configurations = %d",numConf));
confDesc = fDevice->GetFullConfigurationDescriptor(0);
// set the configuration
if(!confDesc) {
DBLog(("\nGetCongigurationDescriptor failed\n"));
return NULL;
}
err = fDevice->SetConfiguration(this, confDesc->bConfigurationValue, true);
memset(&request, 0, sizeof(IOUSBFindInterfaceRequest));
request.bInterfaceClass = kIOUSBFindInterfaceDontCare;
request.bInterfaceSubClass = kIOUSBFindInterfaceDontCare;
request.bInterfaceProtocol = kIOUSBFindInterfaceDontCare;
request.bAlternateSetting = kIOUSBFindInterfaceDontCare;
if (fDevice)
{
DBLog(("\nIOUSBDevice Success\n"));
intf = fDevice->FindNextInterface(NULL, &request);
if(intf)
{
DBLog(("\nIOUSBInterface found\n"));
intf->retain();
return intf;
}else{
DBLog(("\nIOUSBInterface error!\n"));
return NULL;
}
}
else
{
DBLog(("\nIOUSBDevice returned null\n"));
return NULL;
}
}
////////
Thanks for investing your time. Your suggestions are awaited !
Regards,
CHINKI
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden