aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/hosts.c1
-rw-r--r--drivers/scsi/scsi_sysfs.c42
-rw-r--r--include/scsi/scsi_host.h9
3 files changed, 52 insertions, 0 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 96bc31266c98..adc9559cb6f4 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -342,6 +342,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
342 shost->unchecked_isa_dma = sht->unchecked_isa_dma; 342 shost->unchecked_isa_dma = sht->unchecked_isa_dma;
343 shost->use_clustering = sht->use_clustering; 343 shost->use_clustering = sht->use_clustering;
344 shost->ordered_tag = sht->ordered_tag; 344 shost->ordered_tag = sht->ordered_tag;
345 shost->active_mode = sht->supported_mode;
345 346
346 if (sht->max_host_blocked) 347 if (sht->max_host_blocked)
347 shost->max_host_blocked = sht->max_host_blocked; 348 shost->max_host_blocked = sht->max_host_blocked;
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 34cdce6738a6..a3d227f3f520 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -190,6 +190,46 @@ show_shost_state(struct class_device *class_dev, char *buf)
190 190
191static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); 191static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
192 192
193static ssize_t
194show_shost_mode(unsigned int mode, char *buf)
195{
196 ssize_t len = 0;
197
198 if (mode & MODE_INITIATOR)
199 len = sprintf(buf, "%s", "Initiator");
200
201 if (mode & MODE_TARGET)
202 len += sprintf(buf + len, "%s%s", len ? ", " : "", "Target");
203
204 len += sprintf(buf + len, "\n");
205
206 return len;
207}
208
209static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf)
210{
211 struct Scsi_Host *shost = class_to_shost(class_dev);
212
213 if (shost->hostt->supported_mode == MODE_UNKNOWN)
214 return snprintf(buf, 20, "unknown\n");
215 else
216 return show_shost_mode(shost->hostt->supported_mode, buf);
217}
218
219static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
220
221static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf)
222{
223 struct Scsi_Host *shost = class_to_shost(class_dev);
224
225 if (shost->active_mode == MODE_UNKNOWN)
226 return snprintf(buf, 20, "unknown\n");
227 else
228 return show_shost_mode(shost->active_mode, buf);
229}
230
231static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
232
193shost_rd_attr(unique_id, "%u\n"); 233shost_rd_attr(unique_id, "%u\n");
194shost_rd_attr(host_busy, "%hu\n"); 234shost_rd_attr(host_busy, "%hu\n");
195shost_rd_attr(cmd_per_lun, "%hd\n"); 235shost_rd_attr(cmd_per_lun, "%hd\n");
@@ -208,6 +248,8 @@ static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
208 &class_device_attr_proc_name, 248 &class_device_attr_proc_name,
209 &class_device_attr_scan, 249 &class_device_attr_scan,
210 &class_device_attr_state, 250 &class_device_attr_state,
251 &class_device_attr_supported_mode,
252 &class_device_attr_active_mode,
211 NULL 253 NULL
212}; 254};
213 255
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 88f6871badd8..5b79697a3a80 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -32,6 +32,9 @@ struct blk_queue_tags;
32#define SG_NONE 0 32#define SG_NONE 0
33#define SG_ALL 0xff 33#define SG_ALL 0xff
34 34
35#define MODE_UNKNOWN 0x00
36#define MODE_INITIATOR 0x01
37#define MODE_TARGET 0x02
35 38
36#define DISABLE_CLUSTERING 0 39#define DISABLE_CLUSTERING 0
37#define ENABLE_CLUSTERING 1 40#define ENABLE_CLUSTERING 1
@@ -405,6 +408,11 @@ struct scsi_host_template {
405 unsigned char present; 408 unsigned char present;
406 409
407 /* 410 /*
411 * This specifies the mode that a LLD supports.
412 */
413 unsigned supported_mode:2;
414
415 /*
408 * true if this host adapter uses unchecked DMA onto an ISA bus. 416 * true if this host adapter uses unchecked DMA onto an ISA bus.
409 */ 417 */
410 unsigned unchecked_isa_dma:1; 418 unsigned unchecked_isa_dma:1;
@@ -574,6 +582,7 @@ struct Scsi_Host {
574 */ 582 */
575 unsigned long cmd_serial_number, cmd_pid; 583 unsigned long cmd_serial_number, cmd_pid;
576 584
585 unsigned active_mode:2;
577 unsigned unchecked_isa_dma:1; 586 unsigned unchecked_isa_dma:1;
578 unsigned use_clustering:1; 587 unsigned use_clustering:1;
579 unsigned use_blk_tcq:1; 588 unsigned use_blk_tcq:1;