From af57c99395ad7b8fe5c0e25c56713bc0302bf540 Mon Sep 17 00:00:00 2001 From: Zachery Wu Date: Sat, 28 Aug 2021 19:27:41 +0800 Subject: [PATCH] adapter hi3516dv300 for linux-5.10 Signed-off-by: Zachery Wu Change-Id: I815d46214450557580f10edfb4b139442569627b --- model/usb/device/f_generic.c | 8 ++++-- network/src/net_device_adapter.c | 7 +++-- platform/mipi_dsi/mipi_tx_dev.c | 41 ++++++++++++++++++++++++++---- platform/mipi_dsi/mipi_tx_hi35xx.c | 13 ++++++++-- platform/pwm/pwm_hi35xx_linux.c | 4 +++ platform/uart/uart_adapter.c | 10 ++++---- 6 files changed, 67 insertions(+), 16 deletions(-) mode change 100755 => 100644 model/usb/device/f_generic.c mode change 100755 => 100644 network/src/net_device_adapter.c diff --git a/model/usb/device/f_generic.c b/model/usb/device/f_generic.c old mode 100755 new mode 100644 index b5a3c9d..6878c95 --- a/model/usb/device/f_generic.c +++ b/model/usb/device/f_generic.c @@ -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); } diff --git a/network/src/net_device_adapter.c b/network/src/net_device_adapter.c old mode 100755 new mode 100644 index aeae47f..ebf278e --- a/network/src/net_device_adapter.c +++ b/network/src/net_device_adapter.c @@ -17,10 +17,9 @@ */ #include "net_device_adapter.h" - #include #include - +#include #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(); diff --git a/platform/mipi_dsi/mipi_tx_dev.c b/platform/mipi_dsi/mipi_tx_dev.c index 336ae33..ce49737 100644 --- a/platform/mipi_dsi/mipi_tx_dev.c +++ b/platform/mipi_dsi/mipi_tx_dev.c @@ -20,6 +20,10 @@ #include #include #include +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#include +#endif #include #include #include @@ -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, diff --git a/platform/mipi_dsi/mipi_tx_hi35xx.c b/platform/mipi_dsi/mipi_tx_hi35xx.c index fc5b109..dc8a2b8 100644 --- a/platform/mipi_dsi/mipi_tx_hi35xx.c +++ b/platform/mipi_dsi/mipi_tx_hi35xx.c @@ -19,6 +19,7 @@ #include "mipi_tx_hi35xx.h" #include #include +#include #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; diff --git a/platform/pwm/pwm_hi35xx_linux.c b/platform/pwm/pwm_hi35xx_linux.c index 316417f..38c411d 100644 --- a/platform/pwm/pwm_hi35xx_linux.c +++ b/platform/pwm/pwm_hi35xx_linux.c @@ -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; diff --git a/platform/uart/uart_adapter.c b/platform/uart/uart_adapter.c index c554d2e..e817626 100644 --- a/platform/uart/uart_adapter.c +++ b/platform/uart/uart_adapter.c @@ -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; }