scsi_sysfs.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /*
  2. * scsi_sysfs.c
  3. *
  4. * SCSI sysfs interface routines.
  5. *
  6. * Created to pull SCSI mid layer sysfs routines into one file.
  7. */
  8. #include <linux/module.h>
  9. #include <linux/slab.h>
  10. #include <linux/init.h>
  11. #include <linux/blkdev.h>
  12. #include <linux/device.h>
  13. #include <linux/pm_runtime.h>
  14. #include <scsi/scsi.h>
  15. #include <scsi/scsi_device.h>
  16. #include <scsi/scsi_host.h>
  17. #include <scsi/scsi_tcq.h>
  18. #include <scsi/scsi_transport.h>
  19. #include <scsi/scsi_driver.h>
  20. #include "scsi_priv.h"
  21. #include "scsi_logging.h"
  22. static struct device_type scsi_dev_type;
  23. static const struct {
  24. enum scsi_device_state value;
  25. char *name;
  26. } sdev_states[] = {
  27. { SDEV_CREATED, "created" },
  28. { SDEV_RUNNING, "running" },
  29. { SDEV_CANCEL, "cancel" },
  30. { SDEV_DEL, "deleted" },
  31. { SDEV_QUIESCE, "quiesce" },
  32. { SDEV_OFFLINE, "offline" },
  33. { SDEV_TRANSPORT_OFFLINE, "transport-offline" },
  34. { SDEV_BLOCK, "blocked" },
  35. { SDEV_CREATED_BLOCK, "created-blocked" },
  36. };
  37. const char *scsi_device_state_name(enum scsi_device_state state)
  38. {
  39. int i;
  40. char *name = NULL;
  41. for (i = 0; i < ARRAY_SIZE(sdev_states); i++) {
  42. if (sdev_states[i].value == state) {
  43. name = sdev_states[i].name;
  44. break;
  45. }
  46. }
  47. return name;
  48. }
  49. static const struct {
  50. enum scsi_host_state value;
  51. char *name;
  52. } shost_states[] = {
  53. { SHOST_CREATED, "created" },
  54. { SHOST_RUNNING, "running" },
  55. { SHOST_CANCEL, "cancel" },
  56. { SHOST_DEL, "deleted" },
  57. { SHOST_RECOVERY, "recovery" },
  58. { SHOST_CANCEL_RECOVERY, "cancel/recovery" },
  59. { SHOST_DEL_RECOVERY, "deleted/recovery", },
  60. };
  61. const char *scsi_host_state_name(enum scsi_host_state state)
  62. {
  63. int i;
  64. char *name = NULL;
  65. for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
  66. if (shost_states[i].value == state) {
  67. name = shost_states[i].name;
  68. break;
  69. }
  70. }
  71. return name;
  72. }
  73. static int check_set(unsigned long long *val, char *src)
  74. {
  75. char *last;
  76. if (strncmp(src, "-", 20) == 0) {
  77. *val = SCAN_WILD_CARD;
  78. } else {
  79. /*
  80. * Doesn't check for int overflow
  81. */
  82. *val = simple_strtoull(src, &last, 0);
  83. if (*last != '\0')
  84. return 1;
  85. }
  86. return 0;
  87. }
  88. static int scsi_scan(struct Scsi_Host *shost, const char *str)
  89. {
  90. char s1[15], s2[15], s3[17], junk;
  91. unsigned long long channel, id, lun;
  92. int res;
  93. res = sscanf(str, "%10s %10s %16s %c", s1, s2, s3, &junk);
  94. if (res != 3)
  95. return -EINVAL;
  96. if (check_set(&channel, s1))
  97. return -EINVAL;
  98. if (check_set(&id, s2))
  99. return -EINVAL;
  100. if (check_set(&lun, s3))
  101. return -EINVAL;
  102. if (shost->transportt->user_scan)
  103. res = shost->transportt->user_scan(shost, channel, id, lun);
  104. else
  105. res = scsi_scan_host_selected(shost, channel, id, lun, 1);
  106. return res;
  107. }
  108. /*
  109. * shost_show_function: macro to create an attr function that can be used to
  110. * show a non-bit field.
  111. */
  112. #define shost_show_function(name, field, format_string) \
  113. static ssize_t \
  114. show_##name (struct device *dev, struct device_attribute *attr, \
  115. char *buf) \
  116. { \
  117. struct Scsi_Host *shost = class_to_shost(dev); \
  118. return snprintf (buf, 20, format_string, shost->field); \
  119. }
  120. /*
  121. * shost_rd_attr: macro to create a function and attribute variable for a
  122. * read only field.
  123. */
  124. #define shost_rd_attr2(name, field, format_string) \
  125. shost_show_function(name, field, format_string) \
  126. static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
  127. #define shost_rd_attr(field, format_string) \
  128. shost_rd_attr2(field, field, format_string)
  129. /*
  130. * Create the actual show/store functions and data structures.
  131. */
  132. static ssize_t
  133. store_scan(struct device *dev, struct device_attribute *attr,
  134. const char *buf, size_t count)
  135. {
  136. struct Scsi_Host *shost = class_to_shost(dev);
  137. int res;
  138. res = scsi_scan(shost, buf);
  139. if (res == 0)
  140. res = count;
  141. return res;
  142. };
  143. static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
  144. static ssize_t
  145. store_shost_state(struct device *dev, struct device_attribute *attr,
  146. const char *buf, size_t count)
  147. {
  148. int i;
  149. struct Scsi_Host *shost = class_to_shost(dev);
  150. enum scsi_host_state state = 0;
  151. for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
  152. const int len = strlen(shost_states[i].name);
  153. if (strncmp(shost_states[i].name, buf, len) == 0 &&
  154. buf[len] == '\n') {
  155. state = shost_states[i].value;
  156. break;
  157. }
  158. }
  159. if (!state)
  160. return -EINVAL;
  161. if (scsi_host_set_state(shost, state))
  162. return -EINVAL;
  163. return count;
  164. }
  165. static ssize_t
  166. show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
  167. {
  168. struct Scsi_Host *shost = class_to_shost(dev);
  169. const char *name = scsi_host_state_name(shost->shost_state);
  170. if (!name)
  171. return -EINVAL;
  172. return snprintf(buf, 20, "%s\n", name);
  173. }
  174. /* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
  175. struct device_attribute dev_attr_hstate =
  176. __ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
  177. static ssize_t
  178. show_shost_mode(unsigned int mode, char *buf)
  179. {
  180. ssize_t len = 0;
  181. if (mode & MODE_INITIATOR)
  182. len = sprintf(buf, "%s", "Initiator");
  183. if (mode & MODE_TARGET)
  184. len += sprintf(buf + len, "%s%s", len ? ", " : "", "Target");
  185. len += sprintf(buf + len, "\n");
  186. return len;
  187. }
  188. static ssize_t
  189. show_shost_supported_mode(struct device *dev, struct device_attribute *attr,
  190. char *buf)
  191. {
  192. struct Scsi_Host *shost = class_to_shost(dev);
  193. unsigned int supported_mode = shost->hostt->supported_mode;
  194. if (supported_mode == MODE_UNKNOWN)
  195. /* by default this should be initiator */
  196. supported_mode = MODE_INITIATOR;
  197. return show_shost_mode(supported_mode, buf);
  198. }
  199. static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
  200. static ssize_t
  201. show_shost_active_mode(struct device *dev,
  202. struct device_attribute *attr, char *buf)
  203. {
  204. struct Scsi_Host *shost = class_to_shost(dev);
  205. if (shost->active_mode == MODE_UNKNOWN)
  206. return snprintf(buf, 20, "unknown\n");
  207. else
  208. return show_shost_mode(shost->active_mode, buf);
  209. }
  210. static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
  211. static int check_reset_type(const char *str)
  212. {
  213. if (sysfs_streq(str, "adapter"))
  214. return SCSI_ADAPTER_RESET;
  215. else if (sysfs_streq(str, "firmware"))
  216. return SCSI_FIRMWARE_RESET;
  217. else
  218. return 0;
  219. }
  220. static ssize_t
  221. store_host_reset(struct device *dev, struct device_attribute *attr,
  222. const char *buf, size_t count)
  223. {
  224. struct Scsi_Host *shost = class_to_shost(dev);
  225. struct scsi_host_template *sht = shost->hostt;
  226. int ret = -EINVAL;
  227. int type;
  228. type = check_reset_type(buf);
  229. if (!type)
  230. goto exit_store_host_reset;
  231. if (sht->host_reset)
  232. ret = sht->host_reset(shost, type);
  233. exit_store_host_reset:
  234. if (ret == 0)
  235. ret = count;
  236. return ret;
  237. }
  238. static DEVICE_ATTR(host_reset, S_IWUSR, NULL, store_host_reset);
  239. static ssize_t
  240. show_shost_eh_deadline(struct device *dev,
  241. struct device_attribute *attr, char *buf)
  242. {
  243. struct Scsi_Host *shost = class_to_shost(dev);
  244. if (shost->eh_deadline == -1)
  245. return snprintf(buf, strlen("off") + 2, "off\n");
  246. return sprintf(buf, "%u\n", shost->eh_deadline / HZ);
  247. }
  248. static ssize_t
  249. store_shost_eh_deadline(struct device *dev, struct device_attribute *attr,
  250. const char *buf, size_t count)
  251. {
  252. struct Scsi_Host *shost = class_to_shost(dev);
  253. int ret = -EINVAL;
  254. unsigned long deadline, flags;
  255. if (shost->transportt &&
  256. (shost->transportt->eh_strategy_handler ||
  257. !shost->hostt->eh_host_reset_handler))
  258. return ret;
  259. if (!strncmp(buf, "off", strlen("off")))
  260. deadline = -1;
  261. else {
  262. ret = kstrtoul(buf, 10, &deadline);
  263. if (ret)
  264. return ret;
  265. if (deadline * HZ > UINT_MAX)
  266. return -EINVAL;
  267. }
  268. spin_lock_irqsave(shost->host_lock, flags);
  269. if (scsi_host_in_recovery(shost))
  270. ret = -EBUSY;
  271. else {
  272. if (deadline == -1)
  273. shost->eh_deadline = -1;
  274. else
  275. shost->eh_deadline = deadline * HZ;
  276. ret = count;
  277. }
  278. spin_unlock_irqrestore(shost->host_lock, flags);
  279. return ret;
  280. }
  281. static DEVICE_ATTR(eh_deadline, S_IRUGO | S_IWUSR, show_shost_eh_deadline, store_shost_eh_deadline);
  282. shost_rd_attr(use_blk_mq, "%d\n");
  283. shost_rd_attr(unique_id, "%u\n");
  284. shost_rd_attr(cmd_per_lun, "%hd\n");
  285. shost_rd_attr(can_queue, "%hd\n");
  286. shost_rd_attr(sg_tablesize, "%hu\n");
  287. shost_rd_attr(sg_prot_tablesize, "%hu\n");
  288. shost_rd_attr(unchecked_isa_dma, "%d\n");
  289. shost_rd_attr(prot_capabilities, "%u\n");
  290. shost_rd_attr(prot_guard_type, "%hd\n");
  291. shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
  292. static ssize_t
  293. show_host_busy(struct device *dev, struct device_attribute *attr, char *buf)
  294. {
  295. struct Scsi_Host *shost = class_to_shost(dev);
  296. return snprintf(buf, 20, "%d\n", atomic_read(&shost->host_busy));
  297. }
  298. static DEVICE_ATTR(host_busy, S_IRUGO, show_host_busy, NULL);
  299. static struct attribute *scsi_sysfs_shost_attrs[] = {
  300. &dev_attr_use_blk_mq.attr,
  301. &dev_attr_unique_id.attr,
  302. &dev_attr_host_busy.attr,
  303. &dev_attr_cmd_per_lun.attr,
  304. &dev_attr_can_queue.attr,
  305. &dev_attr_sg_tablesize.attr,
  306. &dev_attr_sg_prot_tablesize.attr,
  307. &dev_attr_unchecked_isa_dma.attr,
  308. &dev_attr_proc_name.attr,
  309. &dev_attr_scan.attr,
  310. &dev_attr_hstate.attr,
  311. &dev_attr_supported_mode.attr,
  312. &dev_attr_active_mode.attr,
  313. &dev_attr_prot_capabilities.attr,
  314. &dev_attr_prot_guard_type.attr,
  315. &dev_attr_host_reset.attr,
  316. &dev_attr_eh_deadline.attr,
  317. NULL
  318. };
  319. struct attribute_group scsi_shost_attr_group = {
  320. .attrs = scsi_sysfs_shost_attrs,
  321. };
  322. const struct attribute_group *scsi_sysfs_shost_attr_groups[] = {
  323. &scsi_shost_attr_group,
  324. NULL
  325. };
  326. static void scsi_device_cls_release(struct device *class_dev)
  327. {
  328. struct scsi_device *sdev;
  329. sdev = class_to_sdev(class_dev);
  330. put_device(&sdev->sdev_gendev);
  331. }
  332. static void scsi_device_dev_release_usercontext(struct work_struct *work)
  333. {
  334. struct scsi_device *sdev;
  335. struct device *parent;
  336. struct list_head *this, *tmp;
  337. unsigned long flags;
  338. sdev = container_of(work, struct scsi_device, ew.work);
  339. parent = sdev->sdev_gendev.parent;
  340. spin_lock_irqsave(sdev->host->host_lock, flags);
  341. list_del(&sdev->siblings);
  342. list_del(&sdev->same_target_siblings);
  343. list_del(&sdev->starved_entry);
  344. spin_unlock_irqrestore(sdev->host->host_lock, flags);
  345. cancel_work_sync(&sdev->event_work);
  346. list_for_each_safe(this, tmp, &sdev->event_list) {
  347. struct scsi_event *evt;
  348. evt = list_entry(this, struct scsi_event, node);
  349. list_del(&evt->node);
  350. kfree(evt);
  351. }
  352. blk_put_queue(sdev->request_queue);
  353. /* NULL queue means the device can't be used */
  354. sdev->request_queue = NULL;
  355. kfree(sdev->vpd_pg83);
  356. kfree(sdev->vpd_pg80);
  357. kfree(sdev->inquiry);
  358. kfree(sdev);
  359. if (parent)
  360. put_device(parent);
  361. }
  362. static void scsi_device_dev_release(struct device *dev)
  363. {
  364. struct scsi_device *sdp = to_scsi_device(dev);
  365. execute_in_process_context(scsi_device_dev_release_usercontext,
  366. &sdp->ew);
  367. }
  368. static struct class sdev_class = {
  369. .name = "scsi_device",
  370. .dev_release = scsi_device_cls_release,
  371. };
  372. /* all probing is done in the individual ->probe routines */
  373. static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
  374. {
  375. struct scsi_device *sdp;
  376. if (dev->type != &scsi_dev_type)
  377. return 0;
  378. sdp = to_scsi_device(dev);
  379. if (sdp->no_uld_attach)
  380. return 0;
  381. return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
  382. }
  383. static int scsi_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
  384. {
  385. struct scsi_device *sdev;
  386. if (dev->type != &scsi_dev_type)
  387. return 0;
  388. sdev = to_scsi_device(dev);
  389. add_uevent_var(env, "MODALIAS=" SCSI_DEVICE_MODALIAS_FMT, sdev->type);
  390. return 0;
  391. }
  392. struct bus_type scsi_bus_type = {
  393. .name = "scsi",
  394. .match = scsi_bus_match,
  395. .uevent = scsi_bus_uevent,
  396. #ifdef CONFIG_PM
  397. .pm = &scsi_bus_pm_ops,
  398. #endif
  399. };
  400. EXPORT_SYMBOL_GPL(scsi_bus_type);
  401. int scsi_sysfs_register(void)
  402. {
  403. int error;
  404. error = bus_register(&scsi_bus_type);
  405. if (!error) {
  406. error = class_register(&sdev_class);
  407. if (error)
  408. bus_unregister(&scsi_bus_type);
  409. }
  410. return error;
  411. }
  412. void scsi_sysfs_unregister(void)
  413. {
  414. class_unregister(&sdev_class);
  415. bus_unregister(&scsi_bus_type);
  416. }
  417. /*
  418. * sdev_show_function: macro to create an attr function that can be used to
  419. * show a non-bit field.
  420. */
  421. #define sdev_show_function(field, format_string) \
  422. static ssize_t \
  423. sdev_show_##field (struct device *dev, struct device_attribute *attr, \
  424. char *buf) \
  425. { \
  426. struct scsi_device *sdev; \
  427. sdev = to_scsi_device(dev); \
  428. return snprintf (buf, 20, format_string, sdev->field); \
  429. } \
  430. /*
  431. * sdev_rd_attr: macro to create a function and attribute variable for a
  432. * read only field.
  433. */
  434. #define sdev_rd_attr(field, format_string) \
  435. sdev_show_function(field, format_string) \
  436. static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);
  437. /*
  438. * sdev_rw_attr: create a function and attribute variable for a
  439. * read/write field.
  440. */
  441. #define sdev_rw_attr(field, format_string) \
  442. sdev_show_function(field, format_string) \
  443. \
  444. static ssize_t \
  445. sdev_store_##field (struct device *dev, struct device_attribute *attr, \
  446. const char *buf, size_t count) \
  447. { \
  448. struct scsi_device *sdev; \
  449. sdev = to_scsi_device(dev); \
  450. sscanf (buf, format_string, &sdev->field); \
  451. return count; \
  452. } \
  453. static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field);
  454. /* Currently we don't export bit fields, but we might in future,
  455. * so leave this code in */
  456. #if 0
  457. /*
  458. * sdev_rd_attr: create a function and attribute variable for a
  459. * read/write bit field.
  460. */
  461. #define sdev_rw_attr_bit(field) \
  462. sdev_show_function(field, "%d\n") \
  463. \
  464. static ssize_t \
  465. sdev_store_##field (struct device *dev, struct device_attribute *attr, \
  466. const char *buf, size_t count) \
  467. { \
  468. int ret; \
  469. struct scsi_device *sdev; \
  470. ret = scsi_sdev_check_buf_bit(buf); \
  471. if (ret >= 0) { \
  472. sdev = to_scsi_device(dev); \
  473. sdev->field = ret; \
  474. ret = count; \
  475. } \
  476. return ret; \
  477. } \
  478. static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field);
  479. /*
  480. * scsi_sdev_check_buf_bit: return 0 if buf is "0", return 1 if buf is "1",
  481. * else return -EINVAL.
  482. */
  483. static int scsi_sdev_check_buf_bit(const char *buf)
  484. {
  485. if ((buf[1] == '\0') || ((buf[1] == '\n') && (buf[2] == '\0'))) {
  486. if (buf[0] == '1')
  487. return 1;
  488. else if (buf[0] == '0')
  489. return 0;
  490. else
  491. return -EINVAL;
  492. } else
  493. return -EINVAL;
  494. }
  495. #endif
  496. /*
  497. * Create the actual show/store functions and data structures.
  498. */
  499. sdev_rd_attr (type, "%d\n");
  500. sdev_rd_attr (scsi_level, "%d\n");
  501. sdev_rd_attr (vendor, "%.8s\n");
  502. sdev_rd_attr (model, "%.16s\n");
  503. sdev_rd_attr (rev, "%.4s\n");
  504. static ssize_t
  505. sdev_show_device_busy(struct device *dev, struct device_attribute *attr,
  506. char *buf)
  507. {
  508. struct scsi_device *sdev = to_scsi_device(dev);
  509. return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_busy));
  510. }
  511. static DEVICE_ATTR(device_busy, S_IRUGO, sdev_show_device_busy, NULL);
  512. static ssize_t
  513. sdev_show_device_blocked(struct device *dev, struct device_attribute *attr,
  514. char *buf)
  515. {
  516. struct scsi_device *sdev = to_scsi_device(dev);
  517. return snprintf(buf, 20, "%d\n", atomic_read(&sdev->device_blocked));
  518. }
  519. static DEVICE_ATTR(device_blocked, S_IRUGO, sdev_show_device_blocked, NULL);
  520. /*
  521. * TODO: can we make these symlinks to the block layer ones?
  522. */
  523. static ssize_t
  524. sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf)
  525. {
  526. struct scsi_device *sdev;
  527. sdev = to_scsi_device(dev);
  528. return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ);
  529. }
  530. static ssize_t
  531. sdev_store_timeout (struct device *dev, struct device_attribute *attr,
  532. const char *buf, size_t count)
  533. {
  534. struct scsi_device *sdev;
  535. int timeout;
  536. sdev = to_scsi_device(dev);
  537. sscanf (buf, "%d\n", &timeout);
  538. blk_queue_rq_timeout(sdev->request_queue, timeout * HZ);
  539. return count;
  540. }
  541. static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
  542. static ssize_t
  543. sdev_show_eh_timeout(struct device *dev, struct device_attribute *attr, char *buf)
  544. {
  545. struct scsi_device *sdev;
  546. sdev = to_scsi_device(dev);
  547. return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ);
  548. }
  549. static ssize_t
  550. sdev_store_eh_timeout(struct device *dev, struct device_attribute *attr,
  551. const char *buf, size_t count)
  552. {
  553. struct scsi_device *sdev;
  554. unsigned int eh_timeout;
  555. int err;
  556. if (!capable(CAP_SYS_ADMIN))
  557. return -EACCES;
  558. sdev = to_scsi_device(dev);
  559. err = kstrtouint(buf, 10, &eh_timeout);
  560. if (err)
  561. return err;
  562. sdev->eh_timeout = eh_timeout * HZ;
  563. return count;
  564. }
  565. static DEVICE_ATTR(eh_timeout, S_IRUGO | S_IWUSR, sdev_show_eh_timeout, sdev_store_eh_timeout);
  566. static ssize_t
  567. store_rescan_field (struct device *dev, struct device_attribute *attr,
  568. const char *buf, size_t count)
  569. {
  570. scsi_rescan_device(dev);
  571. return count;
  572. }
  573. static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
  574. static ssize_t
  575. sdev_store_delete(struct device *dev, struct device_attribute *attr,
  576. const char *buf, size_t count)
  577. {
  578. if (device_remove_file_self(dev, attr))
  579. scsi_remove_device(to_scsi_device(dev));
  580. return count;
  581. };
  582. static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
  583. static ssize_t
  584. store_state_field(struct device *dev, struct device_attribute *attr,
  585. const char *buf, size_t count)
  586. {
  587. int i;
  588. struct scsi_device *sdev = to_scsi_device(dev);
  589. enum scsi_device_state state = 0;
  590. for (i = 0; i < ARRAY_SIZE(sdev_states); i++) {
  591. const int len = strlen(sdev_states[i].name);
  592. if (strncmp(sdev_states[i].name, buf, len) == 0 &&
  593. buf[len] == '\n') {
  594. state = sdev_states[i].value;
  595. break;
  596. }
  597. }
  598. if (!state)
  599. return -EINVAL;
  600. if (scsi_device_set_state(sdev, state))
  601. return -EINVAL;
  602. return count;
  603. }
  604. static ssize_t
  605. show_state_field(struct device *dev, struct device_attribute *attr, char *buf)
  606. {
  607. struct scsi_device *sdev = to_scsi_device(dev);
  608. const char *name = scsi_device_state_name(sdev->sdev_state);
  609. if (!name)
  610. return -EINVAL;
  611. return snprintf(buf, 20, "%s\n", name);
  612. }
  613. static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field);
  614. static ssize_t
  615. show_queue_type_field(struct device *dev, struct device_attribute *attr,
  616. char *buf)
  617. {
  618. struct scsi_device *sdev = to_scsi_device(dev);
  619. const char *name = "none";
  620. if (sdev->simple_tags)
  621. name = "simple";
  622. return snprintf(buf, 20, "%s\n", name);
  623. }
  624. static ssize_t
  625. store_queue_type_field(struct device *dev, struct device_attribute *attr,
  626. const char *buf, size_t count)
  627. {
  628. struct scsi_device *sdev = to_scsi_device(dev);
  629. if (!sdev->tagged_supported)
  630. return -EINVAL;
  631. sdev_printk(KERN_INFO, sdev,
  632. "ignoring write to deprecated queue_type attribute");
  633. return count;
  634. }
  635. static DEVICE_ATTR(queue_type, S_IRUGO | S_IWUSR, show_queue_type_field,
  636. store_queue_type_field);
  637. #define sdev_vpd_pg_attr(_page) \
  638. static ssize_t \
  639. show_vpd_##_page(struct file *filp, struct kobject *kobj, \
  640. struct bin_attribute *bin_attr, \
  641. char *buf, loff_t off, size_t count) \
  642. { \
  643. struct device *dev = container_of(kobj, struct device, kobj); \
  644. struct scsi_device *sdev = to_scsi_device(dev); \
  645. if (!sdev->vpd_##_page) \
  646. return -EINVAL; \
  647. return memory_read_from_buffer(buf, count, &off, \
  648. sdev->vpd_##_page, \
  649. sdev->vpd_##_page##_len); \
  650. } \
  651. static struct bin_attribute dev_attr_vpd_##_page = { \
  652. .attr = {.name = __stringify(vpd_##_page), .mode = S_IRUGO }, \
  653. .size = 0, \
  654. .read = show_vpd_##_page, \
  655. };
  656. sdev_vpd_pg_attr(pg83);
  657. sdev_vpd_pg_attr(pg80);
  658. static ssize_t
  659. show_iostat_counterbits(struct device *dev, struct device_attribute *attr,
  660. char *buf)
  661. {
  662. return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
  663. }
  664. static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL);
  665. #define show_sdev_iostat(field) \
  666. static ssize_t \
  667. show_iostat_##field(struct device *dev, struct device_attribute *attr, \
  668. char *buf) \
  669. { \
  670. struct scsi_device *sdev = to_scsi_device(dev); \
  671. unsigned long long count = atomic_read(&sdev->field); \
  672. return snprintf(buf, 20, "0x%llx\n", count); \
  673. } \
  674. static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
  675. show_sdev_iostat(iorequest_cnt);
  676. show_sdev_iostat(iodone_cnt);
  677. show_sdev_iostat(ioerr_cnt);
  678. static ssize_t
  679. sdev_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
  680. {
  681. struct scsi_device *sdev;
  682. sdev = to_scsi_device(dev);
  683. return snprintf (buf, 20, SCSI_DEVICE_MODALIAS_FMT "\n", sdev->type);
  684. }
  685. static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
  686. #define DECLARE_EVT_SHOW(name, Cap_name) \
  687. static ssize_t \
  688. sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
  689. char *buf) \
  690. { \
  691. struct scsi_device *sdev = to_scsi_device(dev); \
  692. int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
  693. return snprintf(buf, 20, "%d\n", val); \
  694. }
  695. #define DECLARE_EVT_STORE(name, Cap_name) \
  696. static ssize_t \
  697. sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\
  698. const char *buf, size_t count) \
  699. { \
  700. struct scsi_device *sdev = to_scsi_device(dev); \
  701. int val = simple_strtoul(buf, NULL, 0); \
  702. if (val == 0) \
  703. clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
  704. else if (val == 1) \
  705. set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
  706. else \
  707. return -EINVAL; \
  708. return count; \
  709. }
  710. #define DECLARE_EVT(name, Cap_name) \
  711. DECLARE_EVT_SHOW(name, Cap_name) \
  712. DECLARE_EVT_STORE(name, Cap_name) \
  713. static DEVICE_ATTR(evt_##name, S_IRUGO, sdev_show_evt_##name, \
  714. sdev_store_evt_##name);
  715. #define REF_EVT(name) &dev_attr_evt_##name.attr
  716. DECLARE_EVT(media_change, MEDIA_CHANGE)
  717. DECLARE_EVT(inquiry_change_reported, INQUIRY_CHANGE_REPORTED)
  718. DECLARE_EVT(capacity_change_reported, CAPACITY_CHANGE_REPORTED)
  719. DECLARE_EVT(soft_threshold_reached, SOFT_THRESHOLD_REACHED_REPORTED)
  720. DECLARE_EVT(mode_parameter_change_reported, MODE_PARAMETER_CHANGE_REPORTED)
  721. DECLARE_EVT(lun_change_reported, LUN_CHANGE_REPORTED)
  722. static ssize_t
  723. sdev_store_queue_depth(struct device *dev, struct device_attribute *attr,
  724. const char *buf, size_t count)
  725. {
  726. int depth, retval;
  727. struct scsi_device *sdev = to_scsi_device(dev);
  728. struct scsi_host_template *sht = sdev->host->hostt;
  729. if (!sht->change_queue_depth)
  730. return -EINVAL;
  731. depth = simple_strtoul(buf, NULL, 0);
  732. if (depth < 1 || depth > sht->can_queue)
  733. return -EINVAL;
  734. retval = sht->change_queue_depth(sdev, depth);
  735. if (retval < 0)
  736. return retval;
  737. sdev->max_queue_depth = sdev->queue_depth;
  738. return count;
  739. }
  740. sdev_show_function(queue_depth, "%d\n");
  741. static DEVICE_ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth,
  742. sdev_store_queue_depth);
  743. static ssize_t
  744. sdev_show_queue_ramp_up_period(struct device *dev,
  745. struct device_attribute *attr,
  746. char *buf)
  747. {
  748. struct scsi_device *sdev;
  749. sdev = to_scsi_device(dev);
  750. return snprintf(buf, 20, "%u\n",
  751. jiffies_to_msecs(sdev->queue_ramp_up_period));
  752. }
  753. static ssize_t
  754. sdev_store_queue_ramp_up_period(struct device *dev,
  755. struct device_attribute *attr,
  756. const char *buf, size_t count)
  757. {
  758. struct scsi_device *sdev = to_scsi_device(dev);
  759. unsigned int period;
  760. if (kstrtouint(buf, 10, &period))
  761. return -EINVAL;
  762. sdev->queue_ramp_up_period = msecs_to_jiffies(period);
  763. return period;
  764. }
  765. static DEVICE_ATTR(queue_ramp_up_period, S_IRUGO | S_IWUSR,
  766. sdev_show_queue_ramp_up_period,
  767. sdev_store_queue_ramp_up_period);
  768. static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
  769. struct attribute *attr, int i)
  770. {
  771. struct device *dev = container_of(kobj, struct device, kobj);
  772. struct scsi_device *sdev = to_scsi_device(dev);
  773. if (attr == &dev_attr_queue_depth.attr &&
  774. !sdev->host->hostt->change_queue_depth)
  775. return S_IRUGO;
  776. if (attr == &dev_attr_queue_ramp_up_period.attr &&
  777. !sdev->host->hostt->change_queue_depth)
  778. return 0;
  779. return attr->mode;
  780. }
  781. /* Default template for device attributes. May NOT be modified */
  782. static struct attribute *scsi_sdev_attrs[] = {
  783. &dev_attr_device_blocked.attr,
  784. &dev_attr_type.attr,
  785. &dev_attr_scsi_level.attr,
  786. &dev_attr_device_busy.attr,
  787. &dev_attr_vendor.attr,
  788. &dev_attr_model.attr,
  789. &dev_attr_rev.attr,
  790. &dev_attr_rescan.attr,
  791. &dev_attr_delete.attr,
  792. &dev_attr_state.attr,
  793. &dev_attr_timeout.attr,
  794. &dev_attr_eh_timeout.attr,
  795. &dev_attr_iocounterbits.attr,
  796. &dev_attr_iorequest_cnt.attr,
  797. &dev_attr_iodone_cnt.attr,
  798. &dev_attr_ioerr_cnt.attr,
  799. &dev_attr_modalias.attr,
  800. &dev_attr_queue_depth.attr,
  801. &dev_attr_queue_type.attr,
  802. &dev_attr_queue_ramp_up_period.attr,
  803. REF_EVT(media_change),
  804. REF_EVT(inquiry_change_reported),
  805. REF_EVT(capacity_change_reported),
  806. REF_EVT(soft_threshold_reached),
  807. REF_EVT(mode_parameter_change_reported),
  808. REF_EVT(lun_change_reported),
  809. NULL
  810. };
  811. static struct bin_attribute *scsi_sdev_bin_attrs[] = {
  812. &dev_attr_vpd_pg83,
  813. &dev_attr_vpd_pg80,
  814. NULL
  815. };
  816. static struct attribute_group scsi_sdev_attr_group = {
  817. .attrs = scsi_sdev_attrs,
  818. .bin_attrs = scsi_sdev_bin_attrs,
  819. .is_visible = scsi_sdev_attr_is_visible,
  820. };
  821. static const struct attribute_group *scsi_sdev_attr_groups[] = {
  822. &scsi_sdev_attr_group,
  823. NULL
  824. };
  825. static int scsi_target_add(struct scsi_target *starget)
  826. {
  827. int error;
  828. if (starget->state != STARGET_CREATED)
  829. return 0;
  830. error = device_add(&starget->dev);
  831. if (error) {
  832. dev_err(&starget->dev, "target device_add failed, error %d\n", error);
  833. return error;
  834. }
  835. transport_add_device(&starget->dev);
  836. starget->state = STARGET_RUNNING;
  837. pm_runtime_set_active(&starget->dev);
  838. pm_runtime_enable(&starget->dev);
  839. device_enable_async_suspend(&starget->dev);
  840. return 0;
  841. }
  842. /**
  843. * scsi_sysfs_add_sdev - add scsi device to sysfs
  844. * @sdev: scsi_device to add
  845. *
  846. * Return value:
  847. * 0 on Success / non-zero on Failure
  848. **/
  849. int scsi_sysfs_add_sdev(struct scsi_device *sdev)
  850. {
  851. int error, i;
  852. struct request_queue *rq = sdev->request_queue;
  853. struct scsi_target *starget = sdev->sdev_target;
  854. error = scsi_device_set_state(sdev, SDEV_RUNNING);
  855. if (error)
  856. return error;
  857. error = scsi_target_add(starget);
  858. if (error)
  859. return error;
  860. transport_configure_device(&starget->dev);
  861. device_enable_async_suspend(&sdev->sdev_gendev);
  862. scsi_autopm_get_target(starget);
  863. pm_runtime_set_active(&sdev->sdev_gendev);
  864. pm_runtime_forbid(&sdev->sdev_gendev);
  865. pm_runtime_enable(&sdev->sdev_gendev);
  866. scsi_autopm_put_target(starget);
  867. scsi_autopm_get_device(sdev);
  868. error = device_add(&sdev->sdev_gendev);
  869. if (error) {
  870. sdev_printk(KERN_INFO, sdev,
  871. "failed to add device: %d\n", error);
  872. return error;
  873. }
  874. device_enable_async_suspend(&sdev->sdev_dev);
  875. error = device_add(&sdev->sdev_dev);
  876. if (error) {
  877. sdev_printk(KERN_INFO, sdev,
  878. "failed to add class device: %d\n", error);
  879. device_del(&sdev->sdev_gendev);
  880. return error;
  881. }
  882. transport_add_device(&sdev->sdev_gendev);
  883. sdev->is_visible = 1;
  884. error = bsg_register_queue(rq, &sdev->sdev_gendev, NULL, NULL);
  885. if (error)
  886. /* we're treating error on bsg register as non-fatal,
  887. * so pretend nothing went wrong */
  888. sdev_printk(KERN_INFO, sdev,
  889. "Failed to register bsg queue, errno=%d\n", error);
  890. /* add additional host specific attributes */
  891. if (sdev->host->hostt->sdev_attrs) {
  892. for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
  893. error = device_create_file(&sdev->sdev_gendev,
  894. sdev->host->hostt->sdev_attrs[i]);
  895. if (error)
  896. return error;
  897. }
  898. }
  899. scsi_autopm_put_device(sdev);
  900. return error;
  901. }
  902. void __scsi_remove_device(struct scsi_device *sdev)
  903. {
  904. struct device *dev = &sdev->sdev_gendev;
  905. if (sdev->is_visible) {
  906. if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
  907. return;
  908. bsg_unregister_queue(sdev->request_queue);
  909. device_unregister(&sdev->sdev_dev);
  910. transport_remove_device(dev);
  911. device_del(dev);
  912. } else
  913. put_device(&sdev->sdev_dev);
  914. /*
  915. * Stop accepting new requests and wait until all queuecommand() and
  916. * scsi_run_queue() invocations have finished before tearing down the
  917. * device.
  918. */
  919. scsi_device_set_state(sdev, SDEV_DEL);
  920. blk_cleanup_queue(sdev->request_queue);
  921. cancel_work_sync(&sdev->requeue_work);
  922. if (sdev->host->hostt->slave_destroy)
  923. sdev->host->hostt->slave_destroy(sdev);
  924. transport_destroy_device(dev);
  925. /*
  926. * Paired with the kref_get() in scsi_sysfs_initialize(). We have
  927. * remoed sysfs visibility from the device, so make the target
  928. * invisible if this was the last device underneath it.
  929. */
  930. scsi_target_reap(scsi_target(sdev));
  931. put_device(dev);
  932. }
  933. /**
  934. * scsi_remove_device - unregister a device from the scsi bus
  935. * @sdev: scsi_device to unregister
  936. **/
  937. void scsi_remove_device(struct scsi_device *sdev)
  938. {
  939. struct Scsi_Host *shost = sdev->host;
  940. mutex_lock(&shost->scan_mutex);
  941. __scsi_remove_device(sdev);
  942. mutex_unlock(&shost->scan_mutex);
  943. }
  944. EXPORT_SYMBOL(scsi_remove_device);
  945. static void __scsi_remove_target(struct scsi_target *starget)
  946. {
  947. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  948. unsigned long flags;
  949. struct scsi_device *sdev;
  950. spin_lock_irqsave(shost->host_lock, flags);
  951. restart:
  952. list_for_each_entry(sdev, &shost->__devices, siblings) {
  953. if (sdev->channel != starget->channel ||
  954. sdev->id != starget->id ||
  955. scsi_device_get(sdev))
  956. continue;
  957. spin_unlock_irqrestore(shost->host_lock, flags);
  958. scsi_remove_device(sdev);
  959. scsi_device_put(sdev);
  960. spin_lock_irqsave(shost->host_lock, flags);
  961. goto restart;
  962. }
  963. spin_unlock_irqrestore(shost->host_lock, flags);
  964. }
  965. /**
  966. * scsi_remove_target - try to remove a target and all its devices
  967. * @dev: generic starget or parent of generic stargets to be removed
  968. *
  969. * Note: This is slightly racy. It is possible that if the user
  970. * requests the addition of another device then the target won't be
  971. * removed.
  972. */
  973. void scsi_remove_target(struct device *dev)
  974. {
  975. struct Scsi_Host *shost = dev_to_shost(dev->parent);
  976. struct scsi_target *starget, *last = NULL;
  977. unsigned long flags;
  978. /* remove targets being careful to lookup next entry before
  979. * deleting the last
  980. */
  981. spin_lock_irqsave(shost->host_lock, flags);
  982. list_for_each_entry(starget, &shost->__targets, siblings) {
  983. if (starget->state == STARGET_DEL)
  984. continue;
  985. if (starget->dev.parent == dev || &starget->dev == dev) {
  986. /* assuming new targets arrive at the end */
  987. kref_get(&starget->reap_ref);
  988. spin_unlock_irqrestore(shost->host_lock, flags);
  989. if (last)
  990. scsi_target_reap(last);
  991. last = starget;
  992. __scsi_remove_target(starget);
  993. spin_lock_irqsave(shost->host_lock, flags);
  994. }
  995. }
  996. spin_unlock_irqrestore(shost->host_lock, flags);
  997. if (last)
  998. scsi_target_reap(last);
  999. }
  1000. EXPORT_SYMBOL(scsi_remove_target);
  1001. int scsi_register_driver(struct device_driver *drv)
  1002. {
  1003. drv->bus = &scsi_bus_type;
  1004. return driver_register(drv);
  1005. }
  1006. EXPORT_SYMBOL(scsi_register_driver);
  1007. int scsi_register_interface(struct class_interface *intf)
  1008. {
  1009. intf->class = &sdev_class;
  1010. return class_interface_register(intf);
  1011. }
  1012. EXPORT_SYMBOL(scsi_register_interface);
  1013. /**
  1014. * scsi_sysfs_add_host - add scsi host to subsystem
  1015. * @shost: scsi host struct to add to subsystem
  1016. **/
  1017. int scsi_sysfs_add_host(struct Scsi_Host *shost)
  1018. {
  1019. int error, i;
  1020. /* add host specific attributes */
  1021. if (shost->hostt->shost_attrs) {
  1022. for (i = 0; shost->hostt->shost_attrs[i]; i++) {
  1023. error = device_create_file(&shost->shost_dev,
  1024. shost->hostt->shost_attrs[i]);
  1025. if (error)
  1026. return error;
  1027. }
  1028. }
  1029. transport_register_device(&shost->shost_gendev);
  1030. transport_configure_device(&shost->shost_gendev);
  1031. return 0;
  1032. }
  1033. static struct device_type scsi_dev_type = {
  1034. .name = "scsi_device",
  1035. .release = scsi_device_dev_release,
  1036. .groups = scsi_sdev_attr_groups,
  1037. };
  1038. void scsi_sysfs_device_initialize(struct scsi_device *sdev)
  1039. {
  1040. unsigned long flags;
  1041. struct Scsi_Host *shost = sdev->host;
  1042. struct scsi_target *starget = sdev->sdev_target;
  1043. device_initialize(&sdev->sdev_gendev);
  1044. sdev->sdev_gendev.bus = &scsi_bus_type;
  1045. sdev->sdev_gendev.type = &scsi_dev_type;
  1046. dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%llu",
  1047. sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
  1048. device_initialize(&sdev->sdev_dev);
  1049. sdev->sdev_dev.parent = get_device(&sdev->sdev_gendev);
  1050. sdev->sdev_dev.class = &sdev_class;
  1051. dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%llu",
  1052. sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
  1053. /*
  1054. * Get a default scsi_level from the target (derived from sibling
  1055. * devices). This is the best we can do for guessing how to set
  1056. * sdev->lun_in_cdb for the initial INQUIRY command. For LUN 0 the
  1057. * setting doesn't matter, because all the bits are zero anyway.
  1058. * But it does matter for higher LUNs.
  1059. */
  1060. sdev->scsi_level = starget->scsi_level;
  1061. if (sdev->scsi_level <= SCSI_2 &&
  1062. sdev->scsi_level != SCSI_UNKNOWN &&
  1063. !shost->no_scsi2_lun_in_cdb)
  1064. sdev->lun_in_cdb = 1;
  1065. transport_setup_device(&sdev->sdev_gendev);
  1066. spin_lock_irqsave(shost->host_lock, flags);
  1067. list_add_tail(&sdev->same_target_siblings, &starget->devices);
  1068. list_add_tail(&sdev->siblings, &shost->__devices);
  1069. spin_unlock_irqrestore(shost->host_lock, flags);
  1070. /*
  1071. * device can now only be removed via __scsi_remove_device() so hold
  1072. * the target. Target will be held in CREATED state until something
  1073. * beneath it becomes visible (in which case it moves to RUNNING)
  1074. */
  1075. kref_get(&starget->reap_ref);
  1076. }
  1077. int scsi_is_sdev_device(const struct device *dev)
  1078. {
  1079. return dev->type == &scsi_dev_type;
  1080. }
  1081. EXPORT_SYMBOL(scsi_is_sdev_device);
  1082. /* A blank transport template that is used in drivers that don't
  1083. * yet implement Transport Attributes */
  1084. struct scsi_transport_template blank_transport_template = { { { {NULL, }, }, }, };