xref: /linux/include/linux/comedi/comedilib.h (revision 83bd89291f5cc866f60d32c34e268896c7ba8a3d)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * comedilib.h
4  * Header file for kcomedilib
5  *
6  * COMEDI - Linux Control and Measurement Device Interface
7  * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org>
8  */
9 
10 #ifndef _LINUX_COMEDILIB_H
11 #define _LINUX_COMEDILIB_H
12 
13 struct comedi_device *comedi_open_from(const char *path, int from);
14 
15 /**
16  * comedi_open() - Open a COMEDI device from the kernel
17  * @filename: Fake pathname of the form "/dev/comediN".
18  *
19  * Converts @filename to a COMEDI device number and "opens" it if it exists
20  * and is attached to a low-level COMEDI driver.
21  *
22  * Return: A pointer to the COMEDI device on success.
23  * Return %NULL on failure.
24  */
comedi_open(const char * path)25 static inline struct comedi_device *comedi_open(const char *path)
26 {
27 	return comedi_open_from(path, -1);
28 }
29 
30 int comedi_close_from(struct comedi_device *dev, int from);
31 
32 /**
33  * comedi_close() - Close a COMEDI device from the kernel
34  * @dev: COMEDI device.
35  *
36  * Closes a COMEDI device previously opened by comedi_open().
37  *
38  * Returns: 0
39  */
comedi_close(struct comedi_device * dev)40 static inline int comedi_close(struct comedi_device *dev)
41 {
42 	return comedi_close_from(dev, -1);
43 }
44 
45 int comedi_dio_get_config(struct comedi_device *dev, unsigned int subdev,
46 			  unsigned int chan, unsigned int *io);
47 int comedi_dio_config(struct comedi_device *dev, unsigned int subdev,
48 		      unsigned int chan, unsigned int io);
49 int comedi_dio_bitfield2(struct comedi_device *dev, unsigned int subdev,
50 			 unsigned int mask, unsigned int *bits,
51 			 unsigned int base_channel);
52 int comedi_find_subdevice_by_type(struct comedi_device *dev, int type,
53 				  unsigned int subd);
54 int comedi_get_n_channels(struct comedi_device *dev, unsigned int subdevice);
55 
56 #endif
57