aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/net/ctcm_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/net/ctcm_sysfs.c')
-rw-r--r--drivers/s390/net/ctcm_sysfs.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/s390/net/ctcm_sysfs.c b/drivers/s390/net/ctcm_sysfs.c
index 650aec1839e9..0c27ae726475 100644
--- a/drivers/s390/net/ctcm_sysfs.c
+++ b/drivers/s390/net/ctcm_sysfs.c
@@ -13,6 +13,7 @@
13#define KMSG_COMPONENT "ctcm" 13#define KMSG_COMPONENT "ctcm"
14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 15
16#include <linux/device.h>
16#include <linux/sysfs.h> 17#include <linux/sysfs.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
18#include "ctcm_main.h" 19#include "ctcm_main.h"
@@ -108,10 +109,12 @@ static void ctcm_print_statistics(struct ctcm_priv *priv)
108} 109}
109 110
110static ssize_t stats_show(struct device *dev, 111static ssize_t stats_show(struct device *dev,
111 struct device_attribute *attr, char *buf) 112 struct device_attribute *attr, char *buf)
112{ 113{
114 struct ccwgroup_device *gdev = to_ccwgroupdev(dev);
113 struct ctcm_priv *priv = dev_get_drvdata(dev); 115 struct ctcm_priv *priv = dev_get_drvdata(dev);
114 if (!priv) 116
117 if (!priv || gdev->state != CCWGROUP_ONLINE)
115 return -ENODEV; 118 return -ENODEV;
116 ctcm_print_statistics(priv); 119 ctcm_print_statistics(priv);
117 return sprintf(buf, "0\n"); 120 return sprintf(buf, "0\n");
@@ -190,34 +193,14 @@ static struct attribute *ctcm_attr[] = {
190 &dev_attr_protocol.attr, 193 &dev_attr_protocol.attr,
191 &dev_attr_type.attr, 194 &dev_attr_type.attr,
192 &dev_attr_buffer.attr, 195 &dev_attr_buffer.attr,
196 &dev_attr_stats.attr,
193 NULL, 197 NULL,
194}; 198};
195 199
196static struct attribute_group ctcm_attr_group = { 200static struct attribute_group ctcm_attr_group = {
197 .attrs = ctcm_attr, 201 .attrs = ctcm_attr,
198}; 202};
199 203const struct attribute_group *ctcm_attr_groups[] = {
200int ctcm_add_attributes(struct device *dev) 204 &ctcm_attr_group,
201{ 205 NULL,
202 int rc; 206};
203
204 rc = device_create_file(dev, &dev_attr_stats);
205
206 return rc;
207}
208
209void ctcm_remove_attributes(struct device *dev)
210{
211 device_remove_file(dev, &dev_attr_stats);
212}
213
214int ctcm_add_files(struct device *dev)
215{
216 return sysfs_create_group(&dev->kobj, &ctcm_attr_group);
217}
218
219void ctcm_remove_files(struct device *dev)
220{
221 sysfs_remove_group(&dev->kobj, &ctcm_attr_group);
222}
223