Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Industrial I/O software device interface
0004  *
0005  * Copyright (c) 2016 Intel Corporation
0006  */
0007 
0008 #ifndef __IIO_SW_DEVICE
0009 #define __IIO_SW_DEVICE
0010 
0011 #include <linux/module.h>
0012 #include <linux/device.h>
0013 #include <linux/iio/iio.h>
0014 #include <linux/configfs.h>
0015 
0016 #define module_iio_sw_device_driver(__iio_sw_device_type) \
0017     module_driver(__iio_sw_device_type, iio_register_sw_device_type, \
0018               iio_unregister_sw_device_type)
0019 
0020 struct iio_sw_device_ops;
0021 
0022 struct iio_sw_device_type {
0023     const char *name;
0024     struct module *owner;
0025     const struct iio_sw_device_ops *ops;
0026     struct list_head list;
0027     struct config_group *group;
0028 };
0029 
0030 struct iio_sw_device {
0031     struct iio_dev *device;
0032     struct iio_sw_device_type *device_type;
0033     struct config_group group;
0034 };
0035 
0036 struct iio_sw_device_ops {
0037     struct iio_sw_device* (*probe)(const char *);
0038     int (*remove)(struct iio_sw_device *);
0039 };
0040 
0041 static inline
0042 struct iio_sw_device *to_iio_sw_device(struct config_item *item)
0043 {
0044     return container_of(to_config_group(item), struct iio_sw_device,
0045                 group);
0046 }
0047 
0048 int iio_register_sw_device_type(struct iio_sw_device_type *dt);
0049 void iio_unregister_sw_device_type(struct iio_sw_device_type *dt);
0050 
0051 struct iio_sw_device *iio_sw_device_create(const char *, const char *);
0052 void iio_sw_device_destroy(struct iio_sw_device *);
0053 
0054 int iio_sw_device_type_configfs_register(struct iio_sw_device_type *dt);
0055 void iio_sw_device_type_configfs_unregister(struct iio_sw_device_type *dt);
0056 
0057 static inline
0058 void iio_swd_group_init_type_name(struct iio_sw_device *d,
0059                   const char *name,
0060                   const struct config_item_type *type)
0061 {
0062 #if IS_ENABLED(CONFIG_CONFIGFS_FS)
0063     config_group_init_type_name(&d->group, name, type);
0064 #endif
0065 }
0066 
0067 #endif /* __IIO_SW_DEVICE */