Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
092b607e
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
092b607e
编写于
12月 13, 2021
作者:
O
openharmony_ci
提交者:
Gitee
12月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
!937 【USB DDK】修改文档描述及拼写错误
Merge pull request !937 from yufengs/usb_develop_release
上级
93706bb9
fa6f975f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
109 addition
and
109 deletion
+109
-109
zh-cn/device-dev/driver/driver-peripherals-usb-des.md
zh-cn/device-dev/driver/driver-peripherals-usb-des.md
+109
-109
未找到文件。
zh-cn/device-dev/driver/driver-peripherals-usb-des.md
浏览文件 @
092b607e
...
...
@@ -378,8 +378,8 @@ USB驱动是基于HDF框架、PLATFORM和OSAL基础接口进行开发,不区
1.
驱动匹配表配置。
2.
初始化Host DDK。
3.
待步骤2初始化完后获取UsbInterface接口对象。
4.
打开步骤3获取到的UsbInterface接口对象,获取
对
应接口的UsbInterfaceHandle对象。
5.
根据步骤4获取到的UsbInterfaceHandle对象,获取指定索引为pi
n
peIndex的pipeInfo信息。
4.
打开步骤3获取到的UsbInterface接口对象,获取
相
应接口的UsbInterfaceHandle对象。
5.
根据步骤4获取到的UsbInterfaceHandle对象,获取指定索引为pipeIndex的pipeInfo信息。
6.
为步骤4获取到的UsbInterfaceHandle预先分配待发送的IO Request对象。
7.
根据输入参数params填充步骤6预先分配的IO Request。
8.
提交IO Request对象,可以选择同步或异步两种模式。
...
...
@@ -388,7 +388,7 @@ USB驱动是基于HDF框架、PLATFORM和OSAL基础接口进行开发,不区
1.
驱动匹配表配置。
2.
初始化Host RAW,并打开USB设备,然后获取描述符,通过描述符获取接口、端点信息。
3.
分配Request,并根据传输类型使用
如下
接口对Request进行填充。
3.
分配Request,并根据传输类型使用
相应
接口对Request进行填充。
4.
提交IO Request对象,可以选择同步或异步两种模式。
### Device DDK API驱动开发步骤<a name="section600mcpsimp"></a>
...
...
@@ -475,16 +475,16 @@ static int SerialCtrlMsg(struct AcmDevice *acm, uint8_t request,
{
int ret;
uint16_t index = acm->intPipe->interfaceId;
struct UsbControlParams controlParams
= {}
;
struct UsbRequestParams par
mas = {}
;
struct UsbControlParams controlParams;
struct UsbRequestParams par
ams
;
if (acm == NULL || buf == NULL) {
HDF_LOGE("%
{public}
s:invalid param", __func__);
HDF_LOGE("%s:invalid param", __func__);
return HDF_ERR_IO;
}
if (acm->ctrlReq == NULL) {
acm->ctrlReq = UsbAllocRequest(acm->ctrDevHandle, 0, len);
if (acm->ctrlReq == NULL) {
HDF_LOGE("%
{public}s: UsbAllocRequest fail
d", __func__);
HDF_LOGE("%
s: UsbAllocRequest faile
d", __func__);
return HDF_ERR_IO;
}
}
...
...
@@ -498,24 +498,24 @@ static int SerialCtrlMsg(struct AcmDevice *acm, uint8_t request,
controlParams.data = buf;
controlParams.size = len;
par
ma
s.interfaceId = USB_CTRL_INTERFACE_ID;
par
ma
s.pipeAddress = acm->ctrPipe->pipeAddress;
par
ma
s.pipeId = acm->ctrPipe->pipeId;
par
ma
s.requestType = USB_REQUEST_PARAMS_CTRL_TYPE;
par
ma
s.timeout = USB_CTRL_SET_TIMEOUT;
par
ma
s.ctrlReq = UsbControlSetUp(&controlParams);
ret = UsbFillRequest(acm->ctrlReq, acm->ctrDevHandle, &par
ma
s);
par
am
s.interfaceId = USB_CTRL_INTERFACE_ID;
par
am
s.pipeAddress = acm->ctrPipe->pipeAddress;
par
am
s.pipeId = acm->ctrPipe->pipeId;
par
am
s.requestType = USB_REQUEST_PARAMS_CTRL_TYPE;
par
am
s.timeout = USB_CTRL_SET_TIMEOUT;
par
am
s.ctrlReq = UsbControlSetUp(&controlParams);
ret = UsbFillRequest(acm->ctrlReq, acm->ctrDevHandle, &par
am
s);
if (HDF_SUCCESS != ret) {
HDF_LOGE("%
{public}s: faile, ret=%{public}
d ", __func__, ret);
HDF_LOGE("%
s: failed, ret=%
d ", __func__, ret);
return ret;
}
ret = UsbSubmitRequestSync(acm->ctrlReq); //发送同步IO Request
if (HDF_SUCCESS != ret) {
HDF_LOGE("UsbSubmitRequestSync
faile, ret=%{public}
d ", ret);
HDF_LOGE("UsbSubmitRequestSync
failed, ret=%
d ", ret);
return ret;
}
if (!acm->ctrlReq->compInfo.status) {
HDF_LOGE("%
{public}s status=%{public}
d ", __func__, acm->ctrlReq->compInfo.status);
HDF_LOGE("%
s status=%
d ", __func__, acm->ctrlReq->compInfo.status);
}
return HDF_SUCCESS;
}
...
...
@@ -556,7 +556,7 @@ static struct UsbPipeInfo *EnumePipe(const struct AcmDevice *acm,
if ((p.pipeDirection == pipeDirection) && (p.pipeType == pipeType)) {
struct UsbPipeInfo *pi = OsalMemCalloc(sizeof(*pi));
if (pi == NULL) {
HDF_LOGE("%
{public}
s: Alloc pipe failed", __func__);
HDF_LOGE("%s: Alloc pipe failed", __func__);
return NULL;
}
p.interfaceId = info->interfaceIndex;
...
...
@@ -572,7 +572,7 @@ static struct UsbPipeInfo *GetPipe(const struct AcmDevice *acm,
{
uint8_t i;
if (acm == NULL) {
HDF_LOGE("%
{public}s: invalid parma
s", __func__);
HDF_LOGE("%
s: invalid param
s", __func__);
return NULL;
}
for (i = 0; i < acm->interfaceCnt; i++) {
...
...
@@ -605,7 +605,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
return HDF_FAILURE;
}
if (OsalMutexInit(&acm->lock) != HDF_SUCCESS) {
HDF_LOGE("%s:%d OsalMutexInit fail", __func__, __LINE__);
HDF_LOGE("%s:%d OsalMutexInit fail
ed
", __func__, __LINE__);
goto error;
}
info = (struct UsbPnpNotifyServiceInfo *)device->priv;
...
...
@@ -618,7 +618,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
err = memcpy_s((void *)(acm->interfaceIndex), USB_MAX_INTERFACES,
(const void*)info->interfaceNumber, info->interfaceLength);
if (err != EOK) {
HDF_LOGE("%s:%d memcpy_s faile
err=%d",
HDF_LOGE("%s:%d memcpy_s faile
d err=%d",
__func__, __LINE__, err);
goto lock_error;
}
...
...
@@ -634,7 +634,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
lock_error:
if (OsalMutexDestroy(&acm->lock)) {
HDF_LOGE("%s:%d OsalMutexDestroy fail", __func__, __LINE__);
HDF_LOGE("%s:%d OsalMutexDestroy fail
ed
", __func__, __LINE__);
}
error:
OsalMemFree(acm);
...
...
@@ -645,26 +645,26 @@ error:
static int AcmAllocReadRequests(struct AcmDevice *acm)
{
int ret;
struct UsbRequestParams readPar
mas = {}
;
struct UsbRequestParams readPar
ams
;
for (int i = 0; i < ACM_NR; i++) {
acm->readReq[i] = UsbAllocRequest(InterfaceIdToHandle(acm, acm->dataInPipe->interfaceId), 0, acm->readSize); //分配待发送的readReq IO Request对象
if (!acm->readReq[i]) {
HDF_LOGE("readReq request fail
dn
");
HDF_LOGE("readReq request fail
ed
");
goto error;
}
readPar
ma
s.userData = (void *)acm;
readPar
ma
s.pipeAddress = acm->dataInPipe->pipeAddress;
readPar
ma
s.pipeId = acm->dataInPipe->pipeId;
readPar
ma
s.interfaceId = acm->dataInPipe->interfaceId;
readPar
ma
s.callback = AcmReadBulk;
readPar
ma
s.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
readPar
ma
s.timeout = USB_CTRL_SET_TIMEOUT;
readPar
ma
s.dataReq.numIsoPackets = 0;
readPar
ma
s.dataReq.directon = (acm->dataInPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) & 0x1;
readPar
ma
s.dataReq.length = acm->readSize;
ret = UsbFillRequest(acm->readReq[i], InterfaceIdToHandle(acm, acm->dataInPipe->interfaceId), &readPar
ma
s); //填充待发送的readReq对象
readPar
am
s.userData = (void *)acm;
readPar
am
s.pipeAddress = acm->dataInPipe->pipeAddress;
readPar
am
s.pipeId = acm->dataInPipe->pipeId;
readPar
am
s.interfaceId = acm->dataInPipe->interfaceId;
readPar
am
s.callback = AcmReadBulk;
readPar
am
s.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
readPar
am
s.timeout = USB_CTRL_SET_TIMEOUT;
readPar
am
s.dataReq.numIsoPackets = 0;
readPar
am
s.dataReq.directon = (acm->dataInPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) & 0x1;
readPar
am
s.dataReq.length = acm->readSize;
ret = UsbFillRequest(acm->readReq[i], InterfaceIdToHandle(acm, acm->dataInPipe->interfaceId), &readPar
am
s); //填充待发送的readReq对象
if (HDF_SUCCESS != ret) {
HDF_LOGE("%
{public}s: UsbFillRequest faile, ret=%{public}
d n", __func__, ret);
HDF_LOGE("%
s: UsbFillRequest failed, ret=%
d n", __func__, ret);
goto error;
}
}
...
...
@@ -678,25 +678,25 @@ error:
static int AcmAllocNotifyRequest(struct AcmDevice *acm)
{
int ret;
struct UsbRequestParams intPar
ma
s = {};
struct UsbRequestParams intPar
am
s = {};
acm->notifyReq = UsbAllocRequest(InterfaceIdToHandle(acm, acm->intPipe->interfaceId), 0, acm->intSize); //分配待发送的中断IO Request对象
if (!acm->notifyReq) {
HDF_LOGE("notifyReq request fail
n
");
HDF_LOGE("notifyReq request fail
ed
");
return HDF_ERR_MALLOC_FAIL;
}
intPar
ma
s.userData = (void *)acm;
intPar
ma
s.pipeAddress = acm->intPipe->pipeAddress;
intPar
ma
s.pipeId = acm->intPipe->pipeId;
intPar
ma
s.interfaceId = acm->intPipe->interfaceId;
intPar
ma
s.callback = AcmCtrlIrq;
intPar
ma
s.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
intPar
ma
s.timeout = USB_CTRL_SET_TIMEOUT;
intPar
ma
s.dataReq.numIsoPackets = 0;
intPar
ma
s.dataReq.directon = (acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) & DIRECTION_MASK;
intPar
ma
s.dataReq.length = acm->intSize;
ret = UsbFillRequest(acm->notifyReq, InterfaceIdToHandle(acm, acm->intPipe->interfaceId), &intPar
ma
s); //填充预先分配的中断IO Request
intPar
am
s.userData = (void *)acm;
intPar
am
s.pipeAddress = acm->intPipe->pipeAddress;
intPar
am
s.pipeId = acm->intPipe->pipeId;
intPar
am
s.interfaceId = acm->intPipe->interfaceId;
intPar
am
s.callback = AcmCtrlIrq;
intPar
am
s.requestType = USB_REQUEST_PARAMS_DATA_TYPE;
intPar
am
s.timeout = USB_CTRL_SET_TIMEOUT;
intPar
am
s.dataReq.numIsoPackets = 0;
intPar
am
s.dataReq.directon = (acm->intPipe->pipeDirection >> USB_PIPE_DIR_OFFSET) & DIRECTION_MASK;
intPar
am
s.dataReq.length = acm->intSize;
ret = UsbFillRequest(acm->notifyReq, InterfaceIdToHandle(acm, acm->intPipe->interfaceId), &intPar
am
s); //填充预先分配的中断IO Request
if (HDF_SUCCESS != ret) {
HDF_LOGE("%
{public}s: UsbFillRequest faile, ret=%{public}
d n", __func__, ret);
HDF_LOGE("%
s: UsbFillRequest failed, ret=%
d n", __func__, ret);
goto error;
}
return HDF_SUCCESS;
...
...
@@ -725,14 +725,14 @@ static int32_t AcmClaimInterfaces(struct AcmDevice *acm)
for (int i = 0; i < acm->interfaceCnt; i++) {
acm->iface[i] = GetUsbInterfaceById((const struct AcmDevice *)acm, acm->interfaceIndex[i]); //获取UsbInterface接口对象
if (acm->iface[i] == NULL) {
HDF_LOGE("%
{public}s: interface%{public}
d is null", __func__, acm->interfaceIndex[i]);
HDF_LOGE("%
s: interface%
d is null", __func__, acm->interfaceIndex[i]);
goto error;
}
}
acm->ctrIface = GetUsbInterfaceById((const struct AcmDevice *)acm, USB_CTRL_INTERFACE_ID); //获取控制接口对应的UsbInterface接口对象
if (acm->ctrIface == NULL) {
HDF_LOGE("%
{public}
s: GetUsbInterfaceById null", __func__);
HDF_LOGE("%s: GetUsbInterfaceById null", __func__);
goto error;
}
...
...
@@ -763,14 +763,14 @@ static int32_t AcmOpenInterfaces(struct AcmDevice *acm)
if (acm->iface[i]) {
acm->devHandle[i] = UsbOpenInterface(acm->iface[i]); //打开获取到的UsbInterface接口对象
if (acm->devHandle[i] == NULL) {
HDF_LOGE("%
{public}
s: UsbOpenInterface null", __func__);
HDF_LOGE("%s: UsbOpenInterface null", __func__);
goto error;
}
}
}
acm->ctrDevHandle = UsbOpenInterface(acm->ctrIface);
if (acm->ctrDevHandle == NULL) {
HDF_LOGE("%
{public}
s: ctrDevHandle UsbOpenInterface null", __func__);
HDF_LOGE("%s: ctrDevHandle UsbOpenInterface null", __func__);
goto error;
}
...
...
@@ -836,7 +836,7 @@ static int32_t AcmAllocRequests(struct AcmDevice *acm)
int32_t ret;
if (AcmWriteBufAlloc(acm) < 0) {
HDF_LOGE("%
{public}
s: AcmWriteBufAlloc failed", __func__);
HDF_LOGE("%s: AcmWriteBufAlloc failed", __func__);
return HDF_ERR_MALLOC_FAIL;
}
...
...
@@ -845,20 +845,20 @@ static int32_t AcmAllocRequests(struct AcmDevice *acm)
snd->request = UsbAllocRequest(InterfaceIdToHandle(acm, acm->dataOutPipe->interfaceId), 0, acm->writeSize); //分配待发送的IO Request对象
snd->instance = acm;
if (snd->request == NULL) {
HDF_LOGE("%
{public}s:%{public}d snd request fail
", __func__, __LINE__);
HDF_LOGE("%
s:%d snd request failed
", __func__, __LINE__);
goto error_alloc_write_req;
}
}
ret = AcmAllocNotifyRequest(acm); //分配并填充中断IO Request对象
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s:%{public}d AcmAllocNotifyRequest fail
", __func__, __LINE__);
HDF_LOGE("%
s:%d AcmAllocNotifyRequest failed
", __func__, __LINE__);
goto error_alloc_int_req;
}
ret = AcmAllocReadRequests(acm); //分配并填充readReq IO Request对象
if (ret) {
HDF_LOGE("%
{public}s:%{public}d AcmAllocReadRequests fail
", __func__, __LINE__);
HDF_LOGE("%
s:%d AcmAllocReadRequests failed
", __func__, __LINE__);
goto error_alloc_read_req;
}
...
...
@@ -879,38 +879,38 @@ static int32_t AcmInit(struct AcmDevice *acm)
struct UsbSession *session = NULL;
if (acm->initFlag == true) {
HDF_LOGE("%
{public}s:%{public}
d: initFlag is true", __func__, __LINE__);
HDF_LOGE("%
s:%
d: initFlag is true", __func__, __LINE__);
return HDF_SUCCESS;
}
ret = UsbInitHostSdk(NULL); //初始化Host DDK
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s: UsbInitHostSdk fail
d", __func__);
HDF_LOGE("%
s: UsbInitHostSdk faile
d", __func__);
return HDF_ERR_IO;
}
acm->session = session;
ret = AcmClaimInterfaces(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s: AcmClaimInterfaces fail
d", __func__);
HDF_LOGE("%
s: AcmClaimInterfaces faile
d", __func__);
goto error_claim_interfaces;
}
ret = AcmOpenInterfaces(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s: AcmOpenInterfaces fail
d", __func__);
HDF_LOGE("%
s: AcmOpenInterfaces faile
d", __func__);
goto error_open_interfaces;
}
ret = AcmGetPipes(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}
s: AcmGetPipes failed", __func__);
HDF_LOGE("%s: AcmGetPipes failed", __func__);
goto error_get_pipes;
}
ret = AcmAllocRequests(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}
s: AcmAllocRequests failed", __func__);
HDF_LOGE("%s: AcmAllocRequests failed", __func__);
goto error_alloc_reqs;
}
...
...
@@ -920,7 +920,7 @@ static int32_t AcmInit(struct AcmDevice *acm)
acm->lineCoding.bDataBits = USB_CDC_1_STOP_BITS;
acm->initFlag = true;
HDF_LOGD("%
{public}s:%{public}
d========OK", __func__, __LINE__);
HDF_LOGD("%
s:%
d========OK", __func__, __LINE__);
return HDF_SUCCESS;
error_alloc_reqs:
...
...
@@ -938,7 +938,7 @@ error_claim_interfaces:
static void AcmRelease(struct AcmDevice *acm)
{
if (acm->initFlag == false) {
HDF_LOGE("%
{public}s:%{public}
d: initFlag is false", __func__, __LINE__);
HDF_LOGE("%
s:%
d: initFlag is false", __func__, __LINE__);
return;
}
...
...
@@ -958,24 +958,24 @@ static int32_t UsbSerialDriverInit(struct HdfDeviceObject *device)
struct AcmDevice *acm = NULL;
if (device == NULL) {
HDF_LOGE("%
{public}
s: device is null", __func__);
HDF_LOGE("%s: device is null", __func__);
return HDF_ERR_INVALID_OBJECT;
}
acm = (struct AcmDevice *)device->service;
OsalMutexInit(&acm->readLock);
OsalMutexInit(&acm->writeLock);
HDF_LOGD("%
{public}s:%{public}d busNum=%{public}d,devAddr=%{public}d",
HDF_LOGD("%
s:%d busNum=%d,devAddr=%d",
__func__, __LINE__, acm->busNum, acm->devAddr);
ret = UsbSerialDeviceAlloc(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s: Serial Device alloc fail
d", __func__);
HDF_LOGE("%
s: Serial Device alloc faile
d", __func__);
}
acm->initFlag = false;
g_acmReleaseFlag = false;
HDF_LOGD("%
{public}s:%{public}
d init ok!", __func__, __LINE__);
HDF_LOGD("%
s:%
d init ok!", __func__, __LINE__);
return ret;
}
...
...
@@ -985,19 +985,19 @@ static void UsbSerialDriverRelease(struct HdfDeviceObject *device)
struct AcmDevice *acm = NULL;
if (device == NULL) {
HDF_LOGE("%
{public}
s: device is NULL", __func__);
HDF_LOGE("%s: device is NULL", __func__);
return;
}
acm = (struct AcmDevice *)device->service;
if (acm == NULL) {
HDF_LOGE("%
{public}
s: acm is null", __func__);
HDF_LOGE("%s: acm is null", __func__);
return;
}
g_acmReleaseFlag = true;
if (acm->initFlag == true) {
HDF_LOGE("%
{public}s:%{public}
d AcmRelease", __func__, __LINE__);
HDF_LOGE("%
s:%
d AcmRelease", __func__, __LINE__);
AcmRelease(acm);
}
UsbSeriaDevicelFree(acm);
...
...
@@ -1006,7 +1006,7 @@ static void UsbSerialDriverRelease(struct HdfDeviceObject *device)
OsalMutexDestroy(&acm->lock);
OsalMemFree(acm);
acm = NULL;
HDF_LOGD("%
{public}s:%{public}
d exit", __func__, __LINE__);
HDF_LOGD("%
s:%
d exit", __func__, __LINE__);
}
struct HdfDriverEntry g_usbSerialDriverEntry = {
...
...
@@ -1097,28 +1097,28 @@ static int UsbGetConfigDescriptor(UsbRawHandle *devHandle, struct UsbRawConfigDe
int ret;
if (devHandle == NULL) {
HDF_LOGE("%
{public}s:%{public}
d devHandle is NULL",
HDF_LOGE("%
s:%
d devHandle is NULL",
__func__, __LINE__);
return HDF_ERR_INVALID_PARAM;
}
ret = UsbRawGetConfiguration(devHandle, &activeConfig);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbRawGetConfiguration failed, ret=%{public}
d",
HDF_LOGE("%
s:%d UsbRawGetConfiguration failed, ret=%
d",
__func__, __LINE__, ret);
return HDF_FAILURE;
}
HDF_LOGE("%
{public}s:%{public}d activeConfig=%{public}
d", __func__, __LINE__, activeConfig);
HDF_LOGE("%
s:%d activeConfig=%
d", __func__, __LINE__, activeConfig);
dev = UsbRawGetDevice(devHandle);
if (dev == NULL) {
HDF_LOGE("%
{public}s:%{public}
d UsbRawGetDevice failed",
HDF_LOGE("%
s:%
d UsbRawGetDevice failed",
__func__, __LINE__);
return HDF_FAILURE;
}
ret = UsbRawGetConfigDescriptor(dev, activeConfig, config);
if (ret) {
HDF_LOGE("UsbRawGetConfigDescriptor failed, ret=%
{public}
dn", ret);
HDF_LOGE("UsbRawGetConfigDescriptor failed, ret=%dn", ret);
return HDF_FAILURE;
}
...
...
@@ -1134,7 +1134,7 @@ static int UsbAllocWriteRequests(struct AcmDevice *acm)
snd->request = UsbRawAllocRequest(acm->devHandle, 0, acm->dataOutEp->maxPacketSize);
snd->instance = acm;
if (snd->request == NULL) {
HDF_LOGE("%
{public}s: UsbRawAllocRequest fail
d", __func__);
HDF_LOGE("%
s: UsbRawAllocRequest faile
d", __func__);
return HDF_ERR_MALLOC_FAIL;
}
}
...
...
@@ -1160,7 +1160,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
return HDF_FAILURE;
}
if (OsalMutexInit(&acm->lock) != HDF_SUCCESS) {
HDF_LOGE("%s:%d OsalMutexInit fail", __func__, __LINE__);
HDF_LOGE("%s:%d OsalMutexInit fail
ed
", __func__, __LINE__);
goto error;
}
...
...
@@ -1172,7 +1172,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
err = memcpy_s((void *)(acm->interfaceIndex), USB_MAX_INTERFACES,
(const void*)info->interfaceNumber, info->interfaceLength);
if (err != EOK) {
HDF_LOGE("%s:%d memcpy_s faile
err=%d",
HDF_LOGE("%s:%d memcpy_s faile
d err=%d",
__func__, __LINE__, err);
goto lock_error;
}
...
...
@@ -1189,7 +1189,7 @@ static int32_t UsbSerialDriverBind(struct HdfDeviceObject *device)
lock_error:
if (OsalMutexDestroy(&acm->lock)) {
HDF_LOGE("%s:%d OsalMutexDestroy fail", __func__, __LINE__);
HDF_LOGE("%s:%d OsalMutexDestroy fail
ed
", __func__, __LINE__);
}
error:
OsalMemFree(acm);
...
...
@@ -1206,7 +1206,7 @@ static int UsbAllocReadRequests(struct AcmDevice *acm)
for (int i = 0; i < ACM_NR; i++) {
acm->readReq[i] = UsbRawAllocRequest(acm->devHandle, 0, size);
if (!acm->readReq[i]) {
HDF_LOGE("readReq request fail
dn
");
HDF_LOGE("readReq request fail
ed
");
return HDF_ERR_MALLOC_FAIL;
}
...
...
@@ -1219,7 +1219,7 @@ static int UsbAllocReadRequests(struct AcmDevice *acm)
ret = UsbRawFillBulkRequest(acm->readReq[i], acm->devHandle, &reqData);
if (ret) {
HDF_LOGE("%
{public}s: FillBulkRequest faile, ret=%{public}
d n",
HDF_LOGE("%
s: FillBulkRequest failed, ret=%
d n",
__func__, ret);
return HDF_FAILURE;
}
...
...
@@ -1236,7 +1236,7 @@ static int UsbAllocNotifyRequest(struct AcmDevice *acm)
acm->notifyReq = UsbRawAllocRequest(acm->devHandle, 0, size);
if (!acm->notifyReq) {
HDF_LOGE("notifyReq request fail
n
");
HDF_LOGE("notifyReq request fail
ed
");
return HDF_ERR_MALLOC_FAIL;
}
...
...
@@ -1249,7 +1249,7 @@ static int UsbAllocNotifyRequest(struct AcmDevice *acm)
ret = UsbRawFillInterruptRequest(acm->notifyReq, acm->devHandle, &fillRequestData);
if (ret) {
HDF_LOGE("%
{public}s: FillInterruptRequest faile, ret=%{public}
d", __func__, ret);
HDF_LOGE("%
s: FillInterruptRequest failed, ret=%
d", __func__, ret);
return HDF_FAILURE;
}
...
...
@@ -1263,62 +1263,62 @@ static int32_t UsbSerialInit(struct AcmDevice *acm)
int32_t ret;
if (acm->initFlag == true) {
HDF_LOGE("%
{public}s:%{public}
d: initFlag is true", __func__, __LINE__);
HDF_LOGE("%
s:%
d: initFlag is true", __func__, __LINE__);
return HDF_SUCCESS;
}
ret = UsbRawInit(NULL);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbRawInit fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbRawInit faile
d", __func__, __LINE__);
return HDF_ERR_IO;
}
acm->session = session;
devHandle = UsbRawOpenDevice(session, acm->busNum, acm->devAddr);
if (devHandle == NULL) {
HDF_LOGE("%
{public}s:%{public}d UsbRawOpenDevice fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbRawOpenDevice faile
d", __func__, __LINE__);
ret = HDF_FAILURE;
goto err_open_device;
}
acm->devHandle = devHandle;
ret = UsbGetConfigDescriptor(devHandle, &acm->config);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbGetConfigDescriptor fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbGetConfigDescriptor faile
d", __func__, __LINE__);
ret = HDF_FAILURE;
goto err_get_desc;
}
ret = UsbParseConfigDescriptor(acm, acm->config);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s:%{public}d UsbParseConfigDescriptor fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbParseConfigDescriptor faile
d", __func__, __LINE__);
ret = HDF_FAILURE;
goto err_parse_desc;
}
ret = AcmWriteBufAlloc(acm);
if (ret < 0) {
HDF_LOGE("%
{public}s:%{public}d AcmWriteBufAlloc fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d AcmWriteBufAlloc faile
d", __func__, __LINE__);
ret = HDF_FAILURE;
goto err_alloc_write_buf;
}
ret = UsbAllocWriteRequests(acm);
if (ret < 0) {
HDF_LOGE("%
{public}s:%{public}d UsbAllocWriteRequests fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbAllocWriteRequests faile
d", __func__, __LINE__);
ret = HDF_FAILURE;
goto err_alloc_write_reqs;
}
ret = UsbAllocNotifyRequest(acm);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbAllocNotifyRequests fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbAllocNotifyRequests faile
d", __func__, __LINE__);
goto err_alloc_notify_req;
}
ret = UsbAllocReadRequests(acm);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbAllocReadRequests fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbAllocReadRequests faile
d", __func__, __LINE__);
goto err_alloc_read_reqs;
}
ret = UsbStartIo(acm);
if (ret) {
HDF_LOGE("%
{public}s:%{public}d UsbAllocReadRequests fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbAllocReadRequests faile
d", __func__, __LINE__);
goto err_start_io;
}
...
...
@@ -1329,13 +1329,13 @@ static int32_t UsbSerialInit(struct AcmDevice *acm)
ret = UsbRawSubmitRequest(acm->notifyReq);
if (ret) {
HDF_LOGE("%
{public}s:%{public}
d UsbRawSubmitRequest failed", __func__, __LINE__);
HDF_LOGE("%
s:%
d UsbRawSubmitRequest failed", __func__, __LINE__);
goto err_submit_req;
}
acm->initFlag = true;
HDF_LOGD("%
{public}s:%{public}
d=========================OK", __func__, __LINE__);
HDF_LOGD("%
s:%
d=========================OK", __func__, __LINE__);
return HDF_SUCCESS;
...
...
@@ -1365,7 +1365,7 @@ err_open_device:
static void UsbSerialRelease(struct AcmDevice *acm)
{
if (acm->initFlag == false) {
HDF_LOGE("%
{public}s:%{public}
d: initFlag is false", __func__, __LINE__);
HDF_LOGE("%
s:%
d: initFlag is false", __func__, __LINE__);
return;
}
...
...
@@ -1394,7 +1394,7 @@ static int32_t UsbSerialDriverInit(struct HdfDeviceObject *device)
int32_t ret;
if (device == NULL) {
HDF_LOGE("%
{public}s:%{public}
d device is null", __func__, __LINE__);
HDF_LOGE("%
s:%
d device is null", __func__, __LINE__);
return HDF_ERR_INVALID_OBJECT;
}
acm = (struct AcmDevice *)device->service;
...
...
@@ -1403,13 +1403,13 @@ static int32_t UsbSerialDriverInit(struct HdfDeviceObject *device)
ret = UsbSerialDeviceAlloc(acm);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}s:%{public}d UsbSerialDeviceAlloc fail
d", __func__, __LINE__);
HDF_LOGE("%
s:%d UsbSerialDeviceAlloc faile
d", __func__, __LINE__);
}
acm->initFlag = false;
g_rawAcmReleaseFlag = false;
HDF_LOGD("%
{public}s:%{public}
d init ok!", __func__, __LINE__);
HDF_LOGD("%
s:%
d init ok!", __func__, __LINE__);
return ret;
}
...
...
@@ -1418,20 +1418,20 @@ static void UsbSerialDriverRelease(struct HdfDeviceObject *device)
{
struct AcmDevice *acm = NULL;
if (device == NULL) {
HDF_LOGE("%
{public}
s: device is NULL", __func__);
HDF_LOGE("%s: device is NULL", __func__);
return;
}
acm = (struct AcmDevice *)device->service;
if (acm == NULL) {
HDF_LOGE("%
{public}
s: acm is null", __func__);
HDF_LOGE("%s: acm is null", __func__);
return;
}
g_rawAcmReleaseFlag = true;
if (acm->initFlag == true) {
HDF_LOGE("%
{public}s:%{public}
d UsbSerialRelease", __func__, __LINE__);
HDF_LOGE("%
s:%
d UsbSerialRelease", __func__, __LINE__);
UsbSerialRelease(acm);
}
UsbSeriaDevicelFree(acm);
...
...
@@ -1440,7 +1440,7 @@ static void UsbSerialDriverRelease(struct HdfDeviceObject *device)
OsalMutexDestroy(&acm->lock);
OsalMemFree(acm);
acm = NULL;
HDF_LOGD("%
{public}s:%{public}
d exit", __func__, __LINE__);
HDF_LOGD("%
s:%
d exit", __func__, __LINE__);
}
struct HdfDriverEntry g_usbSerialRawDriverEntry = {
...
...
@@ -1476,7 +1476,7 @@ if (useHcs == 0) {
/* 创建设备 */
fnDev = (struct UsbFnDevice *)UsbFnDeviceCreate(acm->udcName, &descData);
if (fnDev == NULL) {
HDF_LOGE("%
{public}
s: create usb function device failed", __func__);
HDF_LOGE("%s: create usb function device failed", __func__);
return HDF_FAILURE;
}
...
...
...
@@ -1543,7 +1543,7 @@ int32_t ret;
/* 删除设备 */
ret = UsbFnDeviceRemove(acm->fnDev);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%
{public}
s: remove usb function device failed", __func__);
HDF_LOGE("%s: remove usb function device failed", __func__);
}
return ret;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录