Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
scsi_sysfs.c File Reference
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/device.h>
#include <linux/pm_runtime.h>
#include <scsi/scsi.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_driver.h>
#include "scsi_priv.h"
#include "scsi_logging.h"

Go to the source code of this file.

Macros

#define shost_show_function(name, field, format_string)
 
#define shost_rd_attr2(name, field, format_string)
 
#define shost_rd_attr(field, format_string)   shost_rd_attr2(field, field, format_string)
 
#define sdev_show_function(field, format_string)
 
#define sdev_rd_attr(field, format_string)
 
#define sdev_rw_attr(field, format_string)
 
#define show_sdev_iostat(field)
 
#define DECLARE_EVT_SHOW(name, Cap_name)
 
#define DECLARE_EVT_STORE(name, Cap_name)
 
#define DECLARE_EVT(name, Cap_name)
 
#define REF_EVT(name)   &dev_attr_evt_##name.attr
 

Functions

const charscsi_device_state_name (enum scsi_device_state state)
 
const charscsi_host_state_name (enum scsi_host_state state)
 
 shost_rd_attr (unique_id,"%u\n")
 
 shost_rd_attr (host_busy,"%hu\n")
 
 shost_rd_attr (cmd_per_lun,"%hd\n")
 
 shost_rd_attr (can_queue,"%hd\n")
 
 shost_rd_attr (sg_tablesize,"%hu\n")
 
 shost_rd_attr (sg_prot_tablesize,"%hu\n")
 
 shost_rd_attr (unchecked_isa_dma,"%d\n")
 
 shost_rd_attr (prot_capabilities,"%u\n")
 
 shost_rd_attr (prot_guard_type,"%hd\n")
 
 shost_rd_attr2 (proc_name, hostt->proc_name,"%s\n")
 
 EXPORT_SYMBOL_GPL (scsi_bus_type)
 
int scsi_sysfs_register (void)
 
void scsi_sysfs_unregister (void)
 
 sdev_rd_attr (device_blocked,"%d\n")
 
 sdev_rd_attr (queue_depth,"%d\n")
 
 sdev_rd_attr (type,"%d\n")
 
 sdev_rd_attr (scsi_level,"%d\n")
 
 sdev_rd_attr (vendor,"%.8s\n")
 
 sdev_rd_attr (model,"%.16s\n")
 
 sdev_rd_attr (rev,"%.4s\n")
 
 show_sdev_iostat (iorequest_cnt)
 
 show_sdev_iostat (iodone_cnt)
 
 show_sdev_iostat (ioerr_cnt)
 
int scsi_sysfs_add_sdev (struct scsi_device *sdev)
 
void __scsi_remove_device (struct scsi_device *sdev)
 
void scsi_remove_device (struct scsi_device *sdev)
 
 EXPORT_SYMBOL (scsi_remove_device)
 
void scsi_remove_target (struct device *dev)
 
 EXPORT_SYMBOL (scsi_remove_target)
 
int scsi_register_driver (struct device_driver *drv)
 
 EXPORT_SYMBOL (scsi_register_driver)
 
int scsi_register_interface (struct class_interface *intf)
 
 EXPORT_SYMBOL (scsi_register_interface)
 
int scsi_sysfs_add_host (struct Scsi_Host *shost)
 
void scsi_sysfs_device_initialize (struct scsi_device *sdev)
 
int scsi_is_sdev_device (const struct device *dev)
 
 EXPORT_SYMBOL (scsi_is_sdev_device)
 

Variables

struct device_attribute dev_attr_hstate
 
struct attribute_group scsi_shost_attr_group
 
struct attribute_groupscsi_sysfs_shost_attr_groups []
 
struct bus_type scsi_bus_type
 
struct scsi_transport_template blank_transport_template = { { { {NULL, }, }, }, }
 

Macro Definition Documentation

#define DECLARE_EVT (   name,
  Cap_name 
)
Value:
DECLARE_EVT_SHOW(name, Cap_name) \
DECLARE_EVT_STORE(name, Cap_name) \
static DEVICE_ATTR(evt_##name, S_IRUGO, sdev_show_evt_##name, \
sdev_store_evt_##name);

Definition at line 708 of file scsi_sysfs.c.

#define DECLARE_EVT_SHOW (   name,
  Cap_name 
)
Value:
static ssize_t \
sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
return snprintf(buf, 20, "%d\n", val); \
}

Definition at line 682 of file scsi_sysfs.c.

#define DECLARE_EVT_STORE (   name,
  Cap_name 
)
Value:
static ssize_t \
sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\
const char *buf, size_t count) \
{ \
int val = simple_strtoul(buf, NULL, 0); \
if (val == 0) \
clear_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
else if (val == 1) \
set_bit(SDEV_EVT_##Cap_name, sdev->supported_events); \
else \
return -EINVAL; \
return count; \
}

Definition at line 692 of file scsi_sysfs.c.

#define REF_EVT (   name)    &dev_attr_evt_##name.attr

Definition at line 713 of file scsi_sysfs.c.

#define sdev_rd_attr (   field,
  format_string 
)
Value:
sdev_show_function(field, format_string) \
static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);

Definition at line 464 of file scsi_sysfs.c.

#define sdev_rw_attr (   field,
  format_string 
)
Value:
sdev_show_function(field, format_string) \
\
static ssize_t \
sdev_store_##field (struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
sdev = to_scsi_device(dev); \
sscanf (buf, format_string, &sdev->field); \
return count; \
} \
static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##field);

Definition at line 473 of file scsi_sysfs.c.

#define sdev_show_function (   field,
  format_string 
)
Value:
static ssize_t \
sdev_show_##field (struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
sdev = to_scsi_device(dev); \
return snprintf (buf, 20, format_string, sdev->field); \
} \

Definition at line 450 of file scsi_sysfs.c.

#define shost_rd_attr (   field,
  format_string 
)    shost_rd_attr2(field, field, format_string)

Definition at line 143 of file scsi_sysfs.c.

#define shost_rd_attr2 (   name,
  field,
  format_string 
)
Value:
shost_show_function(name, field, format_string) \
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);

Definition at line 139 of file scsi_sysfs.c.

#define shost_show_function (   name,
  field,
  format_string 
)
Value:
static ssize_t \
show_##name (struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
return snprintf (buf, 20, format_string, shost->field); \
}

Definition at line 126 of file scsi_sysfs.c.

#define show_sdev_iostat (   field)
Value:
static ssize_t \
show_iostat_##field(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
unsigned long long count = atomic_read(&sdev->field); \
return snprintf(buf, 20, "0x%llx\n", count); \
} \
static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)

Definition at line 658 of file scsi_sysfs.c.

Function Documentation

void __scsi_remove_device ( struct scsi_device sdev)

Definition at line 956 of file scsi_sysfs.c.

EXPORT_SYMBOL ( scsi_remove_device  )
EXPORT_SYMBOL ( scsi_remove_target  )
EXPORT_SYMBOL ( scsi_register_driver  )
EXPORT_SYMBOL ( scsi_register_interface  )
EXPORT_SYMBOL ( scsi_is_sdev_device  )
EXPORT_SYMBOL_GPL ( scsi_bus_type  )
const char* scsi_device_state_name ( enum scsi_device_state  state)

Definition at line 43 of file scsi_sysfs.c.

const char* scsi_host_state_name ( enum scsi_host_state  state)

Definition at line 69 of file scsi_sysfs.c.

int scsi_is_sdev_device ( const struct device dev)

Definition at line 1132 of file scsi_sysfs.c.

int scsi_register_driver ( struct device_driver drv)

Definition at line 1062 of file scsi_sysfs.c.

int scsi_register_interface ( struct class_interface intf)

Definition at line 1070 of file scsi_sysfs.c.

void scsi_remove_device ( struct scsi_device sdev)

scsi_remove_device - unregister a device from the scsi bus : scsi_device to unregister

Definition at line 991 of file scsi_sysfs.c.

void scsi_remove_target ( struct device dev)

scsi_remove_target - try to remove a target and all its devices : generic starget or parent of generic stargets to be removed

Note: This is slightly racy. It is possible that if the user requests the addition of another device then the target won't be removed.

Definition at line 1031 of file scsi_sysfs.c.

int scsi_sysfs_add_host ( struct Scsi_Host shost)

scsi_sysfs_add_host - add scsi host to subsystem : scsi host struct to add to subsystem

Definition at line 1082 of file scsi_sysfs.c.

int scsi_sysfs_add_sdev ( struct scsi_device sdev)

scsi_sysfs_add_sdev - add scsi device to sysfs : scsi_device to add

Return value: 0 on Success / non-zero on Failure

Definition at line 870 of file scsi_sysfs.c.

void scsi_sysfs_device_initialize ( struct scsi_device sdev)

Definition at line 1107 of file scsi_sysfs.c.

int scsi_sysfs_register ( void  )

Definition at line 426 of file scsi_sysfs.c.

void scsi_sysfs_unregister ( void  )

Definition at line 440 of file scsi_sysfs.c.

sdev_rd_attr ( device_blocked  ,
"%d\n"   
)
sdev_rd_attr ( queue_depth  ,
"%d\n"   
)
sdev_rd_attr ( type  ,
"%d\n"   
)
sdev_rd_attr ( scsi_level  ,
"%d\n"   
)
sdev_rd_attr ( vendor  ,
"%.8s\n"   
)
sdev_rd_attr ( model  ,
"%.16s\n"   
)
sdev_rd_attr ( rev  ,
"%.4s\n"   
)
shost_rd_attr ( unique_id  ,
"%u\n"   
)
shost_rd_attr ( host_busy  ,
"%hu\n"   
)
shost_rd_attr ( cmd_per_lun  ,
"%hd\n"   
)
shost_rd_attr ( can_queue  ,
"%hd\n"   
)
shost_rd_attr ( sg_tablesize  ,
"%hu\n"   
)
shost_rd_attr ( sg_prot_tablesize  ,
"%hu\n"   
)
shost_rd_attr ( unchecked_isa_dma  ,
"%d\n"   
)
shost_rd_attr ( prot_capabilities  ,
"%u\n"   
)
shost_rd_attr ( prot_guard_type  ,
"%hd\n"   
)
shost_rd_attr2 ( proc_name  ,
hostt->  proc_name,
"%s\n"   
)
show_sdev_iostat ( iorequest_cnt  )
show_sdev_iostat ( iodone_cnt  )
show_sdev_iostat ( ioerr_cnt  )

Variable Documentation

struct scsi_transport_template blank_transport_template = { { { {NULL, }, }, }, }

Definition at line 1140 of file scsi_sysfs.c.

struct device_attribute dev_attr_hstate
Initial value:
=
__ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state)

Definition at line 201 of file scsi_sysfs.c.

char* name

Definition at line 30 of file scsi_sysfs.c.

struct bus_type scsi_bus_type
Initial value:
= {
.name = "scsi",
.match = scsi_bus_match,
.uevent = scsi_bus_uevent,
}

Definition at line 416 of file scsi_sysfs.c.

struct attribute_group scsi_shost_attr_group
Initial value:
= {
.attrs = scsi_sysfs_shost_attrs,
}

Definition at line 317 of file scsi_sysfs.c.

struct attribute_group* scsi_sysfs_shost_attr_groups[]
Initial value:

Definition at line 321 of file scsi_sysfs.c.

enum scsi_host_state value

Definition at line 29 of file scsi_sysfs.c.