2 * Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 #include <linux/string.h>
19 #include <linux/device.h>
24 snic_show_sym_name(struct device
*dev
,
25 struct device_attribute
*attr
,
28 struct snic
*snic
= shost_priv(class_to_shost(dev
));
30 return snprintf(buf
, PAGE_SIZE
, "%s\n", snic
->name
);
34 snic_show_state(struct device
*dev
,
35 struct device_attribute
*attr
,
38 struct snic
*snic
= shost_priv(class_to_shost(dev
));
40 return snprintf(buf
, PAGE_SIZE
, "%s\n",
41 snic_state_str
[snic_get_state(snic
)]);
45 snic_show_drv_version(struct device
*dev
,
46 struct device_attribute
*attr
,
49 return snprintf(buf
, PAGE_SIZE
, "%s\n", SNIC_DRV_VERSION
);
53 snic_show_link_state(struct device
*dev
,
54 struct device_attribute
*attr
,
57 struct snic
*snic
= shost_priv(class_to_shost(dev
));
59 if (snic
->config
.xpt_type
== SNIC_DAS
)
60 snic
->link_status
= svnic_dev_link_status(snic
->vdev
);
62 return snprintf(buf
, PAGE_SIZE
, "%s\n",
63 (snic
->link_status
) ? "Link Up" : "Link Down");
66 static DEVICE_ATTR(snic_sym_name
, S_IRUGO
, snic_show_sym_name
, NULL
);
67 static DEVICE_ATTR(snic_state
, S_IRUGO
, snic_show_state
, NULL
);
68 static DEVICE_ATTR(drv_version
, S_IRUGO
, snic_show_drv_version
, NULL
);
69 static DEVICE_ATTR(link_state
, S_IRUGO
, snic_show_link_state
, NULL
);
71 struct device_attribute
*snic_attrs
[] = {
72 &dev_attr_snic_sym_name
,
74 &dev_attr_drv_version
,