ccwgroup.c 16 KB

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