drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / drivers / scsi / snic / snic_attrs.c
blob48bf82d042b435924cf777a8ba2bb5463909e32b
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>
7 #include "snic.h"
9 static ssize_t
10 snic_show_sym_name(struct device *dev,
11 struct device_attribute *attr,
12 char *buf)
14 struct snic *snic = shost_priv(class_to_shost(dev));
16 return sysfs_emit(buf, "%s\n", snic->name);
19 static ssize_t
20 snic_show_state(struct device *dev,
21 struct device_attribute *attr,
22 char *buf)
24 struct snic *snic = shost_priv(class_to_shost(dev));
26 return sysfs_emit(buf, "%s\n", snic_state_str[snic_get_state(snic)]);
29 static ssize_t
30 snic_show_drv_version(struct device *dev,
31 struct device_attribute *attr,
32 char *buf)
34 return sysfs_emit(buf, "%s\n", SNIC_DRV_VERSION);
37 static ssize_t
38 snic_show_link_state(struct device *dev,
39 struct device_attribute *attr,
40 char *buf)
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,
61 NULL,
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,
70 NULL