00001
00002
00003
00004
00005 #include "E12.h"
00006 #include "E12fops.h"
00007
00008 int E12Major;
00009
00010 E12_device Global_E12device[E12MAXBOARDS];
00011 extern struct file_operations E12fops;
00012
00013
00014 static int Init_Device(E12_device *device, int number)
00015 {
00016 device->num = number;
00017 device->IRQ = UNSET;
00018 device->address = UNSET;
00019 device->valid = UNSET;
00020 device->dataready = NULL;
00021 init_waitqueue_head(&device->readqueue);
00022 sprintf(device->devicename,E12NAME"-%u",number);
00023 return 0;
00024 }
00025
00026 static int Init_Global_Devices(void)
00027 {
00028 int i;
00029 for(i=0;i<E12MAXBOARDS;i++)
00030 Init_Device(&Global_E12device[i], i);
00031 return 0;
00032 }
00033
00034
00035 int init_module(void)
00036 {
00037
00038 SET_MODULE_OWNER(&E12fops);
00039
00040
00041
00042 E12MESSAGE(" "E12NAME " driver version " E12_DRIVER_V " (c) " __DATE__ "\n");
00043 printk(" N.Z. Gustavson (ngustavson@emacinc.com), Emac.inc\n");
00044
00045 E12Major = register_chrdev(E12MAJORNUM, E12NAME, &E12fops);
00046
00047 if(E12Major < 0)
00048 {
00049 E12MESSAGE(E12NAME" driver failed to register Major Number");
00050 return E12Major;
00051 }
00052
00053 if(E12MAJORNUM!=0)
00054 E12Major = E12MAJORNUM;
00055
00056 Init_Global_Devices();
00057 GENDEBUG(E12NAME" Driver Registered\n");
00058
00059
00060 return 0;
00061 }
00062
00063
00064
00065
00066
00067
00068 void cleanup_module(void)
00069 {
00070
00071
00072 unregister_chrdev(E12Major,E12NAME);
00073 GENDEBUG(E12NAME" driver unloaded\n");
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099