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)
364 i->f->set_signalling(shost, type);
368 static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
369 show_spi_host_signalling,
370 store_spi_host_signalling);
372 #define DV_SET(x, y) \
374 i->f->set_##x(sdev->sdev_target, y)
377 #define DV_TIMEOUT (10*HZ)
378 #define DV_RETRIES 3 /* should only need at most
379 * two cc/ua clears */
382 /* This is for read/write Domain Validation: If the device supports
383 * an echo buffer, we do read/write tests to it */
385 spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
386 u8 *ptr, const int retries)
388 struct scsi_device *sdev = sreq->sr_device;
389 int len = ptr - buffer;
391 unsigned int pattern = 0x0000ffff;
393 const char spi_write_buffer[] = {
394 WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
396 const char spi_read_buffer[] = {
397 READ_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0
400 /* set up the pattern buffer. Doesn't matter if we spill
401 * slightly beyond since that's where the read buffer is */
402 for (j = 0; j < len; ) {
404 /* fill the buffer with counting (test a) */
405 for ( ; j < min(len, 32); j++)
408 /* fill the buffer with alternating words of 0x0 and
410 for ( ; j < min(len, k + 32); j += 2) {
411 u16 *word = (u16 *)&buffer[j];
413 *word = (j & 0x02) ? 0x0000 : 0xffff;
416 /* fill with crosstalk (alternating 0x5555 0xaaa)
418 for ( ; j < min(len, k + 32); j += 2) {
419 u16 *word = (u16 *)&buffer[j];
421 *word = (j & 0x02) ? 0x5555 : 0xaaaa;
424 /* fill with shifting bits (test d) */
425 for ( ; j < min(len, k + 32); j += 4) {
426 u32 *word = (unsigned int *)&buffer[j];
427 u32 roll = (pattern & 0x80000000) ? 1 : 0;
430 pattern = (pattern << 1) | roll;
432 /* don't bother with random data (test e) */
435 for (r = 0; r < retries; r++) {
436 sreq->sr_cmd_len = 0; /* wait_req to fill in */
437 sreq->sr_data_direction = DMA_TO_DEVICE;
438 scsi_wait_req(sreq, spi_write_buffer, buffer, len,
439 DV_TIMEOUT, DV_RETRIES);
440 if(sreq->sr_result || !scsi_device_online(sdev)) {
441 scsi_device_set_state(sdev, SDEV_QUIESCE);
442 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Write Buffer failure %x\n", sreq->sr_result);
447 sreq->sr_cmd_len = 0; /* wait_req to fill in */
448 sreq->sr_data_direction = DMA_FROM_DEVICE;
449 scsi_wait_req(sreq, spi_read_buffer, ptr, len,
450 DV_TIMEOUT, DV_RETRIES);
451 scsi_device_set_state(sdev, SDEV_QUIESCE);
453 if (memcmp(buffer, ptr, len) != 0)
459 /* This is for the simplest form of Domain Validation: a read test
460 * on the inquiry data from the device */
462 spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
463 u8 *ptr, const int retries)
466 const int len = sreq->sr_device->inquiry_len;
467 struct scsi_device *sdev = sreq->sr_device;
468 const char spi_inquiry[] = {
469 INQUIRY, 0, 0, 0, len, 0
472 for (r = 0; r < retries; r++) {
473 sreq->sr_cmd_len = 0; /* wait_req to fill in */
474 sreq->sr_data_direction = DMA_FROM_DEVICE;
478 scsi_wait_req(sreq, spi_inquiry, ptr, len,
479 DV_TIMEOUT, DV_RETRIES);
481 if(sreq->sr_result || !scsi_device_online(sdev)) {
482 scsi_device_set_state(sdev, SDEV_QUIESCE);
486 /* If we don't have the inquiry data already, the
487 * first read gets it */
494 if (memcmp(buffer, ptr, len) != 0)
502 spi_dv_retrain(struct scsi_request *sreq, u8 *buffer, u8 *ptr,
503 int (*compare_fn)(struct scsi_request *, u8 *, u8 *, int))
505 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
506 struct scsi_device *sdev = sreq->sr_device;
507 int period = 0, prevperiod = 0;
512 if (compare_fn(sreq, buffer, ptr, DV_LOOPS))
516 /* OK, retrain, fallback */
517 if (i->f->get_period)
518 i->f->get_period(sdev->sdev_target);
519 newperiod = spi_period(sdev->sdev_target);
520 period = newperiod > period ? newperiod : period;
524 period += period >> 1;
526 if (unlikely(period > 0xff || period == prevperiod)) {
527 /* Total failure; set to async and return */
528 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Failure, dropping back to Asynchronous\n");
532 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation detected failure, dropping back\n");
533 DV_SET(period, period);
540 spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
544 /* first off do a test unit ready. This can error out
545 * because of reservations or some other reason. If it
546 * fails, the device won't let us write to the echo buffer
547 * so just return failure */
549 const char spi_test_unit_ready[] = {
550 TEST_UNIT_READY, 0, 0, 0, 0, 0
553 const char spi_read_buffer_descriptor[] = {
554 READ_BUFFER, 0x0b, 0, 0, 0, 0, 0, 0, 4, 0
558 sreq->sr_cmd_len = 0;
559 sreq->sr_data_direction = DMA_NONE;
561 /* We send a set of three TURs to clear any outstanding
562 * unit attention conditions if they exist (Otherwise the
563 * buffer tests won't be happy). If the TUR still fails
564 * (reservation conflict, device not ready, etc) just
565 * skip the write tests */
567 scsi_wait_req(sreq, spi_test_unit_ready, NULL, 0,
568 DV_TIMEOUT, DV_RETRIES);
570 if(sreq->sr_result) {
579 sreq->sr_cmd_len = 0;
580 sreq->sr_data_direction = DMA_FROM_DEVICE;
582 scsi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4,
583 DV_TIMEOUT, DV_RETRIES);
586 /* Device has no echo buffer */
589 return buffer[3] + ((buffer[2] & 0x1f) << 8);
593 spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
595 struct spi_internal *i = to_spi_internal(sreq->sr_host->transportt);
596 struct scsi_device *sdev = sreq->sr_device;
597 int len = sdev->inquiry_len;
598 /* first set us up for narrow async */
602 if (!spi_dv_device_compare_inquiry(sreq, buffer, buffer, DV_LOOPS)) {
603 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Domain Validation Initial Inquiry Failed\n");
604 /* FIXME: should probably offline the device here? */
609 if (i->f->set_width && sdev->wdtr) {
610 i->f->set_width(sdev->sdev_target, 1);
612 if (!spi_dv_device_compare_inquiry(sreq, buffer,
615 SPI_PRINTK(sdev->sdev_target, KERN_ERR, "Wide Transfers Fail\n");
616 i->f->set_width(sdev->sdev_target, 0);
620 if (!i->f->set_period)
623 /* device can't handle synchronous */
624 if(!sdev->ppr && !sdev->sdtr)
627 /* now set up to the maximum */
630 if (!spi_dv_retrain(sreq, buffer, buffer + len,
631 spi_dv_device_compare_inquiry))
634 /* OK, now we have our initial speed set by the read only inquiry
635 * test, now try an echo buffer test (if the device allows it) */
639 len = spi_dv_device_get_echo_buffer(sreq, buffer);
642 SPI_PRINTK(sdev->sdev_target, KERN_INFO, "Domain Validation skipping write tests\n");
645 if (len > SPI_MAX_ECHO_BUFFER_SIZE) {
646 SPI_PRINTK(sdev->sdev_target, KERN_WARNING, "Echo buffer size %d is too big, trimming to %d\n", len, SPI_MAX_ECHO_BUFFER_SIZE);
647 len = SPI_MAX_ECHO_BUFFER_SIZE;
650 spi_dv_retrain(sreq, buffer, buffer + len,
651 spi_dv_device_echo_buffer);
655 /** spi_dv_device - Do Domain Validation on the device
656 * @sdev: scsi device to validate
658 * Performs the domain validation on the given device in the
659 * current execution thread. Since DV operations may sleep,
660 * the current thread must have user context. Also no SCSI
661 * related locks that would deadlock I/O issued by the DV may
665 spi_dv_device(struct scsi_device *sdev)
667 struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL);
668 struct scsi_target *starget = sdev->sdev_target;
670 const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
675 if (unlikely(scsi_device_get(sdev)))
678 buffer = kmalloc(len, GFP_KERNEL);
680 if (unlikely(!buffer))
683 memset(buffer, 0, len);
685 /* We need to verify that the actual device will quiesce; the
686 * later target quiesce is just a nice to have */
687 if (unlikely(scsi_device_quiesce(sdev)))
690 scsi_target_quiesce(starget);
692 spi_dv_pending(starget) = 1;
693 down(&spi_dv_sem(starget));
695 SPI_PRINTK(starget, KERN_INFO, "Beginning Domain Validation\n");
697 spi_dv_device_internal(sreq, buffer);
699 SPI_PRINTK(starget, KERN_INFO, "Ending Domain Validation\n");
701 up(&spi_dv_sem(starget));
702 spi_dv_pending(starget) = 0;
704 scsi_target_resume(starget);
706 spi_initial_dv(starget) = 1;
711 scsi_device_put(sdev);
713 scsi_release_request(sreq);
715 EXPORT_SYMBOL(spi_dv_device);
717 struct work_queue_wrapper {
718 struct work_struct work;
719 struct scsi_device *sdev;
723 spi_dv_device_work_wrapper(void *data)
725 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data;
726 struct scsi_device *sdev = wqw->sdev;
730 spi_dv_pending(sdev->sdev_target) = 0;
731 scsi_device_put(sdev);
736 * spi_schedule_dv_device - schedule domain validation to occur on the device
737 * @sdev: The device to validate
739 * Identical to spi_dv_device() above, except that the DV will be
740 * scheduled to occur in a workqueue later. All memory allocations
741 * are atomic, so may be called from any context including those holding
745 spi_schedule_dv_device(struct scsi_device *sdev)
747 struct work_queue_wrapper *wqw =
748 kmalloc(sizeof(struct work_queue_wrapper), GFP_ATOMIC);
753 if (unlikely(spi_dv_pending(sdev->sdev_target))) {
757 /* Set pending early (dv_device doesn't check it, only sets it) */
758 spi_dv_pending(sdev->sdev_target) = 1;
759 if (unlikely(scsi_device_get(sdev))) {
761 spi_dv_pending(sdev->sdev_target) = 0;
765 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw);
768 schedule_work(&wqw->work);
770 EXPORT_SYMBOL(spi_schedule_dv_device);
772 #define SETUP_ATTRIBUTE(field) \
773 i->private_attrs[count] = class_device_attr_##field; \
774 if (!i->f->set_##field) { \
775 i->private_attrs[count].attr.mode = S_IRUGO; \
776 i->private_attrs[count].store = NULL; \
778 i->attrs[count] = &i->private_attrs[count]; \
779 if (i->f->show_##field) \
782 #define SETUP_HOST_ATTRIBUTE(field) \
783 i->private_host_attrs[count] = class_device_attr_##field; \
784 if (!i->f->set_##field) { \
785 i->private_host_attrs[count].attr.mode = S_IRUGO; \
786 i->private_host_attrs[count].store = NULL; \
788 i->host_attrs[count] = &i->private_host_attrs[count]; \
791 struct scsi_transport_template *
792 spi_attach_transport(struct spi_function_template *ft)
794 struct spi_internal *i = kmalloc(sizeof(struct spi_internal),
800 memset(i, 0, sizeof(struct spi_internal));
803 i->t.target_attrs = &i->attrs[0];
804 i->t.target_class = &spi_transport_class;
805 i->t.target_setup = &spi_setup_transport_attrs;
806 i->t.device_configure = &spi_configure_device;
807 i->t.target_size = sizeof(struct spi_transport_attrs);
808 i->t.host_attrs = &i->host_attrs[0];
809 i->t.host_class = &spi_host_class;
810 i->t.host_setup = &spi_setup_host_attrs;
811 i->t.host_size = sizeof(struct spi_host_attrs);
814 SETUP_ATTRIBUTE(period);
815 SETUP_ATTRIBUTE(offset);
816 SETUP_ATTRIBUTE(width);
819 SETUP_ATTRIBUTE(qas);
820 SETUP_ATTRIBUTE(wr_flow);
821 SETUP_ATTRIBUTE(rd_strm);
822 SETUP_ATTRIBUTE(rti);
823 SETUP_ATTRIBUTE(pcomp_en);
825 /* if you add an attribute but forget to increase SPI_NUM_ATTRS
826 * this bug will trigger */
827 BUG_ON(count > SPI_NUM_ATTRS);
829 i->attrs[count++] = &class_device_attr_revalidate;
831 i->attrs[count] = NULL;
834 SETUP_HOST_ATTRIBUTE(signalling);
836 BUG_ON(count > SPI_HOST_ATTRS);
838 i->host_attrs[count] = NULL;
842 EXPORT_SYMBOL(spi_attach_transport);
844 void spi_release_transport(struct scsi_transport_template *t)
846 struct spi_internal *i = to_spi_internal(t);
850 EXPORT_SYMBOL(spi_release_transport);
853 MODULE_AUTHOR("Martin Hicks");
854 MODULE_DESCRIPTION("SPI Transport Attributes");
855 MODULE_LICENSE("GPL");
857 module_init(spi_transport_init);
858 module_exit(spi_transport_exit);