2 * linux/drivers/s390/scsi/zfcp_sysfs_driver.c
4 * FCP adapter driver for IBM eServer zSeries
6 * sysfs driver related routines
8 * (C) Copyright IBM Corp. 2003, 2004
11 * Martin Peschke <mpeschke@de.ibm.com>
12 * Heiko Carstens <heiko.carstens@de.ibm.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define ZFCP_SYSFS_DRIVER_C_REVISION "$Revision: 1.12 $"
31 #include <asm/ccwdev.h>
35 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
38 * ZFCP_DEFINE_DRIVER_ATTR - define for all loglevels sysfs attributes
39 * @_name: name of attribute
40 * @_define: name of ZFCP loglevel define
42 * Generates store function for a sysfs loglevel attribute of zfcp driver.
44 #define ZFCP_DEFINE_DRIVER_ATTR(_name, _define) \
45 static ssize_t zfcp_sysfs_loglevel_##_name##_store(struct device_driver *drv, \
49 unsigned int loglevel; \
50 unsigned int new_loglevel; \
53 new_loglevel = simple_strtoul(buf, &endp, 0); \
54 if ((endp + 1) < (buf + count)) \
56 if (new_loglevel > 3) \
58 down(&zfcp_data.config_sema); \
59 loglevel = atomic_read(&zfcp_data.loglevel); \
60 loglevel &= ~((unsigned int) 0xf << (ZFCP_LOG_AREA_##_define << 2)); \
61 loglevel |= new_loglevel << (ZFCP_LOG_AREA_##_define << 2); \
62 atomic_set(&zfcp_data.loglevel, loglevel); \
63 up(&zfcp_data.config_sema); \
67 static ssize_t zfcp_sysfs_loglevel_##_name##_show(struct device_driver *dev, \
70 return sprintf(buf,"%d\n", \
71 ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA_##_define)); \
74 static DRIVER_ATTR(loglevel_##_name, S_IWUSR | S_IRUGO, \
75 zfcp_sysfs_loglevel_##_name##_show, \
76 zfcp_sysfs_loglevel_##_name##_store);
78 ZFCP_DEFINE_DRIVER_ATTR(other, OTHER);
79 ZFCP_DEFINE_DRIVER_ATTR(scsi, SCSI);
80 ZFCP_DEFINE_DRIVER_ATTR(fsf, FSF);
81 ZFCP_DEFINE_DRIVER_ATTR(config, CONFIG);
82 ZFCP_DEFINE_DRIVER_ATTR(cio, CIO);
83 ZFCP_DEFINE_DRIVER_ATTR(qdio, QDIO);
84 ZFCP_DEFINE_DRIVER_ATTR(erp, ERP);
85 ZFCP_DEFINE_DRIVER_ATTR(fc, FC);
87 static ssize_t zfcp_sysfs_version_show(struct device_driver *dev,
90 return sprintf(buf, "%s\n", ZFCP_VERSION);
93 static DRIVER_ATTR(version, S_IRUGO, zfcp_sysfs_version_show, NULL);
95 static struct attribute *zfcp_driver_attrs[] = {
96 &driver_attr_loglevel_other.attr,
97 &driver_attr_loglevel_scsi.attr,
98 &driver_attr_loglevel_fsf.attr,
99 &driver_attr_loglevel_config.attr,
100 &driver_attr_loglevel_cio.attr,
101 &driver_attr_loglevel_qdio.attr,
102 &driver_attr_loglevel_erp.attr,
103 &driver_attr_loglevel_fc.attr,
104 &driver_attr_version.attr,
108 static struct attribute_group zfcp_driver_attr_group = {
109 .attrs = zfcp_driver_attrs,
113 * zfcp_sysfs_create_driver_files - create sysfs driver files
114 * @dev: pointer to belonging device
116 * Create all sysfs attributes of the zfcp device driver
119 zfcp_sysfs_driver_create_files(struct device_driver *drv)
121 return sysfs_create_group(&drv->kobj, &zfcp_driver_attr_group);
125 * zfcp_sysfs_remove_driver_files - remove sysfs driver files
126 * @dev: pointer to belonging device
128 * Remove all sysfs attributes of the zfcp device driver
131 zfcp_sysfs_driver_remove_files(struct device_driver *drv)
133 sysfs_remove_group(&drv->kobj, &zfcp_driver_attr_group);