Commit 8b4aaea9 authored by Marvin Scholz's avatar Marvin Scholz

mmc_device_darwin: IODestroyPlugInInterface plugin interface

Store a reference to the plugin interface in the mmc struct and call
IODestroyPlugInInterface instead of Destroy(), as it is explicitly
documented that IODestroyPlugInInterface should be used and not
Destroy.
As destroying the plugin interface might stop the IOBDService,
call it only when we are done with anything needing it.
parent fe29e1e4
......@@ -72,6 +72,8 @@
*/
struct mmcdev {
/* Interfaces required for low-level device communication */
IOCFPlugInInterface **plugInInterface;
MMCDeviceInterface **mmcInterface;
SCSITaskDeviceInterface **taskInterface;
......@@ -320,24 +322,23 @@ static int iokit_find_service_matching (MMCDEV *mmc, io_service_t *servp) {
}
static int iokit_find_interfaces (MMCDEV *mmc, io_service_t service) {
IOCFPlugInInterface **plugInInterface = NULL;
SInt32 score;
int rc;
rc = IOCreatePlugInInterfaceForService (service, kIOMMCDeviceUserClientTypeID,
kIOCFPlugInInterfaceID, &plugInInterface,
kIOCFPlugInInterfaceID, &mmc->plugInInterface,
&score);
if (kIOReturnSuccess != rc || NULL == plugInInterface) {
if (kIOReturnSuccess != rc || NULL == mmc->plugInInterface) {
return -1;
}
BD_DEBUG(DBG_MMC, "Getting MMC interface\n");
IOCFPlugInInterface **plugInInterface = mmc->plugInInterface;
rc = (*plugInInterface)->QueryInterface(plugInInterface,
CFUUIDGetUUIDBytes(kIOMMCDeviceInterfaceID),
(LPVOID)&mmc->mmcInterface);
/* call release instead of IODestroyPlugInInterface to avoid stopping IOBDServices */
(*plugInInterface)->Release(plugInInterface);
if (kIOReturnSuccess != rc || NULL == mmc->mmcInterface) {
BD_DEBUG(DBG_MMC, "Could not get multimedia commands (MMC) interface\n");
return -1;
......@@ -358,6 +359,7 @@ static int mmc_open_iokit (const char *path, MMCDEV *mmc) {
io_service_t service;
int rc;
mmc->plugInInterface = NULL;
mmc->mmcInterface = NULL;
mmc->taskInterface = NULL;
mmc->disk = NULL;
......@@ -443,6 +445,10 @@ void device_close(MMCDEV **pp)
mmc->mmcInterface = NULL;
}
if (mmc->plugInInterface) {
IODestroyPlugInInterface(mmc->plugInInterface);
}
(void) iokit_mount (mmc);
X_FREE(*pp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment