1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright 2014 Cisco Systems, Inc. All rights reserved.
4 #include <linux/string.h>
5 #include <linux/device.h>
10 snic_show_sym_name(struct device
*dev
,
11 struct device_attribute
*attr
,
14 struct snic
*snic
= shost_priv(class_to_shost(dev
));
16 return sysfs_emit(buf
, "%s\n", snic
->name
);
20 snic_show_state(struct device
*dev
,
21 struct device_attribute
*attr
,
24 struct snic
*snic
= shost_priv(class_to_shost(dev
));
26 return sysfs_emit(buf
, "%s\n", snic_state_str
[snic_get_state(snic
)]);
30 snic_show_drv_version(struct device
*dev
,
31 struct device_attribute
*attr
,
34 return sysfs_emit(buf
, "%s\n", SNIC_DRV_VERSION
);
38 snic_show_link_state(struct device
*dev
,
39 struct device_attribute
*attr
,
42 struct snic
*snic
= shost_priv(class_to_shost(dev
));
44 if (snic
->config
.xpt_type
== SNIC_DAS
)
45 snic
->link_status
= svnic_dev_link_status(snic
->vdev
);
47 return sysfs_emit(buf
, "%s\n",
48 (snic
->link_status
) ? "Link Up" : "Link Down");
51 static DEVICE_ATTR(snic_sym_name
, S_IRUGO
, snic_show_sym_name
, NULL
);
52 static DEVICE_ATTR(snic_state
, S_IRUGO
, snic_show_state
, NULL
);
53 static DEVICE_ATTR(drv_version
, S_IRUGO
, snic_show_drv_version
, NULL
);
54 static DEVICE_ATTR(link_state
, S_IRUGO
, snic_show_link_state
, NULL
);
56 static struct attribute
*snic_host_attrs
[] = {
57 &dev_attr_snic_sym_name
.attr
,
58 &dev_attr_snic_state
.attr
,
59 &dev_attr_drv_version
.attr
,
60 &dev_attr_link_state
.attr
,
64 static const struct attribute_group snic_host_attr_group
= {
65 .attrs
= snic_host_attrs
68 const struct attribute_group
*snic_host_groups
[] = {
69 &snic_host_attr_group
,