1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
4 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
6 #include <linux/string.h>
7 #include <linux/device.h>
8 #include <scsi/scsi_host.h>
11 static ssize_t
fnic_show_state(struct device
*dev
,
12 struct device_attribute
*attr
, char *buf
)
14 struct fc_lport
*lp
= shost_priv(class_to_shost(dev
));
15 struct fnic
*fnic
= lport_priv(lp
);
17 return sysfs_emit(buf
, "%s\n", fnic_state_str
[fnic
->state
]);
20 static ssize_t
fnic_show_drv_version(struct device
*dev
,
21 struct device_attribute
*attr
, char *buf
)
23 return sysfs_emit(buf
, "%s\n", DRV_VERSION
);
26 static ssize_t
fnic_show_link_state(struct device
*dev
,
27 struct device_attribute
*attr
, char *buf
)
29 struct fc_lport
*lp
= shost_priv(class_to_shost(dev
));
31 return sysfs_emit(buf
, "%s\n", (lp
->link_up
) ? "Link Up" : "Link Down");
34 static DEVICE_ATTR(fnic_state
, S_IRUGO
, fnic_show_state
, NULL
);
35 static DEVICE_ATTR(drv_version
, S_IRUGO
, fnic_show_drv_version
, NULL
);
36 static DEVICE_ATTR(link_state
, S_IRUGO
, fnic_show_link_state
, NULL
);
38 static struct attribute
*fnic_host_attrs
[] = {
39 &dev_attr_fnic_state
.attr
,
40 &dev_attr_drv_version
.attr
,
41 &dev_attr_link_state
.attr
,
45 static const struct attribute_group fnic_host_attr_group
= {
46 .attrs
= fnic_host_attrs
49 const struct attribute_group
*fnic_host_groups
[] = {
50 &fnic_host_attr_group
,