!89 adapter hi3516dv300 for linux-5.10

Merge pull request !89 from Zachery Wu/zzzuo
This commit is contained in:
openharmony_ci
2021-08-30 03:51:44 +00:00
committed by Gitee
6 changed files with 67 additions and 16 deletions
Executable → Regular
+6 -2
View File
@@ -1604,7 +1604,11 @@ static void ffs_data_put(struct ffs_data *ffs)
pr_info("%s(): freeing\n", __func__);
ffs_data_clear(ffs);
BUG_ON(waitqueue_active(&ffs->ev.waitq) ||
waitqueue_active(&ffs->ep0req_completion.wait) ||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
swait_active(&ffs->ep0req_completion.wait) ||
#else
waitqueue_active(&ffs->ep0req_completion.wait) ||
#endif
waitqueue_active(&ffs->wait) ||
waitqueue_active(&ffs->wait_que));
destroy_workqueue(ffs->io_completion_wq);
@@ -3428,7 +3432,7 @@ static int ffs_set_inst_name(struct usb_function_instance *fi, const char *name)
{
char name_dev[MAX_NAMELEN] = {0};
snprintf_s(name_dev, MAX_NAMELEN, MAX_NAMELEN - 1,"%s.%s", FUNCTION_GENERIC, name);
if (strlen(name_dev) >= FIELD_SIZEOF(struct ffs_dev, name))
if (strlen(name_dev) >= sizeof_field(struct ffs_dev, name))
return -ENAMETOOLONG;
return ffs_name_dev_adapter(to_f_fs_opts(fi)->dev, name_dev);
}
Executable → Regular
+5 -2
View File
@@ -17,10 +17,9 @@
*/
#include "net_device_adapter.h"
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/version.h>
#include "net_device.h"
#include "net_device_impl.h"
#include "osal_mem.h"
@@ -247,7 +246,11 @@ static int32_t NetDevSetStatus(struct NetDeviceImpl *impl,
dev_close(dev);
ret = HDF_SUCCESS;
} else if (status == NETIF_UP) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)
ret = dev_open(dev, NULL);
#else
ret = dev_open(dev);
#endif
} else {
HDF_LOGE("%s fail : status error!", __func__);
rtnl_unlock();
+36 -5
View File
@@ -20,6 +20,10 @@
#include <linux/fs.h>
#include <linux/semaphore.h>
#include <linux/seq_file.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
#include <linux/proc_fs.h>
#endif
#include <linux/init.h>
#include <linux/kdev_t.h>
#include <linux/miscdevice.h>
@@ -118,7 +122,11 @@ static int32_t RegisterDevice(const char *name, uint8_t id, unsigned short mode,
return HDF_SUCCESS;
}
static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct file_operations *ops)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static int32_t ProcRegister(const char *name, uint32_t id, unsigned short mode, const struct proc_ops *ops)
#else
static int32_t ProcRegister(const char *name, uint32_t id, unsigned short mode, const struct file_operations *ops)
#endif
{
char procName[NAME_LEN + 1];
struct proc_dir_entry* entry = NULL;
@@ -319,7 +327,11 @@ static int32_t MipiDsiDevSetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *arg)
return HDF_ERR_MALLOC_FAIL;
}
if (access_ok(VERIFY_READ, arg, size)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_READ,
#endif
arg, size)) { /* user space */
if (CopyFromUser(temp, arg, size) != 0) {
OsalMemFree(temp);
temp = NULL;
@@ -365,7 +377,11 @@ int32_t MipiDsiDevSetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *arg)
return HDF_ERR_MALLOC_FAIL;
}
if (access_ok(VERIFY_READ, arg, size)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_READ,
#endif
arg, size)) { /* user space */
if (CopyFromUser(temp, arg, size) != 0) {
OsalMemFree(temp);
temp = NULL;
@@ -403,7 +419,11 @@ int32_t MipiDsiDevGetCmd(struct MipiDsiCntlr *cntlr, GetDsiCmdDescTag *arg)
HDF_LOGE("%s: [OsalMemCalloc] error.", __func__);
return HDF_ERR_MALLOC_FAIL;
}
if (access_ok(VERIFY_READ, arg, size)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_READ,
#endif
arg, size)) { /* user space */
if (CopyFromUser(temp, arg, size) != 0) {
HDF_LOGE("%s: [CopyFromUser] failed.", __func__);
goto fail0;
@@ -419,7 +439,11 @@ int32_t MipiDsiDevGetCmd(struct MipiDsiCntlr *cntlr, GetDsiCmdDescTag *arg)
HDF_LOGE("%s: [MipiDsiCntlrRx] failed.", __func__);
goto fail0;
}
if (access_ok(VERIFY_WRITE, arg, size)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_WRITE,
#endif
arg, size)) { /* user space */
if (CopyToUser(arg, temp, size) != 0) {
HDF_LOGE("%s: [CopyToUser] failed.", __func__);
goto fail0;
@@ -579,10 +603,17 @@ static int MipiDsiDevProcOpen(struct inode *inode, struct file *file)
return single_open(file, MipiDsiDevProcShow, NULL);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static const struct proc_ops g_procMipiDsiDevOps = {
.proc_open = MipiDsiDevProcOpen,
.proc_read = seq_read,
};
#else
static const struct file_operations g_procMipiDsiDevOps = {
.open = MipiDsiDevProcOpen,
.read = seq_read,
};
#endif
static const struct file_operations g_mipiTxfOps = {
.open = MipiDsiDevOpen,
+11 -2
View File
@@ -19,6 +19,7 @@
#include "mipi_tx_hi35xx.h"
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/version.h>
#include "hdf_log.h"
#include "securec.h"
#include "osal_time.h"
@@ -688,7 +689,11 @@ static int32_t LinuxCopyToKernel(void *dest, uint32_t max, const void *src, uint
{
int32_t ret;
if (access_ok(VERIFY_READ, src, count)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_READ,
#endif
src, count)) { /* user space */
ret = (copy_from_user(dest, src, count) != 0) ? HDF_FAILURE : HDF_SUCCESS;
if (ret == HDF_FAILURE) {
HDF_LOGE("%s: [copy_from_user] failed.", __func__);
@@ -894,7 +899,11 @@ static int MipiTxDrvGetCmdInfo(GetCmdInfoTag *getCmdInfo)
HDF_LOGE("%s: [MipiTxGetReadFifoData] failed!", __func__);
goto fail0;
}
if (access_ok(VERIFY_WRITE, getCmdInfo->getData, getCmdInfo->getDataSize)) { /* user space */
if (access_ok(
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0)
VERIFY_WRITE,
#endif
getCmdInfo->getData, getCmdInfo->getDataSize)) { /* user space */
if (copy_to_user(getCmdInfo->getData, dataBuf, getCmdInfo->getDataSize) != 0) {
HDF_LOGE("%s: copy_to_user fail", __func__);
goto fail0;
+4
View File
@@ -40,7 +40,11 @@ struct Hi35xxPwmChip {
struct clk *clk;
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
static int Hi35xxPwmApply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state)
#else
static int Hi35xxPwmApply(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state)
#endif
{
struct HiPwmRegs *reg = NULL;
struct Hi35xxPwmChip *hi35xxChip = (struct Hi35xxPwmChip *)chip;
+5 -5
View File
@@ -32,7 +32,7 @@
#define HDF_LOG_TAG hdf_uart_adapter
#define UART_NAME_LEN 20
extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *);
static char g_driverName[UART_NAME_LEN];
static int32_t UartAdapterInit(struct UartHost *host)
@@ -96,9 +96,9 @@ static int32_t UartAdapterRead(struct UartHost *host, uint8_t *data, uint32_t si
oldfs = get_fs();
set_fs(KERNEL_DS);
while (size >= tmp) {
ret = __vfs_read(fp, p + tmp, 1, &pos);
ret = vfs_read(fp, p + tmp, 1, &pos);
if (ret < 0) {
HDF_LOGE("__vfs_read fail %d", ret);
HDF_LOGE("vfs_read fail %d", ret);
break;
}
tmp++;
@@ -123,9 +123,9 @@ static int32_t UartAdapterWrite(struct UartHost *host, uint8_t *data, uint32_t s
}
oldfs = get_fs();
set_fs(KERNEL_DS);
ret = __vfs_write(fp, p, size, &pos);
ret = vfs_write(fp, p, size, &pos);
if (ret < 0) {
HDF_LOGE("__vfs_write fail %d", ret);
HDF_LOGE("vfs_write fail %d", ret);
set_fs(oldfs);
return HDF_FAILURE;
}