From: Rostislav Lisovy Date: Sat, 5 Mar 2011 01:48:47 +0000 (+0100) Subject: Changes in Hudaqlib to make it work with MF614 (only this card for now) through UIO. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/mf6xx.git/commitdiff_plain/d63037c5606b148d28e231d6782accaac4c18f58 Changes in Hudaqlib to make it work with MF614 (only this card for now) through UIO. --- diff --git a/src/HuLinux-2.4.3/hudaq_internal.h b/src/HuLinux-2.4.3/hudaq_internal.h index d9acc22..b55b250 100644 --- a/src/HuLinux-2.4.3/hudaq_internal.h +++ b/src/HuLinux-2.4.3/hudaq_internal.h @@ -15,26 +15,26 @@ #define __int32 int #ifndef max - #define max(x,y) (((x)>(y))?(x):(y)) + #define max(x,y) (((x) > (y)) ? (x) : (y)) #endif #ifndef min - #define min(x,y) (((x)>(y))?(x):(y)) + #define min(x,y) (((x) > (y)) ? (x) : (y)) #endif /** * Resource information structure obtained from low level kernel driver. -*/ + */ typedef struct { - size_t Size; ///< Size of this structure. - int NumPhysMemResources; ///< Amount of memory mapped ranges in particular device. - HudaqResourceRange PhysMemResources[8];///< Memory resources available for user access. - HudaqResourceInfo Resources; ///< External structure for users - size_t DriverDataSize; ///< Size of shared memory among all applications. - void* DriverData; ///< Internal data for one device shared across all applications. - - // TODO: these two items are planned to be filled from kernel driver + size_t Size; ///< Size of this structure. + int NumPhysMemResources; ///< Amount of memory-mapped ranges in particular device. + HudaqResourceRange PhysMemResources[8]; ///< Memory resources available for user access. + HudaqResourceInfo Resources; ///< External structure for users + size_t DriverDataSize; ///< Size of shared memory among all applications. + void* DriverData; ///< Internal data for one device shared across all applications. + unsigned int UioDevNum; ///< Which UIO device handles our card + // TODO: these two items are planned to be filled from kernel driver } DriverRecord; @@ -43,12 +43,12 @@ typedef struct CallTable; /** Device record that contains common information about general device resources. */ typedef struct { -//HANDLE SysHandle; ///< System handle assigned from kernel driver - char Name[256]; ///< Device name in ASCII - int Order; ///< Order of device - DriverRecord DrvRes; ///< Kernel resource info + //HANDLE SysHandle; ///< System handle assigned from kernel driver + char Name[256]; ///< Device name in ASCII + int Order; ///< Order of device + DriverRecord DrvRes; ///< Kernel resource info - const struct CallTable *pCT; ///< Interface functions + const struct CallTable *pCT; ///< Interface functions } DeviceRecord; @@ -56,11 +56,11 @@ typedef struct #if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 - #ifdef HUDAQAPI - #undef HUDAQAPI - #define HUDAQAPI __attribute__ ((visibility("default"))) - #pragma visibility(hidden) - #endif +#ifdef HUDAQAPI +#undef HUDAQAPI +#define HUDAQAPI __attribute__ ((visibility("default"))) +#pragma visibility(hidden) +#endif #endif int timeGetTime(void); diff --git a/src/HuLinux-2.4.3/hudaqlib.h b/src/HuLinux-2.4.3/hudaqlib.h index 43099cf..89c1cc5 100644 --- a/src/HuLinux-2.4.3/hudaqlib.h +++ b/src/HuLinux-2.4.3/hudaqlib.h @@ -218,6 +218,8 @@ typedef struct { size_t Base; ///< Base addres/IO port. size_t Length; ///< Amount resources. + unsigned int UioMappingIndex; ///< With UIO driver, we are doing mmap on /dev/uioX; + //for different mappings we just add Index*PAGESIZE as offset } HudaqResourceRange; diff --git a/src/HuLinux-2.4.3/opendevh.c b/src/HuLinux-2.4.3/opendevh.c index 8a60409..bd8efe4 100644 --- a/src/HuLinux-2.4.3/opendevh.c +++ b/src/HuLinux-2.4.3/opendevh.c @@ -19,191 +19,159 @@ static int sysfs_get_value(const char *FileName) FILE *F; int RetVal; - F=fopen(FileName,"rb"); - if(F==NULL) return -1; + F = fopen(FileName, "rb"); + if(F == NULL) + return -1; - fscanf(F,"%X",&RetVal); + fscanf(F, "%X", &RetVal); fclose(F); return RetVal; } static int ScanSys(DWORD DeviceID, int deviceorder, DriverRecord *Rec) { - DIR *dir; + DIR *dir_uio, *dir_memmaps; FILE *F; char ch; - struct dirent *entry; + struct dirent *direntry_uio, *direntry_memmaps; unsigned vendor_id; unsigned device_id; char FileName[1024]; - const char *SysDir="/sys/bus/pci/devices"; + const char *SysDir="/sys/class/uio/"; unsigned long long start, end, size; - DWORD Resources[14]; + unsigned int index; + DWORD Resources[7 * 3]; int i; - int RetVal=0; + int j = 0; + int RetVal = 0; - if(deviceorder <= 0) return -1; - if(Rec==NULL) return -2; + if(deviceorder <= 0) + return -1; + if(Rec == NULL) + return -2; Rec->NumPhysMemResources = Rec->Resources.NumIOResources = 0; - sprintf(FileName,"%s",SysDir); - dir = opendir(FileName); - if(!dir) + sprintf(FileName, "%s", SysDir); + dir_uio = opendir(FileName); + if(!dir_uio) { - //fprintf(stderr,"Cannot open /sys/bus/pci/devices"); + perror("opendir()"); return -3; } - while ((entry = readdir(dir))) + while (direntry_uio = readdir(dir_uio)) { - if(entry->d_name[0]=='.') continue; + if((strcmp((direntry_uio->d_name), ".") == 0) || + (strcmp((direntry_uio->d_name), "..") == 0)) + { + continue; + } - sprintf(FileName,"%s/%s/vendor",SysDir,entry->d_name); + sprintf(FileName, "%s/%s/device/vendor", SysDir, direntry_uio->d_name); vendor_id = sysfs_get_value(FileName); - sprintf(FileName,"%s/%s/device",SysDir,entry->d_name); + sprintf(FileName, "%s/%s/device/device", SysDir, direntry_uio->d_name); device_id = sysfs_get_value(FileName); - memset(Resources, 0, sizeof(Resources)); - sprintf(FileName,"%s/%s/resource",SysDir,entry->d_name); - F=fopen(FileName,"rb"); - if(F) - { - for(i=0;i<7;i++) + + //Fixme search also through iomaps; add into the same Resources array + memset(Resources, 0, sizeof(Resources)); + sprintf(FileName, "%s/%s/maps", SysDir, direntry_uio->d_name); + dir_memmaps = opendir(FileName); + if (!dir_memmaps) { + perror("opendir()"); + printf("%s\n", FileName); + return -3; + } + while (direntry_memmaps = readdir(dir_memmaps)) { + if((strcmp(direntry_memmaps->d_name, ".") == 0) || (strcmp(direntry_memmaps->d_name, "..") == 0)) + continue; + + //printf("maps: %s\n", direntry_memmaps->d_name); + sprintf(FileName, "%s/%s/maps/%s/addr", SysDir, direntry_uio->d_name, direntry_memmaps->d_name); + F = fopen(FileName, "rb"); + if(F) { - if(fscanf(F,"%llx %llx", &start, &end) != 2) + if(fscanf(F, "%llx", &start) != 1) { - fprintf(stderr,"Syntax error in %s", FileName); + fprintf(stderr, "Syntax error in %s", FileName); break; } - do - { - ch=fgetc(F); - if(feof(F)) break; - } while(ch!='\r' && ch!='\n' && ch!=0); - - if(start) - size = end - start + 1; - else - size = 0; - - Resources[i]=start; - Resources[i+7]=size; + + Resources[j] = start; + fclose(F); } - fclose(F); - } - if(DeviceID==(device_id+(vendor_id<<16))) - { - //printf("DEVICE HAS BEEN FOUND!"); - if(--deviceorder<1) + sprintf(FileName, "%s/%s/maps/%s/size", SysDir, direntry_uio->d_name, direntry_memmaps->d_name); + F = fopen(FileName, "rb"); + if(F) { - for(i=0;i<7;i++) + if(fscanf(F, "%llx", &size) != 1) { - if(Resources[i]!=0) - { - if(Resources[i] > 0xFFFF) - { - Rec->PhysMemResources[Rec->NumPhysMemResources].Base=Resources[i]; - Rec->PhysMemResources[Rec->NumPhysMemResources].Length=Resources[i+7]; - Rec->NumPhysMemResources++; - } - else - { - Rec->Resources.IOResources[Rec->Resources.NumIOResources].Base=Resources[i]; - Rec->Resources.IOResources[Rec->Resources.NumIOResources].Length=Resources[i+7]; - Rec->Resources.NumIOResources++; - } - } + fprintf(stderr, "Syntax error in %s", FileName); + break; } - RetVal=1; //device has been found!! - break; - } - } - - // printf("%X %X %s\n", vendor_id, device_id, entry->d_name); - } - - closedir(dir); - return RetVal; -} - -static int ScanProc(DWORD DeviceID, int deviceorder, DriverRecord *Rec) -{ - FILE *devices; - DWORD DevTblID; - DWORD DevPos, DevInt; - DWORD Resources[14]; - int i; - char ch; - int RetVal=0; - - if(deviceorder <= 0) return -1; - if(Rec==NULL) return -2; - - Rec->NumPhysMemResources = Rec->Resources.NumIOResources = 0; - - //devices=fopen("devices","rb"); - devices=fopen("/proc/bus/pci/devices","rb"); - if(devices==NULL) return -4; - - /* loop over devices */ - while (!feof(devices)) - { - if(fscanf(devices,"%X %X %X", &DevPos, &DevTblID, & DevInt)!=3) - return -5; - - memset(Resources, 0, sizeof(Resources)); - for(i=0; i<14; i++) - { - if(fscanf(devices,"%X", &Resources[i])!=1) - { - if(i==6 || i==7) break; //correct - break; //strange + Resources[j + 7] = size; + + fclose(F); } + + + index = atoi((direntry_memmaps->d_name) + 3); // "+3", because we have to skip over the word "map" + Resources[j + 7 + 7] = index; + j ++; } - do { - ch=fgetc(devices); - if(feof(devices)) break; - } while(ch!='\r' && ch!='\n' && ch!=0); + + closedir(dir_memmaps); - if(DeviceID==DevTblID) + if(DeviceID == (device_id + (vendor_id << 16))) { - if(--deviceorder<1) + printf("DEVICE HAS BEEN FOUND!\n"); + if(--deviceorder < 1) { - for(i=0;i<7;i++) + for(i = 0; i < 7; i++) { - if(Resources[i]!=0) + if(Resources[i] != 0) { - if(Resources[i] & 1) + if(Resources[i] > 0xFFFF) { - Rec->Resources.IOResources[Rec->Resources.NumIOResources].Base = Resources[i] & ~1; - Rec->Resources.IOResources[Rec->Resources.NumIOResources].Length=Resources[i+7]; - Rec->Resources.NumIOResources++; + Rec->PhysMemResources[Rec->NumPhysMemResources].Base = Resources[i]; + Rec->PhysMemResources[Rec->NumPhysMemResources].Length = Resources[i + 7]; + Rec->PhysMemResources[Rec->NumPhysMemResources].UioMappingIndex = + Resources[i + 7 + 7]; + Rec->NumPhysMemResources ++; } else { - Rec->PhysMemResources[Rec->NumPhysMemResources].Base=Resources[i]; - Rec->PhysMemResources[Rec->NumPhysMemResources].Length=Resources[i+7]; - Rec->NumPhysMemResources++; + Rec->Resources.IOResources[Rec->Resources.NumIOResources].Base = Resources[i]; + Rec->Resources.IOResources[Rec->Resources.NumIOResources].Length = Resources[i + 7]; + Rec->Resources.IOResources[Rec->Resources.NumIOResources].UioMappingIndex = + Resources[i + 7 + 7]; + Rec->Resources.NumIOResources ++; } } } - RetVal=1; //device has been found!! + + Rec->UioDevNum = atoi((direntry_uio->d_name) + 3); //number of uio device + + RetVal = 1; //device has been found!! break; } - } + } + + //printf("%X %X %s\n", vendor_id, device_id, direntry_uio->d_name); } - fclose(devices); - return(RetVal); + closedir(dir_uio); + return RetVal; } + /***************************************************************************** ;* ;* OpenDeviceHandle @@ -216,46 +184,45 @@ static int ScanProc(DWORD DeviceID, int deviceorder, DriverRecord *Rec) ;****************************************************************************/ int OpenDeviceHandle(const char *devicename, int deviceorder, DriverRecord *Rec) { - DWORD DeviceID=0; + DWORD DeviceID = 0; int RetVal; - if(deviceorder <= 0) return -1; - if(Rec==NULL) return -2; + if(deviceorder <= 0) + return -1; + if(Rec == NULL) + return -2; /* Humusoft */ #ifdef MF61X - if(!strcmp(devicename,"AD612")) DeviceID=0x186C0612; - if(!strcmp(devicename,"MF614")) DeviceID=0x186C0614; + if(!strcmp(devicename,"AD612")) DeviceID = 0x186C0612; /*DeviceID = (Device_ID & (Vendor_ID << 16))*/ + if(!strcmp(devicename,"MF614")) DeviceID = 0x186C0614; #endif #ifdef MF62X - if(!strcmp(devicename,"AD622")) DeviceID=0x186C0622; - if(!strcmp(devicename,"MF624")) DeviceID=0x186C0624; - if(!strcmp(devicename,"MF625")) DeviceID=0x186C0625; + if(!strcmp(devicename,"AD622")) DeviceID = 0x186C0622; + if(!strcmp(devicename,"MF624")) DeviceID = 0x186C0624; + if(!strcmp(devicename,"MF625")) DeviceID = 0x186C0625; #endif /* Advantech */ #ifdef PCI1753 - if(!strcmp(devicename,"PCI1753")) DeviceID=0x13FE1753; + if(!strcmp(devicename,"PCI1753")) DeviceID = 0x13FE1753; #endif /* Tedia */ #ifdef PCD7004 - if(!strcmp(devicename,"PCD7004")) DeviceID=0x17600101; + if(!strcmp(devicename,"PCD7004")) DeviceID = 0x17600101; #endif #ifdef PCT7303B - if(!strcmp(devicename,"PCT7303B")) DeviceID=0x17600201; + if(!strcmp(devicename,"PCT7303B")) DeviceID = 0x17600201; #endif //printf("\n%s deviceID = %X", devicename, DeviceID); - if(DeviceID==0) return -3; + if(DeviceID == 0) + return -3; RetVal = ScanSys(DeviceID, deviceorder, Rec); - if(RetVal>0) return RetVal; - RetVal = ScanProc(DeviceID, deviceorder, Rec); - if(RetVal>0) return RetVal; - - return(RetVal); + return RetVal; } diff --git a/src/HuLinux-2.4.3/resources.c b/src/HuLinux-2.4.3/resources.c index b61a019..7c962fe 100644 --- a/src/HuLinux-2.4.3/resources.c +++ b/src/HuLinux-2.4.3/resources.c @@ -22,7 +22,7 @@ #ifdef _MSC_VER -#pragma comment(lib, "setupapi") + #pragma comment(lib, "setupapi") #endif //_MSC_VER @@ -51,25 +51,23 @@ const CallTable * const AllCTs[] = int OpenDeviceHandle(const char* devicename, int deviceorder, DriverRecord *Rec); -static uintptr_t device_mmap_range(int fd, uintptr_t mem_start, size_t mem_length) +static uintptr_t device_mmap_range(int device_fd, uintptr_t mem_start, size_t mem_length, unsigned int mmap_offset) { size_t pagesize; unsigned char *mm; unsigned char *ptr; - pagesize=getpagesize(); - mem_length+=(mem_start & (pagesize-1))+pagesize-1; - mem_length&=~(pagesize-1); + pagesize = getpagesize(); + //mem_length += (mem_start & (pagesize-1))+pagesize-1; + //mem_length &= ~(pagesize-1); - mm = mmap(NULL, mem_length, PROT_WRITE|PROT_READ, - MAP_SHARED, fd, mem_start & ~(pagesize-1)); - if ((mm == NULL) || (mm == (unsigned char*)-1)) { - fprintf(stderr,"\nHudaqlib: mmap FAILED for range 0x%08lx length 0x%08lx\n", - (long)mem_start,(long)mem_length); + mm = mmap(0, mem_length, PROT_READ | PROT_WRITE, MAP_SHARED, device_fd, mmap_offset * getpagesize()); + if ((mm == NULL) || (mm == MAP_FAILED)) { + perror("mmap()"); return 0; } - ptr=mm + (mem_start & (pagesize-1)); + ptr = mm + (mem_start & (pagesize-1)); //fprintf(stderr,"mmap OK for range 0x%08lx length 0x%08lx -> 0x%08lx\n", // (long)mem_start,(long)mem_length,(long)ptr); @@ -82,55 +80,53 @@ static void device_unmmap_range(uintptr_t mem_start, size_t mem_length) size_t pagesize; unsigned char *mm; - pagesize=getpagesize(); - mem_length+=(mem_start & (pagesize-1))+pagesize-1; - mem_length&=~(pagesize-1); + pagesize = getpagesize(); + mem_length += (mem_start & (pagesize-1))+pagesize-1; + mem_length &= ~(pagesize-1); mm = (mem_start & ~(pagesize-1)); - if(munmap(mm, mem_length)!=0) + if(munmap(mm, mem_length) != 0) { printf("\nHudaqlib: unmmap failed."); + } } - -/********************************* - *********************************/ +/* Allocate available resources (?)*/ int DeviceIoControl(int Operation, DriverRecord *Rec) { - int i,ret; + int i, ret; int fd; - const char *memdev="/dev/mem"; + char memdev[64]; - if(Rec==NULL) return 0; + if(Rec == NULL) { + return 0; + } + sprintf(memdev, "/dev/uio%d", Rec->UioDevNum); if(Operation) //Allocate resources { - fd = open(memdev, O_RDWR|O_SYNC); + fd = open(memdev, O_RDWR | O_SYNC); + if (fd < 0) { + perror("open()"); + } if (fd >= 0) - { - for(i=0;iNumPhysMemResources;i++) + { + for(i = 0; i < Rec->NumPhysMemResources; i ++) { - Rec->Resources.MemResources[i].Base= - device_mmap_range(fd, Rec->PhysMemResources[i].Base, Rec->PhysMemResources[i].Length); - /* - Rec->Resources.MemResources[i].Base = //Rec->PhysMemResources[i].Base; - (size_t)mmap(0, - Rec->PhysMemResources[i].Length, - PROT_WRITE|PROT_READ, - MAP_SHARED, - fd, - Rec->PhysMemResources[i].Base); */ - Rec->Resources.MemResources[i].Length = - Rec->PhysMemResources[i].Length; + Rec->Resources.MemResources[i].Base = + device_mmap_range(fd, Rec->PhysMemResources[i].Base, + Rec->PhysMemResources[i].Length, + Rec->PhysMemResources[i].UioMappingIndex); + Rec->Resources.MemResources[i].Length = Rec->PhysMemResources[i].Length; Rec->Resources.NumMemResources++; } close(fd); } - for(i=0;iResources.NumIOResources;i++) + for(i = 0; i < Rec->Resources.NumIOResources; i ++) { /*baze, delka useku, 1=povoleni 0=zakazani*/ //printf("IOPERM %X %X",Rec->Resources.IOResources[i].Base,Rec->Resources.IOResources[i].Length); - if(Rec->Resources.IOResources[i].Base+Rec->Resources.IOResources[i].Length<=0x3FF) + if(Rec->Resources.IOResources[i].Base + Rec->Resources.IOResources[i].Length <= 0x3FF) { ret = ioperm(Rec->Resources.IOResources[i].Base, Rec->Resources.IOResources[i].Length, 1); @@ -138,32 +134,36 @@ int DeviceIoControl(int Operation, DriverRecord *Rec) else { iopl(3); - IOPLsUsed++; + IOPLsUsed ++; } } return 1; } else //free resources { - for(i=0;iResources.NumMemResources;i++) + for(i = 0; i < Rec->Resources.NumMemResources; i ++) { - device_unmmap_range((void *)Rec->Resources.MemResources[i].Base, + device_unmmap_range((void *) Rec->Resources.MemResources[i].Base, Rec->Resources.MemResources[i].Length); } - Rec->Resources.NumMemResources=0; + Rec->Resources.NumMemResources = 0; - for(i=0;iResources.NumIOResources;i++) + for(i = 0; i < Rec->Resources.NumIOResources; i ++) { /* !!!!!!!!!!! BUG, scan all allocated ranges prevent disabling already used space. !!!!!!!!!!! */ - if(Rec->Resources.IOResources[i].Base+Rec->Resources.IOResources[i].Length<=0x3FF) + if(Rec->Resources.IOResources[i].Base + Rec->Resources.IOResources[i].Length <= 0x3FF) { /*base, IO length, 1=enable 0=disable*/ ret = ioperm(Rec->Resources.IOResources[i].Base, Rec->Resources.IOResources[i].Length, 0); } else { - if(IOPLsUsed>0) IOPLsUsed--; - if(IOPLsUsed<=0) iopl(0); + if(IOPLsUsed > 0) { + IOPLsUsed --; + } + if(IOPLsUsed <= 0) { + iopl(0); + } } } return 1; @@ -179,13 +179,14 @@ HUDAQSTATUS InternalResetDevice(DeviceRecord *DevRecord, int ShareFlag) { int Iter; - if(DevRecord==NULL) return HUDAQFAILURE; + if(DevRecord == NULL) + return HUDAQFAILURE; /* Traverse a list with supported devices. A PCI ID would be much more better. */ - for(Iter=0; Iter<(sizeof(AllCTs)/sizeof(CallTable*));Iter++) + for(Iter = 0; Iter < (sizeof(AllCTs) / sizeof(CallTable*)); Iter ++) { //printf("\nTry to match: %s %s",AllCTs[Iter]->DeviceString,DevRecord->Name); - if(!strcmp(AllCTs[Iter]->DeviceString,DevRecord->Name)) + if(!strcmp(AllCTs[Iter]->DeviceString, DevRecord->Name)) { if(AllCTs[Iter]->HudaqInit(DevRecord, ShareFlag) > 0) return HUDAQSUCCESS; @@ -205,23 +206,25 @@ HUDAQHANDLE HUDAQAPI HudaqOpenDevice(const char* devicename, int deviceorder, in { DeviceRecord* devrecord; - if (devicename==NULL) return(0); /* Invalid device name. */ - + if (devicename == NULL) { + return 0; /* Invalid device name. */ + } /* allocate memory for the device record */ devrecord = calloc(1, sizeof(DeviceRecord)); - if (devrecord==0) - return(0); + if (devrecord == 0) { + return 0; + } /* copy device name and order */ devrecord->DrvRes.Size = sizeof(DriverRecord); - strncpy(devrecord->Name, devicename, sizeof(devrecord->Name)-1); + strncpy(devrecord->Name, devicename, sizeof(devrecord->Name) - 1); devrecord->Order = deviceorder; /* open the system device handle */ - if(OpenDeviceHandle(devrecord->Name, devrecord->Order, &devrecord->DrvRes)<0) + if(OpenDeviceHandle(devrecord->Name, devrecord->Order, &devrecord->DrvRes) < 0) { free(devrecord); - return(0); + return 0; } /* get the resources */ @@ -235,15 +238,17 @@ HUDAQHANDLE HUDAQAPI HudaqOpenDevice(const char* devicename, int deviceorder, in devrecord->DrvRes.DriverData = calloc(1, 1024); //!!!! THIS SHOULD BE SHARED !!!! devrecord->DrvRes.DriverDataSize = 1024; - switch(InternalResetDevice(devrecord,shareflag)) + /* + switch(InternalResetDevice(devrecord, shareflag)) { case HUDAQSUCCESS: break; // everything is OK case HUDAQPARTIAL: break; // unknown device, return its resources only case HUDAQFAILURE: // initialisation failed - go on default: // unexpected return code - HudaqCloseDevice((HUDAQHANDLE)devrecord); + HudaqCloseDevice((HUDAQHANDLE) devrecord); return(0); } + */ return((HUDAQHANDLE) devrecord); } @@ -262,15 +267,18 @@ void HUDAQAPI HudaqCloseDevice(HUDAQHANDLE handle) /* typecast handle to device record, check for validity */ DeviceRecord* devrecord = (DeviceRecord*) handle; - if (devrecord==0) return; + if (devrecord == 0) + return; devrecord->pCT->HudaqDone(devrecord); /* free the resources */ DeviceIoControl(0, &(devrecord->DrvRes)); - if(devrecord->DrvRes.DriverData) - {free(devrecord->DrvRes.DriverData); devrecord->DrvRes.DriverData=NULL;} + if(devrecord->DrvRes.DriverData) { + free(devrecord->DrvRes.DriverData); + devrecord->DrvRes.DriverData = NULL; + } /* close the system device handle */ // CloseHandle(devrecord->SysHandle); @@ -285,7 +293,8 @@ const HudaqResourceInfo* HUDAQAPI HudaqGetDeviceResources(HUDAQHANDLE handle) { /* typecast handle to device record, check for validity */ DeviceRecord* devrecord = (DeviceRecord*) handle; - if (devrecord==0) return(0); + if (devrecord == 0) + return(0); /* return the pointer to resource structure */ return(&(devrecord->DrvRes.Resources)); @@ -297,7 +306,8 @@ const char* HUDAQAPI HudaqGetBoardName(HUDAQHANDLE handle) { /* typecast handle to device record, check for validity */ DeviceRecord* devrecord = (DeviceRecord*) handle; - if (devrecord==0) return(NULL); + if (devrecord == 0) + return(NULL); /* Return a pointer to the device name. */ return(devrecord->Name); @@ -336,7 +346,7 @@ return 1; // Ok int timeGetTime(void) { struct timespec current_time; - clock_gettime(CLOCK_REALTIME,¤t_time); + clock_gettime(CLOCK_REALTIME, ¤t_time); return current_time.tv_nsec/1000 + current_time.tv_sec*1000; }