mirror of
https://github.com/openharmony/drivers_adapter_khdf_linux.git
synced 2026-07-20 00:54:12 -04:00
usb 0817 commit
Change-Id: Ia0d22b9e2bee0cf6bd76e57ba31db0a2cdfb5fc8 Signed-off-by: bigA2021 <yanyin1@huawei.com>
This commit is contained in:
Regular → Executable
+2
-1
@@ -11,5 +11,6 @@ ccflags-y += -lm -lc -lgcc \
|
||||
-Idrivers/hdf/framework/include \
|
||||
-Idrivers/hdf/framework/include/osal \
|
||||
-Idrivers/hdf/framework/include/platform \
|
||||
-Idrivers/hdf/framework/include/config
|
||||
-Idrivers/hdf/framework/include/config \
|
||||
-I$(PROJECT_ROOT)/third_party/bounds_checking_function/include
|
||||
|
||||
|
||||
Regular → Executable
+17
-16
@@ -488,7 +488,7 @@ static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf, siz
|
||||
const size_t size = n * sizeof *events;
|
||||
unsigned i = 0;
|
||||
|
||||
memset(events, 0, size);
|
||||
memset_s(events, size, 0, size);
|
||||
|
||||
do {
|
||||
events[i].type = ffs->ev.types[i];
|
||||
@@ -500,7 +500,7 @@ static ssize_t __ffs_ep0_read_events(struct ffs_data *ffs, char __user *buf, siz
|
||||
|
||||
ffs->ev.count -= n;
|
||||
if (ffs->ev.count)
|
||||
memmove(ffs->ev.types, ffs->ev.types + n,
|
||||
memmove_s(ffs->ev.types, ffs->ev.count * sizeof *ffs->ev.types, ffs->ev.types + n,
|
||||
ffs->ev.count * sizeof *ffs->ev.types);
|
||||
|
||||
spin_unlock_irq(&ffs->ev.waitq.lock);
|
||||
@@ -765,9 +765,9 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
|
||||
if (unlikely(!p))
|
||||
return -ENOMEM;
|
||||
} else {
|
||||
memset(p, 0, sizeof(*p));
|
||||
memset_s(p, sizeof(struct ffs_io_data), 0, sizeof(*p));
|
||||
}
|
||||
memcpy(p, &myIoData, sizeof(struct IoData));
|
||||
memcpy_s(p, sizeof(struct ffs_io_data), &myIoData, sizeof(struct IoData));
|
||||
ret = ffs_ep0_iorw(file, p);
|
||||
if (ret == -EIOCBQUEUED) {
|
||||
return 0;
|
||||
@@ -1272,9 +1272,9 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, unsigned long val
|
||||
return -ENOMEM;
|
||||
}
|
||||
} else {
|
||||
memset(p, 0, sizeof(*p));
|
||||
memset_s(p, sizeof(struct ffs_io_data), 0, sizeof(*p));
|
||||
}
|
||||
memcpy(p,&myIoData,sizeof(struct IoData));
|
||||
memcpy_s(p, sizeof(struct ffs_io_data), &myIoData, sizeof(struct IoData));
|
||||
spin_unlock_irq(&epfile->ffs->eps_lock);
|
||||
ret = ffs_epfile_iorw(file, p);
|
||||
if (ret == -EIOCBQUEUED) {
|
||||
@@ -1470,13 +1470,13 @@ static long usbfn_ioctl(struct file *file, unsigned int cmd, unsigned long value
|
||||
if (unlikely(!ffs))
|
||||
return (-ENOMEM);
|
||||
|
||||
memcpy(ffs->dev_name, newfn.name, newfn.nameLen);
|
||||
memcpy_s(ffs->dev_name, MAX_NAMELEN, newfn.name, newfn.nameLen);
|
||||
if (unlikely(!ffs->dev_name)) {
|
||||
ffs_data_put(ffs);
|
||||
return (-ENOMEM);
|
||||
}
|
||||
|
||||
sprintf(nameEp0, "%s.ep%u", ffs->dev_name, 0);
|
||||
sprintf_s(nameEp0, MAX_NAMELEN, "%s.ep%u", ffs->dev_name, 0);
|
||||
ffs_dev = ffs_acquire_dev(newfn.name);
|
||||
if (IS_ERR(ffs_dev)) {
|
||||
ffs_data_put(ffs);
|
||||
@@ -1760,9 +1760,9 @@ static int ffs_epfiles_create(struct ffs_data *ffs)
|
||||
INIT_LIST_HEAD(&epfile->memory_list);
|
||||
init_waitqueue_head(&epfile->wait_que);
|
||||
if (ffs->user_flags & FUNCTIONFS_VIRTUAL_ADDR)
|
||||
sprintf(epfile->name, "%s.ep%02x", ffs->dev_name, ffs->eps_addrmap[i]);
|
||||
sprintf_s(epfile->name, MAX_NAMELEN, "%s.ep%02x", ffs->dev_name, ffs->eps_addrmap[i]);
|
||||
else
|
||||
sprintf(epfile->name, "%s.ep%u", ffs->dev_name, i);
|
||||
sprintf_s(epfile->name, MAX_NAMELEN, "%s.ep%u", ffs->dev_name, i);
|
||||
|
||||
cdev_init(&epfile->cdev, &ffs_epfile_operations);
|
||||
epfile->devno=MKDEV(MAJOR(ffs->devno), i);
|
||||
@@ -2809,7 +2809,8 @@ static int __ffs_func_bind_do_os_desc(enum ffs_os_desc_type type,
|
||||
|
||||
t = &func->function.os_desc_table[desc->bFirstInterfaceNumber];
|
||||
t->if_id = func->interfaces_nums[desc->bFirstInterfaceNumber];
|
||||
memcpy(t->os_desc->ext_compat_id, &desc->CompatibleID,
|
||||
memcpy_s(t->os_desc->ext_compat_id, ARRAY_SIZE(desc->CompatibleID) +
|
||||
ARRAY_SIZE(desc->SubCompatibleID), &desc->CompatibleID,
|
||||
ARRAY_SIZE(desc->CompatibleID) +
|
||||
ARRAY_SIZE(desc->SubCompatibleID));
|
||||
length = sizeof(*desc);
|
||||
@@ -2841,7 +2842,7 @@ static int __ffs_func_bind_do_os_desc(enum ffs_os_desc_type type,
|
||||
ext_prop_data = func->ffs->ms_os_descs_ext_prop_data_avail;
|
||||
func->ffs->ms_os_descs_ext_prop_data_avail +=
|
||||
ext_prop->data_len;
|
||||
memcpy(ext_prop_data,
|
||||
memcpy_s(ext_prop_data, ext_prop->data_len,
|
||||
usb_ext_prop_data_ptr(data, ext_prop->name_len),
|
||||
ext_prop->data_len);
|
||||
/* unicode data reported to the host as "WCHAR"s */
|
||||
@@ -2855,7 +2856,7 @@ static int __ffs_func_bind_do_os_desc(enum ffs_os_desc_type type,
|
||||
}
|
||||
ext_prop->data = ext_prop_data;
|
||||
|
||||
memcpy(ext_prop_name, usb_ext_prop_name_ptr(data),
|
||||
memcpy_s(ext_prop_name, ext_prop->name_len, usb_ext_prop_name_ptr(data),
|
||||
ext_prop->name_len);
|
||||
/* property name reported to the host as "WCHAR"s */
|
||||
ext_prop->name_len *= 2;
|
||||
@@ -2978,10 +2979,10 @@ static int _ffs_func_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
vla_ptr(vlabuf, d, ext_prop_data);
|
||||
|
||||
/* Copy descriptors */
|
||||
memcpy(vla_ptr(vlabuf, d, raw_descs), ffs->raw_descs,
|
||||
memcpy_s(vla_ptr(vlabuf, d, raw_descs), ffs->raw_descs_length, ffs->raw_descs,
|
||||
ffs->raw_descs_length);
|
||||
|
||||
memset(vla_ptr(vlabuf, d, inums), 0xff, d_inums__sz);
|
||||
memset_s(vla_ptr(vlabuf, d, inums), d_inums__sz, 0xff, d_inums__sz);
|
||||
eps_ptr = vla_ptr(vlabuf, d, eps);
|
||||
for (i = 0; i < ffs->eps_count; i++)
|
||||
eps_ptr[i].num = -1;
|
||||
@@ -3426,7 +3427,7 @@ static void ffs_free_inst(struct usb_function_instance *f)
|
||||
static int ffs_set_inst_name(struct usb_function_instance *fi, const char *name)
|
||||
{
|
||||
char name_dev[MAX_NAMELEN] = {0};
|
||||
sprintf(name_dev,"%s.%s",FUNCTION_GENERIC,name);
|
||||
sprintf_s(name_dev, MAX_NAMELEN, "%s.%s", FUNCTION_GENERIC, name);
|
||||
if (strlen(name_dev) >= FIELD_SIZEOF(struct ffs_dev, name))
|
||||
return -ENAMETOOLONG;
|
||||
return ffs_name_dev_adapter(to_f_fs_opts(fi)->dev, name_dev);
|
||||
|
||||
Regular → Executable
+2
-1
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
#include <linux/nls.h>
|
||||
#include "securec.h"
|
||||
|
||||
#define USB_EXT_PROP_DW_SIZE 0
|
||||
#define USB_EXT_PROP_DW_PROPERTY_DATA_TYPE 4
|
||||
@@ -97,7 +98,7 @@ static inline void usb_ext_prop_put_binary(u8 *buf, int pnl, const u8 *data,
|
||||
int data_len)
|
||||
{
|
||||
put_unaligned_le32(data_len, usb_ext_prop_data_len_ptr(buf, pnl));
|
||||
memcpy(usb_ext_prop_data_ptr(buf, pnl), data, data_len);
|
||||
memcpy_s(usb_ext_prop_data_ptr(buf, pnl), data_len, data, data_len);
|
||||
}
|
||||
|
||||
static inline int usb_ext_prop_put_unicode(u8 *buf, int pnl, const char *string,
|
||||
|
||||
Regular → Executable
+2
-1
@@ -26,4 +26,5 @@ ccflags-y += -lm -lc -lgcc \
|
||||
-Idrivers/hdf/framework/include \
|
||||
-Idrivers/hdf/framework/include/osal \
|
||||
-Idrivers/hdf/framework/include/platform \
|
||||
-Idrivers/hdf/framework/include/config
|
||||
-Idrivers/hdf/framework/include/config \
|
||||
-I$(PROJECT_ROOT)/third_party/bounds_checking_function/include
|
||||
|
||||
Regular → Executable
+5
-3
@@ -24,6 +24,7 @@
|
||||
#include "hdf_device_desc.h"
|
||||
#include "hdf_log.h"
|
||||
#include "osal_mem.h"
|
||||
#include "securec.h"
|
||||
|
||||
#define HDF_LOG_TAG USB_PNP_NOTIFY
|
||||
|
||||
@@ -59,7 +60,8 @@ static struct UsbPnpDeviceInfo *UsbPnpNotifyCreateInfo(void)
|
||||
OsalMutexInit(&infoTemp->lock);
|
||||
infoTemp->status = USB_PNP_DEVICE_INIT_STATUS;
|
||||
DListHeadInit(&infoTemp->list);
|
||||
memset(infoTemp->interfaceRemoveStatus, 0, sizeof(infoTemp->interfaceRemoveStatus));
|
||||
memset_s(infoTemp->interfaceRemoveStatus, USB_PNP_INFO_MAX_INTERFACES,
|
||||
0, sizeof(infoTemp->interfaceRemoveStatus));
|
||||
DListInsertTail(&infoTemp->list, &g_usbPnpInfoListHead);
|
||||
|
||||
return infoTemp;
|
||||
@@ -364,7 +366,7 @@ static int32_t UsbPnpNotifyHdfSendEvent(const struct HdfDeviceObject *deviceObje
|
||||
goto out;
|
||||
}
|
||||
|
||||
HDF_LOGI("%s:%d report one device information, %d usbDevAddr=%px, devNum=%d, busNum=%d, infoTable=%d-0x%x-0x%x!",
|
||||
HDF_LOGI("%s:%d report one device information, %d usbDevAddr=0x%x, devNum=%d, busNum=%d, infoTable=%d-0x%x-0x%x!",
|
||||
__func__, __LINE__, g_usbPnpNotifyCmdType, deviceInfo->info.usbDevAddr, deviceInfo->info.devNum,
|
||||
deviceInfo->info.busNum, deviceInfo->info.numInfos, deviceInfo->info.deviceInfo.vendorId,
|
||||
deviceInfo->info.deviceInfo.productId);
|
||||
@@ -402,7 +404,7 @@ static void TestReadPnpInfo(struct HdfSBuf *data)
|
||||
|
||||
flag = HdfSbufReadBuffer(data, (const void **)(&g_testUsbPnpInfo), &infoSize);
|
||||
if ((flag == false) || (g_testUsbPnpInfo == NULL)) {
|
||||
HDF_LOGE("%{public}s: fail to read g_testUsbPnpInfo, flag=%{public}d, g_testUsbPnpInfo=%{public}px", \
|
||||
HDF_LOGE("%s: fail to read g_testUsbPnpInfo, flag=%d, g_testUsbPnpInfo=%px", \
|
||||
__func__, flag, g_testUsbPnpInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user