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. #include <linux/string_choices.h>
  21. static LIST_HEAD(container_list);
  22. static DEFINE_MUTEX(container_list_lock);
  23. static struct class enclosure_class;
  24. /**
  25. * enclosure_find - find an enclosure given a parent device
  26. * @dev: the parent to match against
  27. * @start: Optional enclosure device to start from (NULL if none)
  28. *
  29. * Looks through the list of registered enclosures to find all those
  30. * with @dev as a parent. Returns NULL if no enclosure is
  31. * found. @start can be used as a starting point to obtain multiple
  32. * enclosures per parent (should begin with NULL and then be set to
  33. * each returned enclosure device). Obtains a reference to the
  34. * enclosure class device which must be released with put_device().
  35. * If @start is not NULL, a reference must be taken on it which is
  36. * released before returning (this allows a loop through all
  37. * enclosures to exit with only the reference on the enclosure of
  38. * interest held). Note that the @dev may correspond to the actual
  39. * device housing the enclosure, in which case no iteration via @start
  40. * is required.
  41. */
  42. struct enclosure_device *enclosure_find(struct device *dev,
  43. struct enclosure_device *start)
  44. {
  45. struct enclosure_device *edev;
  46. mutex_lock(&container_list_lock);
  47. edev = list_prepare_entry(start, &container_list, node);
  48. if (start)
  49. put_device(&start->edev);
  50. list_for_each_entry_continue(edev, &container_list, node) {
  51. struct device *parent = edev->edev.parent;
  52. /* parent might not be immediate, so iterate up to
  53. * the root of the tree if necessary */
  54. while (parent) {
  55. if (parent == dev) {
  56. get_device(&edev->edev);
  57. mutex_unlock(&container_list_lock);
  58. return edev;
  59. }
  60. parent = parent->parent;
  61. }
  62. }
  63. mutex_unlock(&container_list_lock);
  64. return NULL;
  65. }
  66. EXPORT_SYMBOL_GPL(enclosure_find);
  67. /**
  68. * enclosure_for_each_device - calls a function for each enclosure
  69. * @fn: the function to call
  70. * @data: the data to pass to each call
  71. *
  72. * Loops over all the enclosures calling the function.
  73. *
  74. * Note, this function uses a mutex which will be held across calls to
  75. * @fn, so it must have non atomic context, and @fn may (although it
  76. * should not) sleep or otherwise cause the mutex to be held for
  77. * indefinite periods
  78. */
  79. int enclosure_for_each_device(int (*fn)(struct enclosure_device *, void *),
  80. void *data)
  81. {
  82. int error = 0;
  83. struct enclosure_device *edev;
  84. mutex_lock(&container_list_lock);
  85. list_for_each_entry(edev, &container_list, node) {
  86. error = fn(edev, data);
  87. if (error)
  88. break;
  89. }
  90. mutex_unlock(&container_list_lock);
  91. return error;
  92. }
  93. EXPORT_SYMBOL_GPL(enclosure_for_each_device);
  94. /**
  95. * enclosure_register - register device as an enclosure
  96. *
  97. * @dev: device containing the enclosure
  98. * @name: chosen device name
  99. * @components: number of components in the enclosure
  100. * @cb: platform call-backs
  101. *
  102. * This sets up the device for being an enclosure. Note that @dev does
  103. * not have to be a dedicated enclosure device. It may be some other type
  104. * of device that additionally responds to enclosure services
  105. */
  106. struct enclosure_device *
  107. enclosure_register(struct device *dev, const char *name, int components,
  108. struct enclosure_component_callbacks *cb)
  109. {
  110. struct enclosure_device *edev =
  111. kzalloc_flex(*edev, component, components);
  112. int err, i;
  113. BUG_ON(!cb);
  114. if (!edev)
  115. return ERR_PTR(-ENOMEM);
  116. edev->components = components;
  117. edev->edev.class = &enclosure_class;
  118. edev->edev.parent = get_device(dev);
  119. edev->cb = cb;
  120. dev_set_name(&edev->edev, "%s", name);
  121. err = device_register(&edev->edev);
  122. if (err)
  123. goto err;
  124. for (i = 0; i < components; i++) {
  125. edev->component[i].number = -1;
  126. edev->component[i].slot = -1;
  127. edev->component[i].power_status = -1;
  128. }
  129. mutex_lock(&container_list_lock);
  130. list_add_tail(&edev->node, &container_list);
  131. mutex_unlock(&container_list_lock);
  132. return edev;
  133. err:
  134. put_device(edev->edev.parent);
  135. kfree(edev);
  136. return ERR_PTR(err);
  137. }
  138. EXPORT_SYMBOL_GPL(enclosure_register);
  139. static struct enclosure_component_callbacks enclosure_null_callbacks;
  140. /**
  141. * enclosure_unregister - remove an enclosure
  142. *
  143. * @edev: the registered enclosure to remove;
  144. */
  145. void enclosure_unregister(struct enclosure_device *edev)
  146. {
  147. int i;
  148. mutex_lock(&container_list_lock);
  149. list_del(&edev->node);
  150. mutex_unlock(&container_list_lock);
  151. for (i = 0; i < edev->components; i++)
  152. if (edev->component[i].number != -1)
  153. device_unregister(&edev->component[i].cdev);
  154. /* prevent any callbacks into service user */
  155. edev->cb = &enclosure_null_callbacks;
  156. device_unregister(&edev->edev);
  157. }
  158. EXPORT_SYMBOL_GPL(enclosure_unregister);
  159. #define ENCLOSURE_NAME_SIZE 64
  160. #define COMPONENT_NAME_SIZE 64
  161. static void enclosure_link_name(struct enclosure_component *cdev, char *name)
  162. {
  163. strcpy(name, "enclosure_device:");
  164. strcat(name, dev_name(&cdev->cdev));
  165. }
  166. static void enclosure_remove_links(struct enclosure_component *cdev)
  167. {
  168. char name[ENCLOSURE_NAME_SIZE];
  169. enclosure_link_name(cdev, name);
  170. /*
  171. * In odd circumstances, like multipath devices, something else may
  172. * already have removed the links, so check for this condition first.
  173. */
  174. if (cdev->dev->kobj.sd)
  175. sysfs_remove_link(&cdev->dev->kobj, name);
  176. if (cdev->cdev.kobj.sd)
  177. sysfs_remove_link(&cdev->cdev.kobj, "device");
  178. }
  179. static int enclosure_add_links(struct enclosure_component *cdev)
  180. {
  181. int error;
  182. char name[ENCLOSURE_NAME_SIZE];
  183. error = sysfs_create_link(&cdev->cdev.kobj, &cdev->dev->kobj, "device");
  184. if (error)
  185. return error;
  186. enclosure_link_name(cdev, name);
  187. error = sysfs_create_link(&cdev->dev->kobj, &cdev->cdev.kobj, name);
  188. if (error)
  189. sysfs_remove_link(&cdev->cdev.kobj, "device");
  190. return error;
  191. }
  192. static void enclosure_release(struct device *cdev)
  193. {
  194. struct enclosure_device *edev = to_enclosure_device(cdev);
  195. put_device(cdev->parent);
  196. kfree(edev);
  197. }
  198. static void enclosure_component_release(struct device *dev)
  199. {
  200. struct enclosure_component *cdev = to_enclosure_component(dev);
  201. if (cdev->dev) {
  202. enclosure_remove_links(cdev);
  203. put_device(cdev->dev);
  204. }
  205. put_device(dev->parent);
  206. }
  207. static struct enclosure_component *
  208. enclosure_component_find_by_name(struct enclosure_device *edev,
  209. const char *name)
  210. {
  211. int i;
  212. const char *cname;
  213. struct enclosure_component *ecomp;
  214. if (!edev || !name || !name[0])
  215. return NULL;
  216. for (i = 0; i < edev->components; i++) {
  217. ecomp = &edev->component[i];
  218. cname = dev_name(&ecomp->cdev);
  219. if (ecomp->number != -1 &&
  220. cname && cname[0] &&
  221. !strcmp(cname, name))
  222. return ecomp;
  223. }
  224. return NULL;
  225. }
  226. static const struct attribute_group *enclosure_component_groups[];
  227. /**
  228. * enclosure_component_alloc - prepare a new enclosure component
  229. * @edev: the enclosure to add the component
  230. * @number: the device number
  231. * @type: the type of component being added
  232. * @name: an optional name to appear in sysfs (leave NULL if none)
  233. *
  234. * The name is optional for enclosures that give their components a unique
  235. * name. If not, leave the field NULL and a name will be assigned.
  236. *
  237. * Returns a pointer to the enclosure component or an error.
  238. */
  239. struct enclosure_component *
  240. enclosure_component_alloc(struct enclosure_device *edev,
  241. unsigned int number,
  242. enum enclosure_component_type type,
  243. const char *name)
  244. {
  245. struct enclosure_component *ecomp;
  246. struct device *cdev;
  247. int i;
  248. char newname[COMPONENT_NAME_SIZE];
  249. if (number >= edev->components)
  250. return ERR_PTR(-EINVAL);
  251. ecomp = &edev->component[number];
  252. if (ecomp->number != -1)
  253. return ERR_PTR(-EINVAL);
  254. ecomp->type = type;
  255. ecomp->number = number;
  256. cdev = &ecomp->cdev;
  257. cdev->parent = get_device(&edev->edev);
  258. if (name && name[0]) {
  259. /* Some hardware (e.g. enclosure in RX300 S6) has components
  260. * with non unique names. Registering duplicates in sysfs
  261. * will lead to warnings during bootup. So make the names
  262. * unique by appending consecutive numbers -1, -2, ... */
  263. i = 1;
  264. snprintf(newname, COMPONENT_NAME_SIZE,
  265. "%s", name);
  266. while (enclosure_component_find_by_name(edev, newname))
  267. snprintf(newname, COMPONENT_NAME_SIZE,
  268. "%s-%i", name, i++);
  269. dev_set_name(cdev, "%s", newname);
  270. } else
  271. dev_set_name(cdev, "%u", number);
  272. cdev->release = enclosure_component_release;
  273. cdev->groups = enclosure_component_groups;
  274. return ecomp;
  275. }
  276. EXPORT_SYMBOL_GPL(enclosure_component_alloc);
  277. /**
  278. * enclosure_component_register - publishes an initialized enclosure component
  279. * @ecomp: component to add
  280. *
  281. * Returns 0 on successful registration, releases the component otherwise
  282. */
  283. int enclosure_component_register(struct enclosure_component *ecomp)
  284. {
  285. struct device *cdev;
  286. int err;
  287. cdev = &ecomp->cdev;
  288. err = device_register(cdev);
  289. if (err) {
  290. ecomp->number = -1;
  291. put_device(cdev);
  292. return err;
  293. }
  294. return 0;
  295. }
  296. EXPORT_SYMBOL_GPL(enclosure_component_register);
  297. /**
  298. * enclosure_add_device - add a device as being part of an enclosure
  299. * @edev: the enclosure device being added to.
  300. * @component: the number of the component
  301. * @dev: the device being added
  302. *
  303. * Declares a real device to reside in slot (or identifier) @num of an
  304. * enclosure. This will cause the relevant sysfs links to appear.
  305. * This function may also be used to change a device associated with
  306. * an enclosure without having to call enclosure_remove_device() in
  307. * between.
  308. *
  309. * Returns zero on success or an error.
  310. */
  311. int enclosure_add_device(struct enclosure_device *edev, int component,
  312. struct device *dev)
  313. {
  314. struct enclosure_component *cdev;
  315. int err;
  316. if (!edev || component >= edev->components)
  317. return -EINVAL;
  318. cdev = &edev->component[component];
  319. if (cdev->dev == dev)
  320. return -EEXIST;
  321. if (cdev->dev) {
  322. enclosure_remove_links(cdev);
  323. put_device(cdev->dev);
  324. }
  325. cdev->dev = get_device(dev);
  326. err = enclosure_add_links(cdev);
  327. if (err) {
  328. put_device(cdev->dev);
  329. cdev->dev = NULL;
  330. }
  331. return err;
  332. }
  333. EXPORT_SYMBOL_GPL(enclosure_add_device);
  334. /**
  335. * enclosure_remove_device - remove a device from an enclosure
  336. * @edev: the enclosure device
  337. * @dev: device to remove/put
  338. *
  339. * Returns zero on success or an error.
  340. *
  341. */
  342. int enclosure_remove_device(struct enclosure_device *edev, struct device *dev)
  343. {
  344. struct enclosure_component *cdev;
  345. int i;
  346. if (!edev || !dev)
  347. return -EINVAL;
  348. for (i = 0; i < edev->components; i++) {
  349. cdev = &edev->component[i];
  350. if (cdev->dev == dev) {
  351. enclosure_remove_links(cdev);
  352. put_device(dev);
  353. cdev->dev = NULL;
  354. return 0;
  355. }
  356. }
  357. return -ENODEV;
  358. }
  359. EXPORT_SYMBOL_GPL(enclosure_remove_device);
  360. /*
  361. * sysfs pieces below
  362. */
  363. static ssize_t components_show(struct device *cdev,
  364. struct device_attribute *attr, char *buf)
  365. {
  366. struct enclosure_device *edev = to_enclosure_device(cdev);
  367. return sysfs_emit(buf, "%d\n", edev->components);
  368. }
  369. static DEVICE_ATTR_RO(components);
  370. static ssize_t id_show(struct device *cdev,
  371. struct device_attribute *attr,
  372. char *buf)
  373. {
  374. struct enclosure_device *edev = to_enclosure_device(cdev);
  375. if (edev->cb->show_id)
  376. return edev->cb->show_id(edev, buf);
  377. return -EINVAL;
  378. }
  379. static DEVICE_ATTR_RO(id);
  380. static struct attribute *enclosure_class_attrs[] = {
  381. &dev_attr_components.attr,
  382. &dev_attr_id.attr,
  383. NULL,
  384. };
  385. ATTRIBUTE_GROUPS(enclosure_class);
  386. static struct class enclosure_class = {
  387. .name = "enclosure",
  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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%s\n", str_on_off(ecomp->power_status));
  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 sysfs_emit(buf, "%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 sysfs_emit(buf, "%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");