Lines Matching defs:handle

74     struct UsbDeviceHandle *handle = NULL;
84 handle = dev->devHandle;
89 return handle;
94 struct UsbDeviceHandle *handle = NULL;
96 handle = RawUsbMemCalloc(sizeof(*handle));
97 if (handle == NULL) {
98 HDF_LOGE("%{public}s:%{public}d allocate handle failed", __func__, __LINE__);
102 OsalMutexInit(&handle->lock);
104 return handle;
107 static struct UsbDevice *OsAllocDevice(struct UsbSession *session, struct UsbDeviceHandle *handle)
116 dev->devHandle = handle;
120 handle->dev = dev;
368 static int32_t AdapterUsbControlMsg(const struct UsbDeviceHandle *handle, struct UsbControlRequestData *ctrlData)
370 if (handle == NULL || handle->dev == NULL || ctrlData == NULL) {
375 return ioctl(handle->fd, USBDEVFS_CONTROL, ctrlData);
378 static int32_t AdapterGetUsbSpeed(const struct UsbDeviceHandle *handle)
380 if (handle == NULL || handle->dev == NULL) {
384 int32_t ret = ioctl(handle->fd, USBDEVFS_GET_SPEED, NULL);
937 struct UsbDeviceHandle *handle = NULL;
944 handle = OsGetDeviceHandle(session, busNum, usbAddr);
945 if (handle != NULL) {
946 return handle;
949 handle = OsCallocDeviceHandle();
950 if (handle == NULL) {
954 dev = OsAllocDevice(session, handle);
971 return handle;
974 OsalMutexDestroy(&handle->lock);
975 RawUsbMemFree(handle);
979 static void AdapterCloseDevice(struct UsbDeviceHandle *handle)
983 if ((handle == NULL) || (handle->dev == NULL)) {
988 dev = handle->dev;
1005 close(handle->fd);
1006 close(handle->mmapFd);
1007 OsalMutexDestroy(&handle->lock);
1008 RawUsbMemFree(handle);
1009 handle = NULL;
1048 static int32_t AdapterGetConfiguration(const struct UsbDeviceHandle *handle, uint8_t *activeConfig)
1050 if (handle == NULL || activeConfig == NULL || handle->dev == NULL) {
1055 int32_t ret = OsGetActiveConfig(handle->dev, handle->fd);
1060 *activeConfig = handle->dev->activeConfig;
1068 static int32_t AdapterSetConfiguration(struct UsbDeviceHandle *handle, int32_t activeConfig)
1072 if (handle == NULL || handle->dev == NULL) {
1077 ret = ioctl(handle->fd, USBDEVFS_SETCONFIGURATION, &activeConfig);
1085 handle->dev->activeConfig = (uint8_t)activeConfig;
1090 static int32_t AdapterClaimInterface(const struct UsbDeviceHandle *handle, unsigned int interfaceNumber)
1094 if (handle == NULL) {
1099 ret = ioctl(handle->fd, USBDEVFS_CLAIMINTERFACE, &interfaceNumber);
1108 static int32_t AdapterDetachKernelDriver(const struct UsbDeviceHandle *handle, uint8_t interfaceNumber)
1111 if (handle == NULL) {
1117 ret = ioctl(handle->fd, USBDEVFS_IOCTL, &command);
1126 static int32_t AdapterAttachKernelDriver(const struct UsbDeviceHandle *handle, uint8_t interfaceNumber)
1129 if (handle == NULL) {
1135 ret = ioctl(handle->fd, USBDEVFS_IOCTL, &cmd);
1144 static int32_t AdapterDetachKernelDriverAndClaim(const struct UsbDeviceHandle *handle, uint32_t interfaceNumber)
1147 if (handle == NULL) {
1153 ret = ioctl(handle->fd, USBDEVFS_GETDRIVER, &getDriver);
1156 return AdapterClaimInterface(handle, interfaceNumber);
1170 ret = ioctl(handle->fd, USBDEVFS_DISCONNECT_CLAIM, &dc);
1180 ret = ioctl(handle->fd, USBDEVFS_IOCTL, &command);
1185 return AdapterClaimInterface(handle, interfaceNumber);
1188 static int32_t AdapterReleaseInterface(const struct UsbDeviceHandle *handle, unsigned int interfaceNumber)
1192 if (handle == NULL) {
1197 ret = ioctl(handle->fd, USBDEVFS_RELEASEINTERFACE, &interfaceNumber);
1209 static int32_t AdapterSetInterface(const struct UsbDeviceHandle *handle, uint8_t interface, uint8_t altSetting)
1214 if (handle == NULL) {
1221 ret = ioctl(handle->fd, USBDEVFS_SETINTERFACE, &setIntf);
1230 static int32_t AdapterClearHalt(const struct UsbDeviceHandle *handle, unsigned int endPoint)
1234 if (handle == NULL) {
1239 ret = ioctl(handle->fd, USBDEVFS_CLEAR_HALT, &endPoint);
1248 static int32_t AdapterResetDevice(struct UsbDeviceHandle *handle)
1253 if (handle == NULL) {
1259 if (handle->claimedInterfaces & (1UL << i)) {
1260 AdapterReleaseInterface(handle, i);
1264 ret = ioctl(handle->fd, USBDEVFS_RESET, NULL);
1271 if (!(handle->claimedInterfaces & (1UL << i))) {
1274 ret = AdapterDetachKernelDriverAndClaim(handle, i);
1278 handle->claimedInterfaces &= ~(1UL << i);
1286 static struct UsbHostRequest *AdapterAllocRequest(const struct UsbDeviceHandle *handle, int32_t isoPackets, size_t len)
1290 if (handle == NULL) {
1304 memBuf = mmap(NULL, allocSize, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
1327 const struct UsbDeviceHandle *handle, int32_t isoPackets, size_t len)
1331 if (handle == NULL) {
1343 int32_t fd = handle->isAshmem ? handle->ashmemFd : handle->mmapFd;