diff options
| author | Felix Morgner <fmorgner@hsr.ch> | 2017-10-26 10:30:58 +0200 |
|---|---|---|
| committer | Felix Morgner <fmorgner@hsr.ch> | 2017-10-26 10:30:58 +0200 |
| commit | a26891a23c0dcf4157324cf04af1466575d650fb (patch) | |
| tree | 79362fabb38d90d5e1d9fffb8e4b088026920280 /src | |
| parent | 871fc1a89b5f1ff11f47debed4f7d165a639857d (diff) | |
| download | dev-cyber-a26891a23c0dcf4157324cf04af1466575d650fb.tar.xz dev-cyber-a26891a23c0dcf4157324cf04af1466575d650fb.zip | |
device_class: move to newer device class API
Diffstat (limited to 'src')
| -rw-r--r-- | src/cyber_device_device_class.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/cyber_device_device_class.c b/src/cyber_device_device_class.c index c0d108b..56795e3 100644 --- a/src/cyber_device_device_class.c +++ b/src/cyber_device_device_class.c @@ -8,11 +8,11 @@ * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with - * this program. If not, see <http://www.gnu.org/licenses/>. + * this program. If not, see <http://www.gnu.org/licenses/>. */ #include "cyber.h" @@ -25,24 +25,17 @@ extern struct cyber_device device; -static ssize_t cyber_device_show_attribute(struct class * class, struct class_attribute * attribute, char __user * buffer) -{ - char const * const name = attribute->attr.name; - - if(!strcmp(name, "available")) +ssize_t available_show(struct class * class, struct class_attribute * attribute, char * __user buffer) { - return sprintf(buffer, "infinite\n"); + return sprintf(buffer, "infinite\n"); } - else if(!strcmp(name, "storage_technology")) +CLASS_ATTR_RO(available); + +ssize_t storage_technology_show(struct class * class, struct class_attribute * attribute, char * __user buffer) { - return sprintf(buffer, "condensed di-hydrogen-monoxide\n"); + return sprintf(buffer, "condensed di-hydrogen-monoxide\n"); } - - return -EINVAL; -} - -CLASS_ATTR(available, 0444, cyber_device_show_attribute, NULL); -CLASS_ATTR(storage_technology, 0444, cyber_device_show_attribute, NULL); +CLASS_ATTR_RO(storage_technology); static int cyber_device_handle_uevent(struct device * kernelDevice, struct kobj_uevent_env * environment) { @@ -63,7 +56,7 @@ int cyber_device_init_device_class(void) } if((error = class_create_file(&device.class, &class_attr_available)) || - (error = class_create_file(&device.class, &class_attr_storage_technology))) + (error = class_create_file(&device.class, &class_attr_storage_technology))) { printk(KERN_ALERT DEV_NAME ": Failed to register sysfs CYBER attributes!\n"); } |
