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)
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.
24 #define ZFCP_LOG_AREA ZFCP_LOG_AREA_CONFIG
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, \
38 unsigned int loglevel; \
39 unsigned int new_loglevel; \
42 new_loglevel = simple_strtoul(buf, &endp, 0); \
43 if ((endp + 1) < (buf + count)) \
45 if (new_loglevel > 3) \
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); \
56 static ssize_t zfcp_sysfs_loglevel_##_name##_show(struct device_driver *dev, \
59 return sprintf(buf,"%d\n", (unsigned int) \
60 ZFCP_GET_LOG_VALUE(ZFCP_LOG_AREA_##_define)); \
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
,
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
,
97 static struct attribute_group zfcp_driver_attr_group
= {
98 .attrs
= zfcp_driver_attrs
,
102 * zfcp_sysfs_create_driver_files - create sysfs driver files
103 * @dev: pointer to belonging device
105 * Create all sysfs attributes of the zfcp device driver
108 zfcp_sysfs_driver_create_files(struct device_driver
*drv
)
110 return sysfs_create_group(&drv
->kobj
, &zfcp_driver_attr_group
);
114 * zfcp_sysfs_remove_driver_files - remove sysfs driver files
115 * @dev: pointer to belonging device
117 * Remove all sysfs attributes of the zfcp device driver
120 zfcp_sysfs_driver_remove_files(struct device_driver
*drv
)
122 sysfs_remove_group(&drv
->kobj
, &zfcp_driver_attr_group
);