2 * Parallel SCSI (SPI) transport specific attributes exported to sysfs.
4 * Copyright (c) 2003 Silicon Graphics, Inc. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/smp_lock.h>
23 #include <linux/list.h>
24 #include <linux/spinlock.h>
26 #include <linux/workqueue.h>
27 #include <asm/scatterlist.h>
29 #include <scsi/scsi.h>
30 #include "scsi_priv.h"
31 #include <scsi/scsi_device.h>
32 #include <scsi/scsi_host.h>
33 #include <scsi/scsi_request.h>
34 #include <scsi/scsi_transport.h>
35 #include <scsi/scsi_transport_spi.h>
37 #define SPI_PRINTK(x, l, f, a...) dev_printk(l, &(x)->dev, f , ##a)
39 static void transport_class_release(struct class_device *class_dev);
40 static void host_class_release(struct class_device *class_dev);
42 #define SPI_NUM_ATTRS 10 /* increase this if you add attributes */
43 #define SPI_OTHER_ATTRS 1 /* Increase this if you add "always
45 #define SPI_HOST_ATTRS 1
47 #define SPI_MAX_ECHO_BUFFER_SIZE 4096
49 /* Private data accessors (keep these out of the header file) */
50 #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
51 #define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
54 struct scsi_transport_template t;
55 struct spi_function_template *f;
56 /* The actual attributes */
57 struct class_device_attribute private_attrs[SPI_NUM_ATTRS];
58 /* The array of null terminated pointers to attributes
59 * needed by scsi_sysfs.c */
60 struct class_device_attribute *attrs[SPI_NUM_ATTRS + SPI_OTHER_ATTRS + 1];
61 struct class_device_attribute private_host_attrs[SPI_HOST_ATTRS];
62 struct class_device_attribute *host_attrs[SPI_HOST_ATTRS + 1];
65 #define to_spi_internal(tmpl) container_of(tmpl, struct spi_internal, t)
67 static const char *const ppr_to_ns[] = {
68 /* The PPR values 0-6 are reserved, fill them in when
69 * the committee defines them */
84 /* The PPR values at which you calculate the period in ns by multiplying
86 #define SPI_STATIC_PPR 0x0c
89 enum spi_signal_type value;
92 { SPI_SIGNAL_UNKNOWN, "unknown" },
93 { SPI_SIGNAL_SE, "SE" },
94 { SPI_SIGNAL_LVD, "LVD" },
95 { SPI_SIGNAL_HVD, "HVD" },
98 static inline const char *spi_signal_to_string(enum spi_signal_type type)
102 for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
103 if (type == signal_types[i].value)
104 return signal_types[i].name;
108 static inline enum spi_signal_type spi_signal_to_value(const char *name)
112 for (i = 0; i < sizeof(signal_types)/sizeof(signal_types[0]); i++) {
113 len = strlen(signal_types[i].name);
114 if (strncmp(name, signal_types[i].name, len) == 0 &&
115 (name[len] == '\n' || name[len] == '\0'))
116 return signal_types[i].value;
118 return SPI_SIGNAL_UNKNOWN;
122 struct class spi_transport_class = {
123 .name = "spi_transport",
124 .release = transport_class_release,
127 struct class spi_host_class = {
129 .release = host_class_release,
132 static __init int spi_transport_init(void)
134 int error = class_register(&spi_host_class);
137 return class_register(&spi_transport_class);
140 static void __exit spi_transport_exit(void)
142 class_unregister(&spi_transport_class);
143 class_unregister(&spi_host_class);
146 static int spi_setup_host_attrs(struct Scsi_Host *shost)
148 spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
153 static int spi_configure_device(struct scsi_device *sdev)
155 struct scsi_target *starget = sdev->sdev_target;
157 /* Populate the target capability fields with the values
158 * gleaned from the device inquiry */
160 spi_support_sync(starget) = scsi_device_sync(sdev);
161 spi_support_wide(starget) = scsi_device_wide(sdev);
162 spi_support_dt(starget) = scsi_device_dt(sdev);
163 spi_support_dt_only(starget) = scsi_device_dt_only(sdev);
164 spi_support_ius(starget) = scsi_device_ius(sdev);
165 spi_support_qas(starget) = scsi_device_qas(sdev);
170 static int spi_setup_transport_attrs(struct scsi_target *starget)
172 spi_period(starget) = -1; /* illegal value */
173 spi_offset(starget) = 0; /* async */
174 spi_width(starget) = 0; /* narrow */
175 spi_iu(starget) = 0; /* no IU */
176 spi_dt(starget) = 0; /* ST */
177 spi_qas(starget) = 0;
178 spi_wr_flow(starget) = 0;
179 spi_rd_strm(starget) = 0;
180 spi_rti(starget) = 0;
181 spi_pcomp_en(starget) = 0;
182 spi_dv_pending(starget) = 0;
183 spi_initial_dv(starget) = 0;
184 init_MUTEX(&spi_dv_sem(starget));
189 static void transport_class_release(struct class_device *class_dev)
191 struct scsi_target *starget = transport_class_to_starget(class_dev);
192 put_device(&starget->dev);
195 static void host_class_release(struct class_device *class_dev)
197 struct Scsi_Host *shost = transport_class_to_shost(class_dev);
198 put_device(&shost->shost_gendev);
201 #define spi_transport_show_function(field, format_string) \
204 show_spi_transport_##field(struct class_device *cdev, char *buf) \
206 struct scsi_target *starget = transport_class_to_starget(cdev); \
207 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
208 struct spi_transport_attrs *tp; \
209 struct spi_internal *i = to_spi_internal(shost->transportt); \
210 tp = (struct spi_transport_attrs *)&starget->starget_data; \
211 if (i->f->get_##field) \
212 i->f->get_##field(starget); \
213 return snprintf(buf, 20, format_string, tp->field); \
216 #define spi_transport_store_function(field, format_string) \
218 store_spi_transport_##field(struct class_device *cdev, const char *buf, \
222 struct scsi_target *starget = transport_class_to_starget(cdev); \
223 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); \
224 struct spi_internal *i = to_spi_internal(shost->transportt); \
226 val = simple_strtoul(buf, NULL, 0); \
227 i->f->set_##field(starget, val); \
231 #define spi_transport_rd_attr(field, format_string) \
232 spi_transport_show_function(field, format_string) \
233 spi_transport_store_function(field, format_string) \
234 static CLASS_DEVICE_ATTR(field, S_IRUGO | S_IWUSR, \
235 show_spi_transport_##field, \
236 store_spi_transport_##field);
238 /* The Parallel SCSI Tranport Attributes: */
239 spi_transport_rd_attr(offset, "%d\n");
240 spi_transport_rd_attr(width, "%d\n");
241 spi_transport_rd_attr(iu, "%d\n");
242 spi_transport_rd_attr(dt, "%d\n");
243 spi_transport_rd_attr(qas, "%d\n");
244 spi_transport_rd_attr(wr_flow, "%d\n");
245 spi_transport_rd_attr(rd_strm, "%d\n");
246 spi_transport_rd_attr(rti, "%d\n");
247 spi_transport_rd_attr(pcomp_en, "%d\n");
250 store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
252 struct scsi_target *starget = transport_class_to_starget(cdev);
254 /* FIXME: we're relying on an awful lot of device internals
255 * here. We really need a function to get the first available
257 struct device *dev = container_of(starget->dev.children.next, struct device, node);
258 struct scsi_device *sdev = to_scsi_device(dev);
262 static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
264 /* Translate the period into ns according to the current spec
265 * for SDTR/PPR messages */
266 static ssize_t show_spi_transport_period(struct class_device *cdev, char *buf)
269 struct scsi_target *starget = transport_class_to_starget(cdev);
270 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
271 struct spi_transport_attrs *tp;
273 struct spi_internal *i = to_spi_internal(shost->transportt);
275 tp = (struct spi_transport_attrs *)&starget->starget_data;
277 if (i->f->get_period)
278 i->f->get_period(starget);
282 case 0x07 ... SPI_STATIC_PPR:
283 str = ppr_to_ns[tp->period];
289 case (SPI_STATIC_PPR+1) ... 0xff:
290 return sprintf(buf, "%d\n", tp->period * 4);
295 return sprintf(buf, "%s\n", str);
299 store_spi_transport_period(struct class_device *cdev, const char *buf,
302 struct scsi_target *starget = transport_class_to_starget(cdev);
303 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
304 struct spi_internal *i = to_spi_internal(shost->transportt);
307 for (j = 0; j < SPI_STATIC_PPR; j++) {
310 if(ppr_to_ns[j] == NULL)
313 len = strlen(ppr_to_ns[j]);
315 if(strncmp(ppr_to_ns[j], buf, len) != 0)
326 int val = simple_strtoul(buf, NULL, 0);
329 /* Should probably check limits here, but this
330 * gets reasonably close to OK for most things */
337 i->f->set_period(starget, period);
342 static CLASS_DEVICE_ATTR(period, S_IRUGO | S_IWUSR,
343 show_spi_transport_period,
344 store_spi_transport_period);
346 static ssize_t show_spi_host_signalling(struct class_device *cdev, char *buf)
348 struct Scsi_Host *shost = transport_class_to_shost(cdev);
349 struct spi_internal *i = to_spi_internal(shost->transportt);
351 if (i->f->get_signalling)
352 i->f->get_signalling(shost);
354 return sprintf(buf, "%s\n", spi_signal_to_string(spi_signalling(shost)));
356 static ssize_t store_spi_host_signalling(struct class_device *cdev,
357 const char *buf, size_t count)
359 struct Scsi_Host *shost = transport_class_to_shost(cdev);
360 struct spi_internal *i = to_spi_internal(shost->transportt);
361 enum spi_signal_type type = spi_signal_to_value(buf);
363 if (type != SPI_SIGNAL_UNKNOWN)
366 i->f->set_signalling(shost, type);
369 static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
370 show_spi_host_signalling,
371 store_spi_host_signalling);
373 #define DV_SET(x, y) \
375 i->f->set_##x(sdev->sdev_target, y)
378 #define DV_TIMEOUT (10*HZ)
379 #define DV_RETRIES 3 /* should only need at most
380 * two cc/ua clears */
383 /* This is for read/write Domain Validation: If the device supports
384 * an echo buffer, we do read/write tests to it */
386 spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
387 u8 *ptr, const int retries)
389 struct scsi_device *sdev = sreq->sr_device;
390 int len = ptr - buffer;
392 unsigned int pattern = 0x0000ffff;
394 const char spi_write_buffer[] = {
395 WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
397 const char spi_read_buffer[] = {
398 READ_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
401 /* set up the pattern buffer. Doesn't matter if we spill
402 * slightly beyond since that's where the read buffer is */
403 for (j = 0; j < len; ) {
405 /* fill the buffer with counting (test a) */
406 for ( ; j < min(len, 32); j++)
409 /* fill the buffer with alternating words of 0x0 and
411 for ( ; j < min(len, k + 32); j += 2) {
412 u16 *word = (u16 *)&buffer[j];
414 *word = (j & 0x02) ? 0x0000 : 0xffff;
417 /* fill with crosstalk (alternating 0x5555 0xaaa)
419 for ( ; j < min(len, k + 32); j += 2) {
420 u16 *word = (u16 *)&buffer[j];
422 *word = (j & 0x02) ? 0x5555 : 0xaaaa;
425 /* fill with shifting bits (test d) */
426 for ( ; j < min(len, k + 32); j += 4) {
427 u32 *word = (unsigned int *)&buffer[j];
428 u32 roll = (pattern & 0x80000000) ? 1 : 0;
431 pattern = (pattern << 1) | roll;
433 /* don't bother with random data (test e) */
436 for (r = 0; r < retries; r++) {
437 sreq->sr_cmd_len = 0; /* wait_req to fill in */
438 sreq->sr_data_direction = DMA_TO_DEVICE;
439 scsi_wait_req(sreq, spi_write_buffer, buffer, len,
440 DV_TIMEOUT, DV_RETRIES);
441 if(sreq->sr_result || !scsi_device_online(sdev)) {
442 scsi_device_set_state(sdev, SDEV_QUIESCE);
443 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);
448 sreq->sr_cmd_len = 0; /* wait_req to fill in */
449 sreq->sr_data_direction = DMA_FROM_DEVICE;
450 scsi_wait_req(sreq, spi_read_buffer, ptr, len,
451 DV_TIMEOUT, DV_RETRIES);
452 scsi_device_set_state(sdev, SDEV_QUIESCE);
454 if (memcmp(buffer, ptr, len) != 0)
460 /* This is for the simplest form of Domain Validation: a read test
461 * on the inquiry data from the device */
463 spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
464 u8 *ptr, const int retries)
467 const int len = sreq->sr_device->inquiry_len;
468 struct scsi_device *sdev = sreq->sr_device;
469 const char spi_inquiry[] = {
470 INQUIRY, 0, 0, 0, len, 0
473 for (r = 0; r < retries; r++) {
474 sreq->sr_cmd_len = 0; /* wait_req to fill in */
475 sreq->sr_data_direction = DMA_FROM_DEVICE;
479 scsi_wait_req(sreq, spi_inquiry, ptr, len,
480 DV_TIMEOUT, DV_RETRIES);
482 if(sreq->sr_result || !scsi_device_online(sdev)) {
483 scsi_device_set_state(sdev, SDEV_QUIESCE);
487 /* If we don't have the inquiry data already, the
488 * first read gets it */
495 if (memcmp(buffer, ptr, len) != 0)
503 spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,
504 int (*compare_fn)(struct scsi_request *, u8 *, u8 *, int))
506 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
507 struct scsi_device *sdev = sreq->sr_device;
508 int period = 0, prevperiod = 0;
513 if (compare_fn(sreq, buffer, ptr, DV_LOOPS))
517 /* OK, retrain, fallback */
518 if (i->f->get_period)
519 i->f->get_period(sdev->sdev_target);
520 newperiod = spi_period(sdev->sdev_target);
521 period = newperiod > period ? newperiod : period;
525 period += period >> 1;
527 if (unlikely(period > 0xff || period == prevperiod)) {
528 /* Total failure; set to async and return */
529 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");
533 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation detected failure, dropping back\n");
534 DV_SET(period, period);
541 spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
545 /* first off do a test unit ready. This can error out
546 * because of reservations or some other reason. If it
547 * fails, the device won't let us write to the echo buffer
548 * so just return failure */
550 const char spi_test_unit_ready[] = {
551 TEST_UNIT_READY, 0, 0, 0, 0, 0
554 const char spi_read_buffer_descriptor[] = {
555 READ_BUFFER, 0x0b, 0, 0, 0, 0, 0, 0, 4, 0
559 sreq->sr_cmd_len = 0;
560 sreq->sr_data_direction = DMA_NONE;
562 /* We send a set of three TURs to clear any outstanding
563 * unit attention conditions if they exist (Otherwise the
564 * buffer tests won't be happy). If the TUR still fails
565 * (reservation conflict, device not ready, etc) just
566 * skip the write tests */
568 scsi_wait_req(sreq, spi_test_unit_ready, NULL, 0,
569 DV_TIMEOUT, DV_RETRIES);
571 if(sreq->sr_result) {
580 sreq->sr_cmd_len = 0;
581 sreq->sr_data_direction = DMA_FROM_DEVICE;
583 scsi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4,
584 DV_TIMEOUT, DV_RETRIES);
587 /* Device has no echo buffer */
590 return buffer[3] + ((buffer[2] & 0x1f) << 8);
594 spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
596 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
597 struct scsi_device *sdev = sreq->sr_device;
598 int len = sdev->inquiry_len;
599 /* first set us up for narrow async */
603 if (!spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS)) {
604 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
605 /* FIXME: should probably offline the device here? */
610 if (i->f->set_width && sdev->wdtr) {
611 i->f->set_width(sdev->sdev_target, 1);
613 if (!spi_dv_device_compare_inquiry(sreq, buffer,
616 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Wide Transfers Fail\n");
617 i->f->set_width(sdev->sdev_target, 0);
621 if (!i->f->set_period)
624 /* device can't handle synchronous */
625 if(!sdev->ppr && !sdev->sdtr)
628 /* now set up to the maximum */
631 if (!spi_dv_retrain(sreq, buffer, buffer + len,
632 spi_dv_device_compare_inquiry))
635 /* OK, now we have our initial speed set by the read only inquiry
636 * test, now try an echo buffer test (if the device allows it) */
638 if ((len = spi_dv_device_get_echo_buffer(sreq, buffer)) == 0) {
639 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n");
642 if (len > SPI_MAX_ECHO_BUFFER_SIZE) {
643 SPI_PRINTK(sdev->sdev_target, KERN_WARNING, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
644 len = SPI_MAX_ECHO_BUFFER_SIZE;
647 spi_dv_retrain(sreq, buffer, buffer + len,
648 spi_dv_device_echo_buffer);
652 /** spi_dv_device - Do Domain Validation on the device
653 * @sdev: scsi device to validate
655 * Performs the domain validation on the given device in the
656 * current execution thread. Since DV operations may sleep,
657 * the current thread must have user context. Also no SCSI
658 * related locks that would deadlock I/O issued by the DV may
662 spi_dv_device(struct scsi_device *sdev)
664 struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
665 struct scsi_target *starget = sdev->sdev_target;
667 const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
672 if (unlikely(scsi_device_get(sdev)))
675 buffer = kmalloc(len, GFP_KERNEL);
677 if (unlikely(!buffer))
680 memset(buffer, 0, len);
682 /* We need to verify that the actual device will quiesce; the
683 * later target quiesce is just a nice to have */
684 if (unlikely(scsi_device_quiesce(sdev)))
687 scsi_target_quiesce(starget);
689 spi_dv_pending(starget) = 1;
690 down(&spi_dv_sem(starget));
692 SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n");
694 spi_dv_device_internal(sreq, buffer);
696 SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n");
698 up(&spi_dv_sem(starget));
699 spi_dv_pending(starget) = 0;
701 scsi_target_resume(starget);
703 spi_initial_dv(starget) = 1;
708 scsi_device_put(sdev);
710 scsi_release_request(sreq);
712 EXPORT_SYMBOL(spi_dv_device);
714 struct work_queue_wrapper {
715 struct work_struct work;
716 struct scsi_device *sdev;
720 spi_dv_device_work_wrapper(void *data)
722 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data;
723 struct scsi_device *sdev = wqw->sdev;
727 spi_dv_pending(sdev->sdev_target) = 0;
728 scsi_device_put(sdev);
733 * spi_schedule_dv_device - schedule domain validation to occur on the device
734 * @sdev: The device to validate
736 * Identical to spi_dv_device() above, except that the DV will be
737 * scheduled to occur in a workqueue later. All memory allocations
738 * are atomic, so may be called from any context including those holding
742 spi_schedule_dv_device(struct scsi_device *sdev)
744 struct work_queue_wrapper *wqw =
745 kmalloc(sizeof(struct work_queue_wrapper), GFP_ATOMIC);
750 if (unlikely(spi_dv_pending(sdev->sdev_target))) {
754 /* Set pending early (dv_device doesn't check it, only sets it) */
755 spi_dv_pending(sdev->sdev_target) = 1;
756 if (unlikely(scsi_device_get(sdev))) {
758 spi_dv_pending(sdev->sdev_target) = 0;
762 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw);
765 schedule_work(&wqw->work);
767 EXPORT_SYMBOL(spi_schedule_dv_device);
769 #define SETUP_ATTRIBUTE(field) \
770 i->private_attrs[count] = class_device_attr_##field; \
771 if (!i->f->set_##field) { \
772 i->private_attrs[count].attr.mode = S_IRUGO; \
773 i->private_attrs[count].store = NULL; \
775 i->attrs[count] = &i->private_attrs[count]; \
776 if (i->f->show_##field) \
779 #define SETUP_HOST_ATTRIBUTE(field) \
780 i->private_host_attrs[count] = class_device_attr_##field; \
781 if (!i->f->set_##field) { \
782 i->private_host_attrs[count].attr.mode = S_IRUGO; \
783 i->private_host_attrs[count].store = NULL; \
785 i->host_attrs[count] = &i->private_host_attrs[count]; \
788 struct scsi_transport_template *
789 spi_attach_transport(struct spi_function_template *ft)
791 struct spi_internal *i = kmalloc(sizeof(struct spi_internal),
797 memset(i, 0, sizeof(struct spi_internal));
800 i->t.target_attrs = &i->attrs[0];
801 i->t.target_class = &spi_transport_class;
802 i->t.target_setup = &spi_setup_transport_attrs;
803 i->t.device_configure = &spi_configure_device;
804 i->t.target_size = sizeof(struct spi_transport_attrs);
805 i->t.host_attrs = &i->host_attrs[0];
806 i->t.host_class = &spi_host_class;
807 i->t.host_setup = &spi_setup_host_attrs;
808 i->t.host_size = sizeof(struct spi_host_attrs);
811 SETUP_ATTRIBUTE(period);
812 SETUP_ATTRIBUTE(offset);
813 SETUP_ATTRIBUTE(width);
816 SETUP_ATTRIBUTE(qas);
817 SETUP_ATTRIBUTE(wr_flow);
818 SETUP_ATTRIBUTE(rd_strm);
819 SETUP_ATTRIBUTE(rti);
820 SETUP_ATTRIBUTE(pcomp_en);
822 /* if you add an attribute but forget to increase SPI_NUM_ATTRS
823 * this bug will trigger */
824 BUG_ON(count > SPI_NUM_ATTRS);
826 i->attrs[count++] = &class_device_attr_revalidate;
828 i->attrs[count] = NULL;
831 SETUP_HOST_ATTRIBUTE(signalling);
833 BUG_ON(count > SPI_HOST_ATTRS);
835 i->host_attrs[count] = NULL;
839 EXPORT_SYMBOL(spi_attach_transport);
841 void spi_release_transport(struct scsi_transport_template *t)
843 struct spi_internal *i = to_spi_internal(t);
847 EXPORT_SYMBOL(spi_release_transport);
850 MODULE_AUTHOR("Martin Hicks");
851 MODULE_DESCRIPTION("SPI Transport Attributes");
852 MODULE_LICENSE("GPL");
854 module_init(spi_transport_init);
855 module_exit(spi_transport_exit);