diff options
Diffstat (limited to 'drivers/scsi/scsi_sysfs.c')
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 42 |
1 files changed, 42 insertions, 0 deletions
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 | ||
191 | static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); | 191 | static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state); |
192 | 192 | ||
193 | static ssize_t | ||
194 | show_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 | |||
209 | static 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 | |||
219 | static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL); | ||
220 | |||
221 | static 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 | |||
231 | static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL); | ||
232 | |||
193 | shost_rd_attr(unique_id, "%u\n"); | 233 | shost_rd_attr(unique_id, "%u\n"); |
194 | shost_rd_attr(host_busy, "%hu\n"); | 234 | shost_rd_attr(host_busy, "%hu\n"); |
195 | shost_rd_attr(cmd_per_lun, "%hd\n"); | 235 | shost_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 | ||