Lines Matching full:parent

32 	return mdev->parent->dev;  in mdev_parent_dev()
69 struct mdev_parent *parent; in __find_parent_device() local
71 list_for_each_entry(parent, &parent_list, next) { in __find_parent_device()
72 if (parent->dev == dev) in __find_parent_device()
73 return parent; in __find_parent_device()
80 struct mdev_parent *parent = container_of(kref, struct mdev_parent, in mdev_release_parent() local
82 struct device *dev = parent->dev; in mdev_release_parent()
84 kfree(parent); in mdev_release_parent()
88 static struct mdev_parent *mdev_get_parent(struct mdev_parent *parent) in mdev_get_parent() argument
90 if (parent) in mdev_get_parent()
91 kref_get(&parent->ref); in mdev_get_parent()
93 return parent; in mdev_get_parent()
96 static void mdev_put_parent(struct mdev_parent *parent) in mdev_put_parent() argument
98 if (parent) in mdev_put_parent()
99 kref_put(&parent->ref, mdev_release_parent); in mdev_put_parent()
102 /* Caller must hold parent unreg_sem read or write lock */
105 struct mdev_parent *parent; in mdev_device_remove_common() local
112 parent = mdev->parent; in mdev_device_remove_common()
113 lockdep_assert_held(&parent->unreg_sem); in mdev_device_remove_common()
114 ret = parent->ops->remove(mdev); in mdev_device_remove_common()
120 mdev_put_parent(parent); in mdev_device_remove_common()
136 * @dev: device structure representing parent device.
137 * @ops: Parent device operation structure to be registered.
139 * Add device to list of registered parent devices.
145 struct mdev_parent *parent; in mdev_register_device() local
160 parent = __find_parent_device(dev); in mdev_register_device()
161 if (parent) { in mdev_register_device()
162 parent = NULL; in mdev_register_device()
167 parent = kzalloc(sizeof(*parent), GFP_KERNEL); in mdev_register_device()
168 if (!parent) { in mdev_register_device()
173 kref_init(&parent->ref); in mdev_register_device()
174 init_rwsem(&parent->unreg_sem); in mdev_register_device()
176 parent->dev = dev; in mdev_register_device()
177 parent->ops = ops; in mdev_register_device()
187 ret = parent_create_sysfs_files(parent); in mdev_register_device()
195 list_add(&parent->next, &parent_list); in mdev_register_device()
205 if (parent) in mdev_register_device()
206 mdev_put_parent(parent); in mdev_register_device()
214 * mdev_unregister_device : Unregister a parent device
215 * @dev: device structure representing parent device.
217 * Remove device from list of registered parent devices. Give a chance to free
223 struct mdev_parent *parent; in mdev_unregister_device() local
228 parent = __find_parent_device(dev); in mdev_unregister_device()
230 if (!parent) { in mdev_unregister_device()
236 list_del(&parent->next); in mdev_unregister_device()
239 down_write(&parent->unreg_sem); in mdev_unregister_device()
245 parent_remove_sysfs_files(parent); in mdev_unregister_device()
246 up_write(&parent->unreg_sem); in mdev_unregister_device()
248 mdev_put_parent(parent); in mdev_unregister_device()
277 struct mdev_parent *parent; in mdev_device_create() local
280 parent = mdev_get_parent(type->parent); in mdev_device_create()
281 if (!parent) in mdev_device_create()
306 mdev->parent = parent; in mdev_device_create()
308 /* Check if parent unregistration has started */ in mdev_device_create()
309 if (!down_read_trylock(&parent->unreg_sem)) { in mdev_device_create()
316 mdev->dev.parent = dev; in mdev_device_create()
320 mdev->dev.groups = parent->ops->mdev_attr_groups; in mdev_device_create()
323 ret = parent->ops->create(kobj, mdev); in mdev_device_create()
337 up_read(&parent->unreg_sem); in mdev_device_create()
344 parent->ops->remove(mdev); in mdev_device_create()
346 up_read(&parent->unreg_sem); in mdev_device_create()
349 mdev_put_parent(parent); in mdev_device_create()
356 struct mdev_parent *parent; in mdev_device_remove() local
379 parent = mdev->parent; in mdev_device_remove()
380 /* Check if parent unregistration has started */ in mdev_device_remove()
381 if (!down_read_trylock(&parent->unreg_sem)) in mdev_device_remove()
385 up_read(&parent->unreg_sem); in mdev_device_remove()