162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Industrial I/O software device interface 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2016 Intel Corporation 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef __IIO_SW_DEVICE 962306a36Sopenharmony_ci#define __IIO_SW_DEVICE 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <linux/module.h> 1262306a36Sopenharmony_ci#include <linux/device.h> 1362306a36Sopenharmony_ci#include <linux/iio/iio.h> 1462306a36Sopenharmony_ci#include <linux/configfs.h> 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define module_iio_sw_device_driver(__iio_sw_device_type) \ 1762306a36Sopenharmony_ci module_driver(__iio_sw_device_type, iio_register_sw_device_type, \ 1862306a36Sopenharmony_ci iio_unregister_sw_device_type) 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistruct iio_sw_device_ops; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistruct iio_sw_device_type { 2362306a36Sopenharmony_ci const char *name; 2462306a36Sopenharmony_ci struct module *owner; 2562306a36Sopenharmony_ci const struct iio_sw_device_ops *ops; 2662306a36Sopenharmony_ci struct list_head list; 2762306a36Sopenharmony_ci struct config_group *group; 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_cistruct iio_sw_device { 3162306a36Sopenharmony_ci struct iio_dev *device; 3262306a36Sopenharmony_ci struct iio_sw_device_type *device_type; 3362306a36Sopenharmony_ci struct config_group group; 3462306a36Sopenharmony_ci}; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistruct iio_sw_device_ops { 3762306a36Sopenharmony_ci struct iio_sw_device* (*probe)(const char *); 3862306a36Sopenharmony_ci int (*remove)(struct iio_sw_device *); 3962306a36Sopenharmony_ci}; 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_cistatic inline 4262306a36Sopenharmony_cistruct iio_sw_device *to_iio_sw_device(struct config_item *item) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci return container_of(to_config_group(item), struct iio_sw_device, 4562306a36Sopenharmony_ci group); 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciint iio_register_sw_device_type(struct iio_sw_device_type *dt); 4962306a36Sopenharmony_civoid iio_unregister_sw_device_type(struct iio_sw_device_type *dt); 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_cistruct iio_sw_device *iio_sw_device_create(const char *, const char *); 5262306a36Sopenharmony_civoid iio_sw_device_destroy(struct iio_sw_device *); 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ciint iio_sw_device_type_configfs_register(struct iio_sw_device_type *dt); 5562306a36Sopenharmony_civoid iio_sw_device_type_configfs_unregister(struct iio_sw_device_type *dt); 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistatic inline 5862306a36Sopenharmony_civoid iio_swd_group_init_type_name(struct iio_sw_device *d, 5962306a36Sopenharmony_ci const char *name, 6062306a36Sopenharmony_ci const struct config_item_type *type) 6162306a36Sopenharmony_ci{ 6262306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_CONFIGFS_FS) 6362306a36Sopenharmony_ci config_group_init_type_name(&d->group, name, type); 6462306a36Sopenharmony_ci#endif 6562306a36Sopenharmony_ci} 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#endif /* __IIO_SW_DEVICE */ 68