/* * New driver for /dev/crypto device (aka CryptoDev) * Copyright (c) 2010 Nikos Mavrogiannopoulos * * This file is part of linux cryptodev. * * cryptodev is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * cryptodev is distributed in the hope that 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 more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include "cryptodev.h" #include #include #include #include "ncr.h" #include "ncr_int.h" #define err() printk(KERN_DEBUG"ncr: %s: %d\n", __func__, __LINE__) void* ncr_init_lists(void) { struct ncr_lists *lst; lst = kmalloc(sizeof(*lst), GFP_KERNEL); if(!lst) { err(); return NULL; } memset(lst, 0, sizeof(*lst)); init_MUTEX(&lst->data_sem); INIT_LIST_HEAD(&lst->data_list); return lst; } void ncr_deinit_lists(struct ncr_lists *lst) { if(lst) { ncr_data_list_deinit(lst); kfree(lst); } } int ncr_ioctl(unsigned int uid, struct ncr_lists* lst, unsigned int cmd, unsigned long __user arg) { if (unlikely(!lst)) BUG(); switch (cmd) { case NCRIO_DATA_INIT: return ncr_data_new(uid, lst, (void*)arg); case NCRIO_DATA_GET: return ncr_data_get(lst, (void*)arg); case NCRIO_DATA_SET: return ncr_data_set(lst, (void*)arg); case NCRIO_DATA_DEINIT: return ncr_data_deinit(lst, (void*)arg); default: return -EINVAL; } }