Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / drivers / s390 / scsi / zfcp_sysfs_driver.c
blob651edd58906a021fc71f6f12693998abadfd00a7
1 /*
2 * This file is part of the zfcp device driver for
3 * FCP adapters for IBM System z9 and zSeries.
5 * (C) Copyright IBM Corp. 2002, 2006
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "zfcp_ext.h"
24 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
26 /**
27 * ZFCP_DEFINE_DRIVER_ATTR - define for all loglevels sysfs attributes
28 * @_name: name of attribute
29 * @_define: name of ZFCP loglevel define
31 * Generates store function for a sysfs loglevel attribute of zfcp driver.
33 #define ZFCP_DEFINE_DRIVER_ATTR(_name, _define) \
34 static ssize_t zfcp_sysfs_loglevel_##_name##_store(struct device_driver *drv, \
35 const char *buf, \
36 size_t count) \
37 { \
38 unsigned int loglevel; \
39 unsigned int new_loglevel; \
40 char *endp; \
42 new_loglevel = simple_strtoul(buf, &endp, 0); \
43 if ((endp + 1) < (buf + count)) \
44 return -EINVAL; \
45 if (new_loglevel > 3) \
46 return -EINVAL; \
47 down(&zfcp_data.config_sema); \
48 loglevel = atomic_read(&zfcp_data.loglevel); \
49 loglevel &= ~((unsigned int) 0xf << (ZFCP_LOG_AREA_##_define << 2)); \
50 loglevel |= new_loglevel << (ZFCP_LOG_AREA_##_define << 2); \
51 atomic_set(&zfcp_data.loglevel, loglevel); \
52 up(&zfcp_data.config_sema); \
53 return count; \
54 } \
56 static ssize_t zfcp_sysfs_loglevel_##_name##_show(struct device_driver *dev, \
57 char *buf) \
58 { \
59 return sprintf(buf,"%d\n", (unsigned int) \
60 ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA_##_define)); \
61 } \
63 static DRIVER_ATTR(loglevel_##_name, S_IWUSR | S_IRUGO, \
64 zfcp_sysfs_loglevel_##_name##_show, \
65 zfcp_sysfs_loglevel_##_name##_store);
67 ZFCP_DEFINE_DRIVER_ATTR(other, OTHER);
68 ZFCP_DEFINE_DRIVER_ATTR(scsi, SCSI);
69 ZFCP_DEFINE_DRIVER_ATTR(fsf, FSF);
70 ZFCP_DEFINE_DRIVER_ATTR(config, CONFIG);
71 ZFCP_DEFINE_DRIVER_ATTR(cio, CIO);
72 ZFCP_DEFINE_DRIVER_ATTR(qdio, QDIO);
73 ZFCP_DEFINE_DRIVER_ATTR(erp, ERP);
74 ZFCP_DEFINE_DRIVER_ATTR(fc, FC);
76 static ssize_t zfcp_sysfs_version_show(struct device_driver *dev,
77 char *buf)
79 return sprintf(buf, "%s\n", zfcp_data.driver_version);
82 static DRIVER_ATTR(version, S_IRUGO, zfcp_sysfs_version_show, NULL);
84 static struct attribute *zfcp_driver_attrs[] = {
85 &driver_attr_loglevel_other.attr,
86 &driver_attr_loglevel_scsi.attr,
87 &driver_attr_loglevel_fsf.attr,
88 &driver_attr_loglevel_config.attr,
89 &driver_attr_loglevel_cio.attr,
90 &driver_attr_loglevel_qdio.attr,
91 &driver_attr_loglevel_erp.attr,
92 &driver_attr_loglevel_fc.attr,
93 &driver_attr_version.attr,
94 NULL
97 static struct attribute_group zfcp_driver_attr_group = {
98 .attrs = zfcp_driver_attrs,
101 struct attribute_group *zfcp_driver_attr_groups[] = {
102 &zfcp_driver_attr_group,
103 NULL,
106 #undef ZFCP_LOG_AREA