vmod/vmodttl: fixed bug related to luns not ordered and/or not starting from zero.
[ht-drivers.git] / vmod / lib / libvmod12e16.c
blob1c2f6e866028f6c6228dcb4ce12eccce2c99df10
1 /**
2 @file libvmod12e16.c
3 @brief Library file for the vmod12e16 driver
4 @author Juan David Gonzalez Cobas
5 @date October 17 2009
6 */
8 #include <sys/ioctl.h>
9 #include <linux/types.h>
10 #include <unistd.h>
11 #include <fcntl.h>
12 #include <stdio.h>
13 #include "vmod12e16drvr.h"
14 #include "libvmod12e16.h"
16 int vmod12e16_get_handle(unsigned int lun)
18 const int name_size = 256;
19 char devname[name_size];
20 const char *driver_name = "vmod12e16";
22 snprintf(devname, name_size, "/dev/%s.%d", driver_name, lun);
23 return open(devname, O_RDWR);
26 int vmod12e16_convert(int fd, int channel,
27 enum vmod12e16_amplification factor, int *value)
29 struct vmod12e16_conversion cv, *cvp = &cv;
30 int err;
32 cvp->channel = channel;
33 cvp->amplification = factor;
34 err = ioctl(fd, VMOD12E16_IOCCONVERT, cvp);
35 if (err != 0)
36 return err;
37 *value = cvp->data;
38 return 0;
41 int vmod12e16_close(int fd)
43 return close(fd);