• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this list of
8  *    conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11  *    of conditions and the following disclaimer in the documentation and/or other materials
12  *    provided with the distribution.
13  *
14  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
15  *    to endorse or promote products derived from this software without specific prior written
16  *    permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "devsvc_manager_clnt.h"
32 #include "hdf_log.h"
33 #include "hdf_device_desc.h"
34 
35 #define HDF_LOG_TAG USB_TEST_PNP_NOTIFY
36 
37 #ifndef INT32_MAX
38 #define INT32_MAX 0x7fffffff
39 #endif
40 
UsbTestPnpNotifyDispatch(struct HdfDeviceIoClient * client,int32_t cmdId,struct HdfSBuf * data,struct HdfSBuf * reply)41 int32_t UsbTestPnpNotifyDispatch(struct HdfDeviceIoClient *client,
42     int32_t cmdId, struct HdfSBuf *data, struct HdfSBuf *reply)
43 {
44     int32_t ret = HDF_SUCCESS;
45     if (reply == NULL || client == NULL) {
46         return HDF_FAILURE;
47     }
48 
49     HDF_LOGD("%s:%d dispatch success, cmdId=%d", __func__, __LINE__, cmdId);
50 
51     return ret;
52 }
53 
UsbTestPnpNotifyBind(struct HdfDeviceObject * deviceObject)54 int32_t UsbTestPnpNotifyBind(struct HdfDeviceObject *deviceObject)
55 {
56     if (deviceObject == NULL) {
57         return HDF_FAILURE;
58     }
59     static struct IDeviceIoService testService = {
60         .Dispatch = UsbTestPnpNotifyDispatch,
61         .Open = NULL,
62         .Release = NULL,
63     };
64     deviceObject->service = &testService;
65     return HDF_SUCCESS;
66 }
67 
UsbTestPnpNotifyInit(struct HdfDeviceObject * deviceObject)68 int32_t UsbTestPnpNotifyInit(struct HdfDeviceObject *deviceObject)
69 {
70     if (deviceObject == NULL) {
71         HDF_LOGE("%s::ptr is null!", __func__);
72         return HDF_FAILURE;
73     }
74 
75     return HDF_SUCCESS;
76 }
77 
UsbTestPnpNotifyRelease(struct HdfDeviceObject * deviceObject)78 void UsbTestPnpNotifyRelease(struct HdfDeviceObject *deviceObject)
79 {
80     (void)deviceObject;
81     HDF_LOGD("ZXX %s:%d release success", __func__, __LINE__);
82     return;
83 }
84 
85 struct HdfDriverEntry g_usbTestPnpNotifyEntry = {
86     .moduleVersion = 1,
87     .Bind = UsbTestPnpNotifyBind,
88     .Init = UsbTestPnpNotifyInit,
89     .Release = UsbTestPnpNotifyRelease,
90     .moduleName = "usb_test_sample_driver",
91 };
92 
93 HDF_INIT(g_usbTestPnpNotifyEntry);
94