/* * Copyright (C) 2012 SPiDCOM Technologies * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "linux/afe.h" #include "linux/errno.h" #include "linux/kernel.h" #include "linux/module.h" /* The currently registered AFE. */ static struct afe *registered_afe = NULL; int afe_register(struct afe *afe) { BUG_ON(afe == NULL); if (registered_afe != NULL) { printk (KERN_WARNING "An AFE is already registered.\n"); return -EBUSY; } registered_afe = afe; return 0; } EXPORT_SYMBOL(afe_register); int afe_unregister(struct afe *afe) { BUG_ON (afe == NULL); if (registered_afe != afe) { printk (KERN_WARNING "An AFE can only unregister itself, not another AFE.\n"); return -EFAULT; } registered_afe = NULL; return 0; } EXPORT_SYMBOL(afe_unregister); struct afe* afe_get(void) { return registered_afe; } EXPORT_SYMBOL(afe_get); int afe_read(struct afe *afe, uint32_t reg, uint32_t *val) { BUG_ON(afe == NULL); return registered_afe->read(reg, val); } EXPORT_SYMBOL(afe_read); int afe_write(struct afe *afe, uint32_t reg, uint32_t val) { BUG_ON(afe == NULL); return registered_afe->write(reg, val); } EXPORT_SYMBOL(afe_write);