device.c:
#include <stdio.h>
#include <string.h>
#include "device.h"
device_interface_t g_device;
int register_dev(const char* name, device_interface_t *devi)
{
if(devi == NULL) {
printf("%d: devi is NULL!\n",__LINE__ + 1);
return -__LINE__;
}
if(name == NULL || devi->methods == NULL || devi->pdev == NULL) {
printf("%d: name or methods or pdev is NULL!\n",__LINE__ + 1);
return -__LINE__;
}
g_device.methods = devi->methods;
g_device.pdev = devi->pdev;
return 0;
}
|