1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/string.h>
19#include <linux/device.h>
20
21#include "snic.h"
22
23static ssize_t
24snic_show_sym_name(struct device *dev,
25 struct device_attribute *attr,
26 char *buf)
27{
28 struct snic *snic = shost_priv(class_to_shost(dev));
29
30 return snprintf(buf, PAGE_SIZE, "%s\n", snic->name);
31}
32
33static ssize_t
34snic_show_state(struct device *dev,
35 struct device_attribute *attr,
36 char *buf)
37{
38 struct snic *snic = shost_priv(class_to_shost(dev));
39
40 return snprintf(buf, PAGE_SIZE, "%s\n",
41 snic_state_str[snic_get_state(snic)]);
42}
43
44static ssize_t
45snic_show_drv_version(struct device *dev,
46 struct device_attribute *attr,
47 char *buf)
48{
49 return snprintf(buf, PAGE_SIZE, "%s\n", SNIC_DRV_VERSION);
50}
51
52static ssize_t
53snic_show_link_state(struct device *dev,
54 struct device_attribute *attr,
55 char *buf)
56{
57 struct snic *snic = shost_priv(class_to_shost(dev));
58
59 if (snic->config.xpt_type == SNIC_DAS)
60 snic->link_status = svnic_dev_link_status(snic->vdev);
61
62 return snprintf(buf, PAGE_SIZE, "%s\n",
63 (snic->link_status) ? "Link Up" : "Link Down");
64}
65
66static DEVICE_ATTR(snic_sym_name, S_IRUGO, snic_show_sym_name, NULL);
67static DEVICE_ATTR(snic_state, S_IRUGO, snic_show_state, NULL);
68static DEVICE_ATTR(drv_version, S_IRUGO, snic_show_drv_version, NULL);
69static DEVICE_ATTR(link_state, S_IRUGO, snic_show_link_state, NULL);
70
71struct device_attribute *snic_attrs[] = {
72 &dev_attr_snic_sym_name,
73 &dev_attr_snic_state,
74 &dev_attr_drv_version,
75 &dev_attr_link_state,
76 NULL,
77};
78