ccwgroup.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * bus driver for ccwgroup
  4. *
  5. * Copyright IBM Corp. 2002, 2012
  6. *
  7. * Author(s): Arnd Bergmann (arndb@de.ibm.com)
  8. * Cornelia Huck (cornelia.huck@de.ibm.com)
  9. */
  10. #include <linux/module.h>
  11. #include <linux/errno.h>
  12. #include <linux/slab.h>
  13. #include <linux/list.h>
  14. #include <linux/device.h>
  15. #include <linux/init.h>
  16. #include <linux/ctype.h>
  17. #include <linux/dcache.h>
  18. #include <asm/cio.h>
  19. #include <asm/ccwdev.h>
  20. #include <asm/ccwgroup.h>
  21. #include "device.h"
  22. #define CCW_BUS_ID_SIZE 10
  23. /* In Linux 2.4, we had a channel device layer called "chandev"
  24. * that did all sorts of obscure stuff for networking devices.
  25. * This is another driver that serves as a replacement for just
  26. * one of its functions, namely the translation of single subchannels
  27. * to devices that use multiple subchannels.
  28. */
  29. static struct bus_type ccwgroup_bus_type;
  30. static void __ccwgroup_remove_symlinks(struct ccwgroup_device *gdev)
  31. {
  32. int i;
  33. char str[16];
  34. for (i = 0; i < gdev->count; i++) {
  35. sprintf(str, "cdev%d", i);
  36. sysfs_remove_link(&gdev->dev.kobj, str);
  37. sysfs_remove_link(&gdev->cdev[i]->dev.kobj, "group_device");
  38. }
  39. }
  40. /*
  41. * Remove references from ccw devices to ccw group device and from
  42. * ccw group device to ccw devices.
  43. */
  44. static void __ccwgroup_remove_cdev_refs(struct ccwgroup_device *gdev)
  45. {
  46. struct ccw_device *cdev;
  47. int i;
  48. for (i = 0; i < gdev->count; i++) {
  49. cdev = gdev->cdev[i];
  50. if (!cdev)
  51. continue;
  52. spin_lock_irq(cdev->ccwlock);
  53. dev_set_drvdata(&cdev->dev, NULL);
  54. spin_unlock_irq(cdev->ccwlock);
  55. gdev->cdev[i] = NULL;
  56. put_device(&cdev->dev);
  57. }
  58. }
  59. /**
  60. * ccwgroup_set_online() - enable a ccwgroup device
  61. * @gdev: target ccwgroup device
  62. *
  63. * This function attempts to put the ccwgroup device into the online state.
  64. * Returns:
  65. * %0 on success and a negative error value on failure.
  66. */
  67. int ccwgroup_set_online(struct ccwgroup_device *gdev)
  68. {
  69. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  70. int ret = -EINVAL;
  71. if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
  72. return -EAGAIN;
  73. if (gdev->state == CCWGROUP_ONLINE)
  74. goto out;
  75. if (gdrv->set_online)
  76. ret = gdrv->set_online(gdev);
  77. if (ret)
  78. goto out;
  79. gdev->state = CCWGROUP_ONLINE;
  80. out:
  81. atomic_set(&gdev->onoff, 0);
  82. return ret;
  83. }
  84. EXPORT_SYMBOL(ccwgroup_set_online);
  85. /**
  86. * ccwgroup_set_offline() - disable a ccwgroup device
  87. * @gdev: target ccwgroup device
  88. *
  89. * This function attempts to put the ccwgroup device into the offline state.
  90. * Returns:
  91. * %0 on success and a negative error value on failure.
  92. */
  93. int ccwgroup_set_offline(struct ccwgroup_device *gdev)
  94. {
  95. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  96. int ret = -EINVAL;
  97. if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
  98. return -EAGAIN;
  99. if (gdev->state == CCWGROUP_OFFLINE)
  100. goto out;
  101. if (gdrv->set_offline)
  102. ret = gdrv->set_offline(gdev);
  103. if (ret)
  104. goto out;
  105. gdev->state = CCWGROUP_OFFLINE;
  106. out:
  107. atomic_set(&gdev->onoff, 0);
  108. return ret;
  109. }
  110. EXPORT_SYMBOL(ccwgroup_set_offline);
  111. static ssize_t ccwgroup_online_store(struct device *dev,
  112. struct device_attribute *attr,
  113. const char *buf, size_t count)
  114. {
  115. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  116. unsigned long value;
  117. int ret;
  118. device_lock(dev);
  119. if (!dev->driver) {
  120. ret = -EINVAL;
  121. goto out;
  122. }
  123. ret = kstrtoul(buf, 0, &value);
  124. if (ret)
  125. goto out;
  126. if (value == 1)
  127. ret = ccwgroup_set_online(gdev);
  128. else if (value == 0)
  129. ret = ccwgroup_set_offline(gdev);
  130. else
  131. ret = -EINVAL;
  132. out:
  133. device_unlock(dev);
  134. return (ret == 0) ? count : ret;
  135. }
  136. static ssize_t ccwgroup_online_show(struct device *dev,
  137. struct device_attribute *attr,
  138. char *buf)
  139. {
  140. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  141. int online;
  142. online = (gdev->state == CCWGROUP_ONLINE) ? 1 : 0;
  143. return scnprintf(buf, PAGE_SIZE, "%d\n", online);
  144. }
  145. /*
  146. * Provide an 'ungroup' attribute so the user can remove group devices no
  147. * longer needed or accidentially created. Saves memory :)
  148. */
  149. static void ccwgroup_ungroup(struct ccwgroup_device *gdev)
  150. {
  151. mutex_lock(&gdev->reg_mutex);
  152. if (device_is_registered(&gdev->dev)) {
  153. __ccwgroup_remove_symlinks(gdev);
  154. device_unregister(&gdev->dev);
  155. __ccwgroup_remove_cdev_refs(gdev);
  156. }
  157. mutex_unlock(&gdev->reg_mutex);
  158. }
  159. static ssize_t ccwgroup_ungroup_store(struct device *dev,
  160. struct device_attribute *attr,
  161. const char *buf, size_t count)
  162. {
  163. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  164. int rc = 0;
  165. /* Prevent concurrent online/offline processing and ungrouping. */
  166. if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
  167. return -EAGAIN;
  168. if (gdev->state != CCWGROUP_OFFLINE) {
  169. rc = -EINVAL;
  170. goto out;
  171. }
  172. if (device_remove_file_self(dev, attr))
  173. ccwgroup_ungroup(gdev);
  174. else
  175. rc = -ENODEV;
  176. out:
  177. if (rc) {
  178. /* Release onoff "lock" when ungrouping failed. */
  179. atomic_set(&gdev->onoff, 0);
  180. return rc;
  181. }
  182. return count;
  183. }
  184. static DEVICE_ATTR(ungroup, 0200, NULL, ccwgroup_ungroup_store);
  185. static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
  186. static struct attribute *ccwgroup_attrs[] = {
  187. &dev_attr_online.attr,
  188. &dev_attr_ungroup.attr,
  189. NULL,
  190. };
  191. static struct attribute_group ccwgroup_attr_group = {
  192. .attrs = ccwgroup_attrs,
  193. };
  194. static const struct attribute_group *ccwgroup_attr_groups[] = {
  195. &ccwgroup_attr_group,
  196. NULL,
  197. };
  198. static void ccwgroup_ungroup_workfn(struct work_struct *work)
  199. {
  200. struct ccwgroup_device *gdev =
  201. container_of(work, struct ccwgroup_device, ungroup_work);
  202. ccwgroup_ungroup(gdev);
  203. put_device(&gdev->dev);
  204. }
  205. static void ccwgroup_release(struct device *dev)
  206. {
  207. kfree(to_ccwgroupdev(dev));
  208. }
  209. static int __ccwgroup_create_symlinks(struct ccwgroup_device *gdev)
  210. {
  211. char str[16];
  212. int i, rc;
  213. for (i = 0; i < gdev->count; i++) {
  214. rc = sysfs_create_link(&gdev->cdev[i]->dev.kobj,
  215. &gdev->dev.kobj, "group_device");
  216. if (rc) {
  217. for (--i; i >= 0; i--)
  218. sysfs_remove_link(&gdev->cdev[i]->dev.kobj,
  219. "group_device");
  220. return rc;
  221. }
  222. }
  223. for (i = 0; i < gdev->count; i++) {
  224. sprintf(str, "cdev%d", i);
  225. rc = sysfs_create_link(&gdev->dev.kobj,
  226. &gdev->cdev[i]->dev.kobj, str);
  227. if (rc) {
  228. for (--i; i >= 0; i--) {
  229. sprintf(str, "cdev%d", i);
  230. sysfs_remove_link(&gdev->dev.kobj, str);
  231. }
  232. for (i = 0; i < gdev->count; i++)
  233. sysfs_remove_link(&gdev->cdev[i]->dev.kobj,
  234. "group_device");
  235. return rc;
  236. }
  237. }
  238. return 0;
  239. }
  240. static int __get_next_id(const char **buf, struct ccw_dev_id *id)
  241. {
  242. unsigned int cssid, ssid, devno;
  243. int ret = 0, len;
  244. char *start, *end;
  245. start = (char *)*buf;
  246. end = strchr(start, ',');
  247. if (!end) {
  248. /* Last entry. Strip trailing newline, if applicable. */
  249. end = strchr(start, '\n');
  250. if (end)
  251. *end = '\0';
  252. len = strlen(start) + 1;
  253. } else {
  254. len = end - start + 1;
  255. end++;
  256. }
  257. if (len <= CCW_BUS_ID_SIZE) {
  258. if (sscanf(start, "%2x.%1x.%04x", &cssid, &ssid, &devno) != 3)
  259. ret = -EINVAL;
  260. } else
  261. ret = -EINVAL;
  262. if (!ret) {
  263. id->ssid = ssid;
  264. id->devno = devno;
  265. }
  266. *buf = end;
  267. return ret;
  268. }
  269. /**
  270. * ccwgroup_create_dev() - create and register a ccw group device
  271. * @parent: parent device for the new device
  272. * @gdrv: driver for the new group device
  273. * @num_devices: number of slave devices
  274. * @buf: buffer containing comma separated bus ids of slave devices
  275. *
  276. * Create and register a new ccw group device as a child of @parent. Slave
  277. * devices are obtained from the list of bus ids given in @buf.
  278. * Returns:
  279. * %0 on success and an error code on failure.
  280. * Context:
  281. * non-atomic
  282. */
  283. int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
  284. int num_devices, const char *buf)
  285. {
  286. struct ccwgroup_device *gdev;
  287. struct ccw_dev_id dev_id;
  288. int rc, i;
  289. if (num_devices < 1)
  290. return -EINVAL;
  291. gdev = kzalloc(struct_size(gdev, cdev, num_devices), GFP_KERNEL);
  292. if (!gdev)
  293. return -ENOMEM;
  294. atomic_set(&gdev->onoff, 0);
  295. mutex_init(&gdev->reg_mutex);
  296. mutex_lock(&gdev->reg_mutex);
  297. INIT_WORK(&gdev->ungroup_work, ccwgroup_ungroup_workfn);
  298. gdev->count = num_devices;
  299. gdev->dev.bus = &ccwgroup_bus_type;
  300. gdev->dev.parent = parent;
  301. gdev->dev.release = ccwgroup_release;
  302. device_initialize(&gdev->dev);
  303. for (i = 0; i < num_devices && buf; i++) {
  304. rc = __get_next_id(&buf, &dev_id);
  305. if (rc != 0)
  306. goto error;
  307. gdev->cdev[i] = get_ccwdev_by_dev_id(&dev_id);
  308. /*
  309. * All devices have to be of the same type in
  310. * order to be grouped.
  311. */
  312. if (!gdev->cdev[i] || !gdev->cdev[i]->drv ||
  313. gdev->cdev[i]->drv != gdev->cdev[0]->drv ||
  314. gdev->cdev[i]->id.driver_info !=
  315. gdev->cdev[0]->id.driver_info) {
  316. rc = -EINVAL;
  317. goto error;
  318. }
  319. /* Don't allow a device to belong to more than one group. */
  320. spin_lock_irq(gdev->cdev[i]->ccwlock);
  321. if (dev_get_drvdata(&gdev->cdev[i]->dev)) {
  322. spin_unlock_irq(gdev->cdev[i]->ccwlock);
  323. rc = -EINVAL;
  324. goto error;
  325. }
  326. dev_set_drvdata(&gdev->cdev[i]->dev, gdev);
  327. spin_unlock_irq(gdev->cdev[i]->ccwlock);
  328. }
  329. /* Check for sufficient number of bus ids. */
  330. if (i < num_devices) {
  331. rc = -EINVAL;
  332. goto error;
  333. }
  334. /* Check for trailing stuff. */
  335. if (i == num_devices && buf && strlen(buf) > 0) {
  336. rc = -EINVAL;
  337. goto error;
  338. }
  339. /* Check if the devices are bound to the required ccw driver. */
  340. if (gdrv && gdrv->ccw_driver &&
  341. gdev->cdev[0]->drv != gdrv->ccw_driver) {
  342. rc = -EINVAL;
  343. goto error;
  344. }
  345. dev_set_name(&gdev->dev, "%s", dev_name(&gdev->cdev[0]->dev));
  346. gdev->dev.groups = ccwgroup_attr_groups;
  347. if (gdrv) {
  348. gdev->dev.driver = &gdrv->driver;
  349. rc = gdrv->setup ? gdrv->setup(gdev) : 0;
  350. if (rc)
  351. goto error;
  352. }
  353. rc = device_add(&gdev->dev);
  354. if (rc)
  355. goto error;
  356. rc = __ccwgroup_create_symlinks(gdev);
  357. if (rc) {
  358. device_del(&gdev->dev);
  359. goto error;
  360. }
  361. mutex_unlock(&gdev->reg_mutex);
  362. return 0;
  363. error:
  364. for (i = 0; i < num_devices; i++)
  365. if (gdev->cdev[i]) {
  366. spin_lock_irq(gdev->cdev[i]->ccwlock);
  367. if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev)
  368. dev_set_drvdata(&gdev->cdev[i]->dev, NULL);
  369. spin_unlock_irq(gdev->cdev[i]->ccwlock);
  370. put_device(&gdev->cdev[i]->dev);
  371. gdev->cdev[i] = NULL;
  372. }
  373. mutex_unlock(&gdev->reg_mutex);
  374. put_device(&gdev->dev);
  375. return rc;
  376. }
  377. EXPORT_SYMBOL(ccwgroup_create_dev);
  378. static int ccwgroup_notifier(struct notifier_block *nb, unsigned long action,
  379. void *data)
  380. {
  381. struct ccwgroup_device *gdev = to_ccwgroupdev(data);
  382. if (action == BUS_NOTIFY_UNBIND_DRIVER) {
  383. get_device(&gdev->dev);
  384. schedule_work(&gdev->ungroup_work);
  385. }
  386. return NOTIFY_OK;
  387. }
  388. static struct notifier_block ccwgroup_nb = {
  389. .notifier_call = ccwgroup_notifier
  390. };
  391. static int __init init_ccwgroup(void)
  392. {
  393. int ret;
  394. ret = bus_register(&ccwgroup_bus_type);
  395. if (ret)
  396. return ret;
  397. ret = bus_register_notifier(&ccwgroup_bus_type, &ccwgroup_nb);
  398. if (ret)
  399. bus_unregister(&ccwgroup_bus_type);
  400. return ret;
  401. }
  402. static void __exit cleanup_ccwgroup(void)
  403. {
  404. bus_unregister_notifier(&ccwgroup_bus_type, &ccwgroup_nb);
  405. bus_unregister(&ccwgroup_bus_type);
  406. }
  407. module_init(init_ccwgroup);
  408. module_exit(cleanup_ccwgroup);
  409. /************************** driver stuff ******************************/
  410. static int ccwgroup_remove(struct device *dev)
  411. {
  412. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  413. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(dev->driver);
  414. if (!dev->driver)
  415. return 0;
  416. if (gdrv->remove)
  417. gdrv->remove(gdev);
  418. return 0;
  419. }
  420. static void ccwgroup_shutdown(struct device *dev)
  421. {
  422. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  423. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(dev->driver);
  424. if (!dev->driver)
  425. return;
  426. if (gdrv->shutdown)
  427. gdrv->shutdown(gdev);
  428. }
  429. static int ccwgroup_pm_prepare(struct device *dev)
  430. {
  431. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  432. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  433. /* Fail while device is being set online/offline. */
  434. if (atomic_read(&gdev->onoff))
  435. return -EAGAIN;
  436. if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
  437. return 0;
  438. return gdrv->prepare ? gdrv->prepare(gdev) : 0;
  439. }
  440. static void ccwgroup_pm_complete(struct device *dev)
  441. {
  442. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  443. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(dev->driver);
  444. if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
  445. return;
  446. if (gdrv->complete)
  447. gdrv->complete(gdev);
  448. }
  449. static int ccwgroup_pm_freeze(struct device *dev)
  450. {
  451. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  452. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  453. if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
  454. return 0;
  455. return gdrv->freeze ? gdrv->freeze(gdev) : 0;
  456. }
  457. static int ccwgroup_pm_thaw(struct device *dev)
  458. {
  459. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  460. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  461. if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
  462. return 0;
  463. return gdrv->thaw ? gdrv->thaw(gdev) : 0;
  464. }
  465. static int ccwgroup_pm_restore(struct device *dev)
  466. {
  467. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  468. struct ccwgroup_driver *gdrv = to_ccwgroupdrv(gdev->dev.driver);
  469. if (!gdev->dev.driver || gdev->state != CCWGROUP_ONLINE)
  470. return 0;
  471. return gdrv->restore ? gdrv->restore(gdev) : 0;
  472. }
  473. static const struct dev_pm_ops ccwgroup_pm_ops = {
  474. .prepare = ccwgroup_pm_prepare,
  475. .complete = ccwgroup_pm_complete,
  476. .freeze = ccwgroup_pm_freeze,
  477. .thaw = ccwgroup_pm_thaw,
  478. .restore = ccwgroup_pm_restore,
  479. };
  480. static struct bus_type ccwgroup_bus_type = {
  481. .name = "ccwgroup",
  482. .remove = ccwgroup_remove,
  483. .shutdown = ccwgroup_shutdown,
  484. .pm = &ccwgroup_pm_ops,
  485. };
  486. bool dev_is_ccwgroup(struct device *dev)
  487. {
  488. return dev->bus == &ccwgroup_bus_type;
  489. }
  490. EXPORT_SYMBOL(dev_is_ccwgroup);
  491. /**
  492. * ccwgroup_driver_register() - register a ccw group driver
  493. * @cdriver: driver to be registered
  494. *
  495. * This function is mainly a wrapper around driver_register().
  496. */
  497. int ccwgroup_driver_register(struct ccwgroup_driver *cdriver)
  498. {
  499. /* register our new driver with the core */
  500. cdriver->driver.bus = &ccwgroup_bus_type;
  501. return driver_register(&cdriver->driver);
  502. }
  503. EXPORT_SYMBOL(ccwgroup_driver_register);
  504. static int __ccwgroup_match_all(struct device *dev, void *data)
  505. {
  506. return 1;
  507. }
  508. /**
  509. * ccwgroup_driver_unregister() - deregister a ccw group driver
  510. * @cdriver: driver to be deregistered
  511. *
  512. * This function is mainly a wrapper around driver_unregister().
  513. */
  514. void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
  515. {
  516. struct device *dev;
  517. /* We don't want ccwgroup devices to live longer than their driver. */
  518. while ((dev = driver_find_device(&cdriver->driver, NULL, NULL,
  519. __ccwgroup_match_all))) {
  520. struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
  521. ccwgroup_ungroup(gdev);
  522. put_device(dev);
  523. }
  524. driver_unregister(&cdriver->driver);
  525. }
  526. EXPORT_SYMBOL(ccwgroup_driver_unregister);
  527. /**
  528. * ccwgroup_probe_ccwdev() - probe function for slave devices
  529. * @cdev: ccw device to be probed
  530. *
  531. * This is a dummy probe function for ccw devices that are slave devices in
  532. * a ccw group device.
  533. * Returns:
  534. * always %0
  535. */
  536. int ccwgroup_probe_ccwdev(struct ccw_device *cdev)
  537. {
  538. return 0;
  539. }
  540. EXPORT_SYMBOL(ccwgroup_probe_ccwdev);
  541. /**
  542. * ccwgroup_remove_ccwdev() - remove function for slave devices
  543. * @cdev: ccw device to be removed
  544. *
  545. * This is a remove function for ccw devices that are slave devices in a ccw
  546. * group device. It sets the ccw device offline and also deregisters the
  547. * embedding ccw group device.
  548. */
  549. void ccwgroup_remove_ccwdev(struct ccw_device *cdev)
  550. {
  551. struct ccwgroup_device *gdev;
  552. /* Ignore offlining errors, device is gone anyway. */
  553. ccw_device_set_offline(cdev);
  554. /* If one of its devices is gone, the whole group is done for. */
  555. spin_lock_irq(cdev->ccwlock);
  556. gdev = dev_get_drvdata(&cdev->dev);
  557. if (!gdev) {
  558. spin_unlock_irq(cdev->ccwlock);
  559. return;
  560. }
  561. /* Get ccwgroup device reference for local processing. */
  562. get_device(&gdev->dev);
  563. spin_unlock_irq(cdev->ccwlock);
  564. /* Unregister group device. */
  565. ccwgroup_ungroup(gdev);
  566. /* Release ccwgroup device reference for local processing. */
  567. put_device(&gdev->dev);
  568. }
  569. EXPORT_SYMBOL(ccwgroup_remove_ccwdev);
  570. MODULE_LICENSE("GPL");