1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef OSAL_CDEV_H 10 #define OSAL_CDEV_H 11 12 #include "osal_cdev_adapter.h" 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif /* __cplusplus */ 17 18 #ifndef __user 19 #define __user 20 #endif 21 22 struct OsalCdev; 23 struct file; 24 25 struct OsalCdevOps { 26 int64_t (*seek)(struct file *filep, int64_t offset, int whence); 27 ssize_t (*read)(struct file *filep, char __user *buffer, size_t buflen, int64_t *offset); 28 ssize_t (*write)(struct file *filep, const char __user *buffer, size_t buflen, int64_t *offset); 29 unsigned int (*poll)(struct file *filep, poll_table *pollTable); 30 long (*ioctl)(struct file *filep, unsigned int cmd, unsigned long arg); 31 int (*open)(struct OsalCdev *cdev, struct file *filep); 32 int (*release)(struct OsalCdev *cdev, struct file *filep); 33 }; 34 35 struct OsalCdev *OsalAllocCdev(const struct OsalCdevOps *fops); 36 int OsalRegisterCdev(struct OsalCdev *cdev, const char *name, unsigned int mode, void *priv); 37 void OsalUnregisterCdev(struct OsalCdev *cdev); 38 void OsalFreeCdev(struct OsalCdev *cdev); 39 40 void *OsalGetCdevPriv(struct OsalCdev *cdev); 41 42 void OsalSetFilePriv(struct file *filep, void *priv); 43 void *OsalGetFilePriv(struct file *filep); 44 45 #ifdef __cplusplus 46 } 47 #endif /* __cplusplus */ 48 49 #endif /* OSAL_CDEV_H */ 50 /** @} */ 51