mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-08-27 20:49:55 -04:00
usb 0922 commit
Signed-off-by: bigA2021 <yanyin1@huawei.com> Change-Id: Iecce799f7a24e8ceb98153397a00f3c41fa963f9
This commit is contained in:
@@ -133,7 +133,7 @@ static bool UsbDdkPnpLoaderMatchFlag(const struct UsbPnpNotifyMatchInfoTable *de
|
||||
|
||||
if (id->matchFlag & USB_PNP_NOTIFY_MATCH_INT_CLASS) {
|
||||
for (i = 0; i < id->interfaceClassLength; i++) {
|
||||
if (!((id->interfaceClassMask >> i) & 0x01)) {
|
||||
if (!((uint32_t)(id->interfaceClassMask >> i) & 0x01)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,8 +339,8 @@ static void ParsePipes(struct AcmDevice *acmDevice, struct UsbFnInterface *fnIfa
|
||||
{
|
||||
uint32_t j;
|
||||
int ret;
|
||||
struct UsbFnPipeInfo pipeInfo = {0};
|
||||
for (j = 0; j < fnIface->info.numPipes; j++) {
|
||||
struct UsbFnPipeInfo pipeInfo;
|
||||
ret = UsbFnGetInterfacePipeInfo(fnIface, j, &pipeInfo);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
return;
|
||||
@@ -388,12 +388,11 @@ static int ParseInterfaces(struct AcmDevice *acmDevice)
|
||||
|
||||
static void CtrlComplete(uint8_t pipe, struct UsbFnRequest *req)
|
||||
{
|
||||
struct CtrlInfo *ctrlInfo = (struct CtrlInfo *)req->context;
|
||||
struct AcmDevice *acm = ctrlInfo->acm;
|
||||
|
||||
if (req == NULL) {
|
||||
return;
|
||||
}
|
||||
struct CtrlInfo *ctrlInfo = (struct CtrlInfo *)req->context;
|
||||
struct AcmDevice *acm = ctrlInfo->acm;
|
||||
if (USB_REQUEST_COMPLETED != req->status) {
|
||||
goto out;
|
||||
}
|
||||
@@ -446,7 +445,7 @@ static int32_t SendNotifyRequest(struct AcmDevice *acm, uint8_t type,
|
||||
struct UsbFnRequest *req = acm->notifyReq;
|
||||
struct UsbCdcNotification *notify = NULL;
|
||||
int ret;
|
||||
if (acm == NULL || req->buf) {
|
||||
if ((acm == NULL) || (req == NULL) || (req->buf == NULL) || (data == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
acm->notifyReq = NULL;
|
||||
@@ -592,7 +591,7 @@ static struct UsbFnRequest *GetCtrlReq(struct AcmDevice *acm)
|
||||
return req;
|
||||
}
|
||||
|
||||
static void Setup(struct AcmDevice *acm, struct UsbFnCtrlRequest *setup)
|
||||
static int Setup(struct AcmDevice *acm, struct UsbFnCtrlRequest *setup)
|
||||
{
|
||||
struct UsbFnRequest *req = NULL;
|
||||
struct CtrlInfo *ctrlInfo = NULL;
|
||||
@@ -601,7 +600,7 @@ static void Setup(struct AcmDevice *acm, struct UsbFnCtrlRequest *setup)
|
||||
int ret = 0;
|
||||
req = GetCtrlReq(acm);
|
||||
if (req == NULL) {
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
switch (setup->request) {
|
||||
case USB_DDK_CDC_REQ_SET_LINE_CODING:
|
||||
@@ -616,7 +615,9 @@ static void Setup(struct AcmDevice *acm, struct UsbFnCtrlRequest *setup)
|
||||
if (acm->lineCoding.dwDTERate == 0) {
|
||||
acm->lineCoding = acm->port->lineCoding;
|
||||
}
|
||||
memcpy_s(req->buf, req->length, &acm->lineCoding, ret);
|
||||
if (memcpy_s(req->buf, req->length, &acm->lineCoding, ret) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
break;
|
||||
case USB_DDK_CDC_REQ_SET_CONTROL_LINE_STATE:
|
||||
ret = 0;
|
||||
@@ -631,6 +632,7 @@ out:
|
||||
ctrlInfo->request = setup->request;
|
||||
req->length = ret;
|
||||
ret = UsbFnSubmitRequestAsync(req);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void Suspend(struct AcmDevice *acm)
|
||||
|
||||
@@ -946,6 +946,10 @@ int32_t UsbFnDviceTestAllocCtrlRequest005(void)
|
||||
struct UsbFnRequest *req = NULL;
|
||||
UsbFnInterfaceHandle handle = NULL;
|
||||
|
||||
if (g_acmDevice == NULL) {
|
||||
HDF_LOGE("%s: dataIface.handle is invail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
req = UsbFnAllocCtrlRequest(handle,
|
||||
g_acmDevice->notifyPipe.maxPacketSize);
|
||||
if (req != NULL) {
|
||||
@@ -1093,6 +1097,10 @@ int32_t UsbFnDviceTestAllocRequest004(void)
|
||||
struct UsbFnRequest *req = NULL;
|
||||
UsbFnInterfaceHandle handle = NULL;
|
||||
|
||||
if (g_acmDevice == NULL) {
|
||||
HDF_LOGE("%s: dataIface.handle is invail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
req = UsbFnAllocRequest(handle, g_acmDevice->notifyPipe.id, 0x800);
|
||||
if (req != NULL) {
|
||||
HDF_LOGE("%s: alloc req success!!", __func__);
|
||||
@@ -1594,6 +1602,11 @@ int32_t UsbFnDviceTestStartReceEvent003(void)
|
||||
{
|
||||
int ret;
|
||||
struct UsbFnInterface *fn = NULL;
|
||||
|
||||
if (g_acmDevice == NULL) {
|
||||
HDF_LOGE("%s: dataIface.handle is invail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
ret = UsbFnStartRecvInterfaceEvent(fn, 0xff,
|
||||
EventCallBack, g_acmDevice);
|
||||
if (HDF_SUCCESS == ret) {
|
||||
@@ -1818,6 +1831,10 @@ int32_t UsbFnDviceTestCloseInterface003(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (g_acmDevice == NULL) {
|
||||
HDF_LOGE("%s: dataIface.handle is invail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
ret = UsbFnCloseInterface(g_acmDevice->ctrlIface.handle);
|
||||
if (HDF_SUCCESS == ret) {
|
||||
HDF_LOGE("%s: close interface success!!", __func__);
|
||||
@@ -1831,6 +1848,10 @@ int32_t UsbFnDviceTestCloseInterface004(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (g_acmDevice == NULL) {
|
||||
HDF_LOGE("%s: dataIface.handle is invail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
ret = UsbFnCloseInterface(g_acmDevice->dataIface.handle);
|
||||
if (HDF_SUCCESS == ret) {
|
||||
HDF_LOGE("%s: close interface success!!", __func__);
|
||||
|
||||
@@ -154,7 +154,16 @@ int32_t UsbFnDviceTestRequestAsync004(void)
|
||||
req->context = g_acmDevice;
|
||||
g_acmDevice->submit = 0;
|
||||
dprintf("------send \"abc\" to host------\n");
|
||||
memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc"));
|
||||
if (g_acmDevice->dataInPipe.maxPacketSize < strlen("abc")) {
|
||||
ret = UsbFnFreeRequest(req);
|
||||
if (HDF_SUCCESS != ret) {
|
||||
HDF_LOGE("%s: free Request error", __func__);
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc")) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
req->length = strlen("abc");
|
||||
ret = UsbFnSubmitRequestAsync(req);
|
||||
if (HDF_SUCCESS != ret) {
|
||||
@@ -194,7 +203,9 @@ int32_t UsbFnDviceTestRequestAsync005(void)
|
||||
req->complete = WriteComplete;
|
||||
req->context = g_acmDevice;
|
||||
g_acmDevice->submit = 0;
|
||||
memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "xyz", strlen("xyz"));
|
||||
if (memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "xyz", strlen("xyz")) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
req->length = strlen("xyz");
|
||||
ret = UsbFnSubmitRequestAsync(req);
|
||||
if (HDF_SUCCESS != ret) {
|
||||
@@ -318,7 +329,9 @@ int32_t UsbFnDviceTestRequestSync004(void)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
dprintf("------send \"abc\" to host------\n");
|
||||
memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc"));
|
||||
if (memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc")) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
req->length = strlen("abc");
|
||||
ret = UsbFnSubmitRequestSync(req, 0);
|
||||
if (HDF_SUCCESS != ret || (req->actual != strlen("abc")) || \
|
||||
@@ -352,7 +365,9 @@ int32_t UsbFnDviceTestRequestSync005(void)
|
||||
HDF_LOGE("%s: alloc req fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abcdefg", strlen("abcdefg"));
|
||||
if (memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abcdefg", strlen("abcdefg")) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
req->length = strlen("abcdefg");
|
||||
ret = UsbFnSubmitRequestSync(req, 0);
|
||||
if (HDF_SUCCESS != ret || (req->actual != strlen("abcdefg")) || \
|
||||
@@ -412,7 +427,6 @@ int32_t UsbFnDviceTestRequestSync007(void)
|
||||
|
||||
static void TestCancelComplete(uint8_t pipe, struct UsbFnRequest *req)
|
||||
{
|
||||
dprintf("%s, req->buf = 0x%x\n", __func__, (uint32_t)req->buf);
|
||||
g_acmDevice->havedSubmit = true;
|
||||
}
|
||||
|
||||
@@ -546,7 +560,9 @@ int32_t UsbFnDviceTestCancelRequest005(void)
|
||||
req->complete = TestCancelComplete;
|
||||
req->context = g_acmDevice;
|
||||
dprintf("------send \"abc\" to host------\n");
|
||||
memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc"));
|
||||
if (memcpy_s(req->buf, g_acmDevice->dataInPipe.maxPacketSize, "abc", strlen("abc")) != EOK) {
|
||||
HDF_LOGE("%s:%d memcpy_s fail", __func__, __LINE__);
|
||||
}
|
||||
req->length = strlen("abc");
|
||||
ret = UsbFnSubmitRequestAsync(req);
|
||||
if (HDF_SUCCESS != ret) {
|
||||
|
||||
@@ -172,11 +172,11 @@ int32_t CheckRawSdkIfAllocRequest002(void)
|
||||
for (i = 0; i < ACM_NW; i++) {
|
||||
rawAcm->wb[i].request = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataOutEp.maxPacketSize);
|
||||
rawAcm->wb[i].instance = rawAcm;
|
||||
((struct UsbHostRequest *)(rawAcm->wb[i].request))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
if (rawAcm->wb[i].request == NULL) {
|
||||
HDF_LOGE("%s: error", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
((struct UsbHostRequest *)(rawAcm->wb[i].request))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
}
|
||||
HDF_LOGE("%s: success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
@@ -205,11 +205,11 @@ int32_t CheckRawSdkIfAllocRequest004(void)
|
||||
|
||||
for (i = 0; i < ACM_NR; i++) {
|
||||
rawAcm->readReq[i] = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->dataInEp.maxPacketSize);
|
||||
((struct UsbHostRequest *)(rawAcm->readReq[i]))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
if (rawAcm->readReq[i] == NULL) {
|
||||
HDF_LOGE("%s: error", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
((struct UsbHostRequest *)(rawAcm->readReq[i]))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
}
|
||||
HDF_LOGE("%s: success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
@@ -231,11 +231,11 @@ int32_t CheckRawSdkIfAllocRequest006(void)
|
||||
{
|
||||
struct AcmRawDevice *rawAcm = UsbGetIoAcm();
|
||||
rawAcm->ctrlReq = UsbRawAllocRequest(rawAcm->devHandle, 0, USB_CTRL_REQ_SIZE);
|
||||
((struct UsbHostRequest *)(rawAcm->ctrlReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
if (rawAcm->ctrlReq == NULL) {
|
||||
HDF_LOGE("%s: error", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
((struct UsbHostRequest *)(rawAcm->ctrlReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
HDF_LOGE("%s: success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
@@ -256,11 +256,11 @@ int32_t CheckRawSdkIfAllocRequest008(void)
|
||||
{
|
||||
struct AcmRawDevice *rawAcm = UsbGetIoAcm();
|
||||
rawAcm->notifyReq = UsbRawAllocRequest(rawAcm->devHandle, 0, rawAcm->notifyEp.maxPacketSize);
|
||||
((struct UsbHostRequest *)(rawAcm->notifyReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
if (rawAcm->notifyReq == NULL) {
|
||||
HDF_LOGE("%s: error", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
((struct UsbHostRequest *)(rawAcm->notifyReq))->devHandle = (struct UsbDeviceHandle *)rawAcm->devHandle;
|
||||
HDF_LOGE("%s: success", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user