parameters: (device, parent_type)
return_statement: return device
docstring: Find the first parent of a device that implements the parent_type
          @param IOService Service to inspect
          @return Pointer to the parent type, or None if it was not found.
docstring_summary: Find the first parent of a device that implements the parent_type
docstring_tokens: Find the first parent of a device that implements the parent_type
function: def GetParentDeviceByType(device, parent_type):
      """ Find the first parent of a device that implements the parent_type
          @param IOService Service to inspect
          @return Pointer to the parent type, or None if it was not found.
      """
      # First, try to walk up the IOService tree to find a parent of this device that is a IOUSBDevice.
      parent_type = parent_type.encode('mac_roman')
      while IORegistryEntryGetName(device) != parent_type:
          parent = ctypes.c_void_p()
          response = iokit.IORegistryEntryGetParentEntry(
                  device,
                  "IOService".encode("mac_roman"),
                  ctypes.byref(parent))
          # If we weren't able to find a parent for the device, we're done.
          if response != 0:
              return None
          device = parent
      return device
function_tokens: def GetParentDeviceByType ( device , parent_type ) : # First, try to walk up the IOService tree to find a parent of this device that is a IOUSBDevice. parent_type = parent_type . encode ( 'mac_roman' ) while IORegistryEntryGetName ( device ) != parent_type : parent = ctypes . c_void_p ( ) response = iokit . IORegistryEntryGetParentEntry ( device , "IOService" . encode ( "mac_roman" ) , ctypes . byref ( parent ) ) # If we weren't able to find a parent for the device, we're done. if response != 0 : return None device = parent return device