Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Mediated device internal definitions
0004  *
0005  * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
0006  *     Author: Neo Jia <cjia@nvidia.com>
0007  *             Kirti Wankhede <kwankhede@nvidia.com>
0008  */
0009 
0010 #ifndef MDEV_PRIVATE_H
0011 #define MDEV_PRIVATE_H
0012 
0013 int  mdev_bus_register(void);
0014 void mdev_bus_unregister(void);
0015 
0016 struct mdev_parent {
0017     struct device *dev;
0018     struct mdev_driver *mdev_driver;
0019     struct kref ref;
0020     struct list_head next;
0021     struct kset *mdev_types_kset;
0022     struct list_head type_list;
0023     /* Synchronize device creation/removal with parent unregistration */
0024     struct rw_semaphore unreg_sem;
0025 };
0026 
0027 struct mdev_type {
0028     struct kobject kobj;
0029     struct kobject *devices_kobj;
0030     struct mdev_parent *parent;
0031     struct list_head next;
0032     unsigned int type_group_id;
0033 };
0034 
0035 extern const struct attribute_group *mdev_device_groups[];
0036 
0037 #define to_mdev_type_attr(_attr)    \
0038     container_of(_attr, struct mdev_type_attribute, attr)
0039 #define to_mdev_type(_kobj)     \
0040     container_of(_kobj, struct mdev_type, kobj)
0041 
0042 int  parent_create_sysfs_files(struct mdev_parent *parent);
0043 void parent_remove_sysfs_files(struct mdev_parent *parent);
0044 
0045 int  mdev_create_sysfs_files(struct mdev_device *mdev);
0046 void mdev_remove_sysfs_files(struct mdev_device *mdev);
0047 
0048 int mdev_device_create(struct mdev_type *kobj, const guid_t *uuid);
0049 int  mdev_device_remove(struct mdev_device *dev);
0050 
0051 void mdev_release_parent(struct kref *kref);
0052 
0053 static inline void mdev_get_parent(struct mdev_parent *parent)
0054 {
0055     kref_get(&parent->ref);
0056 }
0057 
0058 static inline void mdev_put_parent(struct mdev_parent *parent)
0059 {
0060     kref_put(&parent->ref, mdev_release_parent);
0061 }
0062 
0063 #endif /* MDEV_PRIVATE_H */