vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / vmod / lib / libvmod16a2.c
blob9d686f808bddd428703d558e37491dd17dc9d48b
1 /**
2 @file libvmod16a2.c
3 @brief Library file for the vmod16a2 driver
4 @author Juan David Gonzalez Cobas
5 @date October 17 2009
6 */
8 #include <sys/ioctl.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include "vmod16a2.h"
13 #include "libvmod16a2.h"
15 int vmod16a2_get_handle(unsigned int lun)
17 const int filename_sz = 256;
18 char devname[filename_sz];
19 const char *driver_name = "vmod16a2";
20 int fd;
22 /* open the device file */
23 snprintf(devname, filename_sz, "/dev/%s.%d", driver_name, lun);
24 fd = open(devname, O_RDONLY);
25 return fd;
28 int vmod16a2_convert(int fd, int channel, int datum)
30 struct vmod16a2_convert cvt, *cvtp = &cvt;
32 cvtp->channel = channel;
33 cvtp->value = datum;
34 return ioctl(fd, VMOD16A2_IOCPUT, cvtp);
37 int vmod16a2_close(int fd)
39 return close(fd);