enclosure.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Enclosure Services
  4. *
  5. * Copyright (C) 2008 James Bottomley <James.Bottomley@HansenPartnership.com>
  6. *
  7. **-----------------------------------------------------------------------------
  8. **
  9. **
  10. **-----------------------------------------------------------------------------
  11. */
  12. #include <linux/device.h>
  13. #include <linux/enclosure.h>
  14. #include <linux/err.h>
  15. #include <linux/list.h>
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/mutex.h>
  19. #include <linux/slab.h>
  20. static LIST_HEAD(container_list);
  21. static DEFINE_MUTEX(container_list_lock);
  22. static struct class enclosure_class;
  23. /**
  24. * enclosure_find - find an enclosure given a parent device
  25. * @dev: the parent to match against
  26. * @start: Optional enclosure device to start from (NULL if none)
  27. *
  28. * Looks through the list of registered enclosures to find all those
  29. * with @dev as a parent. Returns NULL if no enclosure is
  30. * found. @start can be used as a starting point to obtain multiple
  31. * enclosures per parent (should begin with NULL and then be set to
  32. * each returned enclosure device). Obtains a reference to the
  33. * enclosure class device which must be released with device_put().
  34. * If @start is not NULL, a reference must be taken on it which is
  35. * released before returning (this allows a loop through all
  36. * enclosures to exit with only the reference on the enclosure of
  37. * interest held). Note that the @dev may correspond to the actual
  38. * device housing the enclosure, in which case no iteration via @start
  39. * is required.
  40. */
  41. struct enclosure_device *enclosure_find(struct device *dev,
  42. struct enclosure_device *start)
  43. {
  44. struct enclosure_device *edev;
  45. mutex_lock(&container_list_lock);
  46. edev = list_prepare_entry(start, &container_list, node);
  47. if (start)
  48. put_device(&start->edev);
  49. list_for_each_entry_continue(edev, &container_list, node) {
  50. struct device *parent = edev->edev.parent;
  51. /* parent might not be immediate, so iterate up to
  52. * the root of the tree if necessary */
  53. while (parent) {
  54. if (parent == dev) {
  55. get_device(&edev->edev);
  56. mutex_unlock(&container_list_lock);
  57. return edev;
  58. }
  59. parent = parent->parent;
  60. }
  61. }
  62. mutex_unlock(&container_list_lock);
  63. return NULL;
  64. }
  65. EXPORT_SYMBOL_GPL(enclosure_find);
  66. /**
  67. * enclosure_for_each_device - calls a function for each enclosure
  68. * @fn: the function to call
  69. * @data: the data to pass to each call
  70. *
  71. * Loops over all the enclosures calling the function.
  72. *
  73. * Note, this function uses a mutex which will be held across calls to
  74. * @fn, so it must have non atomic context, and @fn may (although it
  75. * should not) sleep or otherwise cause the mutex to be held for
  76. * indefinite periods
  77. */
  78. int enclosure_for_each_device(int (*fn)(struct enclosure_device *, void *),
  79. void *data)
  80. {
  81. int error = 0;
  82. struct enclosure_device *edev;
  83. mutex_lock(&container_list_lock);
  84. list_for_each_entry(edev, &container_list, node) {
  85. error = fn(edev, data);
  86. if (error)
  87. break;
  88. }
  89. mutex_unlock(&container_list_lock);
  90. return error;
  91. }
  92. EXPORT_SYMBOL_GPL(enclosure_for_each_device);
  93. /**
  94. * enclosure_register - register device as an enclosure
  95. *
  96. * @dev: device containing the enclosure
  97. * @name: chosen device name
  98. * @components: number of components in the enclosure
  99. * @cb: platform call-backs
  100. *
  101. * This sets up the device for being an enclosure. Note that @dev does
  102. * not have to be a dedicated enclosure device. It may be some other type
  103. * of device that additionally responds to enclosure services
  104. */
  105. struct enclosure_device *
  106. enclosure_register(struct device *dev, const char *name, int components,
  107. struct enclosure_component_callbacks *cb)
  108. {
  109. struct enclosure_device *edev =
  110. kzalloc(struct_size(edev, component, components), GFP_KERNEL);
  111. int err, i;
  112. BUG_ON(!cb);
  113. if (!edev)
  114. return ERR_PTR(-ENOMEM);
  115. edev->components = components;
  116. edev->edev.class = &enclosure_class;
  117. edev->edev.parent = get_device(dev);
  118. edev->cb = cb;
  119. dev_set_name(&edev->edev, "%s", name);
  120. err = device_register(&edev->edev);
  121. if (err)
  122. goto err;
  123. for (i = 0; i < components; i++) {
  124. edev->component[i].number = -1;
  125. edev->component[i].slot = -1;
  126. edev->component[i].power_status = -1;
  127. }
  128. mutex_lock(&container_list_lock);
  129. list_add_tail(&edev->node, &container_list);
  130. mutex_unlock(&container_list_lock);
  131. return edev;
  132. err:
  133. put_device(edev->edev.parent);
  134. kfree(edev);
  135. return ERR_PTR(err);
  136. }
  137. EXPORT_SYMBOL_GPL(enclosure_register);
  138. static struct enclosure_component_callbacks enclosure_null_callbacks;
  139. /**
  140. * enclosure_unregister - remove an enclosure
  141. *
  142. * @edev: the registered enclosure to remove;
  143. */
  144. void enclosure_unregister(struct enclosure_device *edev)
  145. {
  146. int i;
  147. mutex_lock(&container_list_lock);
  148. list_del(&edev->node);
  149. mutex_unlock(&container_list_lock);
  150. for (i = 0; i < edev->components; i++)
  151. if (edev->component[i].number != -1)
  152. device_unregister(&edev->component[i].cdev);
  153. /* prevent any callbacks into service user */
  154. edev->cb = &enclosure_null_callbacks;
  155. device_unregister(&edev->edev);
  156. }
  157. EXPORT_SYMBOL_GPL(enclosure_unregister);
  158. #define ENCLOSURE_NAME_SIZE 64
  159. #define COMPONENT_NAME_SIZE 64
  160. static void enclosure_link_name(struct enclosure_component *cdev, char *name)
  161. {
  162. strcpy(name, "enclosure_device:");
  163. strcat(name, dev_name(&cdev->cdev));
  164. }
  165. static void enclosure_remove_links(struct enclosure_component *cdev)
  166. {
  167. char name[ENCLOSURE_NAME_SIZE];
  168. enclosure_link_name(cdev, name);
  169. /*
  170. * In odd circumstances, like multipath devices, something else may
  171. * already have removed the links, so check for this condition first.
  172. */
  173. if (cdev->dev->kobj.sd)
  174. sysfs_remove_link(&cdev->dev->kobj, name);
  175. if (cdev->cdev.kobj.sd)
  176. sysfs_remove_link(&cdev->cdev.kobj, "device");
  177. }
  178. static int enclosure_add_links(struct enclosure_component *cdev)
  179. {
  180. int error;
  181. char name[ENCLOSURE_NAME_SIZE];
  182. error = sysfs_create_link(&cdev->cdev.kobj, &cdev->dev->kobj, "device");
  183. if (error)
  184. return error;
  185. enclosure_link_name(cdev, name);
  186. error = sysfs_create_link(&cdev->dev->kobj, &cdev->cdev.kobj, name);
  187. if (error)
  188. sysfs_remove_link(&cdev->cdev.kobj, "device");
  189. return error;
  190. }
  191. static void enclosure_release(struct device *cdev)
  192. {
  193. struct enclosure_device *edev = to_enclosure_device(cdev);
  194. put_device(cdev->parent);
  195. kfree(edev);
  196. }
  197. static void enclosure_component_release(struct device *dev)
  198. {
  199. struct enclosure_component *cdev = to_enclosure_component(dev);
  200. if (cdev->dev) {
  201. enclosure_remove_links(cdev);
  202. put_device(cdev->dev);
  203. }
  204. put_device(dev->parent);
  205. }
  206. static struct enclosure_component *
  207. enclosure_component_find_by_name(struct enclosure_device *edev,
  208. const char *name)
  209. {
  210. int i;
  211. const char *cname;
  212. struct enclosure_component *ecomp;
  213. if (!edev || !name || !name[0])
  214. return NULL;
  215. for (i = 0; i < edev->components; i++) {
  216. ecomp = &edev->component[i];
  217. cname = dev_name(&ecomp->cdev);
  218. if (ecomp->number != -1 &&
  219. cname && cname[0] &&
  220. !strcmp(cname, name))
  221. return ecomp;
  222. }
  223. return NULL;
  224. }
  225. static const struct attribute_group *enclosure_component_groups[];
  226. /**
  227. * enclosure_component_alloc - prepare a new enclosure component
  228. * @edev: the enclosure to add the component
  229. * @number: the device number
  230. * @type: the type of component being added
  231. * @name: an optional name to appear in sysfs (leave NULL if none)
  232. *
  233. * The name is optional for enclosures that give their components a unique
  234. * name. If not, leave the field NULL and a name will be assigned.
  235. *
  236. * Returns a pointer to the enclosure component or an error.
  237. */
  238. struct enclosure_component *
  239. enclosure_component_alloc(struct enclosure_device *edev,
  240. unsigned int number,
  241. enum enclosure_component_type type,
  242. const char *name)
  243. {
  244. struct enclosure_component *ecomp;
  245. struct device *cdev;
  246. int i;
  247. char newname[COMPONENT_NAME_SIZE];
  248. if (number >= edev->components)
  249. return ERR_PTR(-EINVAL);
  250. ecomp = &edev->component[number];
  251. if (ecomp->number != -1)
  252. return ERR_PTR(-EINVAL);
  253. ecomp->type = type;
  254. ecomp->number = number;
  255. cdev = &ecomp->cdev;
  256. cdev->parent = get_device(&edev->edev);
  257. if (name && name[0]) {
  258. /* Some hardware (e.g. enclosure in RX300 S6) has components
  259. * with non unique names. Registering duplicates in sysfs
  260. * will lead to warnings during bootup. So make the names
  261. * unique by appending consecutive numbers -1, -2, ... */
  262. i = 1;
  263. snprintf(newname, COMPONENT_NAME_SIZE,
  264. "%s", name);
  265. while (enclosure_component_find_by_name(edev, newname))
  266. snprintf(newname, COMPONENT_NAME_SIZE,
  267. "%s-%i", name, i++);
  268. dev_set_name(cdev, "%s", newname);
  269. } else
  270. dev_set_name(cdev, "%u", number);
  271. cdev->release = enclosure_component_release;
  272. cdev->groups = enclosure_component_groups;
  273. return ecomp;
  274. }
  275. EXPORT_SYMBOL_GPL(enclosure_component_alloc);
  276. /**
  277. * enclosure_component_register - publishes an initialized enclosure component
  278. * @ecomp: component to add
  279. *
  280. * Returns 0 on successful registration, releases the component otherwise
  281. */
  282. int enclosure_component_register(struct enclosure_component *ecomp)
  283. {
  284. struct device *cdev;
  285. int err;
  286. cdev = &ecomp->cdev;
  287. err = device_register(cdev);
  288. if (err) {
  289. ecomp->number = -1;
  290. put_device(cdev);
  291. return err;
  292. }
  293. return 0;
  294. }
  295. EXPORT_SYMBOL_GPL(enclosure_component_register);
  296. /**
  297. * enclosure_add_device - add a device as being part of an enclosure
  298. * @edev: the enclosure device being added to.
  299. * @component: the number of the component
  300. * @dev: the device being added
  301. *
  302. * Declares a real device to reside in slot (or identifier) @num of an
  303. * enclosure. This will cause the relevant sysfs links to appear.
  304. * This function may also be used to change a device associated with
  305. * an enclosure without having to call enclosure_remove_device() in
  306. * between.
  307. *
  308. * Returns zero on success or an error.
  309. */
  310. int enclosure_add_device(struct enclosure_device *edev, int component,
  311. struct device *dev)
  312. {
  313. struct enclosure_component *cdev;
  314. int err;
  315. if (!edev || component >= edev->components)
  316. return -EINVAL;
  317. cdev = &edev->component[component];
  318. if (cdev->dev == dev)
  319. return -EEXIST;
  320. if (cdev->dev) {
  321. enclosure_remove_links(cdev);
  322. put_device(cdev->dev);
  323. }
  324. cdev->dev = get_device(dev);
  325. err = enclosure_add_links(cdev);
  326. if (err) {
  327. put_device(cdev->dev);
  328. cdev->dev = NULL;
  329. }
  330. return err;
  331. }
  332. EXPORT_SYMBOL_GPL(enclosure_add_device);
  333. /**
  334. * enclosure_remove_device - remove a device from an enclosure
  335. * @edev: the enclosure device
  336. * @dev: device to remove/put
  337. *
  338. * Returns zero on success or an error.
  339. *
  340. */
  341. int enclosure_remove_device(struct enclosure_device *edev, struct device *dev)
  342. {
  343. struct enclosure_component *cdev;
  344. int i;
  345. if (!edev || !dev)
  346. return -EINVAL;
  347. for (i = 0; i < edev->components; i++) {
  348. cdev = &edev->component[i];
  349. if (cdev->dev == dev) {
  350. enclosure_remove_links(cdev);
  351. put_device(dev);
  352. cdev->dev = NULL;
  353. return 0;
  354. }
  355. }
  356. return -ENODEV;
  357. }
  358. EXPORT_SYMBOL_GPL(enclosure_remove_device);
  359. /*
  360. * sysfs pieces below
  361. */
  362. static ssize_t components_show(struct device *cdev,
  363. struct device_attribute *attr, char *buf)
  364. {
  365. struct enclosure_device *edev = to_enclosure_device(cdev);
  366. return snprintf(buf, 40, "%d\n", edev->components);
  367. }
  368. static DEVICE_ATTR_RO(components);
  369. static ssize_t id_show(struct device *cdev,
  370. struct device_attribute *attr,
  371. char *buf)
  372. {
  373. struct enclosure_device *edev = to_enclosure_device(cdev);
  374. if (edev->cb->show_id)
  375. return edev->cb->show_id(edev, buf);
  376. return -EINVAL;
  377. }
  378. static DEVICE_ATTR_RO(id);
  379. static struct attribute *enclosure_class_attrs[] = {
  380. &dev_attr_components.attr,
  381. &dev_attr_id.attr,
  382. NULL,
  383. };
  384. ATTRIBUTE_GROUPS(enclosure_class);
  385. static struct class enclosure_class = {
  386. .name = "enclosure",
  387. .owner = THIS_MODULE,
  388. .dev_release = enclosure_release,
  389. .dev_groups = enclosure_class_groups,
  390. };
  391. static const char *const enclosure_status[] = {
  392. [ENCLOSURE_STATUS_UNSUPPORTED] = "unsupported",
  393. [ENCLOSURE_STATUS_OK] = "OK",
  394. [ENCLOSURE_STATUS_CRITICAL] = "critical",
  395. [ENCLOSURE_STATUS_NON_CRITICAL] = "non-critical",
  396. [ENCLOSURE_STATUS_UNRECOVERABLE] = "unrecoverable",
  397. [ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed",
  398. [ENCLOSURE_STATUS_UNKNOWN] = "unknown",
  399. [ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable",
  400. [ENCLOSURE_STATUS_MAX] = NULL,
  401. };
  402. static const char *const enclosure_type[] = {
  403. [ENCLOSURE_COMPONENT_DEVICE] = "device",
  404. [ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device",
  405. };
  406. static ssize_t get_component_fault(struct device *cdev,
  407. struct device_attribute *attr, char *buf)
  408. {
  409. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  410. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  411. if (edev->cb->get_fault)
  412. edev->cb->get_fault(edev, ecomp);
  413. return snprintf(buf, 40, "%d\n", ecomp->fault);
  414. }
  415. static ssize_t set_component_fault(struct device *cdev,
  416. struct device_attribute *attr,
  417. const char *buf, size_t count)
  418. {
  419. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  420. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  421. int val = simple_strtoul(buf, NULL, 0);
  422. if (edev->cb->set_fault)
  423. edev->cb->set_fault(edev, ecomp, val);
  424. return count;
  425. }
  426. static ssize_t get_component_status(struct device *cdev,
  427. struct device_attribute *attr,char *buf)
  428. {
  429. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  430. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  431. if (edev->cb->get_status)
  432. edev->cb->get_status(edev, ecomp);
  433. return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]);
  434. }
  435. static ssize_t set_component_status(struct device *cdev,
  436. struct device_attribute *attr,
  437. const char *buf, size_t count)
  438. {
  439. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  440. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  441. int i;
  442. for (i = 0; enclosure_status[i]; i++) {
  443. if (strncmp(buf, enclosure_status[i],
  444. strlen(enclosure_status[i])) == 0 &&
  445. (buf[strlen(enclosure_status[i])] == '\n' ||
  446. buf[strlen(enclosure_status[i])] == '\0'))
  447. break;
  448. }
  449. if (enclosure_status[i] && edev->cb->set_status) {
  450. edev->cb->set_status(edev, ecomp, i);
  451. return count;
  452. } else
  453. return -EINVAL;
  454. }
  455. static ssize_t get_component_active(struct device *cdev,
  456. struct device_attribute *attr, char *buf)
  457. {
  458. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  459. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  460. if (edev->cb->get_active)
  461. edev->cb->get_active(edev, ecomp);
  462. return snprintf(buf, 40, "%d\n", ecomp->active);
  463. }
  464. static ssize_t set_component_active(struct device *cdev,
  465. struct device_attribute *attr,
  466. const char *buf, size_t count)
  467. {
  468. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  469. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  470. int val = simple_strtoul(buf, NULL, 0);
  471. if (edev->cb->set_active)
  472. edev->cb->set_active(edev, ecomp, val);
  473. return count;
  474. }
  475. static ssize_t get_component_locate(struct device *cdev,
  476. struct device_attribute *attr, char *buf)
  477. {
  478. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  479. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  480. if (edev->cb->get_locate)
  481. edev->cb->get_locate(edev, ecomp);
  482. return snprintf(buf, 40, "%d\n", ecomp->locate);
  483. }
  484. static ssize_t set_component_locate(struct device *cdev,
  485. struct device_attribute *attr,
  486. const char *buf, size_t count)
  487. {
  488. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  489. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  490. int val = simple_strtoul(buf, NULL, 0);
  491. if (edev->cb->set_locate)
  492. edev->cb->set_locate(edev, ecomp, val);
  493. return count;
  494. }
  495. static ssize_t get_component_power_status(struct device *cdev,
  496. struct device_attribute *attr,
  497. char *buf)
  498. {
  499. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  500. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  501. if (edev->cb->get_power_status)
  502. edev->cb->get_power_status(edev, ecomp);
  503. /* If still uninitialized, the callback failed or does not exist. */
  504. if (ecomp->power_status == -1)
  505. return (edev->cb->get_power_status) ? -EIO : -ENOTTY;
  506. return snprintf(buf, 40, "%s\n", ecomp->power_status ? "on" : "off");
  507. }
  508. static ssize_t set_component_power_status(struct device *cdev,
  509. struct device_attribute *attr,
  510. const char *buf, size_t count)
  511. {
  512. struct enclosure_device *edev = to_enclosure_device(cdev->parent);
  513. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  514. int val;
  515. if (strncmp(buf, "on", 2) == 0 &&
  516. (buf[2] == '\n' || buf[2] == '\0'))
  517. val = 1;
  518. else if (strncmp(buf, "off", 3) == 0 &&
  519. (buf[3] == '\n' || buf[3] == '\0'))
  520. val = 0;
  521. else
  522. return -EINVAL;
  523. if (edev->cb->set_power_status)
  524. edev->cb->set_power_status(edev, ecomp, val);
  525. return count;
  526. }
  527. static ssize_t get_component_type(struct device *cdev,
  528. struct device_attribute *attr, char *buf)
  529. {
  530. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  531. return snprintf(buf, 40, "%s\n", enclosure_type[ecomp->type]);
  532. }
  533. static ssize_t get_component_slot(struct device *cdev,
  534. struct device_attribute *attr, char *buf)
  535. {
  536. struct enclosure_component *ecomp = to_enclosure_component(cdev);
  537. int slot;
  538. /* if the enclosure does not override then use 'number' as a stand-in */
  539. if (ecomp->slot >= 0)
  540. slot = ecomp->slot;
  541. else
  542. slot = ecomp->number;
  543. return snprintf(buf, 40, "%d\n", slot);
  544. }
  545. static DEVICE_ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault,
  546. set_component_fault);
  547. static DEVICE_ATTR(status, S_IRUGO | S_IWUSR, get_component_status,
  548. set_component_status);
  549. static DEVICE_ATTR(active, S_IRUGO | S_IWUSR, get_component_active,
  550. set_component_active);
  551. static DEVICE_ATTR(locate, S_IRUGO | S_IWUSR, get_component_locate,
  552. set_component_locate);
  553. static DEVICE_ATTR(power_status, S_IRUGO | S_IWUSR, get_component_power_status,
  554. set_component_power_status);
  555. static DEVICE_ATTR(type, S_IRUGO, get_component_type, NULL);
  556. static DEVICE_ATTR(slot, S_IRUGO, get_component_slot, NULL);
  557. static struct attribute *enclosure_component_attrs[] = {
  558. &dev_attr_fault.attr,
  559. &dev_attr_status.attr,
  560. &dev_attr_active.attr,
  561. &dev_attr_locate.attr,
  562. &dev_attr_power_status.attr,
  563. &dev_attr_type.attr,
  564. &dev_attr_slot.attr,
  565. NULL
  566. };
  567. ATTRIBUTE_GROUPS(enclosure_component);
  568. static int __init enclosure_init(void)
  569. {
  570. return class_register(&enclosure_class);
  571. }
  572. static void __exit enclosure_exit(void)
  573. {
  574. class_unregister(&enclosure_class);
  575. }
  576. module_init(enclosure_init);
  577. module_exit(enclosure_exit);
  578. MODULE_AUTHOR("James Bottomley");
  579. MODULE_DESCRIPTION("Enclosure Services");
  580. MODULE_LICENSE("GPL v2");