Lines Matching refs:gdev
36 static void __ccwgroup_remove_symlinks(struct ccwgroup_device *gdev) in __ccwgroup_remove_symlinks() argument
41 for (i = 0; i < gdev->count; i++) { in __ccwgroup_remove_symlinks()
43 sysfs_remove_link(&gdev->dev.kobj, str); in __ccwgroup_remove_symlinks()
44 sysfs_remove_link(&gdev->cdev[i]->dev.kobj, "group_device"); in __ccwgroup_remove_symlinks()
52 static void __ccwgroup_remove_cdev_refs(struct ccwgroup_device *gdev) in __ccwgroup_remove_cdev_refs() argument
57 for (i = 0; i < gdev->count; i++) { in __ccwgroup_remove_cdev_refs()
58 cdev = gdev->cdev[i]; in __ccwgroup_remove_cdev_refs()
64 gdev->cdev[i] = NULL; in __ccwgroup_remove_cdev_refs()
77 int ccwgroup_set_online(struct ccwgroup_device *gdev) in ccwgroup_set_online() argument
79 struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver); in ccwgroup_set_online()
82 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) in ccwgroup_set_online()
84 if (gdev->state == CCWGROUP_ONLINE) in ccwgroup_set_online()
87 ret = gdrv->set_online(gdev); in ccwgroup_set_online()
91 gdev->state = CCWGROUP_ONLINE; in ccwgroup_set_online()
93 atomic_set(&gdev->onoff, 0); in ccwgroup_set_online()
106 int ccwgroup_set_offline(struct ccwgroup_device *gdev) in ccwgroup_set_offline() argument
108 struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver); in ccwgroup_set_offline()
111 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) in ccwgroup_set_offline()
113 if (gdev->state == CCWGROUP_OFFLINE) in ccwgroup_set_offline()
116 ret = gdrv->set_offline(gdev); in ccwgroup_set_offline()
120 gdev->state = CCWGROUP_OFFLINE; in ccwgroup_set_offline()
122 atomic_set(&gdev->onoff, 0); in ccwgroup_set_offline()
131 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_online_store() local
146 ret = ccwgroup_set_online(gdev); in ccwgroup_online_store()
148 ret = ccwgroup_set_offline(gdev); in ccwgroup_online_store()
160 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_online_show() local
163 online = (gdev->state == CCWGROUP_ONLINE) ? 1 : 0; in ccwgroup_online_show()
172 static void ccwgroup_ungroup(struct ccwgroup_device *gdev) in ccwgroup_ungroup() argument
174 mutex_lock(&gdev->reg_mutex); in ccwgroup_ungroup()
175 if (device_is_registered(&gdev->dev)) { in ccwgroup_ungroup()
176 __ccwgroup_remove_symlinks(gdev); in ccwgroup_ungroup()
177 device_unregister(&gdev->dev); in ccwgroup_ungroup()
178 __ccwgroup_remove_cdev_refs(gdev); in ccwgroup_ungroup()
180 mutex_unlock(&gdev->reg_mutex); in ccwgroup_ungroup()
187 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_ungroup_store() local
191 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) in ccwgroup_ungroup_store()
193 if (gdev->state != CCWGROUP_OFFLINE) { in ccwgroup_ungroup_store()
199 ccwgroup_ungroup(gdev); in ccwgroup_ungroup_store()
205 atomic_set(&gdev->onoff, 0); in ccwgroup_ungroup_store()
228 struct ccwgroup_device *gdev = in ccwgroup_ungroup_workfn() local
231 ccwgroup_ungroup(gdev); in ccwgroup_ungroup_workfn()
232 put_device(&gdev->dev); in ccwgroup_ungroup_workfn()
240 static int __ccwgroup_create_symlinks(struct ccwgroup_device *gdev) in __ccwgroup_create_symlinks() argument
245 for (i = 0; i < gdev->count; i++) { in __ccwgroup_create_symlinks()
246 rc = sysfs_create_link(&gdev->cdev[i]->dev.kobj, in __ccwgroup_create_symlinks()
247 &gdev->dev.kobj, "group_device"); in __ccwgroup_create_symlinks()
250 sysfs_remove_link(&gdev->cdev[i]->dev.kobj, in __ccwgroup_create_symlinks()
255 for (i = 0; i < gdev->count; i++) { in __ccwgroup_create_symlinks()
257 rc = sysfs_create_link(&gdev->dev.kobj, in __ccwgroup_create_symlinks()
258 &gdev->cdev[i]->dev.kobj, str); in __ccwgroup_create_symlinks()
262 sysfs_remove_link(&gdev->dev.kobj, str); in __ccwgroup_create_symlinks()
264 for (i = 0; i < gdev->count; i++) in __ccwgroup_create_symlinks()
265 sysfs_remove_link(&gdev->cdev[i]->dev.kobj, in __ccwgroup_create_symlinks()
322 struct ccwgroup_device *gdev; in ccwgroup_create_dev() local
329 gdev = kzalloc(struct_size(gdev, cdev, num_devices), GFP_KERNEL); in ccwgroup_create_dev()
330 if (!gdev) in ccwgroup_create_dev()
333 atomic_set(&gdev->onoff, 0); in ccwgroup_create_dev()
334 mutex_init(&gdev->reg_mutex); in ccwgroup_create_dev()
335 mutex_lock(&gdev->reg_mutex); in ccwgroup_create_dev()
336 INIT_WORK(&gdev->ungroup_work, ccwgroup_ungroup_workfn); in ccwgroup_create_dev()
337 gdev->count = num_devices; in ccwgroup_create_dev()
338 gdev->dev.bus = &ccwgroup_bus_type; in ccwgroup_create_dev()
339 gdev->dev.parent = parent; in ccwgroup_create_dev()
340 gdev->dev.release = ccwgroup_release; in ccwgroup_create_dev()
341 device_initialize(&gdev->dev); in ccwgroup_create_dev()
347 gdev->cdev[i] = get_ccwdev_by_dev_id(&dev_id); in ccwgroup_create_dev()
352 if (!gdev->cdev[i] || !gdev->cdev[i]->drv || in ccwgroup_create_dev()
353 gdev->cdev[i]->drv != gdev->cdev[0]->drv || in ccwgroup_create_dev()
354 gdev->cdev[i]->id.driver_info != in ccwgroup_create_dev()
355 gdev->cdev[0]->id.driver_info) { in ccwgroup_create_dev()
360 spin_lock_irq(gdev->cdev[i]->ccwlock); in ccwgroup_create_dev()
361 if (dev_get_drvdata(&gdev->cdev[i]->dev)) { in ccwgroup_create_dev()
362 spin_unlock_irq(gdev->cdev[i]->ccwlock); in ccwgroup_create_dev()
366 dev_set_drvdata(&gdev->cdev[i]->dev, gdev); in ccwgroup_create_dev()
367 spin_unlock_irq(gdev->cdev[i]->ccwlock); in ccwgroup_create_dev()
381 gdev->cdev[0]->drv != gdrv->ccw_driver) { in ccwgroup_create_dev()
386 dev_set_name(&gdev->dev, "%s", dev_name(&gdev->cdev[0]->dev)); in ccwgroup_create_dev()
387 gdev->dev.groups = ccwgroup_attr_groups; in ccwgroup_create_dev()
390 gdev->dev.driver = &gdrv->driver; in ccwgroup_create_dev()
391 rc = gdrv->setup ? gdrv->setup(gdev) : 0; in ccwgroup_create_dev()
395 rc = device_add(&gdev->dev); in ccwgroup_create_dev()
398 rc = __ccwgroup_create_symlinks(gdev); in ccwgroup_create_dev()
400 device_del(&gdev->dev); in ccwgroup_create_dev()
403 mutex_unlock(&gdev->reg_mutex); in ccwgroup_create_dev()
407 if (gdev->cdev[i]) { in ccwgroup_create_dev()
408 spin_lock_irq(gdev->cdev[i]->ccwlock); in ccwgroup_create_dev()
409 if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev) in ccwgroup_create_dev()
410 dev_set_drvdata(&gdev->cdev[i]->dev, NULL); in ccwgroup_create_dev()
411 spin_unlock_irq(gdev->cdev[i]->ccwlock); in ccwgroup_create_dev()
412 put_device(&gdev->cdev[i]->dev); in ccwgroup_create_dev()
413 gdev->cdev[i] = NULL; in ccwgroup_create_dev()
415 mutex_unlock(&gdev->reg_mutex); in ccwgroup_create_dev()
416 put_device(&gdev->dev); in ccwgroup_create_dev()
424 struct ccwgroup_device *gdev = to_ccwgroupdev(data); in ccwgroup_notifier() local
427 get_device(&gdev->dev); in ccwgroup_notifier()
428 schedule_work(&gdev->ungroup_work); in ccwgroup_notifier()
466 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_remove() local
472 gdrv->remove(gdev); in ccwgroup_remove()
479 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_shutdown() local
485 gdrv->shutdown(gdev); in ccwgroup_shutdown()
527 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); in ccwgroup_driver_unregister() local
529 ccwgroup_ungroup(gdev); in ccwgroup_driver_unregister()
583 struct ccwgroup_device *gdev; in ccwgroup_remove_ccwdev() local
589 gdev = dev_get_drvdata(&cdev->dev); in ccwgroup_remove_ccwdev()
590 if (!gdev) { in ccwgroup_remove_ccwdev()
595 get_device(&gdev->dev); in ccwgroup_remove_ccwdev()
598 ccwgroup_ungroup(gdev); in ccwgroup_remove_ccwdev()
600 put_device(&gdev->dev); in ccwgroup_remove_ccwdev()