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.14 $"
33 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
36 * ZFCP_DEFINE_DRIVER_ATTR - define for all loglevels sysfs attributes
37 * @_name: name of attribute
38 * @_define: name of ZFCP loglevel define
40 * Generates store function for a sysfs loglevel attribute of zfcp driver.
42 #define ZFCP_DEFINE_DRIVER_ATTR(_name, _define) \
43 static ssize_t zfcp_sysfs_loglevel_##_name##_store(struct device_driver *drv, \
47 unsigned int loglevel; \
48 unsigned int new_loglevel; \
51 new_loglevel = simple_strtoul(buf, &endp, 0); \
52 if ((endp + 1) < (buf + count)) \
54 if (new_loglevel > 3) \
56 down(&zfcp_data.config_sema); \
57 loglevel = atomic_read(&zfcp_data.loglevel); \
58 loglevel &= ~((unsigned int) 0xf << (ZFCP_LOG_AREA_##_define << 2)); \
59 loglevel |= new_loglevel << (ZFCP_LOG_AREA_##_define << 2); \
60 atomic_set(&zfcp_data.loglevel, loglevel); \
61 up(&zfcp_data.config_sema); \
65 static ssize_t zfcp_sysfs_loglevel_##_name##_show(struct device_driver *dev, \
68 return sprintf(buf,"%d\n", \
69 ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA_##_define)); \
72 static DRIVER_ATTR(loglevel_##_name, S_IWUSR | S_IRUGO, \
73 zfcp_sysfs_loglevel_##_name##_show, \
74 zfcp_sysfs_loglevel_##_name##_store);
76 ZFCP_DEFINE_DRIVER_ATTR(other, OTHER);
77 ZFCP_DEFINE_DRIVER_ATTR(scsi, SCSI);
78 ZFCP_DEFINE_DRIVER_ATTR(fsf, FSF);
79 ZFCP_DEFINE_DRIVER_ATTR(config, CONFIG);
80 ZFCP_DEFINE_DRIVER_ATTR(cio, CIO);
81 ZFCP_DEFINE_DRIVER_ATTR(qdio, QDIO);
82 ZFCP_DEFINE_DRIVER_ATTR(erp, ERP);
83 ZFCP_DEFINE_DRIVER_ATTR(fc, FC);
85 static ssize_t zfcp_sysfs_version_show(struct device_driver *dev,
88 return sprintf(buf, "%s\n", ZFCP_VERSION);
91 static DRIVER_ATTR(version, S_IRUGO, zfcp_sysfs_version_show, NULL);
93 static struct attribute *zfcp_driver_attrs[] = {
94 &driver_attr_loglevel_other.attr,
95 &driver_attr_loglevel_scsi.attr,
96 &driver_attr_loglevel_fsf.attr,
97 &driver_attr_loglevel_config.attr,
98 &driver_attr_loglevel_cio.attr,
99 &driver_attr_loglevel_qdio.attr,
100 &driver_attr_loglevel_erp.attr,
101 &driver_attr_loglevel_fc.attr,
102 &driver_attr_version.attr,
106 static struct attribute_group zfcp_driver_attr_group = {
107 .attrs = zfcp_driver_attrs,
111 * zfcp_sysfs_create_driver_files - create sysfs driver files
112 * @dev: pointer to belonging device
114 * Create all sysfs attributes of the zfcp device driver
117 zfcp_sysfs_driver_create_files(struct device_driver *drv)
119 return sysfs_create_group(&drv->kobj, &zfcp_driver_attr_group);
123 * zfcp_sysfs_remove_driver_files - remove sysfs driver files
124 * @dev: pointer to belonging device
126 * Remove all sysfs attributes of the zfcp device driver
129 zfcp_sysfs_driver_remove_files(struct device_driver *drv)
131 sysfs_remove_group(&drv->kobj, &zfcp_driver_attr_group);