0001
0002
0003
0004 #include <linux/string.h>
0005 #include <linux/device.h>
0006
0007 #include "snic.h"
0008
0009 static ssize_t
0010 snic_show_sym_name(struct device *dev,
0011 struct device_attribute *attr,
0012 char *buf)
0013 {
0014 struct snic *snic = shost_priv(class_to_shost(dev));
0015
0016 return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
0017 }
0018
0019 static ssize_t
0020 snic_show_state(struct device *dev,
0021 struct device_attribute *attr,
0022 char *buf)
0023 {
0024 struct snic *snic = shost_priv(class_to_shost(dev));
0025
0026 return snprintf(buf, PAGE_SIZE, "%s\n",
0027 snic_state_str[snic_get_state(snic)]);
0028 }
0029
0030 static ssize_t
0031 snic_show_drv_version(struct device *dev,
0032 struct device_attribute *attr,
0033 char *buf)
0034 {
0035 return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
0036 }
0037
0038 static ssize_t
0039 snic_show_link_state(struct device *dev,
0040 struct device_attribute *attr,
0041 char *buf)
0042 {
0043 struct snic *snic = shost_priv(class_to_shost(dev));
0044
0045 if (snic->config.xpt_type == SNIC_DAS)
0046 snic->link_status = svnic_dev_link_status(snic->vdev);
0047
0048 return snprintf(buf, PAGE_SIZE, "%s\n",
0049 (snic->link_status) ? "Link Up" : "Link Down");
0050 }
0051
0052 static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
0053 static DEVICE_ATTR(snic_state, S_IRUGO, snic_show_state, NULL);
0054 static DEVICE_ATTR(drv_version, S_IRUGO, snic_show_drv_version, NULL);
0055 static DEVICE_ATTR(link_state, S_IRUGO, snic_show_link_state, NULL);
0056
0057 static struct attribute *snic_host_attrs[] = {
0058 &dev_attr_snic_sym_name.attr,
0059 &dev_attr_snic_state.attr,
0060 &dev_attr_drv_version.attr,
0061 &dev_attr_link_state.attr,
0062 NULL,
0063 };
0064
0065 static const struct attribute_group snic_host_attr_group = {
0066 .attrs = snic_host_attrs
0067 };
0068
0069 const struct attribute_group *snic_host_groups[] = {
0070 &snic_host_attr_group,
0071 NULL
0072 };