scsi_transport_spi.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  1. /*
  2. * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
  3. *
  4. * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
  5. * Copyright (c) 2004, 2005 James Bottomley <James.Bottomley@SteelEye.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/ctype.h>
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/workqueue.h>
  25. #include <linux/blkdev.h>
  26. #include <asm/semaphore.h>
  27. #include <scsi/scsi.h>
  28. #include "scsi_priv.h"
  29. #include <scsi/scsi_device.h>
  30. #include <scsi/scsi_host.h>
  31. #include <scsi/scsi_request.h>
  32. #include <scsi/scsi_eh.h>
  33. #include <scsi/scsi_transport.h>
  34. #include <scsi/scsi_transport_spi.h>
  35. #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a)
  36. #define SPI_NUM_ATTRS 14 /* increase this if you add attributes */
  37. #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always
  38. * on" attributes */
  39. #define SPI_HOST_ATTRS 1
  40. #define SPI_MAX_ECHO_BUFFER_SIZE 4096
  41. #define DV_LOOPS 3
  42. #define DV_TIMEOUT (10*HZ)
  43. #define DV_RETRIES 3 /* should only need at most
  44. * two cc/ua clears */
  45. /* Private data accessors (keep these out of the header file) */
  46. #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
  47. #define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
  48. struct spi_internal {
  49. struct scsi_transport_template t;
  50. struct spi_function_template *f;
  51. /* The actual attributes */
  52. struct class_device_attribute private_attrs[SPI_NUM_ATTRS];
  53. /* The array of null terminated pointers to attributes
  54. * needed by scsi_sysfs.c */
  55. struct class_device_attribute *attrs[SPI_NUM_ATTRS + SPI_OTHER_ATTRS + 1];
  56. struct class_device_attribute private_host_attrs[SPI_HOST_ATTRS];
  57. struct class_device_attribute *host_attrs[SPI_HOST_ATTRS + 1];
  58. };
  59. #define to_spi_internal(tmpl) container_of(tmpl, struct spi_internal, t)
  60. static const int ppr_to_ps[] = {
  61. /* The PPR values 0-6 are reserved, fill them in when
  62. * the committee defines them */
  63. -1, /* 0x00 */
  64. -1, /* 0x01 */
  65. -1, /* 0x02 */
  66. -1, /* 0x03 */
  67. -1, /* 0x04 */
  68. -1, /* 0x05 */
  69. -1, /* 0x06 */
  70. 3125, /* 0x07 */
  71. 6250, /* 0x08 */
  72. 12500, /* 0x09 */
  73. 25000, /* 0x0a */
  74. 30300, /* 0x0b */
  75. 50000, /* 0x0c */
  76. };
  77. /* The PPR values at which you calculate the period in ns by multiplying
  78. * by 4 */
  79. #define SPI_STATIC_PPR 0x0c
  80. static int sprint_frac(char *dest, int value, int denom)
  81. {
  82. int frac = value % denom;
  83. int result = sprintf(dest, "%d", value / denom);
  84. if (frac == 0)
  85. return result;
  86. dest[result++] = '.';
  87. do {
  88. denom /= 10;
  89. sprintf(dest + result, "%d", frac / denom);
  90. result++;
  91. frac %= denom;
  92. } while (frac);
  93. dest[result++] = '\0';
  94. return result;
  95. }
  96. /* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions
  97. * resulting from (likely) bus and device resets */
  98. static void spi_wait_req(struct scsi_request *sreq, const void *cmd,
  99. void *buffer, unsigned bufflen)
  100. {
  101. int i;
  102. for(i = 0; i < DV_RETRIES; i++) {
  103. sreq->sr_request->flags |= REQ_FAILFAST;
  104. scsi_wait_req(sreq, cmd, buffer, bufflen,
  105. DV_TIMEOUT, /* retries */ 1);
  106. if (sreq->sr_result & DRIVER_SENSE) {
  107. struct scsi_sense_hdr sshdr;
  108. if (scsi_request_normalize_sense(sreq, &sshdr)
  109. && sshdr.sense_key == UNIT_ATTENTION)
  110. continue;
  111. }
  112. break;
  113. }
  114. }
  115. static struct {
  116. enum spi_signal_type value;
  117. char *name;
  118. } signal_types[] = {
  119. { SPI_SIGNAL_UNKNOWN, "unknown" },
  120. { SPI_SIGNAL_SE, "SE" },
  121. { SPI_SIGNAL_LVD, "LVD" },
  122. { SPI_SIGNAL_HVD, "HVD" },
  123. };
  124. static inline const char *spi_signal_to_string(enum spi_signal_type type)
  125. {
  126. int i;
  127. for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
  128. if (type == signal_types[i].value)
  129. return signal_types[i].name;
  130. }
  131. return NULL;
  132. }
  133. static inline enum spi_signal_type spi_signal_to_value(const char *name)
  134. {
  135. int i, len;
  136. for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
  137. len = strlen(signal_types[i].name);
  138. if (strncmp(name, signal_types[i].name, len) == 0 &&
  139. (name[len] == '\n' || name[len] == '\0'))
  140. return signal_types[i].value;
  141. }
  142. return SPI_SIGNAL_UNKNOWN;
  143. }
  144. static int spi_host_setup(struct transport_container *tc, struct device *dev,
  145. struct class_device *cdev)
  146. {
  147. struct Scsi_Host *shost = dev_to_shost(dev);
  148. spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
  149. return 0;
  150. }
  151. static DECLARE_TRANSPORT_CLASS(spi_host_class,
  152. "spi_host",
  153. spi_host_setup,
  154. NULL,
  155. NULL);
  156. static int spi_host_match(struct attribute_container *cont,
  157. struct device *dev)
  158. {
  159. struct Scsi_Host *shost;
  160. struct spi_internal *i;
  161. if (!scsi_is_host_device(dev))
  162. return 0;
  163. shost = dev_to_shost(dev);
  164. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  165. != &spi_host_class.class)
  166. return 0;
  167. i = to_spi_internal(shost->transportt);
  168. return &i->t.host_attrs.ac == cont;
  169. }
  170. static int spi_device_configure(struct transport_container *tc,
  171. struct device *dev,
  172. struct class_device *cdev)
  173. {
  174. struct scsi_device *sdev = to_scsi_device(dev);
  175. struct scsi_target *starget = sdev->sdev_target;
  176. /* Populate the target capability fields with the values
  177. * gleaned from the device inquiry */
  178. spi_support_sync(starget) = scsi_device_sync(sdev);
  179. spi_support_wide(starget) = scsi_device_wide(sdev);
  180. spi_support_dt(starget) = scsi_device_dt(sdev);
  181. spi_support_dt_only(starget) = scsi_device_dt_only(sdev);
  182. spi_support_ius(starget) = scsi_device_ius(sdev);
  183. spi_support_qas(starget) = scsi_device_qas(sdev);
  184. return 0;
  185. }
  186. static int spi_setup_transport_attrs(struct transport_container *tc,
  187. struct device *dev,
  188. struct class_device *cdev)
  189. {
  190. struct scsi_target *starget = to_scsi_target(dev);
  191. spi_period(starget) = -1; /* illegal value */
  192. spi_min_period(starget) = 0;
  193. spi_offset(starget) = 0; /* async */
  194. spi_max_offset(starget) = 255;
  195. spi_width(starget) = 0; /* narrow */
  196. spi_max_width(starget) = 1;
  197. spi_iu(starget) = 0; /* no IU */
  198. spi_dt(starget) = 0; /* ST */
  199. spi_qas(starget) = 0;
  200. spi_wr_flow(starget) = 0;
  201. spi_rd_strm(starget) = 0;
  202. spi_rti(starget) = 0;
  203. spi_pcomp_en(starget) = 0;
  204. spi_hold_mcs(starget) = 0;
  205. spi_dv_pending(starget) = 0;
  206. spi_initial_dv(starget) = 0;
  207. init_MUTEX(&spi_dv_sem(starget));
  208. return 0;
  209. }
  210. #define spi_transport_show_simple(field, format_string) \
  211. \
  212. static ssize_t \
  213. show_spi_transport_##field(struct class_device *cdev, char *buf) \
  214. { \
  215. struct scsi_target *starget = transport_class_to_starget(cdev); \
  216. struct spi_transport_attrs *tp; \
  217. \
  218. tp = (struct spi_transport_attrs *)&starget->starget_data; \
  219. return snprintf(buf, 20, format_string, tp->field); \
  220. }
  221. #define spi_transport_store_simple(field, format_string) \
  222. \
  223. static ssize_t \
  224. store_spi_transport_##field(struct class_device *cdev, const char *buf, \
  225. size_t count) \
  226. { \
  227. int val; \
  228. struct scsi_target *starget = transport_class_to_starget(cdev); \
  229. struct spi_transport_attrs *tp; \
  230. \
  231. tp = (struct spi_transport_attrs *)&starget->starget_data; \
  232. val = simple_strtoul(buf, NULL, 0); \
  233. tp->field = val; \
  234. return count; \
  235. }
  236. #define spi_transport_show_function(field, format_string) \
  237. \
  238. static ssize_t \
  239. show_spi_transport_##field(struct class_device *cdev, char *buf) \
  240. { \
  241. struct scsi_target *starget = transport_class_to_starget(cdev); \
  242. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
  243. struct spi_transport_attrs *tp; \
  244. struct spi_internal *i = to_spi_internal(shost->transportt); \
  245. tp = (struct spi_transport_attrs *)&starget->starget_data; \
  246. if (i->f->get_##field) \
  247. i->f->get_##field(starget); \
  248. return snprintf(buf, 20, format_string, tp->field); \
  249. }
  250. #define spi_transport_store_function(field, format_string) \
  251. static ssize_t \
  252. store_spi_transport_##field(struct class_device *cdev, const char *buf, \
  253. size_t count) \
  254. { \
  255. int val; \
  256. struct scsi_target *starget = transport_class_to_starget(cdev); \
  257. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
  258. struct spi_internal *i = to_spi_internal(shost->transportt); \
  259. \
  260. val = simple_strtoul(buf, NULL, 0); \
  261. i->f->set_##field(starget, val); \
  262. return count; \
  263. }
  264. #define spi_transport_store_max(field, format_string) \
  265. static ssize_t \
  266. store_spi_transport_##field(struct class_device *cdev, const char *buf, \
  267. size_t count) \
  268. { \
  269. int val; \
  270. struct scsi_target *starget = transport_class_to_starget(cdev); \
  271. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
  272. struct spi_internal *i = to_spi_internal(shost->transportt); \
  273. struct spi_transport_attrs *tp \
  274. = (struct spi_transport_attrs *)&starget->starget_data; \
  275. \
  276. val = simple_strtoul(buf, NULL, 0); \
  277. if (val > tp->max_##field) \
  278. val = tp->max_##field; \
  279. i->f->set_##field(starget, val); \
  280. return count; \
  281. }
  282. #define spi_transport_rd_attr(field, format_string) \
  283. spi_transport_show_function(field, format_string) \
  284. spi_transport_store_function(field, format_string) \
  285. static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
  286. show_spi_transport_##field, \
  287. store_spi_transport_##field);
  288. #define spi_transport_simple_attr(field, format_string) \
  289. spi_transport_show_simple(field, format_string) \
  290. spi_transport_store_simple(field, format_string) \
  291. static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
  292. show_spi_transport_##field, \
  293. store_spi_transport_##field);
  294. #define spi_transport_max_attr(field, format_string) \
  295. spi_transport_show_function(field, format_string) \
  296. spi_transport_store_max(field, format_string) \
  297. spi_transport_simple_attr(max_##field, format_string) \
  298. static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
  299. show_spi_transport_##field, \
  300. store_spi_transport_##field);
  301. /* The Parallel SCSI Tranport Attributes: */
  302. spi_transport_max_attr(offset, "%d\n");
  303. spi_transport_max_attr(width, "%d\n");
  304. spi_transport_rd_attr(iu, "%d\n");
  305. spi_transport_rd_attr(dt, "%d\n");
  306. spi_transport_rd_attr(qas, "%d\n");
  307. spi_transport_rd_attr(wr_flow, "%d\n");
  308. spi_transport_rd_attr(rd_strm, "%d\n");
  309. spi_transport_rd_attr(rti, "%d\n");
  310. spi_transport_rd_attr(pcomp_en, "%d\n");
  311. spi_transport_rd_attr(hold_mcs, "%d\n");
  312. /* we only care about the first child device so we return 1 */
  313. static int child_iter(struct device *dev, void *data)
  314. {
  315. struct scsi_device *sdev = to_scsi_device(dev);
  316. spi_dv_device(sdev);
  317. return 1;
  318. }
  319. static ssize_t
  320. store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
  321. {
  322. struct scsi_target *starget = transport_class_to_starget(cdev);
  323. device_for_each_child(&starget->dev, NULL, child_iter);
  324. return count;
  325. }
  326. static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
  327. /* Translate the period into ns according to the current spec
  328. * for SDTR/PPR messages */
  329. static ssize_t
  330. show_spi_transport_period_helper(struct class_device *cdev, char *buf,
  331. int period)
  332. {
  333. int len, picosec;
  334. if (period < 0 || period > 0xff) {
  335. picosec = -1;
  336. } else if (period <= SPI_STATIC_PPR) {
  337. picosec = ppr_to_ps[period];
  338. } else {
  339. picosec = period * 4000;
  340. }
  341. if (picosec == -1) {
  342. len = sprintf(buf, "reserved");
  343. } else {
  344. len = sprint_frac(buf, picosec, 1000);
  345. }
  346. buf[len++] = '\n';
  347. buf[len] = '\0';
  348. return len;
  349. }
  350. static ssize_t
  351. store_spi_transport_period_helper(struct class_device *cdev, const char *buf,
  352. size_t count, int *periodp)
  353. {
  354. int j, picosec, period = -1;
  355. char *endp;
  356. picosec = simple_strtoul(buf, &endp, 10) * 1000;
  357. if (*endp == '.') {
  358. int mult = 100;
  359. do {
  360. endp++;
  361. if (!isdigit(*endp))
  362. break;
  363. picosec += (*endp - '0') * mult;
  364. mult /= 10;
  365. } while (mult > 0);
  366. }
  367. for (j = 0; j <= SPI_STATIC_PPR; j++) {
  368. if (ppr_to_ps[j] < picosec)
  369. continue;
  370. period = j;
  371. break;
  372. }
  373. if (period == -1)
  374. period = picosec / 4000;
  375. if (period > 0xff)
  376. period = 0xff;
  377. *periodp = period;
  378. return count;
  379. }
  380. static ssize_t
  381. show_spi_transport_period(struct class_device *cdev, char *buf)
  382. {
  383. struct scsi_target *starget = transport_class_to_starget(cdev);
  384. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  385. struct spi_internal *i = to_spi_internal(shost->transportt);
  386. struct spi_transport_attrs *tp =
  387. (struct spi_transport_attrs *)&starget->starget_data;
  388. if (i->f->get_period)
  389. i->f->get_period(starget);
  390. return show_spi_transport_period_helper(cdev, buf, tp->period);
  391. }
  392. static ssize_t
  393. store_spi_transport_period(struct class_device *cdev, const char *buf,
  394. size_t count)
  395. {
  396. struct scsi_target *starget = transport_class_to_starget(cdev);
  397. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  398. struct spi_internal *i = to_spi_internal(shost->transportt);
  399. struct spi_transport_attrs *tp =
  400. (struct spi_transport_attrs *)&starget->starget_data;
  401. int period, retval;
  402. retval = store_spi_transport_period_helper(cdev, buf, count, &period);
  403. if (period < tp->min_period)
  404. period = tp->min_period;
  405. i->f->set_period(starget, period);
  406. return retval;
  407. }
  408. static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR,
  409. show_spi_transport_period,
  410. store_spi_transport_period);
  411. static ssize_t
  412. show_spi_transport_min_period(struct class_device *cdev, char *buf)
  413. {
  414. struct scsi_target *starget = transport_class_to_starget(cdev);
  415. struct spi_transport_attrs *tp =
  416. (struct spi_transport_attrs *)&starget->starget_data;
  417. return show_spi_transport_period_helper(cdev, buf, tp->min_period);
  418. }
  419. static ssize_t
  420. store_spi_transport_min_period(struct class_device *cdev, const char *buf,
  421. size_t count)
  422. {
  423. struct scsi_target *starget = transport_class_to_starget(cdev);
  424. struct spi_transport_attrs *tp =
  425. (struct spi_transport_attrs *)&starget->starget_data;
  426. return store_spi_transport_period_helper(cdev, buf, count,
  427. &tp->min_period);
  428. }
  429. static CLASS_DEVICE_ATTR(min_period, S_IRUGO | S_IWUSR,
  430. show_spi_transport_min_period,
  431. store_spi_transport_min_period);
  432. static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf)
  433. {
  434. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  435. struct spi_internal *i = to_spi_internal(shost->transportt);
  436. if (i->f->get_signalling)
  437. i->f->get_signalling(shost);
  438. return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost)));
  439. }
  440. static ssize_t store_spi_host_signalling(struct class_device *cdev,
  441. const char *buf, size_t count)
  442. {
  443. struct Scsi_Host *shost = transport_class_to_shost(cdev);
  444. struct spi_internal *i = to_spi_internal(shost->transportt);
  445. enum spi_signal_type type = spi_signal_to_value(buf);
  446. if (type != SPI_SIGNAL_UNKNOWN)
  447. i->f->set_signalling(shost, type);
  448. return count;
  449. }
  450. static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
  451. show_spi_host_signalling,
  452. store_spi_host_signalling);
  453. #define DV_SET(x, y) \
  454. if(i->f->set_##x) \
  455. i->f->set_##x(sdev->sdev_target, y)
  456. enum spi_compare_returns {
  457. SPI_COMPARE_SUCCESS,
  458. SPI_COMPARE_FAILURE,
  459. SPI_COMPARE_SKIP_TEST,
  460. };
  461. /* This is for read/write Domain Validation: If the device supports
  462. * an echo buffer, we do read/write tests to it */
  463. static enum spi_compare_returns
  464. spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
  465. u8 *ptr, const int retries)
  466. {
  467. struct scsi_device *sdev = sreq->sr_device;
  468. int len = ptr - buffer;
  469. int j, k, r;
  470. unsigned int pattern = 0x0000ffff;
  471. const char spi_write_buffer[] = {
  472. WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
  473. };
  474. const char spi_read_buffer[] = {
  475. READ_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
  476. };
  477. /* set up the pattern buffer. Doesn't matter if we spill
  478. * slightly beyond since that's where the read buffer is */
  479. for (j = 0; j < len; ) {
  480. /* fill the buffer with counting (test a) */
  481. for ( ; j < min(len, 32); j++)
  482. buffer[j] = j;
  483. k = j;
  484. /* fill the buffer with alternating words of 0x0 and
  485. * 0xffff (test b) */
  486. for ( ; j < min(len, k + 32); j += 2) {
  487. u16 *word = (u16 *)&buffer[j];
  488. *word = (j & 0x02) ? 0x0000 : 0xffff;
  489. }
  490. k = j;
  491. /* fill with crosstalk (alternating 0x5555 0xaaa)
  492. * (test c) */
  493. for ( ; j < min(len, k + 32); j += 2) {
  494. u16 *word = (u16 *)&buffer[j];
  495. *word = (j & 0x02) ? 0x5555 : 0xaaaa;
  496. }
  497. k = j;
  498. /* fill with shifting bits (test d) */
  499. for ( ; j < min(len, k + 32); j += 4) {
  500. u32 *word = (unsigned int *)&buffer[j];
  501. u32 roll = (pattern & 0x80000000) ? 1 : 0;
  502. *word = pattern;
  503. pattern = (pattern << 1) | roll;
  504. }
  505. /* don't bother with random data (test e) */
  506. }
  507. for (r = 0; r < retries; r++) {
  508. sreq->sr_cmd_len = 0; /* wait_req to fill in */
  509. sreq->sr_data_direction = DMA_TO_DEVICE;
  510. spi_wait_req(sreq, spi_write_buffer, buffer, len);
  511. if(sreq->sr_result || !scsi_device_online(sdev)) {
  512. struct scsi_sense_hdr sshdr;
  513. scsi_device_set_state(sdev, SDEV_QUIESCE);
  514. if (scsi_request_normalize_sense(sreq, &sshdr)
  515. && sshdr.sense_key == ILLEGAL_REQUEST
  516. /* INVALID FIELD IN CDB */
  517. && sshdr.asc == 0x24 && sshdr.ascq == 0x00)
  518. /* This would mean that the drive lied
  519. * to us about supporting an echo
  520. * buffer (unfortunately some Western
  521. * Digital drives do precisely this)
  522. */
  523. return SPI_COMPARE_SKIP_TEST;
  524. SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);
  525. return SPI_COMPARE_FAILURE;
  526. }
  527. memset(ptr, 0, len);
  528. sreq->sr_cmd_len = 0; /* wait_req to fill in */
  529. sreq->sr_data_direction = DMA_FROM_DEVICE;
  530. spi_wait_req(sreq, spi_read_buffer, ptr, len);
  531. scsi_device_set_state(sdev, SDEV_QUIESCE);
  532. if (memcmp(buffer, ptr, len) != 0)
  533. return SPI_COMPARE_FAILURE;
  534. }
  535. return SPI_COMPARE_SUCCESS;
  536. }
  537. /* This is for the simplest form of Domain Validation: a read test
  538. * on the inquiry data from the device */
  539. static enum spi_compare_returns
  540. spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
  541. u8 *ptr, const int retries)
  542. {
  543. int r;
  544. const int len = sreq->sr_device->inquiry_len;
  545. struct scsi_device *sdev = sreq->sr_device;
  546. const char spi_inquiry[] = {
  547. INQUIRY, 0, 0, 0, len, 0
  548. };
  549. for (r = 0; r < retries; r++) {
  550. sreq->sr_cmd_len = 0; /* wait_req to fill in */
  551. sreq->sr_data_direction = DMA_FROM_DEVICE;
  552. memset(ptr, 0, len);
  553. spi_wait_req(sreq, spi_inquiry, ptr, len);
  554. if(sreq->sr_result || !scsi_device_online(sdev)) {
  555. scsi_device_set_state(sdev, SDEV_QUIESCE);
  556. return SPI_COMPARE_FAILURE;
  557. }
  558. /* If we don't have the inquiry data already, the
  559. * first read gets it */
  560. if (ptr == buffer) {
  561. ptr += len;
  562. --r;
  563. continue;
  564. }
  565. if (memcmp(buffer, ptr, len) != 0)
  566. /* failure */
  567. return SPI_COMPARE_FAILURE;
  568. }
  569. return SPI_COMPARE_SUCCESS;
  570. }
  571. static enum spi_compare_returns
  572. spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,
  573. enum spi_compare_returns
  574. (*compare_fn)(struct scsi_request *, u8 *, u8 *, int))
  575. {
  576. struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
  577. struct scsi_device *sdev = sreq->sr_device;
  578. struct scsi_target *starget = sdev->sdev_target;
  579. int period = 0, prevperiod = 0;
  580. enum spi_compare_returns retval;
  581. for (;;) {
  582. int newperiod;
  583. retval = compare_fn(sreq, buffer, ptr, DV_LOOPS);
  584. if (retval == SPI_COMPARE_SUCCESS
  585. || retval == SPI_COMPARE_SKIP_TEST)
  586. break;
  587. /* OK, retrain, fallback */
  588. if (i->f->get_iu)
  589. i->f->get_iu(starget);
  590. if (i->f->get_qas)
  591. i->f->get_qas(starget);
  592. if (i->f->get_period)
  593. i->f->get_period(sdev->sdev_target);
  594. /* Here's the fallback sequence; first try turning off
  595. * IU, then QAS (if we can control them), then finally
  596. * fall down the periods */
  597. if (i->f->set_iu && spi_iu(starget)) {
  598. SPI_PRINTK(starget, KERN_ERR, "Domain Validation Disabing Information Units\n");
  599. DV_SET(iu, 0);
  600. } else if (i->f->set_qas && spi_qas(starget)) {
  601. SPI_PRINTK(starget, KERN_ERR, "Domain Validation Disabing Quick Arbitration and Selection\n");
  602. DV_SET(qas, 0);
  603. } else {
  604. newperiod = spi_period(starget);
  605. period = newperiod > period ? newperiod : period;
  606. if (period < 0x0d)
  607. period++;
  608. else
  609. period += period >> 1;
  610. if (unlikely(period > 0xff || period == prevperiod)) {
  611. /* Total failure; set to async and return */
  612. SPI_PRINTK(starget, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");
  613. DV_SET(offset, 0);
  614. return SPI_COMPARE_FAILURE;
  615. }
  616. SPI_PRINTK(starget, KERN_ERR, "Domain Validation detected failure, dropping back\n");
  617. DV_SET(period, period);
  618. prevperiod = period;
  619. }
  620. }
  621. return retval;
  622. }
  623. static int
  624. spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
  625. {
  626. int l;
  627. /* first off do a test unit ready. This can error out
  628. * because of reservations or some other reason. If it
  629. * fails, the device won't let us write to the echo buffer
  630. * so just return failure */
  631. const char spi_test_unit_ready[] = {
  632. TEST_UNIT_READY, 0, 0, 0, 0, 0
  633. };
  634. const char spi_read_buffer_descriptor[] = {
  635. READ_BUFFER, 0x0b, 0, 0, 0, 0, 0, 0, 4, 0
  636. };
  637. sreq->sr_cmd_len = 0;
  638. sreq->sr_data_direction = DMA_NONE;
  639. /* We send a set of three TURs to clear any outstanding
  640. * unit attention conditions if they exist (Otherwise the
  641. * buffer tests won't be happy). If the TUR still fails
  642. * (reservation conflict, device not ready, etc) just
  643. * skip the write tests */
  644. for (l = 0; ; l++) {
  645. spi_wait_req(sreq, spi_test_unit_ready, NULL, 0);
  646. if(sreq->sr_result) {
  647. if(l >= 3)
  648. return 0;
  649. } else {
  650. /* TUR succeeded */
  651. break;
  652. }
  653. }
  654. sreq->sr_cmd_len = 0;
  655. sreq->sr_data_direction = DMA_FROM_DEVICE;
  656. spi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4);
  657. if (sreq->sr_result)
  658. /* Device has no echo buffer */
  659. return 0;
  660. return buffer[3] + ((buffer[2] & 0x1f) << 8);
  661. }
  662. static void
  663. spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
  664. {
  665. struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
  666. struct scsi_device *sdev = sreq->sr_device;
  667. struct scsi_target *starget = sdev->sdev_target;
  668. int len = sdev->inquiry_len;
  669. /* first set us up for narrow async */
  670. DV_SET(offset, 0);
  671. DV_SET(width, 0);
  672. if (spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS)
  673. != SPI_COMPARE_SUCCESS) {
  674. SPI_PRINTK(starget, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
  675. /* FIXME: should probably offline the device here? */
  676. return;
  677. }
  678. /* test width */
  679. if (i->f->set_width && spi_max_width(starget) &&
  680. scsi_device_wide(sdev)) {
  681. i->f->set_width(starget, 1);
  682. if (spi_dv_device_compare_inquiry(sreq, buffer,
  683. buffer + len,
  684. DV_LOOPS)
  685. != SPI_COMPARE_SUCCESS) {
  686. SPI_PRINTK(starget, KERN_ERR, "Wide Transfers Fail\n");
  687. i->f->set_width(starget, 0);
  688. }
  689. }
  690. if (!i->f->set_period)
  691. return;
  692. /* device can't handle synchronous */
  693. if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev))
  694. return;
  695. /* see if the device has an echo buffer. If it does we can
  696. * do the SPI pattern write tests */
  697. len = 0;
  698. if (scsi_device_dt(sdev))
  699. len = spi_dv_device_get_echo_buffer(sreq, buffer);
  700. retry:
  701. /* now set up to the maximum */
  702. DV_SET(offset, spi_max_offset(starget));
  703. DV_SET(period, spi_min_period(starget));
  704. /* try QAS requests; this should be harmless to set if the
  705. * target supports it */
  706. if (scsi_device_qas(sdev))
  707. DV_SET(qas, 1);
  708. /* Also try IU transfers */
  709. if (scsi_device_ius(sdev))
  710. DV_SET(iu, 1);
  711. if (spi_min_period(starget) < 9) {
  712. /* This u320 (or u640). Ignore the coupled parameters
  713. * like DT and IU, but set the optional ones */
  714. DV_SET(rd_strm, 1);
  715. DV_SET(wr_flow, 1);
  716. DV_SET(rti, 1);
  717. if (spi_min_period(starget) == 8)
  718. DV_SET(pcomp_en, 1);
  719. }
  720. if (len == 0) {
  721. SPI_PRINTK(starget, KERN_INFO, "Domain Validation skipping write tests\n");
  722. spi_dv_retrain(sreq, buffer, buffer + len,
  723. spi_dv_device_compare_inquiry);
  724. return;
  725. }
  726. if (len > SPI_MAX_ECHO_BUFFER_SIZE) {
  727. SPI_PRINTK(starget, KERN_WARNING, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
  728. len = SPI_MAX_ECHO_BUFFER_SIZE;
  729. }
  730. if (spi_dv_retrain(sreq, buffer, buffer + len,
  731. spi_dv_device_echo_buffer)
  732. == SPI_COMPARE_SKIP_TEST) {
  733. /* OK, the stupid drive can't do a write echo buffer
  734. * test after all, fall back to the read tests */
  735. len = 0;
  736. goto retry;
  737. }
  738. }
  739. /** spi_dv_device - Do Domain Validation on the device
  740. * @sdev: scsi device to validate
  741. *
  742. * Performs the domain validation on the given device in the
  743. * current execution thread. Since DV operations may sleep,
  744. * the current thread must have user context. Also no SCSI
  745. * related locks that would deadlock I/O issued by the DV may
  746. * be held.
  747. */
  748. void
  749. spi_dv_device(struct scsi_device *sdev)
  750. {
  751. struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
  752. struct scsi_target *starget = sdev->sdev_target;
  753. u8 *buffer;
  754. const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
  755. if (unlikely(!sreq))
  756. return;
  757. if (unlikely(scsi_device_get(sdev)))
  758. goto out_free_req;
  759. buffer = kmalloc(len, GFP_KERNEL);
  760. if (unlikely(!buffer))
  761. goto out_put;
  762. memset(buffer, 0, len);
  763. /* We need to verify that the actual device will quiesce; the
  764. * later target quiesce is just a nice to have */
  765. if (unlikely(scsi_device_quiesce(sdev)))
  766. goto out_free;
  767. scsi_target_quiesce(starget);
  768. spi_dv_pending(starget) = 1;
  769. down(&spi_dv_sem(starget));
  770. SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n");
  771. spi_dv_device_internal(sreq, buffer);
  772. SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n");
  773. up(&spi_dv_sem(starget));
  774. spi_dv_pending(starget) = 0;
  775. scsi_target_resume(starget);
  776. spi_initial_dv(starget) = 1;
  777. out_free:
  778. kfree(buffer);
  779. out_put:
  780. scsi_device_put(sdev);
  781. out_free_req:
  782. scsi_release_request(sreq);
  783. }
  784. EXPORT_SYMBOL(spi_dv_device);
  785. struct work_queue_wrapper {
  786. struct work_struct work;
  787. struct scsi_device *sdev;
  788. };
  789. static void
  790. spi_dv_device_work_wrapper(void *data)
  791. {
  792. struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data;
  793. struct scsi_device *sdev = wqw->sdev;
  794. kfree(wqw);
  795. spi_dv_device(sdev);
  796. spi_dv_pending(sdev->sdev_target) = 0;
  797. scsi_device_put(sdev);
  798. }
  799. /**
  800. * spi_schedule_dv_device - schedule domain validation to occur on the device
  801. * @sdev: The device to validate
  802. *
  803. * Identical to spi_dv_device() above, except that the DV will be
  804. * scheduled to occur in a workqueue later. All memory allocations
  805. * are atomic, so may be called from any context including those holding
  806. * SCSI locks.
  807. */
  808. void
  809. spi_schedule_dv_device(struct scsi_device *sdev)
  810. {
  811. struct work_queue_wrapper *wqw =
  812. kmalloc(sizeof(struct work_queue_wrapper), GFP_ATOMIC);
  813. if (unlikely(!wqw))
  814. return;
  815. if (unlikely(spi_dv_pending(sdev->sdev_target))) {
  816. kfree(wqw);
  817. return;
  818. }
  819. /* Set pending early (dv_device doesn't check it, only sets it) */
  820. spi_dv_pending(sdev->sdev_target) = 1;
  821. if (unlikely(scsi_device_get(sdev))) {
  822. kfree(wqw);
  823. spi_dv_pending(sdev->sdev_target) = 0;
  824. return;
  825. }
  826. INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw);
  827. wqw->sdev = sdev;
  828. schedule_work(&wqw->work);
  829. }
  830. EXPORT_SYMBOL(spi_schedule_dv_device);
  831. /**
  832. * spi_display_xfer_agreement - Print the current target transfer agreement
  833. * @starget: The target for which to display the agreement
  834. *
  835. * Each SPI port is required to maintain a transfer agreement for each
  836. * other port on the bus. This function prints a one-line summary of
  837. * the current agreement; more detailed information is available in sysfs.
  838. */
  839. void spi_display_xfer_agreement(struct scsi_target *starget)
  840. {
  841. struct spi_transport_attrs *tp;
  842. tp = (struct spi_transport_attrs *)&starget->starget_data;
  843. if (tp->offset > 0 && tp->period > 0) {
  844. unsigned int picosec, kb100;
  845. char *scsi = "FAST-?";
  846. char tmp[8];
  847. if (tp->period <= SPI_STATIC_PPR) {
  848. picosec = ppr_to_ps[tp->period];
  849. switch (tp->period) {
  850. case 7: scsi = "FAST-320"; break;
  851. case 8: scsi = "FAST-160"; break;
  852. case 9: scsi = "FAST-80"; break;
  853. case 10:
  854. case 11: scsi = "FAST-40"; break;
  855. case 12: scsi = "FAST-20"; break;
  856. }
  857. } else {
  858. picosec = tp->period * 4000;
  859. if (tp->period < 25)
  860. scsi = "FAST-20";
  861. else if (tp->period < 50)
  862. scsi = "FAST-10";
  863. else
  864. scsi = "FAST-5";
  865. }
  866. kb100 = (10000000 + picosec / 2) / picosec;
  867. if (tp->width)
  868. kb100 *= 2;
  869. sprint_frac(tmp, picosec, 1000);
  870. dev_info(&starget->dev,
  871. "%s %sSCSI %d.%d MB/s %s%s%s%s%s%s%s%s (%s ns, offset %d)\n",
  872. scsi, tp->width ? "WIDE " : "", kb100/10, kb100 % 10,
  873. tp->dt ? "DT" : "ST",
  874. tp->iu ? " IU" : "",
  875. tp->qas ? " QAS" : "",
  876. tp->rd_strm ? " RDSTRM" : "",
  877. tp->rti ? " RTI" : "",
  878. tp->wr_flow ? " WRFLOW" : "",
  879. tp->pcomp_en ? " PCOMP" : "",
  880. tp->hold_mcs ? " HMCS" : "",
  881. tmp, tp->offset);
  882. } else {
  883. dev_info(&starget->dev, "%sasynchronous.\n",
  884. tp->width ? "wide " : "");
  885. }
  886. }
  887. EXPORT_SYMBOL(spi_display_xfer_agreement);
  888. #define SETUP_ATTRIBUTE(field) \
  889. i->private_attrs[count] = class_device_attr_##field; \
  890. if (!i->f->set_##field) { \
  891. i->private_attrs[count].attr.mode = S_IRUGO; \
  892. i->private_attrs[count].store = NULL; \
  893. } \
  894. i->attrs[count] = &i->private_attrs[count]; \
  895. if (i->f->show_##field) \
  896. count++
  897. #define SETUP_RELATED_ATTRIBUTE(field, rel_field) \
  898. i->private_attrs[count] = class_device_attr_##field; \
  899. if (!i->f->set_##rel_field) { \
  900. i->private_attrs[count].attr.mode = S_IRUGO; \
  901. i->private_attrs[count].store = NULL; \
  902. } \
  903. i->attrs[count] = &i->private_attrs[count]; \
  904. if (i->f->show_##rel_field) \
  905. count++
  906. #define SETUP_HOST_ATTRIBUTE(field) \
  907. i->private_host_attrs[count] = class_device_attr_##field; \
  908. if (!i->f->set_##field) { \
  909. i->private_host_attrs[count].attr.mode = S_IRUGO; \
  910. i->private_host_attrs[count].store = NULL; \
  911. } \
  912. i->host_attrs[count] = &i->private_host_attrs[count]; \
  913. count++
  914. static int spi_device_match(struct attribute_container *cont,
  915. struct device *dev)
  916. {
  917. struct scsi_device *sdev;
  918. struct Scsi_Host *shost;
  919. struct spi_internal *i;
  920. if (!scsi_is_sdev_device(dev))
  921. return 0;
  922. sdev = to_scsi_device(dev);
  923. shost = sdev->host;
  924. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  925. != &spi_host_class.class)
  926. return 0;
  927. /* Note: this class has no device attributes, so it has
  928. * no per-HBA allocation and thus we don't need to distinguish
  929. * the attribute containers for the device */
  930. i = to_spi_internal(shost->transportt);
  931. if (i->f->deny_binding && i->f->deny_binding(sdev->sdev_target))
  932. return 0;
  933. return 1;
  934. }
  935. static int spi_target_match(struct attribute_container *cont,
  936. struct device *dev)
  937. {
  938. struct Scsi_Host *shost;
  939. struct scsi_target *starget;
  940. struct spi_internal *i;
  941. if (!scsi_is_target_device(dev))
  942. return 0;
  943. shost = dev_to_shost(dev->parent);
  944. if (!shost->transportt || shost->transportt->host_attrs.ac.class
  945. != &spi_host_class.class)
  946. return 0;
  947. i = to_spi_internal(shost->transportt);
  948. starget = to_scsi_target(dev);
  949. if (i->f->deny_binding && i->f->deny_binding(starget))
  950. return 0;
  951. return &i->t.target_attrs.ac == cont;
  952. }
  953. static DECLARE_TRANSPORT_CLASS(spi_transport_class,
  954. "spi_transport",
  955. spi_setup_transport_attrs,
  956. NULL,
  957. NULL);
  958. static DECLARE_ANON_TRANSPORT_CLASS(spi_device_class,
  959. spi_device_match,
  960. spi_device_configure);
  961. struct scsi_transport_template *
  962. spi_attach_transport(struct spi_function_template *ft)
  963. {
  964. struct spi_internal *i = kmalloc(sizeof(struct spi_internal),
  965. GFP_KERNEL);
  966. int count = 0;
  967. if (unlikely(!i))
  968. return NULL;
  969. memset(i, 0, sizeof(struct spi_internal));
  970. i->t.target_attrs.ac.class = &spi_transport_class.class;
  971. i->t.target_attrs.ac.attrs = &i->attrs[0];
  972. i->t.target_attrs.ac.match = spi_target_match;
  973. transport_container_register(&i->t.target_attrs);
  974. i->t.target_size = sizeof(struct spi_transport_attrs);
  975. i->t.host_attrs.ac.class = &spi_host_class.class;
  976. i->t.host_attrs.ac.attrs = &i->host_attrs[0];
  977. i->t.host_attrs.ac.match = spi_host_match;
  978. transport_container_register(&i->t.host_attrs);
  979. i->t.host_size = sizeof(struct spi_host_attrs);
  980. i->f = ft;
  981. SETUP_ATTRIBUTE(period);
  982. SETUP_RELATED_ATTRIBUTE(min_period, period);
  983. SETUP_ATTRIBUTE(offset);
  984. SETUP_RELATED_ATTRIBUTE(max_offset, offset);
  985. SETUP_ATTRIBUTE(width);
  986. SETUP_RELATED_ATTRIBUTE(max_width, width);
  987. SETUP_ATTRIBUTE(iu);
  988. SETUP_ATTRIBUTE(dt);
  989. SETUP_ATTRIBUTE(qas);
  990. SETUP_ATTRIBUTE(wr_flow);
  991. SETUP_ATTRIBUTE(rd_strm);
  992. SETUP_ATTRIBUTE(rti);
  993. SETUP_ATTRIBUTE(pcomp_en);
  994. SETUP_ATTRIBUTE(hold_mcs);
  995. /* if you add an attribute but forget to increase SPI_NUM_ATTRS
  996. * this bug will trigger */
  997. BUG_ON(count > SPI_NUM_ATTRS);
  998. i->attrs[count++] = &class_device_attr_revalidate;
  999. i->attrs[count] = NULL;
  1000. count = 0;
  1001. SETUP_HOST_ATTRIBUTE(signalling);
  1002. BUG_ON(count > SPI_HOST_ATTRS);
  1003. i->host_attrs[count] = NULL;
  1004. return &i->t;
  1005. }
  1006. EXPORT_SYMBOL(spi_attach_transport);
  1007. void spi_release_transport(struct scsi_transport_template *t)
  1008. {
  1009. struct spi_internal *i = to_spi_internal(t);
  1010. transport_container_unregister(&i->t.target_attrs);
  1011. transport_container_unregister(&i->t.host_attrs);
  1012. kfree(i);
  1013. }
  1014. EXPORT_SYMBOL(spi_release_transport);
  1015. static __init int spi_transport_init(void)
  1016. {
  1017. int error = transport_class_register(&spi_transport_class);
  1018. if (error)
  1019. return error;
  1020. error = anon_transport_class_register(&spi_device_class);
  1021. return transport_class_register(&spi_host_class);
  1022. }
  1023. static void __exit spi_transport_exit(void)
  1024. {
  1025. transport_class_unregister(&spi_transport_class);
  1026. anon_transport_class_unregister(&spi_device_class);
  1027. transport_class_unregister(&spi_host_class);
  1028. }
  1029. MODULE_AUTHOR("Martin Hicks");
  1030. MODULE_DESCRIPTION("SPI Transport Attributes");
  1031. MODULE_LICENSE("GPL");
  1032. module_init(spi_transport_init);
  1033. module_exit(spi_transport_exit);