sonic-buildimage/platform/s3ip-sysfs/demo_driver/include/device_driver_common.h
tianshangfei ea807d7d0b
The demo driver complies with s3ip sysfs specification,which use the s3ip kernel framework (#12895)
Why I did it
A demo driver base on this framework will display the sysfs node wich conform to the s3ip sysfs specification

How I did it
1、 demo driver will call the s3ip kernel framework interface

How to verify it
run the demo ,it will display the sysfs node wich conform to the s3ip sysfs specification
2022-12-14 22:35:33 +08:00

50 lines
1.1 KiB
C

#ifndef _DEVICE_DRIVER_COMMON_H_
#define _DEVICE_DRIVER_COMMON_H_
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/delay.h>
enum LOG_LEVEL{
INFO = 0x1,
ERR = 0x2,
DBG = 0x4,
ALL = 0xf
};
#define LOG_INFO(_prefix, fmt, args...) do { \
if (g_loglevel & INFO) { \
printk( KERN_INFO _prefix "%s "fmt, __FUNCTION__, ##args); \
} \
} while (0)
#define LOG_ERR(_prefix, fmt, args...) do { \
if (g_loglevel & ERR) { \
printk( KERN_ERR _prefix "%s "fmt, __FUNCTION__, ##args); \
} \
} while (0)
#define LOG_DBG(_prefix, fmt, args...) do { \
if (g_loglevel & DBG) { \
printk( KERN_DEBUG _prefix "%s "fmt, __FUNCTION__, ##args); \
} \
} while (0)
#define check_pfun(p) do { \
if (p == NULL) { \
if (g_loglevel & ERR) { \
printk( KERN_ERR "%s, %s is NULL.\n", __FUNCTION__, #p); \
} \
return -ENOSYS; \
} \
} while(0)
#define check_p(p) check_pfun(p)
#endif /* _DEVICE_DRIVER_COMMON_H_ */